コード例 #1
0
 /** Runs the default action (open file). */
 public void runDefaultAction(IStructuredSelection selection) {
   Object element = selection.getFirstElement();
   if (element instanceof IPage) {
     openFileAction.selectionChanged(selection);
     openFileAction.run();
   }
 }
コード例 #2
0
ファイル: OpenActionProvider.java プロジェクト: eclipse/edt
 public void init(ICommonActionExtensionSite aConfig) {
   if (aConfig.getViewSite() instanceof ICommonViewerWorkbenchSite) {
     viewSite = (ICommonViewerWorkbenchSite) aConfig.getViewSite();
     openFileAction = new OpenFileAction(viewSite.getPage());
     openIRFileAction = new OpenIRFileAction(viewSite.getPage());
     openFileAction.setActionDefinitionId(
         IJavaEditorActionDefinitionIds.OPEN_EDITOR); // so F3 will show
     contribute = true;
   }
 }
コード例 #3
0
ファイル: OpenActionProvider.java プロジェクト: eclipse/edt
  public void fillContextMenu(IMenuManager menu) {
    if (!contribute || getContext().getSelection().isEmpty()) {
      return;
    }
    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();

    if (selection.size() == 1) {
      Object selObj = selection.getFirstElement();
      if (selObj instanceof IClassFile) {
        openIRFileAction.setClassFile((IClassFile) selObj);
        menu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openIRFileAction);
      }
    } else {
      openFileAction.selectionChanged(selection);
      if (openFileAction.isEnabled())
        menu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openFileAction);
    }
    addOpenWithMenu(selection, menu);
  }
コード例 #4
0
ファイル: OpenActionProvider.java プロジェクト: eclipse/edt
 private boolean selectionChangedToEGL(IStructuredSelection selection) {
   if (selection.size() == 1) {
     if (selection.getFirstElement() instanceof IEGLFile) {
       IEGLElement eglElem = (IEGLElement) selection.getFirstElement();
       IResource resource = eglElem.getResource();
       if (resource != null) {
         openFileAction.selectionChanged(new StructuredSelection(resource));
         return true;
       }
     } else if (selection.getFirstElement() instanceof IClassFile) {
       IEGLElement eglElem = (IEGLElement) selection.getFirstElement();
       openIRFileAction.setClassFile(((IClassFile) eglElem));
       return true;
     }
   }
   return false;
 }
コード例 #5
0
 public void fillContextMenu(IMenuManager menu, IStructuredSelection selection) {
   MenuManager subMenu = new MenuManager("New");
   menu.add(subMenu);
   for (int i = 0; i < this.addRemoteRepositoryActions.length; i++) {
     subMenu.add(this.addRemoteRepositoryActions[i]);
   }
   subMenu.add(new Separator());
   subMenu.add(this.addSpaceAction);
   subMenu.add(this.addPageAction);
   subMenu.add(new Separator());
   subMenu.add(this.newOtherAction);
   openFileAction.selectionChanged(selection);
   menu.add(openFileAction);
   fillOpenWithMenu(menu, selection.getFirstElement());
   menu.add(new Separator());
   drillDownAdapter.addNavigationActions(menu);
   menu.add(new Separator());
   menu.add(this.deleteAction);
   menu.add(new Separator());
   menu.add(this.refreshAction);
   menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
   menu.add(new Separator());
   menu.add(this.propertyDialogAction);
 }