use of org.freeplane.plugin.workspace.nodes.AFolderNode in project freeplane by freeplane.
the class NodeNewLinkAction method actionPerformed.
/**
*********************************************************************************
* METHODS
*********************************************************************************
*/
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public void actionPerformed(ActionEvent e) {
AWorkspaceTreeNode targetNode = null;
if (e == null || getRootPopupMenu((Component) e.getSource()) == null) {
targetNode = WorkspaceController.getCurrentProject().getModel().getRoot();
} else {
targetNode = getNodeFromActionEvent(e);
}
if (targetNode == null) {
return;
}
AWorkspaceProject project = WorkspaceController.getProject(targetNode);
if (targetNode instanceof AFolderNode) {
JFileChooser chooser = new JFileChooser(URIUtils.getAbsoluteFile(((AFolderNode) targetNode).getPath() == null ? WorkspaceController.getCurrentProject().getProjectHome() : ((AFolderNode) targetNode).getPath()));
chooser.setMultiSelectionEnabled(false);
int response = chooser.showOpenDialog(UITools.getFrame());
if (response == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (file != null) {
LinkTypeFileNode node = new LinkTypeFileNode();
node.setName(file.getName());
URI path = chooser.getSelectedFile().toURI();
if (path == null) {
return;
}
URI uri = project.getRelativeURI(path);
if (uri == null) {
node.setLinkURI(path);
} else {
node.setLinkURI(uri);
}
targetNode.getModel().addNodeTo(node, targetNode);
targetNode.refresh();
targetNode.getModel().requestSave();
}
}
}
}
use of org.freeplane.plugin.workspace.nodes.AFolderNode 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[] {}));
}
Aggregations