use of org.freeplane.plugin.workspace.nodes.DefaultFileNode in project freeplane by freeplane.
the class FileNodeDeleteAction method deleteFile.
private void deleteFile(final AWorkspaceTreeNode node) {
if (node instanceof DefaultFileNode) {
((DefaultFileNode) node).delete();
} else if (node instanceof LinkTypeFileNode) {
File file = URIUtils.getAbsoluteFile(((LinkTypeFileNode) node).getLinkURI());
if (file != null) {
if (!file.delete()) {
// show message?
}
}
}
AWorkspaceTreeNode parent = node.getParent();
node.getModel().removeNodeFromParent(node);
parent.refresh();
parent.getModel().requestSave();
}
use of org.freeplane.plugin.workspace.nodes.DefaultFileNode in project freeplane by freeplane.
the class NodeRemoveAction method actionPerformed.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public void actionPerformed(ActionEvent e) {
AWorkspaceTreeNode[] targetNodes = getSelectedNodes(e);
if (targetNodes.length <= 0) {
return;
}
String question = "the selected nodes";
if (targetNodes.length == 1) {
question = targetNodes[0].getName();
}
int option = JOptionPane.showConfirmDialog(UITools.getFrame(), TextUtils.format("workspace.action.node.remove.confirm.text", question), TextUtils.getRawText("workspace.action.node.remove.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (option == JOptionPane.YES_OPTION) {
for (AWorkspaceTreeNode targetNode : targetNodes) {
AWorkspaceTreeNode parent = targetNode.getParent();
if (targetNode instanceof DefaultFileNode) {
// WORKSPACE - info: used in case of key events
((DefaultFileNode) targetNode).delete();
} else {
targetNode.getModel().removeNodeFromParent(targetNode);
}
if (parent != null) {
parent.refresh();
}
}
}
}
use of org.freeplane.plugin.workspace.nodes.DefaultFileNode in project freeplane by freeplane.
the class FileFolderDropHandler method processWorkspaceNodeDrop.
/**
*********************************************************************************
* CONSTRUCTORS
*********************************************************************************
*/
/**
*********************************************************************************
* METHODS
*********************************************************************************
*/
private void processWorkspaceNodeDrop(AWorkspaceTreeNode targetNode, List<AWorkspaceTreeNode> nodes, int dropAction) {
try {
File targetDir = ((IFileSystemRepresentation) targetNode).getFile();
if (targetDir != null && targetDir.isDirectory()) {
List<ITask> opList = new ArrayList<ITask>();
for (AWorkspaceTreeNode node : nodes) {
if (node instanceof DefaultFileNode) {
File srcFile = ((DefaultFileNode) node).getFile();
if (srcFile.equals(targetDir)) {
continue;
}
File destFile = new File(targetDir, srcFile.getName());
if (dropAction == DnDConstants.ACTION_COPY) {
FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
} else if (dropAction == DnDConstants.ACTION_MOVE) {
FileSystemManager.buildMoveOperationList(srcFile, destFile, opList);
opList.add(getPostOperation(targetNode, node, srcFile, destFile));
}
} else if (node instanceof LinkTypeFileNode) {
File srcFile = URIUtils.getAbsoluteFile(((LinkTypeFileNode) node).getLinkURI());
if (srcFile.equals(targetDir)) {
continue;
}
File destFile = new File(targetDir, srcFile.getName());
FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
if (dropAction == DnDConstants.ACTION_MOVE) {
opList.add(getPostOperation(targetNode, node, srcFile, destFile));
}
} else if (node instanceof FolderLinkNode) {
File srcFile = URIUtils.getAbsoluteFile(((FolderLinkNode) node).getPath());
if (srcFile.equals(targetDir)) {
continue;
}
File destFile = new File(targetDir, srcFile.getName());
FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
if (dropAction == DnDConstants.ACTION_MOVE) {
opList.add(getPostOperation(targetNode, node, srcFile, destFile));
}
}
}
FileSystemManager.execOperations(opList);
}
} catch (Exception e) {
LogUtils.warn(e);
}
}
use of org.freeplane.plugin.workspace.nodes.DefaultFileNode 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.nodes.DefaultFileNode in project freeplane by freeplane.
the class VirtualFolderDropHandler method processWorkspaceNodeDrop.
/**
*********************************************************************************
* CONSTRUCTORS
*********************************************************************************
*/
/**
*********************************************************************************
* METHODS
*********************************************************************************
*/
private void processWorkspaceNodeDrop(AWorkspaceTreeNode targetNode, List<AWorkspaceTreeNode> nodes, int dropAction) {
try {
for (AWorkspaceTreeNode node : nodes) {
AWorkspaceTreeNode newNode = null;
if (node instanceof DefaultFileNode) {
newNode = createFSNodeLinks(targetNode, ((DefaultFileNode) node).getFile());
} else {
if (dropAction == DnDConstants.ACTION_COPY) {
newNode = node.clone();
} else if (dropAction == DnDConstants.ACTION_MOVE) {
AWorkspaceTreeNode parent = node.getParent();
targetNode.getModel().cutNodeFromParent(node);
parent.refresh();
newNode = node;
}
}
if (newNode == null) {
continue;
}
targetNode.getModel().addNodeTo(newNode, targetNode);
// WorkspaceController.getController().getExpansionStateHandler().addPathKey(this.getKey());
}
// WorkspaceUtils.saveCurrentConfiguration();
} catch (Exception e) {
LogUtils.warn(e);
}
}
Aggregations