|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.tasklist.compiler; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.ResourceBundle; import java.util.Iterator; import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Action; import org.netbeans.modules.tasklist.core.ExportAction; import org.netbeans.modules.tasklist.core.TaskNode; import org.netbeans.modules.tasklist.core.filter.FilterAction; import org.openide.ErrorManager; import org.openide.actions.PropertiesAction; import org.openide.filesystems.FileObject; import org.openide.nodes.Node; import org.openide.nodes.PropertySupport; import org.openide.nodes.Sheet; import org.openide.nodes.PropertySupport.ReadOnly; import org.openide.nodes.PropertySupport.Reflection; import org.openide.nodes.Sheet.Set; import org.openide.text.Line; import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; /** * A node in the representing a compile error. * * @author Tor Norbye * @author Tim Lebedkov */ public class CompileErrorNode extends TaskNode { /** property name for summary */ public static final String PROP_SUMMARY = "summary"; // NOI18N /** property name for details */ public static final String PROP_DETAILS = "details"; // NOI18N /** property name for line number */ public static final String PROP_LINE = "line"; // NOI18N /** column number */ public static final String PROP_COLUMN = "column"; // NOI18N /** property name for a file name */ public static final String PROP_FILE = "file"; // NOI18N /** directory with file that contains an error */ public static final String PROP_FOLDER = "folder"; // NOI18N /** severity of the problem */ public static final String PROP_SEVERITY = "severity"; // NOI18N /** * Leaf * * @param item build error */ public CompileErrorNode(CompileError item) { super(item); } /** * Non-leaf/parent * * @param item build error * @param subtasks list of subtasks */ public CompileErrorNode(CompileError item, Iterator subtasks) { super(item, subtasks); } public Action getPreferredAction() { return SystemAction.get(ShowErrorAction.class); } // Handle cloning specially (so as not to invoke the overhead of FilterNode): public Node cloneNode () { CompileError eitem = (CompileError)item; if (eitem.hasSubtasks()) { return new CompileErrorNode(eitem, eitem.subtasksIterator()); } else { return new CompileErrorNode(eitem); } } protected Sheet createSheet() { Sheet s = Sheet.createDefault(); Set ss = s.get(Sheet.PROPERTIES); ResourceBundle rb = NbBundle.getBundle(CompileErrorNode.class); try { Reflection p; p = new Reflection(item, String.class, "getSummary", null); // NOI18N p.setName(PROP_SUMMARY); p.setDisplayName(rb.getString("Summary")); // NOI18N p.setShortDescription(rb.getString("SummaryHint")); // NOI18N ss.put(p); p = new Reflection(item, String.class, "getDetails", null); // NOI18N p.setName(PROP_DETAILS); p.setDisplayName(rb.getString("Details")); // NOI18N p.setShortDescription(rb.getString("DetailsHint")); // NOI18N ss.put(p); PropertySupport ps = new ReadOnly( PROP_FOLDER, String.class, rb.getString("Folder"), rb.getString("FolderHint")) { // NOI18N public Object getValue () throws IllegalAccessException, InvocationTargetException { FileObject fo = ((CompileError) item).getFolder(); if (fo == null) return ""; // NOI18N else return fo.getPath(); } }; ss.put(ps); ps = new ReadOnly( PROP_FILE, String.class, rb.getString("File"), rb.getString("FileHint")) { // NOI18N public Object getValue () throws IllegalAccessException, InvocationTargetException { FileObject fo = ((CompileError) item).getFile(); if (fo == null) return ""; // NOI18N else return fo.getNameExt(); } }; ss.put(ps); ps = new ReadOnly( PROP_LINE, Integer.class, rb.getString("Line"), rb.getString("LineHint")) { // NOI18N public Object getValue () throws IllegalAccessException, InvocationTargetException { Line l = item.getLine(); if (l == null) return new Integer(0); else return new Integer(l.getLineNumber() + 1); } }; ss.put(ps); p = new Reflection(item, Integer.class, "getColumn", null) { // NOI18N public Object getValue() { return new Integer(((CompileError) instance).getColumn() + 1); } }; p.setName(PROP_COLUMN); p.setDisplayName(rb.getString("Column")); // NOI18N p.setShortDescription(rb.getString("ColumnHint")); // NOI18N ss.put(p); p = new Reflection(item, Integer.class, "getSeverity", null); // NOI18N p.setName(PROP_SEVERITY); p.setDisplayName(rb.getString("Severity")); // NOI18N p.setShortDescription(rb.getString("SeverityHint")); // NOI18N ss.put(p); // ss.put(new SeverityPropertyEditor((CompileError) item)); } catch (NoSuchMethodException nsme) { ErrorManager.getDefault().notify(nsme); } return s; } protected SystemAction[] createActions() { return new SystemAction[] { SystemAction.get(ShowErrorAction.class), // "Global" (not node specific) actions null, SystemAction.get(FilterAction.class), null, SystemAction.get(ExportAction.class), // Property: node specific, but by convention last in menu null, SystemAction.get(PropertiesAction.class) }; } public Action[] getActions(boolean empty) { if (empty) { return new SystemAction[] { SystemAction.get(UpdateJavacRegexpAction.class), }; } else { return super.getActions(false); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.