Пример #1
0
 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;
 }
Пример #2
0
  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);
  }