use of org.freeplane.plugin.workspace.nodes.FolderLinkNode in project freeplane by freeplane.
the class VirtualFolderDropHandler method createFSNodeLinks.
/**
* @param file
* @return
*/
private AWorkspaceTreeNode createFSNodeLinks(AWorkspaceTreeNode targetNode, File file) {
AWorkspaceTreeNode node = null;
AWorkspaceProject project = WorkspaceController.getProject(targetNode);
if (file.isDirectory()) {
FolderLinkNode pNode = new FolderLinkNode();
pNode.setPath(project.getRelativeURI(file.toURI()));
node = pNode;
} else {
LinkTypeFileNode lNode = new LinkTypeFileNode();
lNode.setLinkURI(project.getRelativeURI(file.toURI()));
node = lNode;
}
node.setName(file.getName());
return node;
}
use of org.freeplane.plugin.workspace.nodes.FolderLinkNode 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.FolderLinkNode in project freeplane by freeplane.
the class NodeNewFolderAction 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);
int mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_PHYSICAL;
if (targetNode instanceof IFileSystemRepresentation) {
mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_ONLY;
}
WorkspaceNewFolderPanel dialog = new WorkspaceNewFolderPanel(mode, targetNode);
int response = JOptionPane.showConfirmDialog(UITools.getFrame(), dialog, TextUtils.getText("workspace.action.node.new.folder.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (response == JOptionPane.OK_OPTION) {
String value = dialog.getFolderName();
if (value == null || value.trim().length() <= 0) {
// WORKSPACE - ToDo: prepare message, or call this method (with error message) again?
return;
}
if (dialog.isLinkedFolder()) {
File path = new File(dialog.getLinkPath());
if (path != null) {
FolderLinkNode node = new FolderLinkNode();
node.setName(value);
URI uri = project.getRelativeURI(path.toURI());
if (uri == null) {
node.setPath(path.toURI());
} else {
node.setPath(uri);
}
targetNode.getModel().addNodeTo(node, targetNode);
node.refresh();
}
} else {
if (targetNode instanceof IFileSystemRepresentation) {
try {
WorkspaceController.getFileSystemMgr().createDirectory(value, ((IFileSystemRepresentation) targetNode).getFile());
} catch (IOException e1) {
JOptionPane.showMessageDialog(UITools.getFrame(), e1.getMessage());
}
} else {
FolderVirtualNode node = new FolderVirtualNode();
node.setName(value);
targetNode.getModel().addNodeTo(node, targetNode);
}
}
targetNode.refresh();
targetNode.getModel().requestSave();
}
}
use of org.freeplane.plugin.workspace.nodes.FolderLinkNode in project freeplane by freeplane.
the class FolderTypePhysicalCreator method getNode.
public AWorkspaceTreeNode getNode(XMLElement data) {
String type = data.getAttribute("type", AFolderNode.FOLDER_TYPE_PHYSICAL);
FolderLinkNode node = new FolderLinkNode(type);
String path = data.getAttribute("path", null);
if (path == null) {
return null;
}
node.setPath(URIUtils.createURI(path));
File file = URIUtils.getAbsoluteFile(node.getPath());
if (file == null) {
return null;
}
boolean monitor = Boolean.parseBoolean(data.getAttribute("monitor", "false"));
node.enableMonitoring(monitor);
boolean descending = Boolean.parseBoolean(data.getAttribute("orderDescending", "false"));
node.orderDescending(descending);
String name = data.getAttribute("name", file.getName());
node.setName(name);
return node;
}
Aggregations