/** * Create actions managed by this contributor. * * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() */ protected void buildActions() { addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); IWorkbenchWindow iww = getPage().getWorkbenchWindow(); addRetargetAction((RetargetAction)ActionFactory.COPY.create(iww)); addRetargetAction((RetargetAction)ActionFactory.PASTE.create(iww)); // Registering the zooming actions at the menu bar. addRetargetAction(new ZoomInRetargetAction()); addRetargetAction(new ZoomOutRetargetAction()); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, GEFMessages.ToggleGrid_Label, IAction.AS_CHECK_BOX)); }
/** * Builds the actions. * * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() */ protected void buildActions(IActionBars bars) { addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); // addRetargetAction(new PrintAction()); addRetargetAction(new ZoomInRetargetAction()); addRetargetAction(new ZoomOutRetargetAction()); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY, Messages.JrxmlEditorContributor_show_ruler, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(SnapToGuidesAction.ID, Messages.common_snap_to_guides, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, Messages.common_show_grid, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, Messages.common_snap_to_geometry, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(SnapToGridAction.ID, Messages.common_snap_to_grid, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(SizeGridAction.ID, Messages.JrxmlEditorContributor_grid_size)); List<RetargetAction> ractions = JaspersoftStudioPlugin.getDecoratorManager().buildMenuActions(); for (RetargetAction r : ractions) addRetargetAction(r); }
@Override public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } String string = "Add " + EPlanUtils.getActivityGroupDisplayName(); String description = "This action will add a new " + EPlanUtils.getActivityGroupDisplayName() + " to the plan."; RetargetAction action = new RetargetAction(getId(), string); action.setToolTipText(string); action.setDescription(description); window.getPartService().addPartListener(action); action.setActionDefinitionId("gov.nasa.ensemble.core.plan.editor.newActivityGroupAction"); //$NON-NLS-1$ action.setImageDescriptor(new ImageDescriptor() { @Override public ImageData getImageData() { return ADD_GROUP_ICON; } }); return action; }
@Override public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), "Collapse All"); action.setToolTipText("collapses all of the items in the current view/editor"); action.setDescription("This action collapses all of the items in the current view/editor"); window.getPartService().addPartListener(action); action.setActionDefinitionId("gov.nasa.ensemble.core.plan.editor.collapseAllAction"); action.setImageDescriptor(new ImageDescriptor() { @Override public ImageData getImageData() { return COLLAPSE_ALL_ICON; } }); return action; }
@Override public IWorkbenchAction create(IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } RetargetAction action = new RetargetAction(getId(), "Expand All"); action.setToolTipText("expands all of the items in the current view/editor"); action.setDescription("This action expands all of the items in the current view/editor"); window.getPartService().addPartListener(action); action.setActionDefinitionId("gov.nasa.ensemble.core.plan.editor.expandAllAction"); action.setImageDescriptor(new ImageDescriptor() { @Override public ImageData getImageData() { return EXPAND_ALL_ICON; } }); return action; }
public BasicCompilationUnitEditorActionContributor() { fRetargetContentAssist= new RetargetAction(JdtActionConstants.CONTENT_ASSIST, JavaEditorMessages.ContentAssistProposal_label); fRetargetContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); fRetargetContentAssist.setImageDescriptor(JavaPluginImages.DESC_ELCL_CODE_ASSIST); fRetargetContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST); markAsPartListener(fRetargetContentAssist); fContentAssist= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistProposal."); //$NON-NLS-1$ fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); fContentAssist.setImageDescriptor(JavaPluginImages.DESC_ELCL_CODE_ASSIST); fContentAssist.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CODE_ASSIST); fContextInformation= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ContentAssistContextInformation."); //$NON-NLS-1$ fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION); fQuickAssistAction= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "CorrectionAssistProposal."); //$NON-NLS-1$ fQuickAssistAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST); fChangeEncodingAction= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "Editor.ChangeEncodingAction."); //$NON-NLS-1$ }
/** * {@inheritDoc} */ public void init(IWorkbenchWindow window) { disposeSubmenuActions(); // paranoia code: double initialization should not happen if (window != null) { fPartService= window.getPartService(); if (fPartService != null) { fRetargetActions= new RetargetAction[] { createSubmenuAction(fPartService, JdtActionConstants.FIND_OCCURRENCES_IN_FILE, ActionMessages.OccurrencesSearchMenuAction_occurrences_in_file_label, IJavaEditorActionDefinitionIds.SEARCH_OCCURRENCES_IN_FILE), createSubmenuAction(fPartService, JdtActionConstants.FIND_IMPLEMENT_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_implementing_methods_label, IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENT_OCCURRENCES_IN_FILE), createSubmenuAction(fPartService, JdtActionConstants.FIND_EXCEPTION_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_throwing_exception_label, IJavaEditorActionDefinitionIds.SEARCH_EXCEPTION_OCCURRENCES_IN_FILE), createSubmenuAction(fPartService, JdtActionConstants.FIND_METHOD_EXIT_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_method_exits_label, IJavaEditorActionDefinitionIds.SEARCH_METHOD_EXIT_OCCURRENCES), createSubmenuAction(fPartService, JdtActionConstants.FIND_BREAK_CONTINUE_TARGET_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_break_continue_target_label, IJavaEditorActionDefinitionIds.SEARCH_BREAK_CONTINUE_TARGET_OCCURRENCES) }; } } }
private void updateActions() { IWorkbenchPart activePart= JavaPlugin.getActivePage().getActivePart(); if (!(activePart instanceof JavaEditor)) return; ISelection javaSelection= getEditorSelection((JavaEditor) activePart); if (javaSelection == null) return; for (int i= 0; i < fRetargetActions.length; i++) { RetargetAction action= fRetargetActions[i]; IAction actionHandler= action.getActionHandler(); if (actionHandler instanceof SelectionDispatchAction) { ((SelectionDispatchAction) actionHandler).update(javaSelection); } } }
/** {@inheritDoc} */ @Override protected void buildActions() { addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); // add grid icon to grid action final RetargetAction gridAction = new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, "", IAction.AS_CHECK_BOX); gridAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/grid.png")); gridAction.setToolTipText(TOGGLE_GRID_LABEL); addRetargetAction(gridAction); final RetargetAction snapAction = new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, "", IAction.AS_CHECK_BOX); snapAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/grid-snap.png")); snapAction.setToolTipText(TOGGLE_SNAP_TO_GERMETRY_LABEL); addRetargetAction(snapAction); }
@Override protected void buildActions() { this.addRetargetAction(new RetargetAction(ActionFactory.SELECT_ALL .getId(), "selectAll")); this.addRetargetAction(new UndoRetargetAction()); this.addRetargetAction(new RedoRetargetAction()); this.addRetargetAction(new DeleteRetargetAction()); ZoomInRetargetAction zoomInAction = new ZoomInRetargetAction(); zoomInAction.setImageDescriptor(Activator .getImageDescriptor(ImageResource.ZOOM_IN)); ZoomOutRetargetAction zoomOutAction = new ZoomOutRetargetAction(); zoomOutAction.setImageDescriptor(Activator .getImageDescriptor(ImageResource.ZOOM_OUT)); this.addRetargetAction(zoomInAction); this.addRetargetAction(zoomOutAction); this.addRetargetAction(new ZoomAdjustRetargetAction()); }
@Override protected void buildActions() { IWorkbenchWindow iww = getPage().getWorkbenchWindow(); addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new ZoomInRetargetAction()); addRetargetAction(new ZoomOutRetargetAction()); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, GEFMessages.ToggleGrid_Label, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, GEFMessages.ToggleSnapToGeometry_Label, IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction(ActionFactory.SELECT_ALL.getId(), GEFMessages.SelectAllAction_Label)); addRetargetAction((RetargetAction)ActionFactory.COPY.create(iww)); addRetargetAction((RetargetAction)ActionFactory.PASTE.create(iww)); addRetargetAction(new ClearEdgeBenpointLayoutRetargetAction(iww)); }
private void buildActions(IActionBars actionBars) { addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); RetargetAction showGridAction=new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid"); showGridAction.setImageDescriptor(Activator.getImageDescriptorFromPlugin("icons/grid.png")); addRetargetAction(showGridAction); }
@Override public void dispose() { String[] keys = actionMap.keySet().toArray(new String[actionMap.keySet().size()]); for (int i = 0; i < keys.length; i++) { RetargetAction action = (RetargetAction) actionMap.get(keys[i]); getPage().removePartListener(action); action.dispose(); } actionMap.clear(); actionMap = null; }
public void initRetargetActions(final EditorPart newEditor) { final Iterator iter = getActionRegistry().getActions(); while (iter.hasNext()) { final IAction action = (IAction) iter.next(); if (action instanceof RetargetAction) { ((RetargetAction) action).partActivated(newEditor); } } }
public void initRetargetActions(EditorPart newEditor) { Iterator iter = this.getActionRegistry().getActions(); while (iter.hasNext()) { IAction action = (IAction) iter.next(); if (action instanceof RetargetAction) { ((RetargetAction) action).partActivated(newEditor); } } }
/** * Builds the actions. * * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() */ protected void buildActions() { addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new ZoomInRetargetAction()); addRetargetAction(new ZoomOutRetargetAction()); RetargetAction raction = new RetargetAction(ExportJar.ID, "Export Chart Theme jar"); raction.setImageDescriptor(Activator.getDefault().getImageDescriptor("icons/charttheme_export-16.png")); addRetargetAction(raction); }
/** * Adds the retarded actions. * * @param action * The action to add */ protected void addRetargetAction(RetargetAction action) { addAction(action); retargetActions.add(action); getPage().addPartListener(action); addGlobalActionKey(action.getId()); }
/** * Disposes the contributor. Removes all {@link RetargetAction}s that were * {@link org.eclipse.ui.IPartListener}s on the * {@link org.eclipse.ui.IWorkbenchPage} and disposes them. Also disposes the * action registry. * <P> * Subclasses may extend this method to perform additional cleanup. * * @see org.eclipse.ui.part.EditorActionBarContributor#dispose() */ public void dispose() { for (int i = 0; i < retargetActions.size(); i++) { RetargetAction action = retargetActions.get(i); getPage().removePartListener(action); action.dispose(); } registry.dispose(); retargetActions = null; registry = null; }
/** * Adds the retarded actions. * * @param action * The action to add */ public void addRetargetAction(RetargetAction action) { addAction(action); retargetActions.add(action); getPage().addPartListener(action); addGlobalActionKey(action.getId()); }
/** * Disposes the contributor. Removes all {@link RetargetAction}s that were {@link org.eclipse.ui.IPartListener}s on * the {@link org.eclipse.ui.IWorkbenchPage} and disposes them. Also disposes the action registry. * <P> * Subclasses may extend this method to perform additional cleanup. * * @see org.eclipse.ui.part.EditorActionBarContributor#dispose() */ public void dispose() { getPage().removePartListener(partListener); for (RetargetAction action : retargetActions) { getPage().removePartListener(action); action.dispose(); } registry.dispose(); retargetActions = null; registry = null; }
/** * Disposes the contributor. Removes all {@link RetargetAction}s that were {@link org.eclipse.ui.IPartListener}s on * the {@link org.eclipse.ui.IWorkbenchPage} and disposes them. Also disposes the action registry. * <P> * Subclasses may extend this method to perform additional cleanup. * * @see org.eclipse.ui.part.EditorActionBarContributor#dispose() */ public void dispose() { for (int i = 0; i < retargetActions.size(); i++) { RetargetAction action = retargetActions.get(i); getPage().removePartListener(action); action.dispose(); } registry.dispose(); retargetActions = null; registry = null; }
private CommandContributionItem createActionFactoryCommandContributionItem(ActionFactory factory) { IWorkbenchWindow window = getWindow(); CommandContributionItemParameter parameter = new CommandContributionItemParameter(window, factory.getId(), factory.getCommandId(), SWT.PUSH); IWorkbenchAction action = factory.create(window); parameter.icon = action.getImageDescriptor(); parameter.disabledIcon = action.getDisabledImageDescriptor(); parameter.label = action.getText(); parameter.tooltip = action.getToolTipText(); window.getPartService().removePartListener((RetargetAction)action); return new CommandContributionItem(parameter); }
@Override public void init(IActionBars bars, IWorkbenchPage page) { fToggleBreadcrumbAction= new ToggleBreadcrumbAction(page); Iterator<RetargetAction> e= fPartListeners.iterator(); while (e.hasNext()) page.addPartListener(e.next()); super.init(bars, page); bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation); bars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction); bars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.TOGGLE_BREADCRUMB, fToggleBreadcrumbAction); }
@Override public void dispose() { Iterator<RetargetAction> e= fPartListeners.iterator(); while (e.hasNext()) getPage().removePartListener(e.next()); fPartListeners.clear(); setActiveEditor(null); fToggleBreadcrumbAction.dispose(); super.dispose(); }
private RetargetAction createSubmenuAction(IPartService partService, String actionID, String text, String actionDefinitionId) { RetargetAction action= new RetargetAction(actionID, text); action.setActionDefinitionId(actionDefinitionId); partService.addPartListener(action); IWorkbenchPart activePart = partService.getActivePart(); if (activePart != null) { action.partActivated(activePart); } return action; }
/** * Disposes the contributor. Removes all {@link RetargetAction}s that were * {@link org.eclipse.ui.IPartListener}s on the * {@link org.eclipse.ui.IWorkbenchPage} and disposes them. Also disposes * the action registry. * <P> * Subclasses may extend this method to perform additional cleanup. * * @see org.eclipse.ui.part.EditorActionBarContributor#dispose() */ public void dispose() { for (int i = 0; i < retargetActions.size(); i++) { RetargetAction action = (RetargetAction) retargetActions.get(i); getPage().removePartListener(action); action.dispose(); } registry.dispose(); retargetActions = null; registry = null; }
@Override public void setActiveEditor(IEditorPart part) { super.setActiveEditor(part); IActionBars bars = getActionBars(); ITextEditor editor = (part instanceof ITextEditor?(ITextEditor)part:null); for (Iterator<RetargetAction> iter = mRetargetActions.iterator(); iter.hasNext();) { String id = iter.next().getId(); bars.setGlobalActionHandler(id,(editor == null?null:editor.getAction(id))); } bars.updateActionBars(); }
@Override public void dispose() { for (Iterator<RetargetAction> iter = mRetargetActions.iterator(); iter.hasNext();) { RetargetAction action = iter.next(); getPage().removePartListener(action); action.dispose(); } mFixProblemsAction.dispose(); mPreviewGroupAction.dispose(); mLanguageContributionItem.dispose(); super.dispose(); }
@Override protected void buildActions() { addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new RetargetAction( GEFActionConstants.TOGGLE_GRID_VISIBILITY, "网格", IAction.AS_CHECK_BOX)); addRetargetAction(new RetargetAction( GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, "几何对齐", IAction.AS_CHECK_BOX)); }
private void updateDynamicItems( String actionId, IMenuManager menu ) { RetargetAction action = (RetargetAction) getAction( actionId ); if ( action != null && action.getActionHandler( ) instanceof MenuUpdateAction ) { ( (MenuUpdateAction) action.getActionHandler( ) ).updateMenu( (MenuManager) menu ); } }
private void updateInsertGroupMenu( String actionId, IMenuManager menu ) { RetargetAction action = (RetargetAction) getAction( actionId ); if ( action != null && action.getActionHandler( ) instanceof InsertGroupMenuAction ) { ( (InsertGroupMenuAction) action.getActionHandler( ) ).updateMenu( (MenuManager) menu ); } }
private void updateEditMenu( IContributionManager menubar ) { IContributionItem editMenu = menubar.find( IWorkbenchActionConstants.M_EDIT ); if ( editMenu instanceof IMenuManager ) { ( (IMenuManager) editMenu ).addMenuListener( new IMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { refreshUpdateAction( ActionFactory.CUT.getId( ) ); refreshUpdateAction( ActionFactory.COPY.getId( ) ); refreshUpdateAction( ActionFactory.PASTE.getId( ) ); refreshUpdateAction( ActionFactory.DELETE.getId( ) ); } private void refreshUpdateAction( String actionId ) { if ( getActionRegistry( ) != null ) { RetargetAction action = (RetargetAction) getAction( actionId ); if ( action != null && action.getActionHandler( ) != null && action.getActionHandler( ) instanceof UpdateAction ) { ( (UpdateAction) action.getActionHandler( ) ).update( ); } } } } ); } }