Esempio n. 1
0
  // open editor defined in properties
  public static void showInDiagramAndEdit(INodeSymbol symbol) {
    if (symbol instanceof IModelElementNodeSymbol) {
      IIdentifiableModelElement model = ((IModelElementNodeSymbol) symbol).getModelElement();
      if (model != null) {
        WorkflowModelEditor editor =
            (WorkflowModelEditor)
                PlatformUI.getWorkbench()
                    .getActiveWorkbenchWindow()
                    .getActivePage()
                    .getActiveEditor();

        refreshTreeItem(model);

        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)) {
          return;
        } else if (focusMode.equals(BpmProjectNature.PREFERENCE_FOCUS_MODE_DIALOG)) {
          editor.selectSymbol(symbol);
          ActionRegistry registry = editor.getActionRegistry();
          IAction action = registry.getAction(ActionFactory.PROPERTIES.getId());
          if (action != null) {
            action.run();
          }
        } else if (focusMode.equals(BpmProjectNature.PREFERENCE_FOCUS_MODE_EDITOR)) {
          showInOutlineAndEdit(model);
        }
        return;
      }
    }
  }
Esempio n. 2
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());
    }
  }
  @Override
  public void setActivePage(IEditorPart part) {
    if (activeEditorPart == part) return;

    activeEditorPart = part;

    IActionBars actionBars = getActionBars();

    if (activeEditorPart != null && activeEditorPart instanceof ITextEditor) {
      IActionBars siteActionBars = ((IEditorSite) activeEditorPart.getEditorSite()).getActionBars();
      siteActionBars.setGlobalActionHandler(
          ITextEditorActionConstants.UNDO,
          getAction((ITextEditor) activeEditorPart, ITextEditorActionConstants.UNDO));
      siteActionBars.setGlobalActionHandler(
          ITextEditorActionConstants.REDO,
          getAction((ITextEditor) activeEditorPart, ITextEditorActionConstants.REDO));
      siteActionBars.updateActionBars();
    } else {
      if (part instanceof BPELEditor) {
        bpelEditor = (BPELEditor) part;
      }
      if (bpelEditor != null) {
        Object adapter = bpelEditor.getAdapter(ActionRegistry.class);
        if (adapter instanceof ActionRegistry) {
          ActionRegistry registry = (ActionRegistry) adapter;
          // COPY
          IAction action = registry.getAction(BPELCopyAction.ID);
          actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), action);
          // CUT
          action = registry.getAction(BPELCutAction.ID);
          actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), action);
          // PASTE
          action = registry.getAction(BPELPasteAction.ID);
          actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), action);
          // DELETE
          action = registry.getAction(BPELDeleteAction.ID);
          actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), action);
        }

        IWorkbenchPartSite site = bpelEditor.getSite();
        if (site instanceof IEditorSite) {
          ITextEditor textEditor = bpelEditor.getMultipageEditor().getTextEditor();
          IActionBars siteActionBars = ((IEditorSite) site).getActionBars();
          siteActionBars.setGlobalActionHandler(
              ITextEditorActionConstants.UNDO,
              getAction(textEditor, ITextEditorActionConstants.UNDO));
          siteActionBars.setGlobalActionHandler(
              ITextEditorActionConstants.REDO,
              getAction(textEditor, ITextEditorActionConstants.REDO));
          siteActionBars.updateActionBars();
        }
      }
    }

    if (actionBars != null) {
      // update menu bar and tool bar
      actionBars.updateActionBars();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.part.Page#init(org.eclipse.ui.part.IPageSite)
   */
  @Override
  public void init(IPageSite pageSite) {
    super.init(pageSite);
    ActionRegistry registry = editor.getActionRegistry();
    IActionBars bars = pageSite.getActionBars();
    for (Iterator<IAction> it = registry.getActions(); it.hasNext(); ) {
      IAction ia = it.next();
      bars.setGlobalActionHandler(ia.getId(), ia);
    }

    bars.updateActionBars();
  }
  private void createDiagramAction(GraphicalViewer viewer) {
    ActionRegistry registry = getActionRegistry();
    AutoLayoutAction autoLayoutAction = new AutoLayoutAction(this, getGraphicalViewer());
    registry.registerAction(autoLayoutAction);
    getSelectionActions().add(autoLayoutAction.getId());

    IAction action = new TableSelectionAction(this, getGraphicalViewer());
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    ERDViewStyleAction erdStyledAction = new ERDViewStyleAction(this, getGraphicalViewer());
    registry.registerAction(erdStyledAction);
    getSelectionActions().add(ERDViewStyleAction.ID);

    ERDRefreshAction refreshAction = new ERDRefreshAction(this, getGraphicalViewer());
    registry.registerAction(refreshAction);
    getSelectionActions().add(refreshAction.getId());
  }
Esempio n. 6
0
 /**
  * In order for the right-click menu to work, this shell must be registered with a view. Register
  * the context menu against the view. Make the view the default.
  *
  * @param view
  */
 public void registerWithView(IViewPart view) {
   this.view = view;
   actionRegistry.registerAction(new RefreshOPIAction(this));
   SingleSourceHelper.registerRCPRuntimeActions(actionRegistry, this);
   OPIRunnerContextMenuProvider contextMenuProvider =
       new OPIRunnerContextMenuProvider(viewer, this);
   getSite().registerContextMenu(contextMenuProvider, viewer);
   viewer.setContextMenu(contextMenuProvider);
 }
  @Override
  protected void createActions() {
    super.createActions();
    ActionRegistry registry = getActionRegistry();

    IAction action = new MatchWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new MatchHeightAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
  }
Esempio n. 8
0
 private IAction getAction(String actionId) {
   return actionRegistry.getAction(actionId);
 }
 /** This method should be called by the containing class. */
 public void dispose() {
   selectionListeners.clear();
   if (actionRegistry != null) {
     actionRegistry.dispose();
   }
 }
Esempio n. 10
0
 @Override
 public void dispose() {
   shell.dispose();
   actionRegistry.dispose();
 }