コード例 #1
0
  private void init(IMemento memento) {

    updateActionBars = new UpdateActionBarsJob(commonNavigator.getTitle());

    CommonViewer commonViewer = commonNavigator.getCommonViewer();
    commonViewer.addSelectionChangedListener(this);
    commonViewer.addPostSelectionChangedListener(statusBarListener);
    updateStatusBar(commonViewer.getSelection());

    ICommonViewerSite commonViewerSite =
        CommonViewerSiteFactory.createCommonViewerSite(commonNavigator.getViewSite());
    actionService =
        new NavigatorActionService(
            commonViewerSite, commonViewer, commonViewer.getNavigatorContentService());

    final RetargetAction openAction =
        new RetargetAction(ICommonActionConstants.OPEN, CommonNavigatorMessages.Open_action_label);
    commonNavigator.getViewSite().getPage().addPartListener(openAction);
    openAction.setActionDefinitionId(ICommonActionConstants.OPEN);
    //		RAP [bmichalik]: help system
    //		new OpenAndLinkWithEditorHelper(commonNavigator.getCommonViewer()) {
    //			protected void activate(ISelection selection) {
    //				final int currentMode = OpenStrategy.getOpenMethod();
    //				try {
    //					/*
    //					 * XXX:
    //					 * Currently the only way to activate the editor because there is no API to
    //					 * get an editor input for a given object.
    //					 */
    //					OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK);
    //					actionService.setContext(new
    // ActionContext(commonNavigator.getCommonViewer().getSelection()));
    //					actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
    //					openAction.run();
    //				} finally {
    //					OpenStrategy.setOpenMethod(currentMode);
    //				}
    //			}
    //
    //			protected void linkToEditor(ISelection selection) {
    //				// do nothing: this is handled by
    // org.eclipse.ui.internal.navigator.actions.LinkEditorAction
    //			}
    //
    //			protected void open(ISelection selection, boolean activate) {
    //				actionService.setContext(new
    // ActionContext(commonNavigator.getCommonViewer().getSelection()));
    //				actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
    //				openAction.run();
    //			}
    //
    //		};

    if (memento != null) restoreState(memento);

    initContextMenu();
    initViewMenu();
  }
  @Override
  protected void buildActions() {

    addRetargetAction(new UndoRetargetAction());
    addRetargetAction(new RedoRetargetAction());
    addRetargetAction(new DeleteRetargetAction());

    addRetargetAction(new ZoomInRetargetAction());
    addRetargetAction(new ZoomOutRetargetAction());

    // Show/hide grid
    //		addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY,
    // GEFMessages.get().get().ToggleRulerVisibility_Label, IAction.AS_CHECK_BOX));
    //		addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY,
    // GEFMessages.get().get().ToggleSnapToGeometry_Label, IAction.AS_CHECK_BOX));
    addRetargetAction(
        new RetargetAction(
            GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid", IAction.AS_CHECK_BOX));

    // aligment action
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.LEFT));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.CENTER));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.RIGHT));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.TOP));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.MIDDLE));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.BOTTOM));

    RetargetAction retargetAction =
        new RetargetAction(GEFActionConstants.MATCH_WIDTH, "Match Width");
    retargetAction.setImageDescriptor(InternalImages.DESC_MATCH_WIDTH);
    retargetAction.setDisabledImageDescriptor(InternalImages.DESC_MATCH_WIDTH_DIS);
    retargetAction.setToolTipText("Match Width");
    addRetargetAction(retargetAction);

    retargetAction = new RetargetAction(GEFActionConstants.MATCH_HEIGHT, "Match Height");
    retargetAction.setImageDescriptor(InternalImages.DESC_MATCH_HEIGHT);
    retargetAction.setDisabledImageDescriptor(InternalImages.DESC_MATCH_HEIGHT_DIS);
    retargetAction.setToolTipText("Match Height");
    addRetargetAction(retargetAction);

    // styled action
    addRetargetAction(new ERDViewStyleRetargetAction());
  }