/** * initialize the background for a graphical element * * @param view the element to initialize * @param store the preference store * @param elementName the name to the element */ public static void initBackgroundFromPrefs( View view, final IPreferenceStore store, String elementName) { if (!usePreferenceInitializer(view)) { return; } String fillColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FILL); String gradientColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_GRADIENT); String gradientPolicyConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.GRADIENT_POLICY); String shadowConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.SHADOW); String elementIcon = getpreferenceKey(view, elementName, PreferenceConstantHelper.ELEMENTICON); String qualifiedName = getpreferenceKey(view, elementName, PreferenceConstantHelper.QUALIFIEDNAME); org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant); ViewUtil.setStructuralFeatureValue( view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE); fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue()); if (store.getBoolean(gradientPolicyConstant)) { GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant)); fillStyle.setGradient(gradientPreferenceConverter.getGradientData()); fillStyle.setTransparency(gradientPreferenceConverter.getTransparency()); } EditingDomain domain = EMFHelper.resolveEditingDomain(view); if (domain instanceof TransactionalEditingDomain) { TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) domain; // shadow RecordingCommand shadowcommand = AnnotationStyleProvider.getSetShadowCommand( editingDomain, view, store.getBoolean(shadowConstant)); if (shadowcommand.canExecute()) { shadowcommand.execute(); } // icon label RecordingCommand namelabelIconCommand = AnnotationStyleProvider.getSetElementIconCommand( editingDomain, view, store.getBoolean(elementIcon)); if (namelabelIconCommand.canExecute()) { namelabelIconCommand.execute(); } // qualified name if (!store.getBoolean(qualifiedName)) { RecordingCommand qualifiedNameCommand = AnnotationStyleProvider.getSetQualifiedNameDepthCommand(editingDomain, view, 1000); if (qualifiedNameCommand.canExecute()) { qualifiedNameCommand.execute(); } } } }
/** @generated */ public Node createViewTable_1002( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createNode(); node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle()); node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); FillStyle fillStyle = NotationFactory.eINSTANCE.createFillStyle(); Color color = ViewTableEditPart.getDeclaredBackgroundColor(); fillStyle.setFillColor(FigureUtilities.colorToInteger(color)); node.getStyles().add(fillStyle); LineStyle lineStyle = NotationFactory.eINSTANCE.createLineStyle(); lineStyle.setLineColor(FigureUtilities.RGBToInteger(new org.eclipse.swt.graphics.RGB(0, 0, 0))); node.getStyles().add(lineStyle); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(SqlmodelVisualIDRegistry.getType(ViewTableEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE); if (nodeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); nodeFontStyle.setFontName(fontData.getName()); nodeFontStyle.setFontHeight(fontData.getHeight()); nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Node label4002 = createLabel(node, SqlmodelVisualIDRegistry.getType(ViewTableNameEditPart.VISUAL_ID)); createCompartment( node, SqlmodelVisualIDRegistry.getType(ViewTableViewedColumnsEditPart.VISUAL_ID), false, false, true, true); createCompartment( node, SqlmodelVisualIDRegistry.getType(ViewTableViewedTablesEditPart.VISUAL_ID), false, false, true, true); return node; }
/** * Set the gradient data to the correct figure * * <p>{@inheritDoc} */ @Override protected void setGradient(GradientData gradient) { IPapyrusNodeFigure fig = getPrimaryShape(); FillStyle style = (FillStyle) getPrimaryView().getStyle(NotationPackage.Literals.FILL_STYLE); if (gradient != null) { fig.setIsUsingGradient(true); ; fig.setGradientData( style.getFillColor(), gradient.getGradientColor1(), gradient.getGradientStyle()); } else { fig.setIsUsingGradient(false); } }