use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class NodeRenameAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
AWorkspaceTreeNode targetNode = this.getNodeFromActionEvent(e);
String oldName = targetNode.getName();
NodeRenameDialogPanel panel;
// if (targetNode instanceof IMutableLinkNode) {
// panel = new NodeRenameDialogPanel(oldName, true);
// }
// else {
panel = new NodeRenameDialogPanel(oldName);
if (targetNode instanceof DefaultFileNode) {
panel.setCheckboxSelected(true);
}
// }
int okButton = JOptionPane.showConfirmDialog(UITools.getFrame(), panel, TextUtils.getText("confirm_rename_file_action"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
String newName = panel.getText();
if (okButton != JOptionPane.OK_OPTION || oldName.equals(newName)) {
return;
}
if (newName != null) {
if (targetNode instanceof IMutableLinkNode) {
if (((IMutableLinkNode) targetNode).changeName(newName, panel.applyChangesForLink())) {
targetNode.refresh();
} else {
JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file"), TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
targetNode.setName(oldName);
}
} else {
try {
targetNode.getModel().changeNodeName(targetNode, newName);
targetNode.refresh();
} catch (Exception ex) {
JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file") + " (" + ex.getMessage() + ")", TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
}
}
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class FileSystemManager method iterateDirectory.
private void iterateDirectory(AWorkspaceTreeNode parent, File directory, FileFilter filter, final boolean orderDescending) {
boolean orderDesc = orderDescending;
for (File file : sortFiles(directory.listFiles(new DirectoryFilter(filter)), orderDesc, true)) {
AWorkspaceTreeNode newParent = createFileNode(parent, FileReadManager.DIRECTORY_HANDLE, file);
iterateDirectory(newParent, file, filter, orderDesc);
}
for (File file : sortFiles(directory.listFiles(new FilesOnlyFilter(filter)), orderDesc, true)) {
createFileNode(parent, file);
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class InputController method keyPressed.
public void keyPressed(KeyEvent e) {
KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
TreePath path = ((JTree) e.getSource()).getSelectionPath();
if (path == null) {
return;
}
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
if (node instanceof IWorkspaceNodeActionListener) {
((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
e.consume();
}
} else {
for (HotKeyIdentifier id : actionKeyMap.keySet()) {
if (currentStroke.equals(id.getKeyStroke())) {
if (id.accept(e)) {
AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
if (action != null) {
action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
} else {
LogUtils.info("No action set for: " + id.getKeyStroke());
}
}
e.consume();
break;
}
}
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class NodeCopyAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
AWorkspaceTreeNode[] targetNodes = getSelectedNodes(e);
WorkspaceTransferable transferable = null;
for (AWorkspaceTreeNode targetNode : targetNodes) {
if (targetNode instanceof IWorkspaceTransferableCreator) {
if (transferable == null) {
transferable = ((IWorkspaceTransferableCreator) targetNode).getTransferable();
} else {
transferable.merge(((IWorkspaceTransferableCreator) targetNode).getTransferable());
}
}
}
if (transferable == null) {
return;
}
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, new CopyClipboardOwner(transferable));
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class ActionCreator method getNode.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public AWorkspaceTreeNode getNode(XMLElement data) {
String type = data.getAttribute("type", null);
if (type == null || !creatorTable.containsKey(type)) {
return null;
}
AWorkspaceNodeCreator creator = creatorTable.get(type);
AWorkspaceTreeNode node = creator.getNode(data);
return node;
}
Aggregations