private IContributionItem getDeleteItem() {
   return getItem(
       ActionFactory.DELETE.getId(),
       ActionFactory.DELETE.getCommandId(),
       ISharedImages.IMG_TOOL_DELETE,
       ISharedImages.IMG_TOOL_DELETE_DISABLED,
       Messages.Workbench_delete,
       Messages.Workbench_deleteToolTip,
       IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION);
 }
    @Override
    public void init(IPageSite pageSite) {
      super.init(pageSite);

      IActionBars bars = getSite().getActionBars();
      bars.setGlobalActionHandler(
          ActionFactory.UNDO.getId(), getActionRegistry().getAction(ActionFactory.UNDO.getId()));
      bars.setGlobalActionHandler(
          ActionFactory.REDO.getId(), getActionRegistry().getAction(ActionFactory.REDO.getId()));
      bars.setGlobalActionHandler(
          ActionFactory.DELETE.getId(),
          getActionRegistry().getAction(ActionFactory.DELETE.getId()));
      bars.updateActionBars();

      getViewer().setKeyHandler(keyHandler);
    }
    /**
     * Creates the 'Edit' menu.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
    protected IMenuManager createEditMenu(IWorkbenchWindow window) {
      IMenuManager menu =
          new MenuManager(getString("_UI_Menu_Edit_label"), IWorkbenchActionConstants.M_EDIT);
      menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));

      addToMenuAndRegister(menu, ActionFactory.UNDO.create(window));
      addToMenuAndRegister(menu, ActionFactory.REDO.create(window));
      menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
      menu.add(new Separator());

      addToMenuAndRegister(menu, ActionFactory.CUT.create(window));
      addToMenuAndRegister(menu, ActionFactory.COPY.create(window));
      addToMenuAndRegister(menu, ActionFactory.PASTE.create(window));
      menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
      menu.add(new Separator());

      addToMenuAndRegister(menu, ActionFactory.DELETE.create(window));
      addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window));
      menu.add(new Separator());

      menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));

      menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
      menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      return menu;
    }
  @Override
  public void contributeToToolBar(IToolBarManager toolBarManager) {
    super.contributeToToolBar(toolBarManager);
    toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
    toolBarManager.add(getAction(ActionFactory.REDO.getId()));
    toolBarManager.add(getAction(ActionFactory.DELETE.getId()));

    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
    toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
    toolBarManager.add(new ZoomComboContributionItem(getPage()));

    toolBarManager.add(new Separator());
    //		toolBarManager.add(getAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY));
    //		toolBarManager.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY));
    toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));

    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_LEFT));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_CENTER));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_RIGHT));
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_TOP));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_MIDDLE));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_BOTTOM));
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.MATCH_WIDTH));
    toolBarManager.add(getAction(GEFActionConstants.MATCH_HEIGHT));

    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(ERDViewStyleAction.ID));
  }
  /** configure key handler */
  private void configureKeyHandler() {
    GraphicalViewer viewer = getGraphicalViewer();

    keyHandler = new KeyHandler();
    //		keyHandler.put(KeyStroke.getPressed('a', 0x61, SWT.COMMAND),
    //	getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(
        KeyStroke.getPressed('s', 0x61, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.SAVE.getId()));

    keyHandler.put(
        KeyStroke.getPressed('z', 0x7a, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.UNDO.getId()));
    keyHandler.put(
        KeyStroke.getPressed('z', 0x7a, SWT.CTRL | SWT.SHIFT),
        getActionRegistry().getAction(ActionFactory.REDO.getId()));
    keyHandler.put(
        KeyStroke.getPressed('a', 0x61, SWT.CTRL),
        getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));

    keyHandler.put(
        KeyStroke.getPressed(SWT.DEL, 127, 0),
        getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    keyHandler.put(
        KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(
        KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));

    viewer.setProperty(
        MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
  }
  public void setActivePage(IEditorPart part) {
    if (activeEditorPart == part) return;

    activeEditorPart = part;

    IActionBars actionBars = getActionBars();
    if (actionBars != null) {

      ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

      actionBars.setGlobalActionHandler(
          ActionFactory.DELETE.getId(), getAction(editor, ITextEditorActionConstants.DELETE));
      actionBars.setGlobalActionHandler(
          ActionFactory.UNDO.getId(), getAction(editor, ITextEditorActionConstants.UNDO));
      actionBars.setGlobalActionHandler(
          ActionFactory.REDO.getId(), getAction(editor, ITextEditorActionConstants.REDO));
      actionBars.setGlobalActionHandler(
          ActionFactory.CUT.getId(), getAction(editor, ITextEditorActionConstants.CUT));
      actionBars.setGlobalActionHandler(
          ActionFactory.COPY.getId(), getAction(editor, ITextEditorActionConstants.COPY));
      actionBars.setGlobalActionHandler(
          ActionFactory.PASTE.getId(), getAction(editor, ITextEditorActionConstants.PASTE));
      actionBars.setGlobalActionHandler(
          ActionFactory.SELECT_ALL.getId(),
          getAction(editor, ITextEditorActionConstants.SELECT_ALL));
      actionBars.setGlobalActionHandler(
          ActionFactory.FIND.getId(), getAction(editor, ITextEditorActionConstants.FIND));
      actionBars.setGlobalActionHandler(
          IDEActionFactory.BOOKMARK.getId(), getAction(editor, IDEActionFactory.BOOKMARK.getId()));
      actionBars.updateActionBars();
    }
  }
  @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();
    }
  }
 public void contributeToToolBar(IToolBarManager toolBarManager) {
   toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
   toolBarManager.add(getAction(ActionFactory.REDO.getId()));
   toolBarManager.add(getAction(ActionFactory.DELETE.getId()));
   toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
   toolBarManager.add(new ZoomComboContributionItem(getPage()));
   toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
 }
 private void saveCurrentActions(IActionBars _actionBars) {
   copy = _actionBars.getGlobalActionHandler(ActionFactory.COPY.getId());
   paste = _actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId());
   delete = _actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId());
   selectAll = _actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId());
   cut = _actionBars.getGlobalActionHandler(ActionFactory.CUT.getId());
   find = _actionBars.getGlobalActionHandler(ActionFactory.FIND.getId());
   undo = _actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId());
   redo = _actionBars.getGlobalActionHandler(ActionFactory.REDO.getId());
 }
 private void restoreSavedActions(IActionBars _actionBars) {
   _actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy);
   _actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste);
   _actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), delete);
   _actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAll);
   _actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut);
   _actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), find);
   _actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo);
   _actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo);
 }
 @Override
 public void fillActionBars(IActionBars actionBars) {
   {
     actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeAction);
     actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
     actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
     actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
   }
   actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
   actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
 }
  @Override
  public void buildContextMenu(IMenuManager menu) {
    GEFActionConstants.addStandardActionGroups(menu);

    //      menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(EditAction.ID));
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.UNDO.getId()));
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));
    menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId()));
    menu.appendToGroup(GEFActionConstants.GROUP_PRINT, getAction(ActionFactory.PRINT.getId()));
    menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.IMPORT.getId()));
    menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.EXPORT.getId()));
  }
  public void setActiveView(IViewPart part) {
    IActionBars actionBars = part.getViewSite().getActionBars();
    if (!(part instanceof PropertySheet)) {
      actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeAction);
      actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
      actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
      actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
    }
    actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
    actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);

    actionBars.updateActionBars();
  }
 /* (non-Javadoc)
  * @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String)
  */
 public boolean doGlobalAction(String actionId) {
   if (actionId.equals(ActionFactory.DELETE.getId())) {
     handleDelete();
     return true;
   }
   if (actionId.equals(ActionFactory.CUT.getId())) {
     handleDelete();
     return false;
   }
   if (actionId.equals(ActionFactory.PASTE.getId())) {
     doPaste();
     return true;
   }
   return false;
 }
Example #15
0
  private void textEditorContextMenuAboutToShow(IMenuManager manager) {
    if (queryString != null) {
      undo.setEnabled(queryViewer.getUndoManager().undoable());
      redo.setEnabled(queryViewer.getUndoManager().redoable());
      manager.add(undo);
      manager.add(redo);
      manager.add(new Separator());

      manager.add(getAction(ActionFactory.CUT.getId()));
      manager.add(getAction(ActionFactory.COPY.getId()));
      manager.add(getAction(ActionFactory.PASTE.getId()));
      manager.add(new Separator());
      manager.add(getAction(ActionFactory.DELETE.getId()));
      manager.add(getAction(ActionFactory.SELECT_ALL.getId()));
    }
  }
 public boolean doGlobalAction(String actionId) {
   if (actionId.equals(ActionFactory.CUT.getId())) {
     handleRemove();
     return false;
   }
   if (actionId.equals(ActionFactory.PASTE.getId())) {
     doPaste();
     return true;
   }
   if (actionId.equals(ActionFactory.DELETE.getId())) {
     return handleRemove();
   }
   if (actionId.equals(ActionFactory.SELECT_ALL.getId())) {
     fCategoryViewer.getTree().selectAll();
     refresh();
   }
   return false;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.ContextMenuProvider#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
   */
  public void buildContextMenu(IMenuManager manager) {
    GEFActionConstants.addStandardActionGroups(manager);

    IAction action;

    action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
    manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    action = getActionRegistry().getAction(ActionFactory.REDO.getId());
    manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId()));

    manager.add(new Separator());

    action = getActionRegistry().getAction(PropertyAction.COPY);
    if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_REST, action);

    manager.add(new Separator());

    action = getActionRegistry().getAction(ActionFactory.SAVE.getId());
    manager.appendToGroup(GEFActionConstants.GROUP_SAVE, action);
  }
  @Override
  public boolean doGlobalAction(String actionId) {

    if (!isEditable()) {
      return false;
    }

    if (actionId.equals(ActionFactory.DELETE.getId())) {
      handleRemove();
      return true;
    }
    if (actionId.equals(ActionFactory.CUT.getId())) {
      // delete here and let the editor transfer
      // the selection to the clipboard
      handleRemove();
      return false;
    }
    if (actionId.equals(ActionFactory.PASTE.getId())) {
      doPaste();
      return true;
    }
    return false;
  }
  /** @generated NOT */
  protected void makeActions(IWorkbenchWindow window) {
    toggleCoolbarAction = ActionFactory.TOGGLE_COOLBAR.create(window);
    register(toggleCoolbarAction);
    lockToolBarAction = ActionFactory.LOCK_TOOL_BAR.create(window);
    register(lockToolBarAction);

    // register(ActionFactory.CLOSE.create(window));

    // register(ActionFactory.CLOSE_ALL.create(window));

    register(ActionFactory.SAVE.create(window));

    register(ActionFactory.SAVE_AS.create(window));

    register(ActionFactory.SAVE_ALL.create(window));

    register(ActionFactory.QUIT.create(window));

    register(ActionFactory.UNDO.create(window));

    register(ActionFactory.REDO.create(window));

    register(ActionFactory.CUT.create(window));

    register(ActionFactory.COPY.create(window));

    register(ActionFactory.PASTE.create(window));

    register(ActionFactory.DELETE.create(window));

    register(ActionFactory.SELECT_ALL.create(window));

    register(ActionFactory.OPEN_NEW_WINDOW.create(window));

    register(ActionFactory.PRINT.create(window));
  }
Example #20
0
  private void registContextMenu(Composite parent) {
    IWorkbenchWindow window = getSite().getWorkbenchWindow();

    IWorkbenchAction renameAction = ActionFactory.RENAME.create(window);
    renameAction.setToolTipText(NBLabel.get(0x006B));
    renameAction.setText(NBLabel.get(0x006E));

    IWorkbenchAction refreshAction = ActionFactory.REFRESH.create(window);
    refreshAction.setToolTipText(NBLabel.get(0x025F));
    refreshAction.setText(NBLabel.get(0x0260));

    IWorkbenchAction deleteAction = ActionFactory.DELETE.create(window);
    deleteAction.setToolTipText(NBLabel.get(0x0062));
    deleteAction.setText(NBLabel.get(0x0068));

    MenuManager newMgr = new MenuManager("&New                    ", "file.mnuNew");
    newMgr.add(new NewServerAction(window));
    newMgr.add(new Separator());
    newMgr.add(new GroupMarker("file.new.OTHERS"));

    MenuManager mgr = new MenuManager();
    mgr.add(newMgr);
    mgr.add(new Separator());
    mgr.add(ResourceFactory.CONNECT.create(window));
    mgr.add(ResourceFactory.DISCONNECT.create(window));
    mgr.add(new Separator());
    mgr.add(refreshAction);
    mgr.add(new Separator());
    mgr.add(deleteAction);
    mgr.add(renameAction);
    mgr.add(new Separator());
    mgr.add(new PropertyAction(window));

    Menu menu = mgr.createContextMenu(parent);
    treeViewer.getTree().setMenu(menu);
  }
  @Override
  public void buildContextMenu(IMenuManager manager) {
    GEFActionConstants.addStandardActionGroups(manager);

    IAction action;

    action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
    if (action != null) manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    action = getActionRegistry().getAction(ActionFactory.REDO.getId());
    if (action != null) manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    action = getActionRegistry().getAction(AutoLayoutAction.ID);
    if (action != null) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    action = getActionRegistry().getAction(AutoLayoutPagesAction.ID);
    if (action != null) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
    if (action != null) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    //		action = getActionRegistry().getAction(DeleteReportItemAction.ID);
    //		manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    //		action = getActionRegistry().getAction(ActionFactory.PASTE.getId());
    //		if (action.isEnabled())
    //			manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    //		action = getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT);
    //		if (action.isEnabled())
    //			manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    //
    //		// Alignment Actions
    //		MenuManager submenu = new MenuManager("Align");
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		submenu.add(new Separator());
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		action = getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM);
    //		if (action.isEnabled())
    //			submenu.add(action);
    //
    //		if (!submenu.isEmpty())
    //			manager.appendToGroup(GEFActionConstants.GROUP_REST, submenu);
    //
    //		action = getActionRegistry().getAction(ActionFactory.SAVE.getId());
    //		manager.appendToGroup(GEFActionConstants.GROUP_SAVE, action);
  }
  /** @generated NOT */
  protected void fillMenuBar(IMenuManager menu) {

    ContributionItemFactory.VIEWS_SHORTLIST.create(getWindow());

    {
      IMenuManager menuX =
          new MenuManager(Messages.ApplicationMenuName_File, IWorkbenchActionConstants.M_FILE);

      menuX.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));

      {
        IMenuManager menuXX = new MenuManager(Messages.ApplicationMenuName_New, "new");

        menuXX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        menuX.add(menuXX);
      }

      menuX.add(new Separator());

      menuX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

      menuX.add(new Separator());

      menuX.add(getAction(ActionFactory.SAVE.getId()));

      menuX.add(getAction(ActionFactory.SAVE_AS.getId()));

      menuX.add(getAction(ActionFactory.SAVE_ALL.getId()));
      /*++ added*/
      menuX.add(new Separator());
      IMenuManager menuExport = new MenuManager("Export", "export");
      menuExport.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
      menuX.add(menuExport);
      menuX.add(getAction(ActionFactory.PRINT.getId()));

      menuX.add(new Separator());

      menuX.add(getAction(ActionFactory.QUIT.getId()));

      menuX.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
      menu.add(menuX);
    }

    {
      IMenuManager menuX =
          new MenuManager(Messages.ApplicationMenuName_Edit, IWorkbenchActionConstants.M_EDIT);

      menuX.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));

      menuX.add(getAction(ActionFactory.UNDO.getId()));

      menuX.add(getAction(ActionFactory.REDO.getId()));

      menuX.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));

      menuX.add(new Separator());

      menuX.add(getAction(ActionFactory.CUT.getId()));

      menuX.add(getAction(ActionFactory.COPY.getId()));

      menuX.add(getAction(ActionFactory.PASTE.getId()));

      menuX.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));

      menuX.add(new Separator());

      menuX.add(getAction(ActionFactory.DELETE.getId()));

      menuX.add(getAction(ActionFactory.SELECT_ALL.getId()));

      menuX.add(new Separator());

      menuX.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));

      menuX.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));

      menuX.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

      menu.add(menuX);
    }

    // menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    IMenuManager menuX =
        new MenuManager(Messages.ApplicationMenuName_Help, IWorkbenchActionConstants.M_HELP);

    menuX.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));

    menuX.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));

    menuX.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menu.add(menuX);
  }
Example #23
0
  protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(createEditPartFactory());

    ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
    viewer.setRootEditPart(rootEditPart);

    // ZoomManagerの取得
    ZoomManager manager = rootEditPart.getZoomManager();

    // ズームレベルの設定
    double[] zoomLevels =
        new double[] {0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0};
    manager.setZoomLevels(zoomLevels);

    // ズーム レベル コントリビューションの設定
    ArrayList<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);
    // 拡大アクションの作成と登録
    getActionRegistry().registerAction(new ZoomInAction(manager));
    // 縮小アクションの作成と登録
    getActionRegistry().registerAction(new ZoomOutAction(manager));

    getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()));

    // コンテクストメニューの作成
    String menuId = this.getClass().getName() + ".EditorContext";

    MenuManager menuMgr = new MenuManager(menuId, menuId);
    openPropertyAction = new OpenPropertyViewAction(viewer);
    openOutlineAction = new OpenOutlineViewAction(viewer);
    saveAsImageAction = new SaveAsImageAction(viewer);
    copyAsImageAction = new CopyAsImageAction(viewer);
    createDiagramAction(viewer);

    getSite().registerContextMenu(menuId, menuMgr, viewer);

    PrintAction printAction = new PrintAction(this);
    printAction.setImageDescriptor(UMLPlugin.getImageDescriptor("icons/print.gif"));
    getActionRegistry().registerAction(printAction);

    final DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) this);
    deleteAction.setSelectionProvider(getGraphicalViewer());
    getActionRegistry().registerAction(deleteAction);
    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            deleteAction.update();
          }
        });

    // Actions
    //		IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(showRulers);
    //
    //		IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(snapAction);
    //
    //		IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(showGrid);

    menuMgr.add(new Separator("edit"));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.UNDO.getId()));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.REDO.getId()));
    //		menuMgr.add(getActionRegistry().getAction(ActionFactory.COPY.getId()));
    //		menuMgr.add(getActionRegistry().getAction(ActionFactory.PASTE.getId()));
    menuMgr.add(new Separator("zoom"));
    menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    fillDiagramPopupMenu(menuMgr);
    menuMgr.add(new Separator("print"));
    menuMgr.add(saveAsImageAction);
    menuMgr.add(copyAsImageAction);
    menuMgr.add(printAction);
    menuMgr.add(new Separator("views"));
    menuMgr.add(openPropertyAction);
    menuMgr.add(openOutlineAction);
    menuMgr.add(new Separator("generate"));
    menuMgr.add(new Separator("additions"));
    viewer.setContextMenu(menuMgr);
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
  }
  @Override
  public void buildContextMenu(final IMenuManager menu) {
    IAction action;
    GEFActionConstants.addStandardActionGroups(menu);

    // Undo
    action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    // Redo
    action = getActionRegistry().getAction(ActionFactory.REDO.getId());
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);

    // Delete
    action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
    menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    // Rename
    action = getActionRegistry().getAction(ActionFactory.RENAME.getId());
    menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);

    // Color
    action = getActionRegistry().getAction(ChangeColorAction.changeColorProperty);
    menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);

    // Opacity
    final MenuManager opacitySubmenu = new MenuManager("Figure opacity"); // $NON-NLS-1$

    action = getActionRegistry().getAction(OpacityTenAction.opacityPropertyTen);
    opacitySubmenu.add(action);

    action = getActionRegistry().getAction(OpacityTwentyAction.opacityPropertyTwenty);
    opacitySubmenu.add(action);

    action = getActionRegistry().getAction(OpacityFourtyAction.opacityPropertyFourty);
    opacitySubmenu.add(action);

    action = getActionRegistry().getAction(OpacitySixtyAction.opacityPropertySixty);
    opacitySubmenu.add(action);

    action = getActionRegistry().getAction(OpacityEightyAction.opacityPropertyEighty);
    opacitySubmenu.add(action);

    action = getActionRegistry().getAction(OpacityHundredAction.opacityPropertyHundred);
    opacitySubmenu.add(action);

    menu.appendToGroup(GEFActionConstants.GROUP_VIEW, opacitySubmenu);

    // Font Style
    final MenuManager fontStyleSubmenu = new MenuManager("Font style"); // $NON-NLS-1$

    action = getActionRegistry().getAction(FontStyleNormalAction.fontStylePropertyNormal);
    fontStyleSubmenu.add(action);

    action = getActionRegistry().getAction(FontStyleBoldAction.fontStylePropertyBold);
    fontStyleSubmenu.add(action);

    action = getActionRegistry().getAction(FontStyleItalicAction.fontStylePropertyItalic);
    fontStyleSubmenu.add(action);

    action = getActionRegistry().getAction(FontStyleBoldItalicAction.fontStylePropertyBoldItalic);
    fontStyleSubmenu.add(action);

    menu.appendToGroup(GEFActionConstants.GROUP_REST, fontStyleSubmenu);

    // Font Size
    final MenuManager fontSizeSubmenu = new MenuManager("Font size"); // $NON-NLS-1$

    action = getActionRegistry().getAction(FontSizeSevenAction.fontSizePropertySeven);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeNineAction.fontSizePropertyNine);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeTenAction.fontSizePropertyTen);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeThirteenAction.fontSizePropertyThirteen);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeSixteenAction.fontSizePropertySixteen);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeTwentyAction.fontSizePropertyTwenty);
    fontSizeSubmenu.add(action);

    action = getActionRegistry().getAction(FontSizeTwentyfiveAction.fontSizePropertyTwentyfive);
    fontSizeSubmenu.add(action);

    menu.appendToGroup(GEFActionConstants.GROUP_REST, fontSizeSubmenu);

    // Font Color
    action = getActionRegistry().getAction(FontColorAction.fontColorProperty);
    menu.appendToGroup(GEFActionConstants.GROUP_REST, action);

    // Label Color
    action = getActionRegistry().getAction(ChangeLabelColorAction.changeLabelColorProperty);
    menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
  }
Example #25
0
  private void addRetargetableAction(Composite parent) {
    deleteAction =
        new Action() {
          public void run() {

            ISelection incomming = treeViewer.getSelection();
            if (incomming instanceof IStructuredSelection) {
              if (IMessageBox.Confirm(shell, NBLabel.get(0x0092)) != SWT.OK) return;

              IStructuredSelection selection = (IStructuredSelection) incomming;
              deleteServer((Server) selection.getFirstElement());
            }
          }
        };

    refreshAction =
        new Action() {
          public void run() {
            Server server = null;
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();

            if (selection.getFirstElement() instanceof Server) {
              server = (Server) selection.getFirstElement();
            } else {
              IMessageBox.Error(shell, NBLabel.get(0x0091));
              return;
            }

            server.setImage(
                Activator.getImageDescriptor("/icons/disconserver.gif").createImage(display));

            server.removeConfig();
            server.removeUserList();
            server.removeInstance();
            treeViewer.refresh();

            connectAction.setEnabled(true);
            disconnectAction.setEnabled(false);
            refreshAction.setEnabled(false);
            terminateAction.setEnabled(false);

            closeInstanceView(server.getName());

            IPCProtocol protocol =
                ((ServerConnect) ((Server) selection.getFirstElement()).getConnect()).getProtocol();

            NBFields netFields = new NBFields();
            netFields.put(IPC.NB_LOAD_CLASS, "com.nabsys.management.instance.InstanceConfig");
            netFields.put("CMD_CODE", "L");

            try {
              netFields = protocol.execute(netFields);

              if (protocol.getUserAuthority().equals("Admin")) {
                new ServerConfig(
                    server,
                    NBLabel.get(0x0049),
                    Activator.getImageDescriptor("/icons/config_obj.gif").createImage(display));
                new UserList(
                    server,
                    NBLabel.get(0x009D),
                    Activator.getImageDescriptor("/icons/user_view.gif").createImage(display));
                new InstanceList(
                    server,
                    NBLabel.get(0x0093),
                    Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
                terminateAction.setEnabled(true);
              } else if (protocol.getUserAuthority().equals("Operator")) {
                new UserList(
                    server,
                    NBLabel.get(0x009D),
                    Activator.getImageDescriptor("/icons/user_view.gif").createImage(display));
                new InstanceList(
                    server,
                    NBLabel.get(0x0093),
                    Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
              } else if (protocol.getUserAuthority().equals("Developer")) {
                new InstanceList(
                    server,
                    NBLabel.get(0x0093),
                    Activator.getImageDescriptor("/icons/pview.gif").createImage(display));
              }

              server.setImage(
                  Activator.getImageDescriptor("/icons/conserver.gif").createImage(display));
              treeViewer.refresh();

              connectAction.setEnabled(false);
              disconnectAction.setEnabled(true);

              treeViewer.expandToLevel(server, 1);

              openInstanceView(server.getName(), server.getInstance(), netFields, server);
            } catch (SocketClosedException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            } catch (TimeoutException e) {
              IMessageBox.Error(shell, e.getMessage());
            } catch (NetException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            } catch (UnsupportedEncodingException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            } catch (NoSuchAlgorithmException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            } catch (DataTypeException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            } catch (ProtocolException e) {
              IMessageBox.Error(shell, NBLabel.get(0x0090));
              closeConnection();
            }
          }
        };

    renameAction =
        new Action() {
          public void run() {
            final HashMap<String, String> params = new HashMap<String, String>();
            SimpleInputBox inputBox = new SimpleInputBox(shell, params);
            inputBox.setTitle(NBLabel.get(0x009A));
            inputBox.setImage("/icons/topic.gif");
            inputBox.setLabel(NBLabel.get(0x009B));
            inputBox.open(getSite().getWorkbenchWindow(), false);

            if (params.containsKey("EVENT") && params.get("EVENT").equals("CANCEL")) {
              return;
            }

            ISelection incomming = treeViewer.getSelection();
            if (incomming instanceof IStructuredSelection) {
              IStructuredSelection selection = (IStructuredSelection) incomming;
              Server server = (Server) selection.getFirstElement();
              DOMConfigurator config = null;
              try {
                Bundle bundle = Platform.getBundle(Application.PLUGIN_ID);
                URL fileURL =
                    FileLocator.toFileURL(BundleUtility.find(bundle, "configuration/nabee.xml"));

                config = new DOMConfigurator(fileURL.getPath());

                config.modifyConf("monitor/server", server.getName(), params.get("TEXT"));

                if (server.getConnect().isConnect()) {
                  InstanceView instanceView =
                      ((InstanceView)
                          getSite().getWorkbenchWindow().getActivePage().findView(InstanceView.ID));
                  if (instanceView.getPartProperty("SERVER_NAME").equals(server.getName())) {
                    instanceView.serverNameChanged(params.get("TEXT"));
                  }
                }

                server.setName(params.get("TEXT"));
                treeViewer.refresh();

              } catch (ParserConfigurationException e) {
                IMessageBox.Error(shell, NBLabel.get(0x008F));
                return;
              } catch (TransformerException e) {
                IMessageBox.Error(shell, NBLabel.get(0x008F));
                return;
              } catch (IOException e) {
                IMessageBox.Error(shell, NBLabel.get(0x008F));
                return;
              } catch (SAXException e) {
                IMessageBox.Error(shell, NBLabel.get(0x008F));
                return;
              } catch (Exception e) {
                IMessageBox.Error(shell, NBLabel.get(0x008F));
                return;
              }
            }
          }
        };

    terminateAction =
        new TerminateAction(getSite().getWorkbenchWindow()) {
          public void run() {

            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();

            if (selection.getFirstElement() instanceof Server) {
              Server server = (Server) selection.getFirstElement();

              if (IMessageBox.Confirm(shell, "[" + server.getName() + "] " + NBLabel.get(0x022B))
                  != SWT.OK) return;

              IPCProtocol protocol =
                  ((ServerConnect) ((Server) selection.getFirstElement()).getConnect())
                      .getProtocol();
              boolean rtn = controlServer(IPC.CMD_SHUTDOWN, protocol);

              if (rtn) {
                disconnectServer(false);
                setEnabled(false);
              }
            }
          }

          public void selectionChanged(IWorkbenchPart part, ISelection incoming) {
            if (incoming instanceof IStructuredSelection) {
              IStructuredSelection selection = (IStructuredSelection) incoming;

              if (selection.getFirstElement() != null
                  && selection.getFirstElement() instanceof Server) {
                IPCProtocol protocol =
                    ((Server) selection.getFirstElement()).getConnect().getProtocol();
                if (selection.size() == 1
                    && selection.getFirstElement() instanceof Server
                    && protocol != null) {
                  setEnabled(protocol.getUserAuthority().equals("Admin") && protocol.isConnected());
                } else {
                  setEnabled(false);
                }
              } else {
                setEnabled(false);
              }
            } else {
              setEnabled(false);
            }
          }
        };

    connectAction = new ConnectAction(getSite().getWorkbenchWindow());
    disconnectAction = new DisconnectAction(getSite().getWorkbenchWindow());

    IActionBars actionBars = getViewSite().getActionBars();

    actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
    actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
    actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
    actionBars.setGlobalActionHandler("connect", connectAction);
    actionBars.setGlobalActionHandler("disconnect", disconnectAction);
    actionBars.setGlobalActionHandler(ResourceFactory.TERMINATE.getId(), terminateAction);
  }