From: <sh...@us...> - 2009-03-12 11:25:01
|
Revision: 14759 http://jedit.svn.sourceforge.net/jedit/?rev=14759&view=rev Author: shlomy Date: 2009-03-12 11:24:46 +0000 (Thu, 12 Mar 2009) Log Message: ----------- 1. Added an interface function for plugins to toggle markers in files without specifying a buffer. 2. Repaint only gutters when marker sets are changed. 3. Added an interface to let source link tree users provide context menu items for the tree nodes under each SourceLinkParentNode using their user objects. Modified Paths: -------------- plugins/MarkerSets/trunk/src/marker/MarkerSet.java plugins/MarkerSets/trunk/src/marker/MarkerSetsPlugin.java plugins/MarkerSets/trunk/src/marker/tree/SourceLinkTree.java Modified: plugins/MarkerSets/trunk/src/marker/MarkerSet.java =================================================================== --- plugins/MarkerSets/trunk/src/marker/MarkerSet.java 2009-03-11 19:22:48 UTC (rev 14758) +++ plugins/MarkerSets/trunk/src/marker/MarkerSet.java 2009-03-12 11:24:46 UTC (rev 14759) @@ -141,7 +141,7 @@ jEdit.visit(new JEditVisitorAdapter() { @Override public void visit(JEditTextArea textArea) { - textArea.repaint(); + textArea.getGutter().repaint(); } }); } Modified: plugins/MarkerSets/trunk/src/marker/MarkerSetsPlugin.java =================================================================== --- plugins/MarkerSets/trunk/src/marker/MarkerSetsPlugin.java 2009-03-11 19:22:48 UTC (rev 14758) +++ plugins/MarkerSets/trunk/src/marker/MarkerSetsPlugin.java 2009-03-12 11:24:46 UTC (rev 14759) @@ -315,7 +315,18 @@ } } + // Interface for plugins + + static public void toggleMarker(FileMarker marker) + { + if (active.toggle(marker)) + notifyChange(Event.MARKER_ADDED, marker, active); + else + notifyChange(Event.MARKER_REMOVED, marker, active); + } + // Actions + static public void setActiveMarkerSet(View view) { String current = (active == null) ? null : active.getName(); Modified: plugins/MarkerSets/trunk/src/marker/tree/SourceLinkTree.java =================================================================== --- plugins/MarkerSets/trunk/src/marker/tree/SourceLinkTree.java 2009-03-11 19:22:48 UTC (rev 14758) +++ plugins/MarkerSets/trunk/src/marker/tree/SourceLinkTree.java 2009-03-12 11:24:46 UTC (rev 14759) @@ -73,8 +73,17 @@ final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent(); JPopupMenu p = new JPopupMenu(); + // Allow node-specific context menu items if (node instanceof PopupMenuProvider) ((PopupMenuProvider) node).addPopupMenuItems(p); + // Allow SourceLinkParent objects to provide context menu items + // for all descendant nodes. + for (Object pathNode: tp.getPath()) + { + if (pathNode instanceof SourceLinkParentNode) + ((SourceLinkParentNode) pathNode).addSubtreePopupMenuItems(p, node); + } + // Common items for all nodes p.add(new AbstractAction("Remove") { public void actionPerformed(ActionEvent e) { removeNode(node); @@ -186,6 +195,15 @@ } } + // An interface for source link parent objects to provide pop-up menus for their + // descendant nodes, which are created by the source link tree. + + public interface SubtreePopupMenuProvider + { + void addPopupMenuItemsFor(JPopupMenu popup, SourceLinkParentNode parent, + DefaultMutableTreeNode node); + } + /* * SourceLinkParentNode represents a root node for a list of * FileMarker nodes (SourceLinkNode objects) that can be @@ -226,7 +244,7 @@ } private void rebuild() { - Vector<DefaultMutableTreeNode> leafs = collectLeafs(); + Vector<DefaultMutableTreeNode> leafs = collectLeafs(this); removeAllChildren(); builder.buildSubTree(this, leafs); model.nodeStructureChanged(this); @@ -238,20 +256,42 @@ this.builder = builder; rebuild(); } - private Vector<DefaultMutableTreeNode> collectLeafs() + private Vector<DefaultMutableTreeNode> collectLeafs(DefaultMutableTreeNode node) { Vector<DefaultMutableTreeNode> leafs = new Vector<DefaultMutableTreeNode>(); - if (isLeaf()) - return leafs; - DefaultMutableTreeNode leaf = getFirstLeaf(); + DefaultMutableTreeNode leaf = node.getFirstLeaf(); do { + if (leaf instanceof SourceLinkParentNode) + break; // Do not collect source link parents... leafs.add(leaf); leaf = leaf.getNextLeaf(); - } while ((leaf != null) && isNodeDescendant(leaf)); + } while ((leaf != null) && node.isNodeDescendant(leaf)); return leafs; } + // Returns the markers under the given node + public Vector<FileMarker> getFileMarkers(DefaultMutableTreeNode node) + { + Vector<FileMarker> markers = new Vector<FileMarker>(); + Vector<DefaultMutableTreeNode> markerNodes = collectLeafs(node); + for (DefaultMutableTreeNode markerNode: markerNodes) + { + FileMarker marker = (FileMarker) markerNode.getUserObject(); + markers.add(marker); + } + return markers; + } + // This allows the user object of the SourceLinkParent node to + // provide context menu actions for all children. + public void addSubtreePopupMenuItems(JPopupMenu popup, DefaultMutableTreeNode node) + { + if (popup == null) + return; + Object userObj = getUserObject(); + if (userObj instanceof SubtreePopupMenuProvider) + ((SubtreePopupMenuProvider) userObj).addPopupMenuItemsFor(popup, this, node); + } public void addPopupMenuItems(JPopupMenu popup) { if (popup == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |