/** * Register a node. Nodes can be registered for easy access. */ public void registerNode(ITreeNode node) { synchronized(nodes) { // System.out.println("registered: "+node.getId()); if(nodes.containsKey(node.getId())) throw new RuntimeException("Node id already contained: " + node + ", " + node.getId()); nodes.put(node.getId(), node); } }
/** * Build a tree path to the given node. * * @param desc The node. * @return The path items. */ public List<ITreeNode> buildTreePath(ITreeNode node) { List<ITreeNode> path = new LinkedList<ITreeNode>(); ITreeNode pnode = node; while (pnode != null) { path.add(0, pnode); pnode = pnode.getParent(); } return path; }
/** * Test if the node is a leaf. */ public boolean isLeaf(Object node) { return ((ITreeNode) node).isLeaf(); }
/** * Add a node. Informs listeners. */ public void addNode(ITreeNode node) { added.put(node.getId(), node); INodeListener[] lis = nodelisteners.toArray(new INodeListener[nodelisteners.size()]); for(int i = 0; i < lis.length; i++) { lis[i].nodeAdded(node); } for(int i = 0; i < node.getCachedChildren().size(); i++) { addNode((ITreeNode)node.getCachedChildren().get(i)); } }
node.dispose(); boolean notify = false; synchronized (nodes) if(zombies.containsKey(node.getId())) zombies.remove(node.getId()); nodes.remove(node.getId()); nodes.remove(node.getId()); added.remove(node.getId()); notify = true; for(int i = 0; i < node.getCachedChildren().size(); i++) deregisterNode((ITreeNode)node.getCachedChildren().get(i));
changed.add(node.getParent(), node); if (parents[i] == null || getAddedNode(parents[i].getId()) != null) if(getAddedNode(nodes[cnt].getId()) != null) indices[cnt] = parents[i].getIndexOfChild((ITreeNode) nodes[cnt]); if (indices[cnt] != -1)
public void customExceptionOccurred(Exception exception) { jcc.setStatusText("Copy error: "+sel1+" to: "+sel2+" exception: "+exception.getMessage()); ((ITreeNode)sp2.getLastPathComponent()).refresh(true); } });
/** * Get the given child of a node. */ public ITreeNode getChild(Object parent, int index) { return ((ITreeNode) parent).getChild(index); }
/** * Called when the tree is removed. */ public void dispose() { ITreeNode[] anodes; synchronized (nodes) { anodes = nodes.values().toArray(new ITreeNode[nodes.values().size()]); } for (int i = 0; i < anodes.length; i++) { anodes[i].dispose(); } }
public void customFinished() { jcc.setStatusText("Copied: "+sel1+" to "+sel2); ((ITreeNode)sp2.getLastPathComponent()).refresh(true); }
/** * Remove a zombie node. */ public void removeZombieNode(ITreeNode node) { synchronized(nodes) { Integer num = zombies.get(node.getId()); if(num.intValue()>1) { num = Integer.valueOf(num.intValue()-1); zombies.put(node.getId(), num); // if(node.getId().toString().startsWith("ANDTest@")) // System.out.println("Zombie node count decreased: "+node+", "+num); } else { // if(node.getId().toString().startsWith("ANDTest@")) // System.out.println("Zombie node removed: "+node+", "+num); deregisterNode(node); } } }
/** * Create a resource identifier. */ public IFuture<IResourceIdentifier> createResourceIdentifier(IFileNode node) { // Get the first child of selection path as url // TreePath selpath = mpanel.getTree().getSelectionModel().getSelectionPath(); ITreeNode root = node; while(root.getParent()!=null && root.getParent().getParent()!=null) root = root.getParent(); final String filepath = ((IFileNode)root).getFilePath(); return ModelTreePanel.createResourceIdentifier(jcc.getPlatformAccess(), filepath); // final Future<IResourceIdentifier> ret = new Future<IResourceIdentifier>(); // SServiceProvider.getService(jcc.getPlatformAccess().getServiceProvider(), ILibraryService.class, RequiredServiceInfo.SCOPE_PLATFORM) // .addResultListener(new ExceptionDelegationResultListener<ILibraryService, IResourceIdentifier>(ret) // { // public void customResultAvailable(ILibraryService ls) // { // // Must be done on remote site as SUtil.toURL() uses new File() // final URL url = SUtil.toURL(filepath); // // ls.getResourceIdentifier(url).addResultListener(new DelegationResultListener<IResourceIdentifier>(ret)); // } // }); // // return ret; } }
public void customFinished() { jcc.setStatusText("Copied: "+sel1+" to "+sel2); ((ITreeNode)sp2.getLastPathComponent()).refresh(true); }
/** * Create transferable on drag start. */ protected Transferable createTransferable(JComponent c) { Transferable ret = null; JTree tree = (JTree)c; TreePath path = tree.getSelectionPath(); Object o = path!=null ? path.getLastPathComponent() : null; if(o instanceof IFileNode && (((ITreeNode)o).isLeaf() || !isRealDirectory((IFileNode)o))) { ret = new NodesTransferable(new TransferInfo(DeploymentServiceViewerPanel.this)); } return ret; }
/** * Create a resource identifier. */ public IFuture<IResourceIdentifier> createResourceIdentifier(IFileNode node) { // Get the first child of selection path as url // TreePath selpath = mpanel.getTree().getSelectionModel().getSelectionPath(); ITreeNode root = node; while(root.getParent()!=null && root.getParent().getParent()!=null) root = root.getParent(); final String filepath = ((IFileNode)root).getFilePath(); return ModelTreePanel.createResourceIdentifier(jcc.getPlatformAccess(), filepath); // final Future<IResourceIdentifier> ret = new Future<IResourceIdentifier>(); // SServiceProvider.getService(jcc.getPlatformAccess().getServiceProvider(), ILibraryService.class, RequiredServiceInfo.SCOPE_PLATFORM) // .addResultListener(new ExceptionDelegationResultListener<ILibraryService, IResourceIdentifier>(ret) // { // public void customResultAvailable(ILibraryService ls) // { // // Must be done on remote site as SUtil.toURL() uses new File() // final URL url = SUtil.toURL(filepath); // // ls.getResourceIdentifier(url).addResultListener(new DelegationResultListener<IResourceIdentifier>(ret)); // } // }); // // return ret; } }
public void customExceptionOccurred(Exception exception) { jcc.setStatusText("Copy error: "+sel1+" to: "+sel2+" exception: "+exception.getMessage()); ((ITreeNode)sp2.getLastPathComponent()).refresh(true); } });
/** * Create transferable on drag start. */ protected Transferable createTransferable(JComponent c) { Transferable ret = null; JTree tree = (JTree)c; TreePath path = tree.getSelectionPath(); Object o = path!=null ? path.getLastPathComponent() : null; if(o instanceof IFileNode && (((ITreeNode)o).isLeaf() || !isRealDirectory((IFileNode)o))) { ret = new NodesTransferable(new TransferInfo(FileTransferServiceViewerPanel.this)); } return ret; }