/** * Main for testing. */ public static void main(String[] args) { JFrame f = new JFrame(); FileTreePanel ftp = new FileTreePanel(null); final DefaultFileFilterMenuItemConstructor mic = new DefaultFileFilterMenuItemConstructor(new String[]{".doc"}, ftp.getModel()); ftp.setPopupBuilder(new PopupBuilder(new Object[]{mic})); ftp.setNodeFactory(new DefaultNodeFactory() { public IRemoteFilter getFileFilter() { return new DefaultFileFilter(mic.isAll(), mic.getSelectedComponentTypes()); } }); ftp.addNodeHandler(new DefaultNodeHandler(ftp.getTree())); ftp.addTopLevelNode(new File("c:/")); f.add(new JScrollPane(ftp), BorderLayout.CENTER); f.pack(); f.setLocation(SGUI.calculateMiddlePosition(f)); f.setVisible(true); }
/** * Show the popup. * @param x The x position. * @param y The y position. */ protected void showPopUp(int x, int y) { TreePath sel = tree.getPathForLocation(x, y); if(sel==null) { tree.clearSelection(); // System.out.println("show"); if(pubuilder!=null) { JPopupMenu pop = pubuilder.buildPopupMenu(); pop.show(tree, x, y); } } }
RefreshAllAction ra = new RefreshAllAction(ftp, service); final DefaultFileFilterMenuItemConstructor mic = new DefaultFileFilterMenuItemConstructor(ftp.getModel(), true); ftp.setPopupBuilder(new PopupBuilder(new Object[]{ra, mic})); ftp.setMenuItemConstructor(mic); ftp.setNodeFactory(new DefaultNodeFactory()
RefreshAllAction ra = new RefreshAllAction(ftp, service); final DefaultFileFilterMenuItemConstructor mic = new DefaultFileFilterMenuItemConstructor(ftp.getModel(), true); ftp.setPopupBuilder(new PopupBuilder(new Object[]{ra, mic})); ftp.setMenuItemConstructor(mic); ftp.setNodeFactory(new DefaultNodeFactory()
actions.put(AddRIDAction.getName(), new AddRIDAction(taa)); actions.put(RemovePathAction.getName(), rpa); setPopupBuilder(new PopupBuilder(new Object[]{actions.get(AddPathAction.getName()), actions.get(AddRIDAction.getName()), actions.get(AddRemotePathAction.getName()), mic})); setMenuItemConstructor(mic);