这是我的导航器视图。
public class myNavigatorView extends ResourceNavigator {
private NavigatorActionGroup navigatorActionGroup;
private CollapseAllHandler collapseAllHandler;
public myNavigatorView() {
// TODO Auto-generated constructor stub
}
protected void makeActions() {
navigatorActionGroup = new NavigatorActionGroup( this );
setActionGroup(navigatorActionGroup);
IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
service.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR,
new ActionHandler(navigatorActionGroup.toggleLinkingAction));
collapseAllHandler = new CollapseAllHandler(this.getViewer());
service.activateHandler(CollapseAllHandler.COMMAND_ID,
collapseAllHandler);
}
}
当我双击我选择的项目时,内容没有显示在编辑器中。
layout.setEditorAreaVisible(true);
leftFolder.addView("BIT_DEC.myNavigator");
答案 0 :(得分:1)
资源导航器执行此操作以进行打开:
protected void handleOpen(ISelection selection) {
if (selection instanceof IStructuredSelection) {
getActionGroup().runDefaultAction((IStructuredSelection)selection);
}
}
因此,您的操作组runDefaultAction
方法需要打开。资源导航器代码执行此操作:
public void runDefaultAction(IStructuredSelection selection) {
Object element = selection.getFirstElement();
if (element instanceof IFile) {
openFileAction.selectionChanged(selection);
openFileAction.run();
}
}
其中openFileAction
是org.eclipse.ui.actions.OpenFileAction
的实例。
注意:ResourceNavigator
已被弃用了很长时间!