org.eclipse.gef.ui.actions.GEFActionConstants Java Examples
The following examples show how to use
org.eclipse.gef.ui.actions.GEFActionConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ERDiagramMultiPageEditorActionBarContributor.java From ermaster-b with Apache License 2.0 | 6 votes |
@Override public void setActivePage(IEditorPart activeEditor) { ERDiagramEditor editor = (ERDiagramEditor) activeEditor; ERDiagramActionBarContributor actionBarContributor = editor .getActionBarContributor(); IActionBars actionBars = this.getActionBars(); actionBars.clearGlobalActionHandlers(); actionBars.getToolBarManager().removeAll(); actionBarContributor.init(actionBars, editor.getEditorSite().getPage()); actionBarContributor.setActiveEditor(editor); ZoomComboContributionItem item = (ZoomComboContributionItem) getActionBars() .getToolBarManager().find( GEFActionConstants.ZOOM_TOOLBAR_WIDGET); if (item != null) { ZoomManager zoomManager = (ZoomManager) editor .getAdapter(ZoomManager.class); item.setZoomManager(zoomManager); } getActionBars().updateActionBars(); }
Example #2
Source File: ERFluteMultiPageEditorActionBarContributor.java From erflute with Apache License 2.0 | 6 votes |
@Override public void setActivePage(IEditorPart activeEditor) { final MainDiagramEditor editor = (MainDiagramEditor) activeEditor; final ERDiagramActionBarContributor actionBarContributor = editor.getActionBarContributor(); final IActionBars actionBars = getActionBars(); actionBars.clearGlobalActionHandlers(); actionBars.getToolBarManager().removeAll(); actionBarContributor.init(actionBars, editor.getEditorSite().getPage()); actionBarContributor.setActiveEditor(editor); final ZoomComboContributionItem item = (ZoomComboContributionItem) getActionBars().getToolBarManager().find(GEFActionConstants.ZOOM_TOOLBAR_WIDGET); if (item != null) { final ZoomManager zoomManager = (ZoomManager) editor.getAdapter(ZoomManager.class); item.setZoomManager(zoomManager); } getActionBars().updateActionBars(); }
Example #3
Source File: MenuProvider.java From olca-app with Mozilla Public License 2.0 | 6 votes |
/** Undo, Redo, and Delete */ private void addEditActions(final IMenuManager menu) { GEFActionConstants.addStandardActionGroups(menu); IAction undoAction = registry.getAction(ActionFactory.UNDO.getId()); undoAction.setImageDescriptor(Icon.UNDO.descriptor()); undoAction.setDisabledImageDescriptor(Icon.UNDO_DISABLED.descriptor()); IAction redoAction = registry.getAction(ActionFactory.REDO.getId()); redoAction.setImageDescriptor(Icon.REDO.descriptor()); redoAction.setDisabledImageDescriptor(Icon.REDO_DISABLED.descriptor()); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, undoAction); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, redoAction); IAction deleteAction = registry.getAction(ActionFactory.DELETE.getId()); deleteAction.setText(M.Delete); deleteAction.setImageDescriptor(Icon.DELETE.descriptor()); deleteAction.setDisabledImageDescriptor(Icon.DELETE_DISABLED.descriptor()); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, deleteAction); }
Example #4
Source File: ImageMenuAdapterFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
public Object getAdapter( final Object adaptableObject, Class adapterType ) { if ( ( adaptableObject instanceof ImageHandle ) && adapterType == IMenuListener.class ) { return new ISchematicMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { manager.appendToGroup( GEFActionConstants.GROUP_EDIT, new ReloadImageAction( adaptableObject ) ); } public void setActionRegistry( ActionRegistry actionRegistry ) { } }; } return null; }
Example #5
Source File: EditorRulerContextMenuProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
public void buildContextMenu( IMenuManager menu ) { GEFActionConstants.addStandardActionGroups( menu ); IChoiceSet choiceSet = null; choiceSet = ChoiceSetFactory.getElementChoiceSet( ReportDesignConstants.REPORT_DESIGN_ELEMENT, ReportDesignHandle.UNITS_PROP ); if (choiceSet == null ) { return ; } int len = choiceSet.getChoices().length; for (int i=0; i<len; i++) { IChoice ch = choiceSet.getChoices()[i]; ChangeRulerUnitAction action = new ChangeRulerUnitAction(ch.getName(), ch.getDisplayName()); menu.appendToGroup( GEFActionConstants.GROUP_ADD, action ); } }
Example #6
Source File: SankeyDiagram.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected void configureGraphicalViewer() { super.configureGraphicalViewer(); MenuManager menu = SankeyMenu.create(this); getGraphicalViewer().setContextMenu(menu); GraphicalViewer viewer = getGraphicalViewer(); viewer.setEditPartFactory(new SankeyEditPartFactory()); ScalableRootEditPart root = new ScalableRootEditPart(); viewer.setRootEditPart(root); // append zoom actions to action registry ZoomManager zoom = root.getZoomManager(); getActionRegistry().registerAction(new ZoomInAction(zoom)); getActionRegistry().registerAction(new ZoomOutAction(zoom)); zoom.setZoomLevelContributions(Arrays.asList( ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH)); // create key handler KeyHandler keyHandler = new KeyHandler(); 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_OUT)); viewer.setKeyHandler(keyHandler); viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON); }
Example #7
Source File: GraphConfig.java From olca-app with Mozilla Public License 2.0 | 5 votes |
void configureKeyHandler() { KeyHandler keyHandler = new KeyHandler(); IAction delete = actionRegistry.getAction(org.eclipse.ui.actions.ActionFactory.DELETE.getId()); IAction zoomIn = actionRegistry.getAction(GEFActionConstants.ZOOM_IN); IAction zoomOut = actionRegistry.getAction(GEFActionConstants.ZOOM_OUT); keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), delete); keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), zoomIn); keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), zoomOut); viewer.setKeyHandler(keyHandler); }
Example #8
Source File: CrosstabMenuAdapterFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public Object getAdapter( Object adaptableObject, Class adapterType ) { if ( adaptableObject instanceof ExtendedItemHandle && ( (ExtendedItemHandle) adaptableObject ).getExtensionName( ) .equals( "Crosstab" ) && adapterType == IMenuListener.class ) { final ExtendedItemHandle handle = (ExtendedItemHandle)adaptableObject; return new ISchematicMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { CrosstabReportItemHandle crosstab = null; try { crosstab = (CrosstabReportItemHandle)( (ExtendedItemHandle) handle ).getReportItem( ); } catch ( ExtendedElementException e ) { return; } //manager.appendToGroup( "additions", new AddComputedMeasureAction( ); //$NON-NLS-1$ manager.appendToGroup( GEFActionConstants.GROUP_VIEW, new AddComputedMeasureAction( crosstab ) ); manager.appendToGroup( GEFActionConstants.GROUP_VIEW, new AddRelativeTimePeriodAction( handle ) ); } public void setActionRegistry( ActionRegistry actionRegistry ) { } }; } return null; }
Example #9
Source File: LibraryContextMenuProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public void buildContextMenu( IMenuManager menuManager ) { super.buildContextMenu( menuManager ); List list = getElements(); if (list.size() == 1 && list.get(0) instanceof DesignElementHandle) { appendToGroup(GEFActionConstants.GROUP_REST, getAction(ExportAction.ID)); } }
Example #10
Source File: ReportViewerKeyHandler.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Constructor of KeyHandler * * @param viewer * @param actionRegistry */ public ReportViewerKeyHandler( GraphicalViewer viewer, ActionRegistry actionRegistry ) { super( viewer ); this.actionRegistry = actionRegistry; put( KeyStroke.getPressed( SWT.F2, 0 ), actionRegistry.getAction( GEFActionConstants.DIRECT_EDIT ) ); tableDelgate = new TableCellKeyDelegate( viewer, actionRegistry ); }
Example #11
Source File: ERDiagramAlignmentAction.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * Initializes the actions UI presentation. */ protected void initUI() { switch (alignment) { case PositionConstants.LEFT: setId(GEFActionConstants.ALIGN_LEFT); setText(ALIGNMENT_ACTION_LEFT.getText()); setToolTipText(ALIGNMENT_ACTION_LEFT.getToolTipText()); setImageDescriptor(Activator .getImageDescriptor(ImageKey.ALIGN_LEFT)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_LEFT // .getDisabledImageDescriptor()); break; case PositionConstants.RIGHT: setId(GEFActionConstants.ALIGN_RIGHT); setText(ALIGNMENT_ACTION_RIGHT.getText()); setToolTipText(ALIGNMENT_ACTION_RIGHT.getToolTipText()); setImageDescriptor(Activator .getImageDescriptor(ImageKey.ALIGN_RIGHT)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_RIGHT // .getDisabledImageDescriptor()); break; case PositionConstants.TOP: setId(GEFActionConstants.ALIGN_TOP); setText(ALIGNMENT_ACTION_TOP.getText()); setToolTipText(ALIGNMENT_ACTION_TOP.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_TOP)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_TOP // .getDisabledImageDescriptor()); break; case PositionConstants.BOTTOM: setId(GEFActionConstants.ALIGN_BOTTOM); setText(ALIGNMENT_ACTION_BOTTOM.getText()); setToolTipText(ALIGNMENT_ACTION_BOTTOM.getToolTipText()); setImageDescriptor(Activator .getImageDescriptor(ImageKey.ALIGN_BOTTOM)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_BOTTOM // .getDisabledImageDescriptor()); break; case PositionConstants.CENTER: setId(GEFActionConstants.ALIGN_CENTER); setText(ALIGNMENT_ACTION_CENTER.getText()); setToolTipText(ALIGNMENT_ACTION_CENTER.getToolTipText()); setImageDescriptor(Activator .getImageDescriptor(ImageKey.ALIGN_CENTER)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_CENTER // .getDisabledImageDescriptor()); break; case PositionConstants.MIDDLE: setId(GEFActionConstants.ALIGN_MIDDLE); setText(ALIGNMENT_ACTION_MIDDLE.getText()); setToolTipText(ALIGNMENT_ACTION_MIDDLE.getToolTipText()); setImageDescriptor(Activator .getImageDescriptor(ImageKey.ALIGN_MIDDLE)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_MIDDLE // .getDisabledImageDescriptor()); break; } }
Example #12
Source File: ERDiagramActionBarContributor.java From ermasterr with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void buildActions() { addRetargetAction(new RetargetAction(ActionFactory.SELECT_ALL.getId(), "selectAll")); addRetargetAction(new RetargetAction(ActionFactory.PRINT.getId(), "print")); addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new RetargetAction(ActionFactory.COPY.getId(), "copy")); addRetargetAction(new RetargetAction(ActionFactory.PASTE.getId(), "paste")); addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); final ZoomInRetargetAction zoomInAction = new ZoomInRetargetAction(); zoomInAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ZOOM_IN)); final ZoomOutRetargetAction zoomOutAction = new ZoomOutRetargetAction(); zoomOutAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ZOOM_OUT)); addRetargetAction(zoomInAction); addRetargetAction(zoomOutAction); addRetargetAction(new ZoomAdjustRetargetAction()); final RetargetAction gridAction = new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, ResourceString.getResourceString("action.title.grid"), IAction.AS_CHECK_BOX); gridAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.GRID)); addRetargetAction(gridAction); final RetargetAction gridSnapAction = new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, ResourceString.getResourceString("action.title.grid.snap"), IAction.AS_CHECK_BOX); gridSnapAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.GRID_SNAP)); addRetargetAction(gridSnapAction); final RetargetAction tooltipAction = new RetargetAction(TooltipAction.ID, ResourceString.getResourceString("action.title.tooltip"), IAction.AS_CHECK_BOX); tooltipAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.TOOLTIP)); addRetargetAction(tooltipAction); final RetargetAction lockEditAction = new RetargetAction(LockEditAction.ID, ResourceString.getResourceString("action.title.lock.edit"), IAction.AS_CHECK_BOX); lockEditAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.LOCK_EDIT)); addRetargetAction(lockEditAction); addRetargetAction(new ExportToDBRetargetAction()); final AlignmentRetargetAction alignLeftAction = new AlignmentRetargetAction(PositionConstants.LEFT); alignLeftAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_LEFT)); alignLeftAction.setDisabledImageDescriptor(null); addRetargetAction(alignLeftAction); final AlignmentRetargetAction alignCenterAction = new AlignmentRetargetAction(PositionConstants.CENTER); alignCenterAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_CENTER)); alignCenterAction.setDisabledImageDescriptor(null); addRetargetAction(alignCenterAction); final AlignmentRetargetAction alignRightAction = new AlignmentRetargetAction(PositionConstants.RIGHT); alignRightAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_RIGHT)); alignRightAction.setDisabledImageDescriptor(null); addRetargetAction(alignRightAction); final AlignmentRetargetAction alignTopAction = new AlignmentRetargetAction(PositionConstants.TOP); alignTopAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_TOP)); alignTopAction.setDisabledImageDescriptor(null); addRetargetAction(alignTopAction); final AlignmentRetargetAction alignMiddleAction = new AlignmentRetargetAction(PositionConstants.MIDDLE); alignMiddleAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_MIDDLE)); alignMiddleAction.setDisabledImageDescriptor(null); addRetargetAction(alignMiddleAction); final AlignmentRetargetAction alignBottomAction = new AlignmentRetargetAction(PositionConstants.BOTTOM); alignBottomAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_BOTTOM)); alignBottomAction.setDisabledImageDescriptor(null); addRetargetAction(alignBottomAction); final MatchWidthRetargetAction matchWidthAction = new MatchWidthRetargetAction(); matchWidthAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.MATCH_WIDTH)); matchWidthAction.setDisabledImageDescriptor(null); addRetargetAction(matchWidthAction); final MatchHeightRetargetAction matchHeightAction = new MatchHeightRetargetAction(); matchHeightAction.setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.MATCH_HEIGHT)); matchHeightAction.setDisabledImageDescriptor(null); addRetargetAction(matchHeightAction); addRetargetAction(new HorizontalLineRetargetAction()); addRetargetAction(new VerticalLineRetargetAction()); addRetargetAction(new ChangeBackgroundColorRetargetAction()); }
Example #13
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * @generated BonitaSoft */ protected void configurePaletteViewer() { PaletteViewer viewer = getEditDomain().getPaletteViewer(); if (viewer == null) return; ContextMenuProvider paletteContextProvider = new PaletteContextMenuProvider(viewer) { /* * (non-Javadoc) * * @see org.eclipse.gef.ui.palette.PaletteContextMenuProvider# * buildContextMenu(org.eclipse.jface.action.IMenuManager) */ @Override public void buildContextMenu(IMenuManager menu) { super.buildContextMenu(menu); menu.appendToGroup(GEFActionConstants.GROUP_REST, new Action() { public String getText() { return org.bonitasoft.studio.common.Messages.switchPaletteAction; } public void run() { IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command switchCommand = commandService .getCommand("org.bonitasoft.studio.application.switchPalette"); ExecutionEvent executionEvent = new ExecutionEvent(switchCommand, Collections.EMPTY_MAP, null, handlerService.getClass()); try { switchCommand.executeWithChecks(executionEvent); } catch (Exception e) { BonitaStudioLog.error(e); } } }); } }; viewer.setContextMenu(paletteContextProvider); }
Example #14
Source File: DesignerActionBarContributor.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void buildActions( ) { if ( isBuilt ) return; isBuilt = true; addRetargetAction( new UndoRetargetAction( ) ); addRetargetAction( new RedoRetargetAction( ) ); addRetargetAction( new DeleteRetargetAction( ) ); addRetargetAction( new ZoomInRetargetAction( ) ); addRetargetAction( new ZoomOutRetargetAction( ) ); addRetargetAction( new RetargetAction( ActionFactory.CUT.getId( ), null ) ); addRetargetAction( new RetargetAction( ActionFactory.COPY.getId( ), null ) ); addRetargetAction( new RetargetAction( ActionFactory.PASTE.getId( ), null ) ); addRetargetAction( new RetargetAction( ImportCSSStyleAction.ID, ImportCSSStyleAction.ACTION_TEXT ) ); addRetargetAction( new RetargetAction( AddStyleAction.ID, Messages.getString( "DesignerActionBarContributor.style.new" ) ) ); //$NON-NLS-1$ addRetargetAction( new RetargetAction( ApplyStyleMenuAction.ID, null ) ); addRetargetAction( new RetargetAction( EditStyleMenuAction.ID, null ) ); addRetargetAction( new RetargetAction( DeleteStyleMenuAction.ID, null ) ); addRetargetAction( new RetargetAction( EditGroupMenuAction.ID, null ) ); addRetargetAction( new RetargetAction( InsertGroupMenuAction.ID, null ) ); registerActions( new RegisterAction[]{ new RegisterAction( GEFActionConstants.TOGGLE_RULER_VISIBILITY, Messages.getString( "DesignerActionBarContributor.menu.element-showRuler" ), //$NON-NLS-1$ IAction.AS_CHECK_BOX ) } ); registerActions( new RegisterAction[]{ new RegisterAction( ToggleMarginVisibilityAction.ID, ToggleMarginVisibilityAction.LABEL, IAction.AS_CHECK_BOX ) } ); registerActions( getInsertElementActions( ) ); registerActions( elementActions ); addRetargetAction( new RetargetAction( ImportLibraryAction.ID, ImportLibraryAction.ACTION_TEXT ) ); addRetargetAction( new RetargetAction( InsertAggregationAction.ID, InsertAggregationAction.TEXT ) ); addRetargetAction( new RetargetAction( InsertRelativeTimePeriodAction.ID, InsertRelativeTimePeriodAction.TEXT ) ); }
Example #15
Source File: ERDiagramAlignmentAction.java From erflute with Apache License 2.0 | 4 votes |
/** * Initializes the actions UI presentation. */ protected void initUI() { switch (alignment) { case PositionConstants.LEFT: setId(GEFActionConstants.ALIGN_LEFT); setText(ALIGNMENT_ACTION_LEFT.getText()); setToolTipText(ALIGNMENT_ACTION_LEFT.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_LEFT)); break; case PositionConstants.RIGHT: setId(GEFActionConstants.ALIGN_RIGHT); setText(ALIGNMENT_ACTION_RIGHT.getText()); setToolTipText(ALIGNMENT_ACTION_RIGHT.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_RIGHT)); break; case PositionConstants.TOP: setId(GEFActionConstants.ALIGN_TOP); setText(ALIGNMENT_ACTION_TOP.getText()); setToolTipText(ALIGNMENT_ACTION_TOP.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_TOP)); break; case PositionConstants.BOTTOM: setId(GEFActionConstants.ALIGN_BOTTOM); setText(ALIGNMENT_ACTION_BOTTOM.getText()); setToolTipText(ALIGNMENT_ACTION_BOTTOM.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_BOTTOM)); break; case PositionConstants.CENTER: setId(GEFActionConstants.ALIGN_CENTER); setText(ALIGNMENT_ACTION_CENTER.getText()); setToolTipText(ALIGNMENT_ACTION_CENTER.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_CENTER)); break; case PositionConstants.MIDDLE: setId(GEFActionConstants.ALIGN_MIDDLE); setText(ALIGNMENT_ACTION_MIDDLE.getText()); setToolTipText(ALIGNMENT_ACTION_MIDDLE.getToolTipText()); setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_MIDDLE)); break; } }
Example #16
Source File: ERDiagramActionBarContributor.java From erflute with Apache License 2.0 | 4 votes |
@Override public void contributeToToolBar(IToolBarManager toolBarManager) { toolBarManager.add(getAction(ActionFactory.DELETE.getId())); 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(getActionRegistry().getAction(ZoomAdjustAction.ID)); toolBarManager.add(zoomComboContributionItem); toolBarManager.add(new Separator()); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); toolBarManager.add(getAction(ToggleMainColumnAction.ID)); toolBarManager.add(getAction(LockEditAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getAction(ExportToDDLAction.ID)); toolBarManager.add(getAction(ExportToDBAction.ID)); 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)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(HorizontalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(VerticalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(ChangeBackgroundColorAction.ID)); toolBarManager.add(new Separator()); final FontNameContributionItem fontNameContributionItem = new FontNameContributionItem(getPage()); final FontSizeContributionItem fontSizeContributionItem = new FontSizeContributionItem(getPage()); toolBarManager.add(fontNameContributionItem); toolBarManager.add(fontSizeContributionItem); getPage().addSelectionListener(new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection instanceof IStructuredSelection) { final List<?> selectedEditParts = ((IStructuredSelection) selection).toList(); if (!selectedEditParts.isEmpty()) { if (selectedEditParts.get(0) instanceof EditPart) { final Object model = ((EditPart) selectedEditParts.get(0)).getModel(); if (model instanceof ViewableModel) { final ViewableModel viewableModel = (ViewableModel) model; final String fontName = viewableModel.getFontName(); if (fontName != null) { fontNameContributionItem.setText(fontName); } else { final FontData fonData = Display.getCurrent().getSystemFont().getFontData()[0]; fontNameContributionItem.setText(fonData.getName()); viewableModel.setFontName(fonData.getName()); } final int fontSize = viewableModel.getFontSize(); if (fontSize > 0) { fontSizeContributionItem.setText(String.valueOf(fontSize)); } else { fontSizeContributionItem.setText(String.valueOf(ViewableModel.DEFAULT_FONT_SIZE)); viewableModel.setFontSize(fontSize); } } } } } } }); }
Example #17
Source File: ERDiagramActionBarContributor.java From erflute with Apache License 2.0 | 4 votes |
@Override protected void buildActions() { addRetargetAction(new RetargetAction(ActionFactory.SELECT_ALL.getId(), "selectAll")); addRetargetAction(new RetargetAction(ActionFactory.PRINT.getId(), "print")); addRetargetAction(new DeleteRetargetAction()); addRetargetAction(new RetargetAction(ActionFactory.COPY.getId(), "copy")); addRetargetAction(new RetargetAction(ActionFactory.PASTE.getId(), "paste")); addRetargetAction(new UndoRetargetAction()); addRetargetAction(new RedoRetargetAction()); final ZoomInRetargetAction zoomInAction = new ZoomInRetargetAction(); zoomInAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ZOOM_IN)); final ZoomOutRetargetAction zoomOutAction = new ZoomOutRetargetAction(); zoomOutAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ZOOM_OUT)); addRetargetAction(zoomInAction); addRetargetAction(zoomOutAction); addRetargetAction(new ZoomAdjustRetargetAction()); final RetargetAction gridAction = new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, DisplayMessages.getMessage("action.title.grid"), IAction.AS_CHECK_BOX); gridAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.GRID)); addRetargetAction(gridAction); final RetargetAction tooltipAction = new RetargetAction(ToggleMainColumnAction.ID, DisplayMessages.getMessage("action.title.tooltip"), IAction.AS_CHECK_BOX); tooltipAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.TOOLTIP)); addRetargetAction(tooltipAction); final RetargetAction toggleMainColumnAction = new RetargetAction(ToggleMainColumnAction.ID, DisplayMessages.getMessage("action.title.mainColumn"), IAction.AS_CHECK_BOX); toggleMainColumnAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.MAIN_COLUMN)); addRetargetAction(toggleMainColumnAction); final RetargetAction exportDdlAction = new RetargetAction(ExportToDDLAction.ID, DisplayMessages.getMessage("dialog.title.export.ddl"), IAction.AS_CHECK_BOX); exportDdlAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.EXPORT_DDL)); addRetargetAction(exportDdlAction); final RetargetAction lockEditAction = new RetargetAction(LockEditAction.ID, DisplayMessages.getMessage("action.title.lock.edit"), IAction.AS_CHECK_BOX); lockEditAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.LOCK_EDIT)); addRetargetAction(lockEditAction); addRetargetAction(new ExportToDBRetargetAction()); final AlignmentRetargetAction alignLeftAction = new AlignmentRetargetAction(PositionConstants.LEFT); alignLeftAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_LEFT)); alignLeftAction.setDisabledImageDescriptor(null); addRetargetAction(alignLeftAction); final AlignmentRetargetAction alignCenterAction = new AlignmentRetargetAction(PositionConstants.CENTER); alignCenterAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_CENTER)); alignCenterAction.setDisabledImageDescriptor(null); addRetargetAction(alignCenterAction); final AlignmentRetargetAction alignRightAction = new AlignmentRetargetAction(PositionConstants.RIGHT); alignRightAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_RIGHT)); alignRightAction.setDisabledImageDescriptor(null); addRetargetAction(alignRightAction); final AlignmentRetargetAction alignTopAction = new AlignmentRetargetAction(PositionConstants.TOP); alignTopAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_TOP)); alignTopAction.setDisabledImageDescriptor(null); addRetargetAction(alignTopAction); final AlignmentRetargetAction alignMiddleAction = new AlignmentRetargetAction(PositionConstants.MIDDLE); alignMiddleAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_MIDDLE)); alignMiddleAction.setDisabledImageDescriptor(null); addRetargetAction(alignMiddleAction); final AlignmentRetargetAction alignBottomAction = new AlignmentRetargetAction(PositionConstants.BOTTOM); alignBottomAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.ALIGN_BOTTOM)); alignBottomAction.setDisabledImageDescriptor(null); addRetargetAction(alignBottomAction); final MatchWidthRetargetAction matchWidthAction = new MatchWidthRetargetAction(); matchWidthAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.MATCH_WIDTH)); matchWidthAction.setDisabledImageDescriptor(null); addRetargetAction(matchWidthAction); final MatchHeightRetargetAction matchHeightAction = new MatchHeightRetargetAction(); matchHeightAction.setImageDescriptor(Activator.getImageDescriptor(ImageKey.MATCH_HEIGHT)); matchHeightAction.setDisabledImageDescriptor(null); addRetargetAction(matchHeightAction); addRetargetAction(new HorizontalLineRetargetAction()); addRetargetAction(new VerticalLineRetargetAction()); addRetargetAction(new ChangeBackgroundColorRetargetAction()); }
Example #18
Source File: ERDiagramAlignmentAction.java From ermasterr with Apache License 2.0 | 4 votes |
/** * Initializes the actions UI presentation. */ protected void initUI() { switch (alignment) { case PositionConstants.LEFT: setId(GEFActionConstants.ALIGN_LEFT); setText(ALIGNMENT_ACTION_LEFT.getText()); setToolTipText(ALIGNMENT_ACTION_LEFT.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_LEFT)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_LEFT // .getDisabledImageDescriptor()); break; case PositionConstants.RIGHT: setId(GEFActionConstants.ALIGN_RIGHT); setText(ALIGNMENT_ACTION_RIGHT.getText()); setToolTipText(ALIGNMENT_ACTION_RIGHT.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_RIGHT)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_RIGHT // .getDisabledImageDescriptor()); break; case PositionConstants.TOP: setId(GEFActionConstants.ALIGN_TOP); setText(ALIGNMENT_ACTION_TOP.getText()); setToolTipText(ALIGNMENT_ACTION_TOP.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_TOP)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_TOP // .getDisabledImageDescriptor()); break; case PositionConstants.BOTTOM: setId(GEFActionConstants.ALIGN_BOTTOM); setText(ALIGNMENT_ACTION_BOTTOM.getText()); setToolTipText(ALIGNMENT_ACTION_BOTTOM.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_BOTTOM)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_BOTTOM // .getDisabledImageDescriptor()); break; case PositionConstants.CENTER: setId(GEFActionConstants.ALIGN_CENTER); setText(ALIGNMENT_ACTION_CENTER.getText()); setToolTipText(ALIGNMENT_ACTION_CENTER.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_CENTER)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_CENTER // .getDisabledImageDescriptor()); break; case PositionConstants.MIDDLE: setId(GEFActionConstants.ALIGN_MIDDLE); setText(ALIGNMENT_ACTION_MIDDLE.getText()); setToolTipText(ALIGNMENT_ACTION_MIDDLE.getToolTipText()); setImageDescriptor(ERDiagramActivator.getImageDescriptor(ImageKey.ALIGN_MIDDLE)); // setDisabledImageDescriptor(ALIGNMENT_ACTION_MIDDLE // .getDisabledImageDescriptor()); break; } }
Example #19
Source File: ERDiagramActionBarContributor.java From ermasterr with Apache License 2.0 | 4 votes |
public void contributeToToolBar(final ERDiagram diagram, final IToolBarManager toolBarManager, final ZoomComboContributionItem zoomComboContributionItem) { toolBarManager.add(getAction(ActionFactory.DELETE.getId())); 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(getActionRegistry().getAction(ZoomAdjustAction.ID)); toolBarManager.add(zoomComboContributionItem); toolBarManager.add(new Separator()); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY)); toolBarManager.add(getAction(TooltipAction.ID)); toolBarManager.add(getAction(LockEditAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getAction(ExportToDBAction.ID)); 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)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(HorizontalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(VerticalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(ChangeBackgroundColorAction.ID)); toolBarManager.add(new Separator()); final FontNameContributionItem fontNameContributionItem = new FontNameContributionItem(getPage()); final FontSizeContributionItem fontSizeContributionItem = new FontSizeContributionItem(getPage()); toolBarManager.add(fontNameContributionItem); toolBarManager.add(fontSizeContributionItem); getPage().addSelectionListener(new ISelectionListener() { @Override public void selectionChanged(final IWorkbenchPart part, final ISelection selection) { if (selection instanceof IStructuredSelection) { final List selectedEditParts = ((IStructuredSelection) selection).toList(); if (!selectedEditParts.isEmpty()) { if (selectedEditParts.get(0) instanceof EditPart) { final Object model = ((EditPart) selectedEditParts.get(0)).getModel(); if (model instanceof ViewableModel) { final ViewableModel viewableModel = (ViewableModel) model; final String fontName = viewableModel.getFontName(); final int fontSize = viewableModel.getFontSize(); if (fontName != null) { fontNameContributionItem.setText(fontName); } else { final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0]; fontNameContributionItem.setText(fontData.getName()); viewableModel.setFontName(fontData.getName()); } if (fontSize > 0) { fontSizeContributionItem.setText(String.valueOf(fontSize)); } else { fontSizeContributionItem.setText(String.valueOf(ViewableModel.DEFAULT_FONT_SIZE)); viewableModel.setFontSize(fontSize); } } } } } } }); }