/**Short-hand for the four-argument <code>buildTreePath</code> method. * Calls <code>buildTreePath(source,label,<strong>null</strong>,topNode)</code>. * @see buildTreePath(String,String,String,DefaultMutableTreeNode). * */ private void buildTreePath(String source, String label, DefaultMutableTreeNode topNode) { buildTreePath(source, label, null, topNode); }
synchronized void load() { commands = Menus.getCommands(); pluginsArray = Menus.getPlugins(); root=doRootFromMenus(); if (root==null || root.getChildCount()==0 ) return; // do nothing if there's no tree or a root w/o children loadProperties(); restoreVisiblePanels(); if (panels.isEmpty()) newPanel(root); }
/** Creates a panel with the hierarchical tree structure of ImageJ's commands. */ public void run(String arg) { load(); }
public void treeExpanded(TreeExpansionEvent ev) { TreePath evPath = ev.getPath(); //DefaultMutableTreeNode node = (DefaultMutableTreeNode)evPath.getLastPathComponent(); String evPathString = ev.getPath().toString(); evPathString = pcp.pStr2Key(evPathString); evPathString = evPathString.substring(getTitle().length()+1,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = pcp.pStr2Key(rootPath); //String path = rootPath+"."+evPathString; String path = rootPath+"."+evPathString; if (pcp.hasPanelShowingProperty(path)) { Hashtable panels = pcp.getPanels(); TreePanel p = (TreePanel)panels.get(path); if(p!=null) p.close(); } pcp.setExpandedStateProperty(path); }
public void actionPerformed(ActionEvent e) { String cmd=e.getActionCommand(); if(cmd==null) return; if (cmd.equals("Help")) { showHelp(); return; } if(cmd.equals("Show Parent")) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel panel = pcp.getPanelForNode(parent); if(panel==null) panel = pcp.newPanel(parent); if(panel!=null) panel.setVisible(); } return; } if(cmd.equals("Reload Plugins From Panel")) {// cmd fired by clicking on tree leaf pcp.closeAll(false); IJ.doCommand("Reload Plugins"); } else { if(cmd.equals("Reload Plugins")) // cmd fired from ImageJ menu; don't propagate it further pcp.closeAll(false); else IJ.doCommand(cmd); return; } }
if(pcp.hasExpandedStateProperty(npS) && !pcp.hasPanelShowingProperty(npS)) else if((pcp.hasExpandedStateProperty(npS) || pTree.isExpanded(newPath)) && pcp.hasPanelShowingProperty(npS)) pcp.unsetExpandedStateProperty(npS);
void saveProperties() { if (IJ.debugMode) IJ.log("CP.saveProperties: "+propertiesChanged); if (propertiesChanged) { clearProperties(); for (Enumeration e=visiblePanels.elements(); e.hasMoreElements();) { String s = (String)e.nextElement(); TreePanel p = (TreePanel)panels.get(s); if (p!=null) recordGeometry(p); } for(Enumeration e=expandedNodes.elements(); e.hasMoreElements();) Prefs.set((String)e.nextElement(),"expand"); } propertiesChanged=false; }
/**Constructs a TreePanel rooted at the path. * * @param s A string with the structure "[item1,item2,...,itemn]", as returned by * a call to the <code>toString()</code> method in the <code>javax.swing.tree.TreePath</code> class. * */ TreePanel newPanel(String path) { if (path.equals("Control_Panel.@Main")) path = "Control_Panel"; path = key2pStr(path); TreePanel pnl = null; for(Enumeration e = root.breadthFirstEnumeration(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode)e.nextElement(); TreePath p = new TreePath(n.getPath()); if (p.toString().equals(path)) pnl=newPanel(n); } return pnl; }
void setVisible() { if (pFrame!=null && !pFrame.isVisible()) { restoreExpandedNodes(); if (defaultLocation!=null) pFrame.setLocation(defaultLocation); pFrame.setVisible(true); // close expanded path to this panel in its parent panel (if visible and if the path is expanded) DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel pnl = pcp.getPanelForNode(parent); if (pnl!=null && pnl.isVisible()) { TreeNode[] rPath = root.getPath(); TreeNode[] pPath = pnl.getRootNode().getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[rPath.length-pPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)rPath[i+pPath.length-1]; //TreePath path = new TreePath(rPath); TreePath localPath = new TreePath(tPath); pnl.getTree().collapsePath(localPath); } } } if (pcp!=null) pcp.setPanelShowingProperty(getRootPath().toString()); }
void tearOff(DefaultMutableTreeNode node, Point pnt) { isDragging = false; pFrame.setCursor(Cursor.getDefaultCursor()); if(node==null) node = (DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); if(node.isLeaf()) return; TreeNode[] nPath = node.getPath(); TreeNode[] rPath = root.getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[nPath.length-rPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)nPath[i+rPath.length-1]; TreePath path = new TreePath(nPath); TreePath localPath = new TreePath(tPath); String pathString = localPath.toString(); TreePanel p = pcp.getPanelForNode(node); if (p==null) { if(pnt!=null) p = pcp.newPanel(node, pnt); else p = pcp.newPanel(node); pTree.collapsePath(localPath); } else { if (pnt!=null) p.setLocation(pnt); p.setVisible(); pTree.collapsePath(localPath); } }
public void treeExpanded(TreeExpansionEvent ev) { TreePath evPath = ev.getPath(); //DefaultMutableTreeNode node = (DefaultMutableTreeNode)evPath.getLastPathComponent(); String evPathString = ev.getPath().toString(); evPathString = pcp.pStr2Key(evPathString); evPathString = evPathString.substring(getTitle().length()+1,evPathString.length()); String rootPath = getRootPath().toString(); rootPath = pcp.pStr2Key(rootPath); //String path = rootPath+"."+evPathString; String path = rootPath+"."+evPathString; if (pcp.hasPanelShowingProperty(path)) { Hashtable panels = pcp.getPanels(); TreePanel p = (TreePanel)panels.get(path); if(p!=null) p.close(); } pcp.setExpandedStateProperty(path); }
public void actionPerformed(ActionEvent e) { String cmd=e.getActionCommand(); if(cmd==null) return; if (cmd.equals("Help")) { showHelp(); return; } if(cmd.equals("Show Parent")) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel panel = pcp.getPanelForNode(parent); if(panel==null) panel = pcp.newPanel(parent); if(panel!=null) panel.setVisible(); } return; } if(cmd.equals("Reload Plugins From Panel")) {// cmd fired by clicking on tree leaf pcp.closeAll(false); IJ.doCommand("Reload Plugins"); } else { if(cmd.equals("Reload Plugins")) // cmd fired from ImageJ menu; don't propagate it further pcp.closeAll(false); else IJ.doCommand(cmd); return; } }
if(pcp.hasExpandedStateProperty(npS) && !pcp.hasPanelShowingProperty(npS)) else if((pcp.hasExpandedStateProperty(npS) || pTree.isExpanded(newPath)) && pcp.hasPanelShowingProperty(npS)) pcp.unsetExpandedStateProperty(npS);
void saveProperties() { if (IJ.debugMode) IJ.log("CP.saveProperties: "+propertiesChanged); if (propertiesChanged) { clearProperties(); for (Enumeration e=visiblePanels.elements(); e.hasMoreElements();) { String s = (String)e.nextElement(); TreePanel p = (TreePanel)panels.get(s); if (p!=null) recordGeometry(p); } for(Enumeration e=expandedNodes.elements(); e.hasMoreElements();) Prefs.set((String)e.nextElement(),"expand"); } propertiesChanged=false; }
/**Constructs a TreePanel rooted at the path. * * @param s A string with the structure "[item1,item2,...,itemn]", as returned by * a call to the <code>toString()</code> method in the <code>javax.swing.tree.TreePath</code> class. * */ TreePanel newPanel(String path) { if (path.equals("Control_Panel.@Main")) path = "Control_Panel"; path = key2pStr(path); TreePanel pnl = null; for(Enumeration e = root.breadthFirstEnumeration(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode)e.nextElement(); TreePath p = new TreePath(n.getPath()); if (p.toString().equals(path)) pnl=newPanel(n); } return pnl; }
void setVisible() { if (pFrame!=null && !pFrame.isVisible()) { restoreExpandedNodes(); if (defaultLocation!=null) pFrame.setLocation(defaultLocation); pFrame.setVisible(true); // close expanded path to this panel in its parent panel (if visible and if the path is expanded) DefaultMutableTreeNode parent = (DefaultMutableTreeNode)root.getParent(); if (parent!=null) { TreePanel pnl = pcp.getPanelForNode(parent); if (pnl!=null && pnl.isVisible()) { TreeNode[] rPath = root.getPath(); TreeNode[] pPath = pnl.getRootNode().getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[rPath.length-pPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)rPath[i+pPath.length-1]; //TreePath path = new TreePath(rPath); TreePath localPath = new TreePath(tPath); pnl.getTree().collapsePath(localPath); } } } if (pcp!=null) pcp.setPanelShowingProperty(getRootPath().toString()); }
void tearOff(DefaultMutableTreeNode node, Point pnt) { isDragging = false; pFrame.setCursor(Cursor.getDefaultCursor()); if(node==null) node = (DefaultMutableTreeNode)pTree.getLastSelectedPathComponent(); if(node.isLeaf()) return; TreeNode[] nPath = node.getPath(); TreeNode[] rPath = root.getPath(); DefaultMutableTreeNode[] tPath = new DefaultMutableTreeNode[nPath.length-rPath.length+1]; for(int i=0; i<tPath.length; i++) tPath[i] = (DefaultMutableTreeNode)nPath[i+rPath.length-1]; TreePath path = new TreePath(nPath); TreePath localPath = new TreePath(tPath); String pathString = localPath.toString(); TreePanel p = pcp.getPanelForNode(node); if (p==null) { if(pnt!=null) p = pcp.newPanel(node, pnt); else p = pcp.newPanel(node); pTree.collapsePath(localPath); } else { if (pnt!=null) p.setLocation(pnt); p.setVisible(); pTree.collapsePath(localPath); } }
synchronized void load() { commands = Menus.getCommands(); pluginsArray = Menus.getPlugins(); root=doRootFromMenus(); if (root==null || root.getChildCount()==0 ) return; // do nothing if there's no tree or a root w/o children loadProperties(); restoreVisiblePanels(); if (panels.isEmpty()) newPanel(root); }
/**Short-hand for the four-argument <code>buildTreePath</code> method. * Calls <code>buildTreePath(source,label,<strong>null</strong>,topNode)</code>. * @see buildTreePath(String,String,String,DefaultMutableTreeNode). * */ private void buildTreePath(String source, String label, DefaultMutableTreeNode topNode) { buildTreePath(source, label, null, topNode); }
/** Creates a panel with the hierarchical tree structure of ImageJ's commands. */ public void run(String arg) { load(); }