/** 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);
  }
    @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);
    }
  @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));
  }
  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();
    }
  }
 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));
 }
Exemplo n.º 6
0
 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());
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 @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()));
  }
  /**
   * Called when the context menu is about to show. Actions, whose state is enabled, will appear in
   * the context menu.
   *
   * @see
   *     org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
   */
  public void buildContextMenu(IMenuManager menu) {
    // Add standard action groups to the menu
    GEFActionConstants.addStandardActionGroups(menu);

    // Add actions to the menu
    menu.appendToGroup(
        GEFActionConstants.GROUP_UNDO, // target group id
        getAction(ActionFactory.UNDO.getId())); // action to add
    menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));
    //		menu.appendToGroup(
    //				GEFActionConstants.GROUP_EDIT,
    //				getAction(ActionFactory.DELETE.getId()));
  }
Exemplo n.º 11
0
  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();
  }
  /** @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) */
  @Override
  public void setActionBars(final IActionBars actionBars) {
    // Override the undo and redo global action handlers
    // to use the contributor action handlers
    IActionBars partActionBars = null;
    if (contributor instanceof IEditorPart) {
      final IEditorPart editorPart = (IEditorPart) contributor;
      partActionBars = editorPart.getEditorSite().getActionBars();
    } else if (contributor instanceof IViewPart) {
      final IViewPart viewPart = (IViewPart) contributor;
      partActionBars = viewPart.getViewSite().getActionBars();
    }

    if (partActionBars != null) {
      IAction action = partActionBars.getGlobalActionHandler(ActionFactory.UNDO.getId());
      if (action != null) {
        actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), action);
      }
      action = partActionBars.getGlobalActionHandler(ActionFactory.REDO.getId());
      if (action != null) {
        actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), action);
      }
    }
  }
Exemplo n.º 13
0
 public void fillContextMenu(IMenuManager menu) {
   menu.add(getTextAction(ActionFactory.UNDO.getId()));
   menu.add(getTextAction(ActionFactory.REDO.getId()));
   menu.add(new Separator());
   menu.add(getTextAction(ActionFactory.CUT.getId()));
   menu.add(getTextAction(ActionFactory.COPY.getId()));
   menu.add(getTextAction(ActionFactory.PASTE.getId()));
   menu.add(new Separator());
   menu.add(getTextAction(ActionFactory.SELECT_ALL.getId()));
   menu.add(new Separator());
   super.fillContextMenu(menu);
   if (spellingActivation != null) {
     IMenuContributor contributor =
         (IMenuContributor) spellingActivation.getAdapter(IMenuContributor.class);
     if (contributor != null) {
       menu.add(new Separator());
       contributor.fillMenu(menu);
     }
   }
 }
  /**
   * @see
   *     org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager)
   */
  public void contributeToToolBar(IToolBarManager toolBarManager) {
    toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
    toolBarManager.add(getAction(ActionFactory.REDO.getId()));
    toolBarManager.add(new Separator());
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));

    toolBarManager.add(new Separator());
    // 수평 방향의 정렬 액션의 추가
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT));
    toolBarManager.add(new Separator());
    // 수직 방향의 정렬 액션의 추가
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM));

    toolBarManager.add(new Separator());
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_WIDTH));
    toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_HEIGHT));
  }
Exemplo n.º 15
0
  /*
   * (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);
  }
Exemplo n.º 16
0
 @Override
 public String getId() {
   return ActionFactory.REDO.getId();
 }
  @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);
  }
Exemplo n.º 19
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()));
  }
Exemplo n.º 20
0
 /**
  * Add actions to the given toolbar.
  *
  * @see
  *     org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager)
  */
 public void contributeToToolBar(IToolBarManager toolBarManager) {
   toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
   toolBarManager.add(getAction(ActionFactory.REDO.getId()));
 }
Exemplo n.º 21
0
  @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);
  }
 /**
  * Overwritten to register global action handlers for undo and redo.
  *
  * @see
  *     org.eclipse.ui.views.properties.PropertySheetPage#setActionBars(org.eclipse.ui.IActionBars)
  */
 public void setActionBars(IActionBars actionBars) {
   super.setActionBars(actionBars);
   // register global action handlers for undo and redo
   actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoHandler);
   actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoHandler);
 }