Search in sources :

Example 31 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ProjectModel method removeNodeFromParent.

/**
 * @param node
 */
public void removeNodeFromParent(AWorkspaceTreeNode node) {
    this.hashStringKeyIndex.remove(node.getKey());
    AWorkspaceTreeNode parent = node.getParent();
    parent.removeChild(node);
    node.disassociateReferences();
    fireTreeNodesRemoved(this, parent.getTreePath(), null, new Object[] { node });
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 32 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ProjectModel method setRoot.

public void setRoot(AWorkspaceTreeNode newRoot) {
    AWorkspaceTreeNode oldRoot = this.root;
    this.root = newRoot;
    if (this.root != null) {
        this.root.setModel(this);
        if (oldRoot == null) {
            fireTreeNodesInserted(this, null, new int[] {}, new Object[] { root });
        } else {
            fireTreeNodesChanged(this, null, new int[] {}, new Object[] { root });
        }
    } else {
        if (oldRoot != null) {
            fireTreeNodesRemoved(this, null, new int[] {}, new Object[] { oldRoot });
        }
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 33 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ProjectModel method getAllNodesFiltered.

public List<URI> getAllNodesFiltered(String filter) {
    HashSet<URI> set = new HashSet<URI>();
    Collection<AWorkspaceTreeNode> values = hashStringKeyIndex.values();
    for (AWorkspaceTreeNode node : values) {
        if (node instanceof AFolderNode || node instanceof FolderFileNode) {
            continue;
        }
        if (node instanceof DefaultFileNode) {
            File file = ((DefaultFileNode) node).getFile();
            if (file.getName().endsWith(filter)) {
                set.add(file.toURI());
            }
        } else if (node instanceof ALinkNode) {
            URI uri = ((ALinkNode) node).getLinkURI();
            if (uri.getPath().endsWith(filter)) {
                URI absUri = URIUtils.getAbsoluteURI(uri);
                if (absUri == null) {
                    continue;
                }
                set.add(absUri);
            }
        }
    }
    return Arrays.asList(set.toArray(new URI[] {}));
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) FolderFileNode(org.freeplane.plugin.workspace.nodes.FolderFileNode) AFolderNode(org.freeplane.plugin.workspace.nodes.AFolderNode) ALinkNode(org.freeplane.plugin.workspace.nodes.ALinkNode) URI(java.net.URI) File(java.io.File) DefaultFileNode(org.freeplane.plugin.workspace.nodes.DefaultFileNode) HashSet(java.util.HashSet)

Example 34 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ProjectModel method removeAllElements.

/**
 * @param node
 */
public void removeAllElements(AWorkspaceTreeNode node) {
    Enumeration<AWorkspaceTreeNode> children = node.children();
    AWorkspaceTreeNode child = null;
    while (children.hasMoreElements()) {
        child = children.nextElement();
        this.hashStringKeyIndex.remove(child.getKey());
        child.disassociateReferences();
        fireTreeNodesRemoved(this, node.getTreePath(), null, new Object[] { child });
    }
    node.removeAllChildren();
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 35 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class DefaultFileNode method getTransferable.

public WorkspaceTransferable getTransferable() {
    WorkspaceTransferable transferable = new WorkspaceTransferable();
    try {
        URI uri = URIUtils.getAbsoluteURI(getFile().toURI());
        transferable.addData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR, uri.toString());
        List<File> fileList = new Vector<File>();
        fileList.add(new File(uri));
        transferable.addData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR, fileList);
    } catch (Exception e) {
        LogUtils.warn(e);
    }
    if (!this.isSystem()) {
        List<AWorkspaceTreeNode> objectList = new ArrayList<AWorkspaceTreeNode>();
        objectList.add(this);
        transferable.addData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR, objectList);
    }
    return transferable;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) ArrayList(java.util.ArrayList) WorkspaceTransferable(org.freeplane.plugin.workspace.dnd.WorkspaceTransferable) URI(java.net.URI) File(java.io.File) Vector(java.util.Vector)

Aggregations

AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)51 File (java.io.File)13 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 WorkspaceTransferable (org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)7 TreePath (javax.swing.tree.TreePath)6 DefaultFileNode (org.freeplane.plugin.workspace.nodes.DefaultFileNode)6 JTree (javax.swing.JTree)5 IOException (java.io.IOException)4 IWorkspaceView (org.freeplane.plugin.workspace.components.IWorkspaceView)4 IFileSystemRepresentation (org.freeplane.plugin.workspace.io.IFileSystemRepresentation)4 LinkTypeFileNode (org.freeplane.plugin.workspace.nodes.LinkTypeFileNode)4 Vector (java.util.Vector)3 IWorkspaceNodeActionListener (org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener)3 WorkspaceActionEvent (org.freeplane.plugin.workspace.event.WorkspaceActionEvent)3 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)3 AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)3 FolderLinkNode (org.freeplane.plugin.workspace.nodes.FolderLinkNode)3 List (java.util.List)2 WorkspacePopupMenu (org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)2