Example #1
0
  // show new element in outline and open editor defined in properties
  public static void showInOutlineAndEdit(EObject element) {
    WorkflowModelEditor editor =
        (WorkflowModelEditor)
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    WorkflowModelOutlinePage outlinePage = (WorkflowModelOutlinePage) editor.getOutlinePage();

    String focusMode =
        PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_FOCUS_MODE);
    // do nothing, default (will select the new element)
    if (focusMode.equals(BpmProjectNature.PREFERENCE_FOCUS_MODE_ELEMENT)) {
      editor.selectInOutline(element);
      return;
    } else if (focusMode.equals(BpmProjectNature.PREFERENCE_FOCUS_MODE_DIALOG)) {
      editor.selectInOutline(element);
      ActionRegistry registry = outlinePage.getActionRegistry();
      IAction action = registry.getAction(ActionFactory.PROPERTIES.getId());
      if (action != null) {
        action.run();
      }
    } else if (focusMode.equals(BpmProjectNature.PREFERENCE_FOCUS_MODE_EDITOR)) {
      editor.selectInOutline(element);
      AbstractEObjectTreeEditPart treeEditPart =
          (AbstractEObjectTreeEditPart) outlinePage.getEditPart(element);
      treeEditPart.performRequest(new DirectEditRequest());
    }
  }