在Eclipse 3.2核心中发现的一段诡异代码

位于org.eclipse.ui.workbenck.texteditor_3.2.0v20060605-1400.jar包的
org.eclipse.ui.texteditor.AbstractTextEditor.class中。
2569行开始
直观上感觉这段代码是想支持鼠标手势的
/* gestures commented out until proper solution (i.e. preference page) can be found
* for bug # 28417:
*
final Map gestureMap= new HashMap();
gestureMap.put("E", "org.eclipse.ui.navigate.forwardHistory");
gestureMap.put("N", "org.eclipse.ui.file.save");
gestureMap.put("NW", "org.eclipse.ui.file.saveAll");
gestureMap.put("S", "org.eclipse.ui.file.close");
gestureMap.put("SW", "org.eclipse.ui.file.closeAll");
gestureMap.put("W", "org.eclipse.ui.navigate.backwardHistory");
gestureMap.put("EN", "org.eclipse.ui.edit.copy");
gestureMap.put("ES", "org.eclipse.ui.edit.paste");
gestureMap.put("EW", "org.eclipse.ui.edit.cut");
Capture capture= Capture.create();
capture.setControl(styledText);
capture.addCaptureListener(new CaptureListener() {
public void gesture(Gesture gesture) {
if (gesture.getPen() == 3) {
String actionId= (String) gestureMap.get(Util.recognize(gesture.getPoints(), 20));
if (actionId != null) {
IKeyBindingService keyBindingService= getEditorSite().getKeyBindingService();
if (keyBindingService instanceof KeyBindingService) {
IAction action= ((KeyBindingService) keyBindingService).getAction(actionId);
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
if (action.isEnabled())
action.run();
}
}
return;
}
fTextContextMenu.setVisible(true);
}
};
});
*/

作者:Gem Chen

原谅我这一生不羁放纵爱自由

发表评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据