use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class InputController method initActionKeyMap.
/**
*******
* Keyboard events
*/
private void initActionKeyMap() {
actionKeyMap.put(new HotKeyIdentifier("copy", KeyStroke.getKeyStroke(KeyEvent.VK_C, /*KeyEvent.CTRL_DOWN_MASK*/
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())), NodeCopyAction.KEY);
actionKeyMap.put(new HotKeyIdentifier("cut", KeyStroke.getKeyStroke(KeyEvent.VK_X, /*KeyEvent.CTRL_DOWN_MASK*/
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())), NodeCutAction.KEY);
actionKeyMap.put(new HotKeyIdentifier("paste", KeyStroke.getKeyStroke(KeyEvent.VK_V, /*KeyEvent.CTRL_DOWN_MASK*/
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new KeyEventAcceptor() {
public boolean accept(KeyEvent e) {
TreePath path = ((JTree) e.getSource()).getSelectionPath();
if (path == null) {
return false;
}
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
if (DnDController.isDropAllowed(node)) {
return true;
}
return false;
}
}), NodePasteAction.KEY);
actionKeyMap.put(new HotKeyIdentifier("delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), new KeyEventAcceptor() {
public boolean accept(KeyEvent e) {
TreePath path = ((JTree) e.getSource()).getSelectionPath();
if (path == null) {
return false;
}
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
if (!node.isSystem() && node.isTransferable()) {
return true;
}
return false;
}
}), NodeRemoveAction.KEY);
actionKeyMap.put(new HotKeyIdentifier("rename", KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), new KeyEventAcceptor() {
public boolean accept(KeyEvent event) {
TreePath path = ((JTree) event.getSource()).getSelectionPath();
if (path == null) {
return false;
}
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
if (!node.isSystem()) {
return true;
}
return false;
}
}), NodeRenameAction.KEY);
actionKeyMap.put(new HotKeyIdentifier("refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)), NodeRefreshAction.KEY);
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode 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);
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class ProjectModel method removeFromIndexRecursively.
/**
* @param node
*/
private void removeFromIndexRecursively(AWorkspaceTreeNode node) {
List<AWorkspaceTreeNode> removes = new ArrayList<AWorkspaceTreeNode>();
this.hashStringKeyIndex.remove(node.getKey());
if (node.getChildCount() > 0) {
int[] indices = new int[node.getChildCount()];
for (int i = 0; i < node.getChildCount(); i++) {
AWorkspaceTreeNode childNode = node.getChildAt(i);
removeFromIndexRecursively(childNode);
removes.add(childNode);
indices[i] = i;
}
fireTreeNodesRemoved(this, node.getTreePath(), indices, removes.toArray());
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class ProjectModel method cutNodeFromParent.
/**
* @param node
*/
public void cutNodeFromParent(AWorkspaceTreeNode node) {
AWorkspaceTreeNode parent = node.getParent();
removeFromIndexRecursively(node);
parent.removeChild(node);
fireTreeNodesRemoved(this, parent.getTreePath(), null, new Object[] { node });
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class FolderVirtualNode method getTransferable.
public WorkspaceTransferable getTransferable() {
WorkspaceTransferable transferable = new WorkspaceTransferable();
try {
List<AWorkspaceTreeNode> objectList = new ArrayList<AWorkspaceTreeNode>();
objectList.add(this);
transferable.addData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR, objectList);
return transferable;
} catch (Exception e) {
LogUtils.warn(e);
}
return null;
}
Aggregations