private void makeActions() {
    newPatientAction =
        new Action() {
          public void run() {
            openPatientenDialog();
          }
        };
    newPatientAction.setText(
        Messages.getString("WeisseSeitenSearchView.popup.newPatient")); // $NON-NLS-1$
    newPatientAction.setToolTipText(
        Messages.getString("WeisseSeitenSearchView.tooltip.newPatient")); // $NON-NLS-1$
    newPatientAction.setImageDescriptor(Images.IMG_PERSON_ADD.getImageDescriptor());

    newKontaktAction =
        new Action() {
          public void run() {
            openKontaktDialog();
          }
        };
    newKontaktAction.setText(
        Messages.getString("WeisseSeitenSearchView.popup.newKontakt")); // $NON-NLS-1$
    newKontaktAction.setToolTipText(
        Messages.getString("WeisseSeitenSearchView.tooltip.newKontakt")); // $NON-NLS-1$
    newKontaktAction.setImageDescriptor(Images.IMG_NEW.getImageDescriptor());
  }
Example #2
0
  private void makeActions() {
    action1 =
        new Action() {

          @Override
          public void run() {
            showMessage("Action 1 executed");
          }
        };
    action1.setText("Action 1");
    action1.setToolTipText("Action 1 tooltip");
    action1.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    action2 =
        new Action() {

          @Override
          public void run() {
            // testing
            // final IErlModel mdl = ErlangCore.getModel();
            // final List<IErlModule> ms = mdl.findModule("test", ".*");
            // ErlLogger.debug("found(\"*\") " + ms.size());
            // for (IErlModule element : ms) {
            // ErlLogger.debug(" " + element.getName());
            // }
            //
            // final List<IErlFunction> fs = mdl.findFunction("test", ".*",
            // "st.*", IErlModel.UNKNOWN_ARITY);
            // ErlLogger.debug("found(\"*\") " + fs.size());
            // for (IErlFunction element : fs) {
            // ErlLogger.debug(" " + element.getName() + "/"
            // + element.getArity());
            // }
            //
            // viewer.setInput(ms);
            //

            showMessage("Action 2 executed");
          }
        };
    action2.setText("Action 2");
    action2.setToolTipText("Action 2 tooltip");
    action2.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
    doubleClickAction =
        new Action() {

          @Override
          public void run() {
            final ISelection selection = viewer.getSelection();
            final Object obj = ((IStructuredSelection) selection).getFirstElement();
            showMessage("Double-click detected on " + obj.toString());
          }
        };
  }
Example #3
0
  private void makeActions() {
    startJUnit =
        new Action() {
          public void run() {
            showMessage("Started JUnit Test");
          }
        };
    startJUnit.setText("Start JUnit Test");
    startJUnit.setToolTipText("Action 1 tooltip");
    startJUnit.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    startSWTBot =
        new Action() {
          public void run() {
            showMessage("Started SWTBot Test");
          }
        };
    startSWTBot.setText("Start SWTBot");
    startSWTBot.setToolTipText("Action 2 tooltip");
    startSWTBot.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
    ViewResults =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            showMessage("Double-click detected on " + obj.toString());
          }
        };
  }
  private void makeActions() {
    action1 =
        new Action() {
          public void run() {
            showMessage("Action 1 executed");
          }
        };
    action1.setText("Action 1");
    action1.setToolTipText("Action 1 tooltip");
    action1.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    action2 =
        new Action() {
          public void run() {
            showMessage("Action 2 executed");
          }
        };
    action2.setText("Action 2");
    action2.setToolTipText("Action 2 tooltip");
    action2.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
    doubleClickAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            showMessage("Double-click detected on " + obj.toString());
          }
        };
  }
Example #5
0
  private static void hookMenu(final Graph g) {
    MenuManager menuMgr = new MenuManager("#PopupMenu");

    Action parentAction =
        new Action() {
          public void run() {
            List selection = g.getSelection();
            if (!selection.isEmpty()) {
              GraphNode selected = (GraphNode) selection.get(0);
              parentNode = selected;
              tryToAddConnection(g);
            }
          }
        };
    parentAction.setText("use as parent");
    menuMgr.add(parentAction);

    Action childAction =
        new Action() {
          public void run() {
            List selection = g.getSelection();
            if (!selection.isEmpty()) {
              GraphNode selected = (GraphNode) selection.get(0);
              childNode = selected;
              tryToAddConnection(g);
            }
          }
        };
    childAction.setText("use as child");
    menuMgr.add(childAction);

    Action expandAction =
        new Action() {
          public void run() {
            List selection = g.getSelection();
            if (!selection.isEmpty()) {
              GraphNode selected = (GraphNode) selection.get(0);
              g.setExpanded((GraphNode) selected, true);
            }
          }
        };
    expandAction.setText("expand");
    menuMgr.add(expandAction);

    Action collapseAction =
        new Action() {
          public void run() {
            List selection = g.getSelection();
            if (!selection.isEmpty()) {
              GraphItem selected = (GraphItem) selection.get(0);
              g.setExpanded((GraphNode) selected, false);
            }
          }
        };
    collapseAction.setText("collapse");
    menuMgr.add(collapseAction);

    g.setMenu(menuMgr.createContextMenu(g));
  }
  private void makeActions() {
    action1 =
        new Action() {
          public void run() {
            showMessage("Action 1 executed");
          }
        };
    action1.setText("Action 1");
    action1.setToolTipText("Action 1 tooltip");
    action1.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    action2 =
        new Action() {
          public void run() {
            showMessage("Action 2 executed");
          }
        };
    action2.setText("Action 2");
    action2.setToolTipText("Action 2 tooltip");
    action2.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
    doubleClickAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            showMessage("Double-click detected on " + obj.toString());
          }
        };

    pageForwardAction = createPageAction(true);
    pageBackwardsAction = createPageAction(false);

    refreshAction =
        new Action("Refresh", Activator.getImageDescriptor("icons/refresh_tab.gif")) {
          @Override
          public void run() {
            refresh();
          }
        };

    contentProvider.setPageLength(20);
    contentProvider.setPageOffset(1);
    createItemAction(20, true);
    createItemAction(50, false);
    createItemAction(100, false);
  }
Example #7
0
  void createActions() {
    collapseAllAction =
        new Action() {
          @Override
          public void run() {
            viewer.collapseAll();
          }
        };
    collapseAllAction.setText("Collapse All");
    collapseAllAction.setToolTipText("Collapse All");
    collapseAllAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/collapseall.gif"));

    refreshAction =
        new Action() {
          @Override
          public void run() {
            doRefresh();
          }
        };
    refreshAction.setText("Refresh");
    refreshAction.setToolTipText("Refresh Repositories Tree");
    refreshAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/arrow_refresh.png"));

    addBundlesAction =
        new Action() {
          @Override
          public void run() {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Object element = selection.getFirstElement();
            if (element != null && element instanceof RepositoryPlugin) {
              RepositoryPlugin repo = (RepositoryPlugin) element;
              if (repo.canWrite()) {
                AddFilesToRepositoryWizard wizard =
                    new AddFilesToRepositoryWizard(repo, new File[0]);
                WizardDialog dialog = new WizardDialog(getViewSite().getShell(), wizard);
                dialog.open();

                viewer.refresh(repo);
              }
            }
          }
        };
    addBundlesAction.setEnabled(false);
    addBundlesAction.setText("Add");
    addBundlesAction.setToolTipText("Add Bundles to Repository");
    addBundlesAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/brick_add.png"));
  }
Example #8
0
  private void makeActions() {
    final MeclipseView mView = this;
    connection =
        new Action() {

          public void run() {

            ConnectionWizard wizard = new ConnectionWizard();
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

            WizardDialog dialog = new WizardDialog(shell, wizard);
            dialog.create();
            dialog.open();
            mView.refreshMe();
          }
        };

    connection.setText(getCaption("connection.new"));
    connection.setToolTipText(getCaption("connection.new"));
    connection.setImageDescriptor(Images.getDescriptor(Images.PageCommit));

    doubleClickAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            TreeObject obj = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
            obj.doubleClickAction();
          }
        };
  }
  /**
   * @param editingDomain
   * @param manager
   * @param selection
   */
  private void addDeleteActionToContextMenu(
      final EditingDomain editingDomain,
      final IMenuManager manager,
      final IStructuredSelection selection) {

    final Action deleteAction =
        new Action() {
          @Override
          public void run() {
            super.run();
            DeleteService deleteService = getViewModelContext().getService(DeleteService.class);
            if (deleteService == null) {
              /*
               * #getService(Class<?>) will report to the reportservice if it could not be found
               * Use Default
               */
              deleteService = new EMFDeleteServiceImpl();
            }
            for (final Object obj : selection.toList()) {
              deleteService.deleteElement(obj);
            }
            treeViewer.setSelection(
                new StructuredSelection(getViewModelContext().getDomainModel()));
          }
        };
    final String deleteImagePath = "icons/delete.png"; // $NON-NLS-1$
    deleteAction.setImageDescriptor(
        ImageDescriptor.createFromURL(
            Activator.getDefault().getBundle().getResource(deleteImagePath)));
    deleteAction.setText("Delete"); // $NON-NLS-1$
    manager.add(deleteAction);
  }
 @Override
 protected void configureAction(Action action) {
   action.setText(Messages.HideReturnTypesAction_title);
   action.setToolTipText(Messages.HideReturnTypesAction_tooltip);
   action.setDescription(Messages.HideReturnTypesAction_description);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
 @Override
 protected void configureAction(Action action) {
   action.setText(Messages.FilterTerminalRulesContribution_title);
   action.setDescription(Messages.FilterTerminalRulesContribution_description);
   action.setToolTipText(Messages.FilterTerminalRulesContribution_tooltip);
   action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
   action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif"));
 }
Example #12
0
  private void fillLocalToolBar(final IToolBarManager manager) {
    final Action viewInPlotter =
        new Action() {
          @Override
          public void run() {
            openPlotter();
          }
        };
    viewInPlotter.setText("View in LPD");
    viewInPlotter.setToolTipText("View 2D overview of scenario");
    viewInPlotter.setImageDescriptor(CorePlugin.getImageDescriptor("icons/overview.gif"));

    final Action actionReloadDatafiles =
        new Action() {
          @Override
          public void run() {
            _myPresenter.reloadDataFiles();
          }
        };
    actionReloadDatafiles.setText("Reload");
    actionReloadDatafiles.setToolTipText("Reload data files");
    final ImageDescriptor desc = CorePlugin.getImageDescriptor("icons/repaint.gif");
    actionReloadDatafiles.setImageDescriptor(desc);

    final Action doNetwork =
        new Action("Broadcast", SWT.TOGGLE) {
          @Override
          public void run() {
            doNetwork(this.isChecked());
          }
        };
    doNetwork.setChecked(true);
    doNetwork.setToolTipText("Broadcast scenarios on network");
    doNetwork.setImageDescriptor(Activator.getImageDescriptor("icons/app_link.png"));

    // and display them
    manager.add(doNetwork);
    manager.add(viewInPlotter);
    manager.add(actionReloadDatafiles);

    manager.add(new Separator());
    manager.add(
        CorePlugin.createOpenHelpAction("org.mwc.asset.help.ScenarioController", null, this));
  }
Example #13
0
  private void hookPopupMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    Menu menu = menuMgr.createContextMenu(rtTypeListViewer.getList());
    rtTypeListViewer.getControl().setMenu(menu);

    Action act = this.unlinkAction;
    act.setText(Messages.getString("RTCTypeToRTTypeWidget.24")); // $NON-NLS-1$
    act.setEnabled(false);
    menuMgr.add(act);
  }
Example #14
0
 private void makeActions() {
   actionTestQuery =
       new Action() {
         public void run() {
           testQuery();
         }
       };
   actionTestQuery.setText("Test Query");
   actionTestQuery.setToolTipText("Test Query");
   actionTestQuery.setImageDescriptor(
       SmartRule1Plugin.getImageDescriptor("/icons/db_execute.gif"));
 }
Example #15
0
 /**
  * Adds a home button to the toolbar
  *
  * @param toolBar
  */
 private void setupToolbarButtons(IToolBarManager toolBar) {
   Action homeButton =
       new Action() {
         @Override
         public void run() {
           webEngine.load(homeLocation);
         }
       };
   homeButton.setText("Home");
   homeButton.setImageDescriptor(Activator.getImageDescriptor("icons/home.png"));
   toolBar.add(homeButton);
 }
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      if (treeViewer.getSelection().isEmpty()) {
        return;
      }
      final EObject root = ((RootObject) treeViewer.getInput()).getRoot();

      if (treeViewer.getSelection() instanceof IStructuredSelection) {
        final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();

        if (selection.size() == 1 && EObject.class.isInstance(selection.getFirstElement())) {
          final EObject eObject = (EObject) selection.getFirstElement();
          final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(eObject);
          if (domain == null) {
            return;
          }
          final Collection<?> descriptors = childrenDescriptorCollector.getDescriptors(eObject);
          fillContextMenu(manager, descriptors, editingDomain, eObject);
        }
        if (!selection.toList().contains(root)) {
          manager.add(new Separator(GLOBAL_ADDITIONS));
          addDeleteActionToContextMenu(editingDomain, manager, selection);
        }
        manager.add(new Separator());

        if (selection.getFirstElement() != null
            && EObject.class.isInstance(selection.getFirstElement())) {
          final EObject selectedObject = (EObject) selection.getFirstElement();

          for (final MasterDetailAction menuAction : menuActions) {
            if (menuAction.shouldShow(selectedObject)) {
              final Action newAction =
                  new Action() {
                    @Override
                    public void run() {
                      super.run();
                      menuAction.execute(selectedObject);
                    }
                  };

              newAction.setImageDescriptor(
                  ImageDescriptor.createFromURL(
                      FrameworkUtil.getBundle(menuAction.getClass())
                          .getResource(menuAction.getImagePath())));
              newAction.setText(menuAction.getLabel());

              manager.add(newAction);
            }
          }
        }
      }
    }
  private void makeActions() {

    action2 =
        new Action() {
          public void run() {
            showMessage("Action 2 executed");
          }
        };
    action2.setText("Action 2");
    action2.setToolTipText("Action 2 tooltip");
    action2.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    AddServiceCodeAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            Object TreeObj = ((IStructuredSelection) selection).getFirstElement();

            FederationOffice.NamedElement obj = ((ui_TaxonomyTreeItem) TreeObj).getOfficeElement();
            if (!(obj instanceof FederationOffice.services.Service)
                && !(obj instanceof FederationOffice.resources.Resource)) return;

            // System.out.println("============ AddServiceCodeAction: "+ obj.toString() );
            FSDLSourceCompletion sc = new FSDLSourceCompletion();
            sc.AddOfferedService(
                ((Office) obj.eContainer()), (FederationOffice.services.Service) obj);
          }
        };

    AddServiceCodeAction.setText("Insert selected object");
    AddServiceCodeAction.setToolTipText("Insert code for selected object");
    AddServiceCodeAction.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
  }
Example #18
0
 private void makeActions() {
   action1 =
       new Action() {
         public void run() {
           // _chart.rescale();
         }
       };
   action1.setText("Action 1");
   action1.setToolTipText("Action 1 tooltip");
   action1.setImageDescriptor(
       PlatformUI.getWorkbench()
           .getSharedImages()
           .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 }
 private void createActions() {
   sampleAction =
       new Action() {
         public void run() {
           MessageDialog.openInformation(null, "EWicket", "Sample Action Executed");
         }
       };
   sampleAction.setText("Sample Action");
   sampleAction.setToolTipText("Sample Action tool tip");
   sampleAction.setImageDescriptor(
       PlatformUI.getWorkbench()
           .getSharedImages()
           .getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
 }
 private void addFocusActionOrNot(IMenuManager manager) {
   if (fViewer.getSelection() instanceof IStructuredSelection) {
     IStructuredSelection structuredSelection = (IStructuredSelection) fViewer.getSelection();
     if (structuredSelection.size() == 1) {
       Object first = structuredSelection.getFirstElement();
       if (first instanceof JavaElement) {
         IJavaElement javaElement = ((JavaElement) first).getJavaElement();
         if (javaElement != null) {
           String name = javaElement.getElementName();
           fFocusAction.setText("Fo&cus On '" + name + '\'');
           manager.add(fFocusAction);
         }
       } else if (first instanceof JEResource) {
         IResource resource = ((JEResource) first).getResource();
         if (resource != null) {
           String name = resource.getName();
           fFocusAction.setText("Fo&cus On '" + name + '\'');
           manager.add(fFocusAction);
         }
       }
     }
   }
 }
Example #21
0
  private void makeActions() {
    refreshAction =
        new Action() {

          @Override
          public void run() {
            viewer.refresh();
          }
        };
    refreshAction.setText("Refresh");
    refreshAction.setToolTipText("Refresh process list");
    refreshAction.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    doubleClickAction =
        new Action() {

          @Override
          public void run() {
            final ISelection selection = viewer.getSelection();
            final Object obj = ((IStructuredSelection) selection).getFirstElement();

            if (obj == null) {
              return;
            }

            final OtpErlangPid pid = (OtpErlangPid) ((OtpErlangTuple) obj).elementAt(0);

            final OtpErlangObject r = ErlideProclist.getProcessInfo(getBackend(), pid);
            if (r instanceof OtpErlangList) {
              final OtpErlangList l = (OtpErlangList) r;
              final StringBuilder s = new StringBuilder();
              for (int i = 0; i < l.arity(); i++) {
                final OtpErlangTuple e = (OtpErlangTuple) l.elementAt(i);
                s.append(' ')
                    .append(e.elementAt(0).toString())
                    .append("\t= ")
                    .append(e.elementAt(1).toString())
                    .append('\n');
              }
              showMessage(s.toString());
            } else {
              showMessage(
                  "Process " + pid.toString() + " is probably dead.\nPlease refresh process list.");
            }
          }
        };
  }
  /** @see com.vectrace.MercurialEclipse.views.AbstractRootView#onRootChanged() */
  @Override
  protected void onRootChanged() {
    if (hgRoot == null || !MercurialStatusCache.getInstance().isMergeInProgress(hgRoot)) {
      table.setItems(null);
      abortAction.setEnabled(false);
      completeAction.setEnabled(false);
      markResolvedAction.setEnabled(false);
      markUnresolvedAction.setEnabled(false);
      table.setEnabled(false);

      return;
    }

    abortAction.setEnabled(true);
    completeAction.setEnabled(true);
    markResolvedAction.setEnabled(true);
    markUnresolvedAction.setEnabled(true);
    table.setEnabled(true);

    try {
      merging = !HgRebaseClient.isRebasing(hgRoot);

      if (merging) {
        abortAction.setText(Messages.getString("MergeView.merge.abort"));
        completeAction.setText(Messages.getString("MergeView.merge.complete"));
      } else {
        abortAction.setText(Messages.getString("MergeView.rebase.abort"));
        completeAction.setText(Messages.getString("MergeView.rebase.complete"));
      }

      getViewSite().getActionBars().getToolBarManager().update(true);
      populateView(false);
    } catch (HgException e) {
      handleError(e);
    }
  }
  protected void updateSelected() {
    StatusBean bean = getSelection();
    if (bean == null) bean = new StatusBean();

    remove.setEnabled(bean.getStatus() != null);
    rerun.setEnabled(true);

    boolean isSubmitted =
        bean.getStatus() == org.eclipse.scanning.api.event.status.Status.SUBMITTED;
    up.setEnabled(isSubmitted);
    edit.setEnabled(isSubmitted);
    down.setEnabled(isSubmitted);
    pause.setEnabled(bean.getStatus().isRunning() || bean.getStatus().isPaused());
    pause.setChecked(bean.getStatus().isPaused());
    pause.setText(bean.getStatus().isPaused() ? "Resume job" : "Pause job");
  }
 private void addActions(Menu menu) { // add repository action
   Presentation selectedPresentation = view.getContentProvider().getPresentation();
   for (final Presentation presentation : Presentation.values()) {
     Action action =
         new Action() {
           @Override
           public void run() {
             view.getContentProvider().setPresentation(presentation);
           }
         };
     action.setText(presentation.toString());
     action.setChecked(presentation == selectedPresentation);
     ActionContributionItem item = new ActionContributionItem(action);
     item.fill(menu, -1);
   }
 }
 private void makeActions() {
   showHierarchyOfModulesAction =
       new Action("", IAction.AS_CHECK_BOX) {
         @Override
         public void run() {
           setShowModuleHierarchy(isChecked());
         }
       };
   showHierarchyOfModulesAction.setText(CALUIMessages.CALWorkspace_showHierarchyOfModules);
   showHierarchyOfModulesAction.setChecked(getModuleContentProvider().getShowModuleHierarchy());
   showHierarchyOfModulesAction.setToolTipText(
       CALUIMessages.CALWorkspace_showHierarchyOfModules_tooltip);
   //
   // showHierarchyOfModulesAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
   //                getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 }
  private List<Action> readToolbarActions(EObject modelElement, final EditingDomain editingDomain) {
    final List<Action> actions = new ArrayList<Action>();
    final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return actions;
    }
    if (!VView.class.isInstance(modelElement)) {
      return actions;
    }
    final VView view = (VView) modelElement;

    final IConfigurationElement[] controls =
        extensionRegistry.getConfigurationElementsFor(
            "org.eclipse.emf.ecp.view.treemasterdetail.ui.swt.masterDetailActions"); //$NON-NLS-1$
    for (final IConfigurationElement e : controls) {
      try {
        final String location = e.getAttribute("location"); // $NON-NLS-1$
        if (!location.equals("toolbar")) { // $NON-NLS-1$
          continue;
        }

        final String label = e.getAttribute("label"); // $NON-NLS-1$
        final String imagePath = e.getAttribute("imagePath"); // $NON-NLS-1$
        final MasterDetailAction command =
            (MasterDetailAction) e.createExecutableExtension("command"); // $NON-NLS-1$
        final Action newAction =
            new Action() {
              @Override
              public void run() {
                super.run();
                command.execute(view);
              }
            };

        newAction.setImageDescriptor(
            ImageDescriptor.createFromURL(
                FrameworkUtil.getBundle(command.getClass()).getResource(imagePath)));
        newAction.setText(label);
        actions.add(newAction);
      } catch (final CoreException e1) {
        e1.printStackTrace();
      }
    }
    return actions;
  }
  private Action createPageAction(final boolean isPageForwardAction) {
    Action pageAction =
        new Action() {
          @Override
          public void run() {
            contentProvider.movePage(isPageForwardAction);
            refresh();
          }
        };

    pageAction.setText((isPageForwardAction ? "Next" : "Previous") + " Page");
    pageAction.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(
                isPageForwardAction
                    ? ISharedImages.IMG_TOOL_FORWARD
                    : ISharedImages.IMG_TOOL_BACK));

    return pageAction;
  }
 public void createActions(CommonViewer tableViewer, ISelectionProvider provider) {
   action =
       new Action() {
         @Override
         public void run() {
           new Job("Fetching Welcome Page URL") {
             public IStatus run(IProgressMonitor monitor) {
               // Get the url in a background thread to not freeze the UI
               String url2 = null;
               try {
                 url2 = getUrl();
               } catch (CoreException ce) {
                 return ce.getStatus();
               }
               final String url = url2;
               if (url != null) {
                 Display.getDefault()
                     .asyncExec(
                         new Runnable() {
                           public void run() {
                             JBTWebLaunchableClient.checkedCreateInternalBrowser(
                                 url,
                                 getServer().getName(),
                                 JBossServerUIPlugin.PLUGIN_ID,
                                 JBossServerUIPlugin.getDefault().getLog());
                           }
                         });
               }
               return Status.OK_STATUS;
             }
           }.schedule();
         }
       };
   action.setText(ServerActionMessages.OpenWithBrowser);
   action.setDescription(ServerActionMessages.OpenWithBrowserDescription);
   action.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_INTERNAL_BROWSER));
 }
Example #29
0
  /** 初始化action */
  private void makeActions() {

    /** 测试按钮 */
    testAction = new StartTestAction();
    testAction.setText("Start");
    testAction.setToolTipText("开始检测");
    testAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/start.png"));

    /** 刷新按钮 */
    refreshAction =
        new Action() {
          public void run() {
            refreshGetPkgInfo();
          }
        };
    refreshAction.setText("获取手机上的进程列表");
    refreshAction.setToolTipText("获取手机上的进程列表");
    refreshAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/refresh.png"));

    /** 打开log目录 */
    openResultDirAction =
        new Action() {
          public void run() {
            try {
              if (PCInfo.OSName.toLowerCase().indexOf("window") != -1) {
                Runtime.getRuntime()
                    .exec(
                        "explorer.exe "
                            + Constant.LOG_FOLDER_ON_PC
                            + File.separator
                            + TestSence.getInstance().curDir);
              } else {
                Runtime.getRuntime()
                    .exec(
                        "open "
                            + Constant.LOG_FOLDER_ON_PC
                            + File.separator
                            + TestSence.getInstance().curDir);
              }

            } catch (IOException e) {
              e.printStackTrace();
              APTConsoleFactory.getInstance().APTPrint("打开测试结果文件夹失败");
            }
          }
        };

    openResultDirAction.setText("打开测试结果保存目录");
    openResultDirAction.setToolTipText("打开测试结果保存目录");
    openResultDirAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));

    /** 打开log */
    openLogWithChartAction =
        new Action() {
          public void run() {
            FileDialog dialog =
                new FileDialog(sourcePkgTableViewer.getControl().getShell(), SWT.OPEN);
            dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC); // 设置初始路径
            final String fileName = dialog.open(); // 返回的全路径(路径+文件名)
            if (fileName == null) {
              return;
            }
            final APTLogFileHeader afh = APTLogFileParse.pareseAPTLogFileHeader(fileName);
            if (afh == null) {
              APTConsoleFactory.getInstance().APTPrint("文件头格式不兼容");
              return;
            }

            // 在数据量比较大时,解析会比较大
            APTState.getInstance().DealWithEventBefore(APTEventEnum.OPENLOG_OPER);
            APTConsoleFactory.getInstance().APTPrint("正解析log数据,请稍候......");
            final CPUView cpuViewPart =
                (CPUView)
                    PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow()
                        .getActivePage()
                        .findView(CPUView.ID);
            final MemoryView memViewPart =
                (MemoryView)
                    PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow()
                        .getActivePage()
                        .findView(MemoryView.ID);

            cpuViewPart.setCpuTableViewerFilter(null);
            cpuViewPart.setJiffiesTableViewerFilter(null);
            memViewPart.setTableViewerFilter(null);

            Thread parseLogThread =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        final JfreeChartDatas datas = APTLogFileParse.getData(fileName, afh);
                        if (datas == null) {
                          APTConsoleFactory.getInstance().APTPrint("文件格式不兼容");
                          return;
                        }

                        if (datas.monitorItem.equals(
                            Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX])) {
                          cpuViewPart.cpuRealTimeChart.fillData(datas);
                        } else {
                          memViewPart.memRealTimeChart.fillData(datas);
                        }
                      }
                    });

            parseLogThread.start();
            try {
              // TODO 这里使用会不会存在很卡的情况,打开比较大的文件的时候
              parseLogThread.join();

              for (int i = 0; i < afh.pkgNames.length; i++) {
                PkgInfo item = new PkgInfo();
                item.contents[PkgInfo.NAME_INDEX] = afh.pkgNames[i];
                item.contents[PkgInfo.PID_INDEX] = "-1";
                addDataItem(targetPkgTableViewer, item);
              }
              APTState.getInstance().DealWithEventAfter(APTEventEnum.OPENLOG_OPER);
              // APTConsoleFactory.getInstance().APTPrint("打开log更新");
              GetCurCheckedStateUtil.update();
              APTConsoleFactory.getInstance().APTPrint("log打开完毕");

            } catch (InterruptedException e) {
              e.printStackTrace();
            }
          }
        };
    openLogWithChartAction.setText("用JFreechart打开log");
    openLogWithChartAction.setToolTipText("用JFreechart打开log");
    openLogWithChartAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/generate_chart.png"));

    /** 复制数据 */
    copyAction = new CopyAllFromTableViewAction(sourcePkgTableViewer);
    copyAction.setText("复制");
    copyAction.setToolTipText("复制当前显示的表格数据到剪切板");
    ImageDescriptor descriptor =
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/save.png");
    copyAction.setImageDescriptor(descriptor);

    /** 添加菜单 */
    addPkgAction =
        new Action() {
          @Override
          public void run() {
            if (isSupportAddOrDeleteOper) {
              super.run();
              APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
              IStructuredSelection iss = (IStructuredSelection) sourcePkgTableViewer.getSelection();
              if (iss == null) {
                return;
              }

              PkgInfo itemData = (PkgInfo) iss.getFirstElement();

              addDataItem(targetPkgTableViewer, itemData);
              APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
            } else {
              APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
          }
        };
    addPkgAction.setText("添加");
    addPkgAction.setToolTipText("添加该进程到被测进程列表");
    addPkgAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/add.png"));

    /** 删除菜单 */
    removePkgAction =
        new Action() {

          @Override
          public void run() {
            if (isSupportAddOrDeleteOper) {
              super.run();
              APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
              TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
              if (selectData == null || selectData.length == 0) {
                return;
              }

              PkgInfo itemData = (PkgInfo) selectData[0].getData();

              targetPkgTableViewer.remove(itemData);
              APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
            } else {
              APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
          }
        };
    removePkgAction.setText("删除");
    removePkgAction.setToolTipText("从被测进程列表中删除该进程");
    removePkgAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/remove.png"));

    pmapAction = new GetPMAPInfoAction(sourcePkgTableViewer);
    pmapAction.setText("PMAP");
    pmapAction.setToolTipText("PMAP");
    pmapAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));

    smapAction = new GetSMAPInfoAction(sourcePkgTableViewer);
    smapAction.setText("SMAP");
    smapAction.setToolTipText("SMAP");
    smapAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));

    dumpHprofAction = new DumpHprofAction();
    dumpHprofAction.setText("DumpHprof");
    dumpHprofAction.setToolTipText("DumpHprof");
    dumpHprofAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/dump.png"));

    gcAction = new GCAction();
    gcAction.setText("GC");
    gcAction.setToolTipText("GC");
    gcAction.setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/gc.png"));
  }
  private void makeActions() {
    fCodeSelectAction =
        new Action(
            "Set Input from Editor (&codeSelect)", JEPluginImages.IMG_SET_FOCUS_CODE_SELECT) {
          @Override
          public void run() {
            IEditorPart editor = getSite().getPage().getActiveEditor();
            if (editor == null) {
              setEmptyInput();
              return;
            }
            IEditorInput input = editor.getEditorInput();
            ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
            if (input == null || selectionProvider == null) {
              setEmptyInput();
              return;
            }
            ISelection selection = selectionProvider.getSelection();
            if (!(selection instanceof ITextSelection)) {
              setEmptyInput();
              return;
            }
            IJavaElement javaElement = (IJavaElement) input.getAdapter(IJavaElement.class);
            if (javaElement == null) {
              setEmptyInput();
              return;
            }

            IJavaElement[] resolved;
            try {
              resolved = codeResolve(javaElement, (ITextSelection) selection);
            } catch (JavaModelException e) {
              setEmptyInput();
              return;
            }
            if (resolved.length == 0) {
              setEmptyInput();
              return;
            }

            setInput(Arrays.asList(resolved));
          }
        };
    fCodeSelectAction.setToolTipText("Set input from current editor's selection (codeSelect)");

    fElementAtAction =
        new Action("Set Input from Editor location (&getElementAt)", JEPluginImages.IMG_SET_FOCUS) {
          @Override
          public void run() {
            IEditorPart editor = getSite().getPage().getActiveEditor();
            if (editor == null) {
              setEmptyInput();
              return;
            }
            IEditorInput input = editor.getEditorInput();
            ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
            if (input == null || selectionProvider == null) {
              setEmptyInput();
              return;
            }
            ISelection selection = selectionProvider.getSelection();
            if (!(selection instanceof ITextSelection)) {
              setEmptyInput();
              return;
            }
            IJavaElement javaElement = (IJavaElement) input.getAdapter(IJavaElement.class);
            if (javaElement == null) {
              setEmptyInput();
              return;
            }

            IJavaElement resolved;
            try {
              resolved = getElementAtOffset(javaElement, (ITextSelection) selection);
            } catch (JavaModelException e) {
              setEmptyInput();
              return;
            }
            if (resolved == null) {
              setEmptyInput();
              return;
            }

            setSingleInput(resolved);
          }
        };
    fElementAtAction.setToolTipText(
        "Set input from current editor's selection location (getElementAt)");

    fCreateFromHandleAction =
        new Action("Create From &Handle...") {
          @Override
          public void run() {
            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "Create Java Element From Handle Identifier",
                    "&Handle identifier:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            String handleIdentifier = dialog.getValue();
            IJavaElement javaElement = JavaCore.create(handleIdentifier);
            setSingleInput(javaElement);
          }
        };

    fFocusAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            if (selected instanceof JavaElement) {
              setSingleInput(((JavaElement) selected).getJavaElement());
            } else if (selected instanceof JEResource) {
              setSingleInput(((JEResource) selected).getResource());
            }
          }
        };
    fFocusAction.setToolTipText("Focus on Selection");

    fFindTypeAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findType(String fullyQualifiedName)",
                    "fullyQualifiedName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;

            final String fullyQualifiedName = dialog.getValue();
            try {
              IType type = project.findType(fullyQualifiedName);
              JavaElement element = new JavaElement(fInput, fullyQualifiedName, type);
              fViewer.add(fInput, element);
              fViewer.setSelection(new StructuredSelection(element));
            } catch (JavaModelException e) {
              JEViewPlugin.log(e);
            }
          }
        };
    fFindTypeAction.setText("findType(String)...");

    fFindType2Action =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findType(String fullyQualifiedName, IProgressMonitor pm)",
                    "fullyQualifiedName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String fullyQualifiedName = dialog.getValue();

            class Runner implements IRunnableWithProgress {
              IType type;

              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  type = project.findType(fullyQualifiedName, monitor);
                } catch (JavaModelException e) {
                  throw new InvocationTargetException(e);
                }
              }
            }
            Runner runner = new Runner();
            try {
              PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
            } catch (InvocationTargetException e) {
              JEViewPlugin.log(e);
            } catch (InterruptedException e) {
              JEViewPlugin.log(e);
            }
            JavaElement element = new JavaElement(fInput, fullyQualifiedName, runner.type);
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
          }
        };
    fFindType2Action.setText("findType(String, IProgressMonitor)...");

    fResolveTypeAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IType type = (IType) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IType#resolveType(String typeName)",
                    "typeName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String typeName = dialog.getValue();

            JavaElementChildrenProperty element =
                new JavaElementChildrenProperty(
                    fInput,
                    "'" + type.getFullyQualifiedName() + "'.resolveType(\"" + typeName + "\")") {
                  @Override
                  protected JEAttribute[] computeChildren() throws Exception {
                    String[][] resolvedTypes = type.resolveType(typeName);
                    if (resolvedTypes == null) {
                      return new JEAttribute[] {new Null(this, "result")};
                    }
                    JEAttribute[] resolvedJEAttributes = new JEAttribute[resolvedTypes.length];
                    for (int i = 0; i < resolvedTypes.length; i++) {
                      String[] resolvedType = resolvedTypes[i];
                      resolvedJEAttributes[i] =
                          new JavaElementProperty(
                              this, null, resolvedType[0] + ", " + resolvedType[1]);
                    }
                    return resolvedJEAttributes;
                  }
                };
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
            fViewer.setExpandedState(element, true);
          }
        };
    fResolveTypeAction.setText("resolveType(String)...");

    fGetAnnotationAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IAnnotatable annotatable =
                (IAnnotatable) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IAnnotatable#getAnnotation(String name)",
                    "name:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String name = dialog.getValue();

            JavaElementChildrenProperty element =
                new JavaElementChildrenProperty(
                    fInput,
                    "'"
                        + ((IJavaElement) annotatable).getElementName()
                        + "'.getAnnotation(\""
                        + name
                        + "\")") {
                  @Override
                  protected JEAttribute[] computeChildren() throws Exception {
                    IAnnotation annotation = annotatable.getAnnotation(name);
                    return new JEAttribute[] {new JavaElement(this, annotation)};
                  }
                };
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
            fViewer.setExpandedState(element, true);
          }
        };
    fGetAnnotationAction.setText("getAnnotation(String)...");

    fCreateFromBindingKeyAction =
        new Action("Create From &Binding Key...") {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findElement(String bindingKey, WorkingCopyOwner owner)",
                    "&bindingKey:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String bindingKey = dialog.getValue();

            class Runner implements IRunnableWithProgress {
              IJavaElement element;

              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  element = project.findElement(bindingKey, null);
                } catch (JavaModelException e) {
                  throw new InvocationTargetException(e);
                }
              }
            }
            Runner runner = new Runner();
            try {
              PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
            } catch (InvocationTargetException e) {
              JEViewPlugin.log(e);
            } catch (InterruptedException e) {
              JEViewPlugin.log(e);
            }
            JavaElement element = new JavaElement(fInput, bindingKey, runner.element);
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
          }
        };

    fResetAction =
        new Action("&Reset View", getJavaModelImageDescriptor()) {
          @Override
          public void run() {
            reset();
          }
        };
    fResetAction.setToolTipText("Reset View to JavaModel");

    fRefreshAction =
        new Action("Re&fresh", JEPluginImages.IMG_REFRESH) {
          @Override
          public void run() {
            BusyIndicator.showWhile(
                getSite().getShell().getDisplay(),
                new Runnable() {
                  public void run() {
                    fViewer.refresh();
                  }
                });
          }
        };
    fRefreshAction.setToolTipText("Refresh");
    fRefreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh");

    fCopyAction = new TreeCopyAction(new Tree[] {fViewer.getTree()});

    fPropertiesAction =
        new Action("&Properties", JEPluginImages.IMG_PROPERTIES) {
          @Override
          public void run() {
            String viewId = IPageLayout.ID_PROP_SHEET;
            IWorkbenchPage page = getViewSite().getPage();
            IViewPart view;
            try {
              view = page.showView(viewId);
              page.activate(JavaElementView.this);
              page.bringToTop(view);
            } catch (PartInitException e) {
              JEViewPlugin.log("could not find Properties view", e);
            }
          }
        };
    fPropertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);

    fDoubleClickAction =
        new Action() {
          private Object fPreviousDouble;

          @Override
          public void run() {
            ISelection selection = fViewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();

            boolean isSecondDoubleClick = (obj == fPreviousDouble);
            fPreviousDouble = isSecondDoubleClick ? null : obj;

            if (obj instanceof JavaElement) {
              IJavaElement javaElement = ((JavaElement) obj).getJavaElement();
              if (javaElement != null) {
                switch (javaElement.getElementType()) {
                  case IJavaElement.JAVA_MODEL:
                    break;

                  case IJavaElement.JAVA_PROJECT:
                  case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                  case IJavaElement.PACKAGE_FRAGMENT:
                    ICommandService service =
                        (ICommandService) getSite().getService(ICommandService.class);
                    Command showInCommand =
                        service.getCommand(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN);
                    Map<String, String> params =
                        Collections.singletonMap(
                            "org.eclipse.ui.navigate.showIn.targetId", JavaUI.ID_PACKAGES);
                    try {
                      Object context =
                          ((IHandlerService) getSite().getService(IHandlerService.class))
                              .getCurrentState();
                      showInCommand.executeWithChecks(
                          new ExecutionEvent(null, params, null, context));
                    } catch (ExecutionException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotDefinedException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotEnabledException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotHandledException e1) {
                      showAndLogError("Could not show element", e1);
                    }
                    break;

                  default:
                    try {
                      IEditorPart editorPart = JavaUI.openInEditor(javaElement);
                      if (editorPart != null) {
                        if (isSecondDoubleClick
                            && javaElement instanceof ISourceReference
                            && editorPart instanceof ITextEditor) {
                          ISourceRange sourceRange =
                              ((ISourceReference) javaElement).getSourceRange();
                          EditorUtility.selectInEditor(
                              (ITextEditor) editorPart,
                              sourceRange.getOffset(),
                              sourceRange.getLength());
                        } else {
                          JavaUI.revealInEditor(editorPart, javaElement);
                        }
                      }
                    } catch (PartInitException e) {
                      showAndLogError("Could not open editor.", e); // $NON-NLS-1$
                    } catch (JavaModelException e) {
                      showAndLogError("Could not open editor.", e); // $NON-NLS-1$
                    }
                }
              }

            } else if (obj instanceof Error) {
              Error error = (Error) obj;
              JEViewPlugin.log(error.getException());

            } else if (obj instanceof JEMarker) {
              JEMarker marker = (JEMarker) obj;
              try {
                IDE.openEditor(getSite().getPage(), marker.getMarker());
              } catch (PartInitException e) {
                showAndLogError("Could not open editor.", e); // $NON-NLS-1$
              }
            }
          }
        };

    fCompareAction =
        new Action() {
          @Override
          public void run() {
            TreePath[] selection = ((ITreeSelection) fViewer.getSelection()).getPaths();
            Object first = ((JEAttribute) selection[0].getLastSegment()).getWrappedObject();
            Object second = ((JEAttribute) selection[1].getLastSegment()).getWrappedObject();
            boolean identical = first == second;
            boolean equals1 = first != null && first.equals(second);
            boolean equals2 = second != null && second.equals(first);
            boolean inconsistentEquals = equals1 != equals2;

            String msg =
                "==: "
                    + identical
                    + "\nequals(..): "
                    + (inconsistentEquals ? "INCONSISTENT" : equals1);
            MessageDialog.openInformation(fViewer.getTree().getShell(), "Comparison", msg);
          }
        };
    fCompareAction.setText("C&ompare with Each Other...");

    fLogDeltasAction =
        new Action("Log Java element deltas", IAction.AS_CHECK_BOX) {

          private IElementChangedListener fListener =
              new IElementChangedListener() {
                @SuppressWarnings("deprecation")
                public void elementChanged(ElementChangedEvent event) {
                  String type = "\nEvent type: ";
                  switch (event.getType()) {
                    case ElementChangedEvent.POST_CHANGE:
                      type += "POST_CHANGE";
                      break;
                    case ElementChangedEvent.POST_RECONCILE:
                      type += "POST_RECONCILE";
                      break;
                    case ElementChangedEvent.PRE_AUTO_BUILD:
                      type += "PRE_AUTO_BUILD";
                      break;
                    default:
                      type += event.getType();
                      break;
                  }
                  JEViewPlugin.logMessage(event.getDelta().toString() + type);
                }
              };

          @Override
          public void run() {
            String message;
            if (!isChecked()) {
              JavaCore.removeElementChangedListener(fListener);
              message = "Element listener removed";
            } else {
              JavaCore.addElementChangedListener(fListener);
              message = "Element listener added. Deltas are now written to log.";
            }
            MessageDialog.openInformation(
                fViewer.getTree().getShell(), "Log Java Element Deltas", message);
          }
        };
  }