void restoreVisiblePanels() { String[] visPanls = new String[visiblePanels.size()]; visiblePanels.toArray(visPanls); Arrays.sort(visPanls); for (int i=0; i<visPanls.length; i++) { if (!panels.containsKey(visPanls[i])) { TreePanel p = newPanel(visPanls[i]); } } }
void restoreVisiblePanels() { String[] visPanls = new String[visiblePanels.size()]; visiblePanels.toArray(visPanls); Arrays.sort(visPanls); for (int i=0; i<visPanls.length; i++) { if (!panels.containsKey(visPanls[i])) { TreePanel p = newPanel(visPanls[i]); } } }
/**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; }
/**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; }
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); }
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; } }
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); }
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; } }
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); } }
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); } }