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 });
}
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 });
}
}
}
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[] {}));
}
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();
}
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;
}
Aggregations