@Override protected void doExecute() { if (designEditor != null) { GraphicalViewer graphicalViewer = designEditor.getGraphicalViewer(); if (graphicalViewer != null && graphicalViewer.getEditPartRegistry() != null) { ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID); IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER); IColorConstant cc = StyleUtil.getColorConstant( PreferenceManager.getInstance() .loadPreferenceAsString(PreferencesConstants.EDITOR_GRID_COLOR)); Diagram diagram = designEditor.getDiagramTypeProvider().getDiagram(); if (cc != null && diagram != null) { GraphicsAlgorithm ga = diagram.getGraphicsAlgorithm(); if (ga != null) { ga.setForeground(GraphitiUi.getGaService().manageColor(diagram, cc)); gridFigure.repaint(); gridFigure.revalidate(); designEditor.getDiagramBehavior().refreshContent(); } } } } }
protected static synchronized TransactionalEditingDomain createEditingDomain( CamelDesignEditor designEditor) { TransactionalEditingDomain editingDomain = designEditor.getEditingDomain(); IDiagramTypeProvider diagramTypeProvider = designEditor.getDiagramTypeProvider(); if (diagramTypeProvider == null) { return null; } Diagram diagram = diagramTypeProvider.getDiagram(); if (diagram == null) { return null; } if (editingDomain == null) { IDiagramBehavior diagramBehavior = diagramTypeProvider.getDiagramBehavior(); if (diagramBehavior != null) { editingDomain = diagramBehavior.getEditingDomain(); } } if (editingDomain == null) { ResourceSet resourceSet = null; Resource eResource = diagram.eResource(); if (eResource != null) { resourceSet = eResource.getResourceSet(); } if (resourceSet == null) { resourceSet = new ResourceSetImpl(); } editingDomain = TransactionUtil.getEditingDomain(resourceSet); if (editingDomain == null) { editingDomain = GraphitiUi.getEmfService().createResourceSetAndEditingDomain(); } } // TODO: do we need to set transactionaldomain? // if (designEditor.getEditingDomain() == null) { // designEditor.setEditingDomain(editingDomain); // } return editingDomain; }
/** * Returns the minimal height needed to display the value of given Text with its associated Font. * * @param text * @return */ public static int getTextMinHeight(Text text) { final IUiLayoutService uiLayoutService = GraphitiUi.getUiLayoutService(); final Font currentFont = Graphiti.getGaService().getFont(text, true); return uiLayoutService.calculateTextSize(text.getValue(), currentFont).getHeight(); }
private int getPinNameWidth(String pinName) { return GraphitiUi.getUiLayoutService().calculateTextSize(pinName, getPinNameFont()).getWidth() + PIN_LABEL_MARGIN; }
private int getActionNameWidth() { return GraphitiUi.getUiLayoutService() .calculateTextSize(action.getName(), getActionNameFont()) .getWidth() + getDoubleActionLabelMargin(); }