示例#1
0
  public PasteAction(IWorkbenchPart part, GraphicalViewer viewer) {
    super(part);

    fGraphicalViewer = viewer;

    setText(Messages.PasteAction_0);
    setId(ActionFactory.PASTE.getId());
    ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
    setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
    setDisabledImageDescriptor(
        sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
    setEnabled(false);

    /** Listen to window activation to udpate Paste Action if clipboard contents has changed */
    getWorkbenchPart()
        .getSite()
        .getWorkbenchWindow()
        .getWorkbench()
        .addWindowListener(windowListener);

    /** Listen to mouse click position so that the Paste Action can paste objects at that point */
    ((GraphicalEditPart) fGraphicalViewer.getRootEditPart())
        .getFigure()
        .addMouseListener(mouseListener);
  }
  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 registerMenu(IMenuManager menu) {
   view.getViewSite()
       .getActionBars()
       .setGlobalActionHandler(ActionFactory.CUT.getId(), this.cutAction);
   view.getViewSite()
       .getActionBars()
       .setGlobalActionHandler(ActionFactory.PASTE.getId(), this.pasteAction);
 }
 private IContributionItem getPasteItem() {
   return getItem(
       ActionFactory.PASTE.getId(),
       ActionFactory.PASTE.getCommandId(),
       ISharedImages.IMG_TOOL_PASTE,
       ISharedImages.IMG_TOOL_PASTE_DISABLED,
       Messages.Workbench_paste,
       Messages.Workbench_pasteToolTip,
       null);
 }
 public PasteAction(VisualDBEditor editor) {
   super(editor);
   setId(ActionFactory.PASTE.getId());
   // setActionDefinitionId(ActionFactory.PASTE.getId());
   setText(DBPlugin.getResourceString("action.paste"));
   ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
   setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
   setDisabledImageDescriptor(
       sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
 }
 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);
 }
  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;
 }
示例#12
0
  private void initToolBars() {
    IActionBars bars = this.getViewSite().getActionBars();

    bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction);
    bars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
    bars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
    bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);

    IToolBarManager toolBarManager = bars.getToolBarManager();

    addToolbarContributions(toolBarManager);
    addMenuContributions(bars.getMenuManager());

    //		pifSelector.init(getViewSite().getWorkbenchWindow());
    automatedSelector.init(getViewSite().getWorkbenchWindow());
  }
示例#13
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;
 }
示例#15
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);
     }
   }
 }
  @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;
  }
 /** @see org.eclipse.gef.ui.actions.ActionBarContributor#declareGlobalActionKeys() */
 @Override
 protected void declareGlobalActionKeys() {
   addGlobalActionKey(ActionFactory.PRINT.getId());
   addGlobalActionKey(ActionFactory.SELECT_ALL.getId());
   addGlobalActionKey(ActionFactory.PASTE.getId());
 }
  /** @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);
  }