use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode 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.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class ProjectNodeWriter method writeContent.
public void writeContent(ITreeWriter writer, Object element, String tag) throws IOException {
final AWorkspaceTreeNode node = (AWorkspaceTreeNode) element;
for (int i = 0; i < node.getChildCount(); i++) {
AWorkspaceTreeNode child = node.getChildAt(i);
if (child == null || child.getTagName() == null) {
continue;
}
writer.addElement(child, child.getTagName());
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class FileFolderDropHandler method processDrop.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
@SuppressWarnings("unchecked")
public boolean processDrop(AWorkspaceTreeNode targetNode, Transferable transferable, int dropAction) {
try {
if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR)) {
processWorkspaceNodeDrop(targetNode, (List<AWorkspaceTreeNode>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR), dropAction);
} else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR)) {
processFileListDrop(targetNode, (List<File>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR), dropAction);
} else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR)) {
ArrayList<URI> uriList = new ArrayList<URI>();
String uriString = (String) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR);
if (!uriString.startsWith("file://")) {
return false;
}
String[] uriArray = uriString.split("\r\n");
for (String singleUri : uriArray) {
try {
uriList.add(URIUtils.createURI(singleUri));
} catch (Exception e) {
LogUtils.info("org.freeplane.plugin.workspace.mindmapmode.FolderFileDropHandler.processDrop(targetNode, transferable, dropAction)@1" + e.getMessage());
}
}
processUriListDrop(targetNode, uriList, dropAction);
}
targetNode.refresh();
IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
if (view != null) {
view.expandPath(targetNode.getTreePath());
WorkspaceController.getCurrentModeExtension().getView().refreshView();
}
} catch (Exception e) {
LogUtils.warn("org.freeplane.plugin.workspace.mindmapmode.FolderFileDropHandler.processDrop(targetNode, transferable, dropAction)@2", e);
}
return true;
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode 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.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class ProjectModel method removeIndexOnlyRecursively.
/**
* @param node
*/
private void removeIndexOnlyRecursively(AWorkspaceTreeNode node) {
this.hashStringKeyIndex.remove(node.getKey());
if (node.getChildCount() > 0) {
for (int i = 0; i < node.getChildCount(); i++) {
AWorkspaceTreeNode childNode = node.getChildAt(i);
removeIndexOnlyRecursively(childNode);
}
}
}
Aggregations