コード例 #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());
    }
  }
コード例 #2
0
  public static void refreshTreeItem(EObject element) {
    WorkflowModelEditor editor =
        GenericUtils.getWorkflowModelEditor(ModelUtils.findContainingModel(element));
    if (editor == null) {
      return;
    }
    WorkflowModelOutlinePage outlinePage = (WorkflowModelOutlinePage) editor.getOutlinePage();

    if (outlinePage != null) {
      // because of SVN creates file after the label was refreshed, we refresh again
      AbstractEObjectTreeEditPart treeEditPart =
          (AbstractEObjectTreeEditPart) outlinePage.getEditPart(element);
      if (treeEditPart != null) {
        Widget widget = treeEditPart.getWidget();
        if (widget != null && !widget.isDisposed()) {
          treeEditPart.refresh();
        }
      }
    }
  }