- 论坛徽章:
- 0
|
针对freemind 0.9.0_Beta_17.
freemind用着很不错, 但总觉得移动光标和添加CHILDNODE,删除NODE太麻烦, 不利于快速编辑. 于是花了几个小时搜索了源程序, 添加了类vim这样的快捷键. 实现了用j,k,h,l向下,上,左,右的移动;用i,d添加子结点,删除结点的功能. 这样用起来更加快捷了.
下面是修改方法:
说明: 红色为添加的代码.
freemind/view/mindmapview/MapView.java:
//
// Node Navigation
//
private NodeView getNeighbour(int directionCode) {
NodeView oldSelected = getSelected();
NodeView newSelected = null;
switch (directionCode) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_H:
setSiblingMaxLevel(oldSelected.getModel().getNodeLevel()); // for case of return
if(oldSelected.getModel().isRoot()){
LinkedList left = (oldSelected).getLeft(true);
if (left.size() == 0) return null;
newSelected = oldSelected.getPreferredChild();
if (!left.contains(newSelected)) {
newSelected = (NodeView)left.getFirst();
}
} else if(!oldSelected.isLeft()) {
newSelected = oldSelected.getParentView();
} else {
if (oldSelected.getModel().isFolded()) { // If folded in the direction, unfold
model.getModeController().setFolded(oldSelected.getModel(), false);
return oldSelected;
}
if (oldSelected.getChildrenViews().size() == 0) return null;
newSelected = oldSelected.getPreferredChild();
}
setSiblingMaxLevel(newSelected.getModel().getNodeLevel());
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_L:
setSiblingMaxLevel(oldSelected.getModel().getNodeLevel()); // for case of return
if(oldSelected.isRoot()) {
LinkedList right = (oldSelected).getRight(true);
if (right.size() == 0) return null;
newSelected = oldSelected.getPreferredChild();
if (!right.contains(newSelected)) {
newSelected = (NodeView)right.getFirst();
}
} else if(oldSelected.isLeft()) {
newSelected = oldSelected.getParentView();
} else {
if (oldSelected.getModel().isFolded()) { // If folded in the direction, unfold
// URGENT: Change to controller setFolded.
// getModel().setFolded(oldSelected.getModel(), false);
getController().getModeController().setFolded(oldSelected.getModel(), false);
return oldSelected;
}
if (oldSelected.getChildrenViews().size() == 0) return null;
newSelected = oldSelected.getPreferredChild();
}
setSiblingMaxLevel(newSelected.getModel().getNodeLevel());
break;
case KeyEvent.VK_UP:
case KeyEvent.VK_K:
newSelected = oldSelected.getPreviousSibling();
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_J:
newSelected = oldSelected.getNextSibling();
break;
case KeyEvent.VK_PAGE_UP:
newSelected = oldSelected.getPreviousPage();
break;
case KeyEvent.VK_PAGE_DOWN:
newSelected = oldSelected.getNextPage();
break;
}
return newSelected != oldSelected ? newSelected : null;
}
freemind/modes/common/CommonNodeKeylistener.java:
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_ESCAPE:
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_DELETE:
case KeyEvent.VK_SPACE:
case KeyEvent.VK_INSERT:
// fc, 20.6.2004: to enable tab for insert.
case KeyEvent.VK_TAB:
// end change.
return; // processed by Adapters ActionListener
// explicitly what is not catched in e.isActionKey()
case KeyEvent.VK_I: e.setKeyCode(KeyEvent.VK_INSERT); return; case KeyEvent.VK_D: e.setKeyCode(KeyEvent.VK_DELETE); return;
case KeyEvent.VK_UP:
case KeyEvent.VK_DOWN:
case KeyEvent.VK_LEFT:
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_PAGE_UP:
case KeyEvent.VK_PAGE_DOWN:
case KeyEvent.VK_J: case KeyEvent.VK_K: case KeyEvent.VK_L: case KeyEvent.VK_H:
c.getView().move(e);
return;
case KeyEvent.VK_HOME:
case KeyEvent.VK_END:
case KeyEvent.VK_BACK_SPACE:
editHandler.edit(e, false, false);
return;
// case KeyEvent.VK_SPACE:
// c.getMode().getModeController().toggleFolded();
// e.consume();
// return;
}
freemind/view/mindmapview/EditNodeBase.java:
去掉以下代码:
// while(iterator.hasNext()){
// final KeyEvent ke = (KeyEvent)iterator.next();
// ke.setSource(textComponent);
// textComponent.dispatchEvent(ke);
// }
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/24274/showart_693533.html |
|