/** * Installs the given color in the preference store and optionally the color registry. * * @param definition the color definition * @param theme the theme defining the color * @param store the preference store from which to set and obtain color data * @param setInRegistry whether the color should be put into the registry */ private static void installColor( ColorDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) { // TODO: store shouldn't be null, should assert instead of checking null all over ColorRegistry registry = theme.getColorRegistry(); String id = definition.getId(); String key = createPreferenceKey(theme, id); RGB prefColor = store != null ? PreferenceConverter.getColor(store, key) : null; RGB defaultColor = (definition.getValue() != null) ? definition.getValue() : registry.getRGB(definition.getDefaultsTo()); if (prefColor == null || prefColor == PreferenceConverter.COLOR_DEFAULT_DEFAULT) { prefColor = defaultColor; } // if the preference value isn't the default then retain that pref value RGB colorToUse = !store.isDefault(key) ? prefColor : defaultColor; if (setInRegistry) { registry.put(id, colorToUse); } if (store != null) { PreferenceConverter.setDefault(store, key, defaultColor); } }
/** @generated */ public Node createPersistentTable_2003( 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.createLineStyle()); node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle()); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(SqlmodelVisualIDRegistry.getType(PersistentTable2EditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); return node; }
/** @generated */ public Edge createViewTableViewedTables_3002( View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Edge edge = NotationFactory.eINSTANCE.createEdge(); edge.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle()); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList points = new ArrayList(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType(SqlmodelVisualIDRegistry.getType(ViewTableViewedTables2EditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } return edge; }
/** @generated */ public Edge createAssociation_4001( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AssociationEditPart.VISUAL_ID)); edge.setElement(domainElement); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } Node label6001 = createLabel( edge, edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AssociationNameEditPart.VISUAL_ID)); label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location6001 = (Location) label6001.getLayoutConstraint(); location6001.setX(0); location6001.setY(40); return edge; }
private RGB getColorFromStore(IPreferenceStore store, String key) { RGB rgb = null; if (store.contains(key)) { if (store.isDefault(key)) rgb = PreferenceConverter.getDefaultColor(store, key); else rgb = PreferenceConverter.getColor(store, key); } return rgb; }
/** @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; }
/** @generated */ public Node createAttribute_3001( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart .VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); 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()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5001 = createLabel( node, edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AttributeNameEditPart.VISUAL_ID)); return node; }
/** * Creates a color from the information stored in the given preference store. Returns <code>null * </code> if there is no such information available. * * @param store the store to read from * @param key the key used for the lookup in the preference store * @param display the display used create the color * @return the created color according to the specification in the preference store * @since 3.0 */ private Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb = null; if (store.contains(key)) { if (store.isDefault(key)) rgb = PreferenceConverter.getDefaultColor(store, key); else rgb = PreferenceConverter.getColor(store, key); if (rgb != null) return new Color(display, rgb); } return null; }
private static Color createColor(IPreferenceStore store, String key, Display display) { // TODO(messick) Remove display or use it instead of color manager RGB rgb = null; if (store.contains(key)) { if (store.isDefault(key)) { rgb = PreferenceConverter.getDefaultColor(store, key); } else { rgb = PreferenceConverter.getColor(store, key); } if (rgb != null) { return getColorManager().getColor(rgb); } } return null; }
private TextAttribute tokenAttribute( IPreferenceStore store, String colorPrefs, String boldPrefs, String italicPrefs, String underlinePrefs) { int style = SWT.NORMAL; boolean isBold = store.getBoolean(boldPrefs); if (isBold) { style = style | SWT.BOLD; } boolean isItalic = store.getBoolean(italicPrefs); if (isItalic) { style = style | SWT.ITALIC; } boolean isUnderline = store.getBoolean(underlinePrefs); if (isUnderline) { style = style | TextAttribute.UNDERLINE; } RGB color = PreferenceConverter.getColor(store, colorPrefs); TextAttribute attr = new TextAttribute(colorManager.getColor(color), null, style); return attr; }
protected void initializeFields() { Iterator<Object> e = fColorButtons.keySet().iterator(); while (e.hasNext()) { ColorSelector c = (ColorSelector) e.next(); String key = fColorButtons.get(c); RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); c.setColorValue(rgb); } e = fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b = (Button) e.next(); String key = fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); } e = fTextFields.keySet().iterator(); while (e.hasNext()) { Text t = (Text) e.next(); String key = fTextFields.get(t); t.setText(fOverlayStore.getString(key)); } e = fComboBoxes.keySet().iterator(); while (e.hasNext()) { Combo c = (Combo) e.next(); String key = fComboBoxes.get(c); String state = fOverlayStore.getString(key); // Interpret the state string as a Combo state description ProposalFilterPreferencesUtil.restoreComboFromString(c, state); } }
/** * Creates the highlighting manager class. * * @param textResource the text resource to be provided to other classes * @param sourceviewer the source viewer converts offset between master and slave documents * @param colorManager the color manager provides highlighting colors * @param editor */ public BentoHighlighting( bento.language.bentocomp.resource.bento.IBentoTextResource textResource, org.eclipse.jface.text.source.projection.ProjectionViewer sourceviewer, bento.language.bentocomp.resource.bento.ui.BentoColorManager colorManager, bento.language.bentocomp.resource.bento.ui.BentoEditor editor) { this.display = org.eclipse.swt.widgets.Display.getCurrent(); sourceviewer.getSelectionProvider(); preferenceStore = bento.language.bentocomp.resource.bento.ui.BentoUIPlugin.getDefault().getPreferenceStore(); this.editor = editor; textWidget = sourceviewer.getTextWidget(); projectionViewer = sourceviewer; scanner = new bento.language.bentocomp.resource.bento.ui.BentoTokenScanner( textResource, colorManager); occurrence = new bento.language.bentocomp.resource.bento.ui.BentoOccurrence( textResource, sourceviewer, scanner); bracketSet = new bento.language.bentocomp.resource.bento.ui.BentoBracketSet(editor, sourceviewer); this.colorManager = colorManager; isHighlightBrackets = preferenceStore.getBoolean( bento.language.bentocomp.resource.bento.ui.BentoPreferenceConstants .EDITOR_MATCHING_BRACKETS_CHECKBOX); bracketColor = colorManager.getColor( org.eclipse.jface.preference.PreferenceConverter.getColor( preferenceStore, bento.language.bentocomp.resource.bento.ui.BentoPreferenceConstants .EDITOR_MATCHING_BRACKETS_COLOR)); black = colorManager.getColor(new org.eclipse.swt.graphics.RGB(0, 0, 0)); addListeners(editor); }
/** Initialize semantic highlightings. */ private void initializeHighlightings() { fSemanticHighlightings = SemanticHighlightings.getSemanticHighlightings(); fHighlightings = new Highlighting[fSemanticHighlightings.length]; for (int i = 0, n = fSemanticHighlightings.length; i < n; i++) { SemanticHighlighting semanticHighlighting = fSemanticHighlightings[i]; String colorKey = SemanticHighlightings.getColorPreferenceKey(semanticHighlighting); addColor(colorKey); String boldKey = SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting); int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; String italicKey = SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(italicKey)) style |= SWT.ITALIC; String strikethroughKey = SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(strikethroughKey)) style |= TextAttribute.STRIKETHROUGH; String underlineKey = SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(underlineKey)) style |= TextAttribute.UNDERLINE; boolean isEnabled = fPreferenceStore.getBoolean( SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting)); fHighlightings[i] = new Highlighting( new TextAttribute( fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)), null, style), isEnabled); } }
/** * 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 createStakeHolder_2011( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(RdalVisualIDRegistry.getType(StakeHolderEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); 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()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5018 = createLabel(node, RdalVisualIDRegistry.getType(StakeHolderNameEditPart.VISUAL_ID)); label5018.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location5018 = (Location) label5018.getLayoutConstraint(); location5018.setX(0); location5018.setY(5); return node; }
private void handleAppearanceColorListSelection() { int i = fAppearanceColorList.getSelectionIndex(); if (i == -1) return; String key = fAppearanceColorListModel[i][1]; RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key); fAppearanceColorEditor.setColorValue(rgb); updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]); }
@Override protected void initializeFromPreferences(View view) { super.initializeFromPreferences(view); IPreferenceStore store = (IPreferenceStore) getPreferencesHint().getPreferenceStore(); if (store == null) { return; } // Create region default styles ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE); RGB fillRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_BACKGROUND); style.setFillColor(FigureUtilities.RGBToInteger(fillRGB)); RGB lineRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_LINE); style.setLineColor(FigureUtilities.RGBToInteger(lineRGB)); }
/** @generated */ public Node createRequirementsGroup_2007( 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()); node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle()); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(RdalVisualIDRegistry.getType(RequirementsGroupEditPart.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()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue( node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5013 = createLabel(node, RdalVisualIDRegistry.getType(RequirementsGroupNameEditPart.VISUAL_ID)); createCompartment( node, RdalVisualIDRegistry.getType(RequirementsGroupRequirementsCompartmentEditPart.VISUAL_ID), true, false, false, false); return node; }
private static Color getForegroundColor() { IPreferenceStore preference = DartToolsPlugin.getDefault().getPreferenceStore(); RGB rgb = PreferenceConverter.getColor( preference, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND); DartTextTools textTools = DartToolsPlugin.getDefault().getDartTextTools(); return textTools.getColorManager().getColor(rgb); }
private void adjustCurrentLineColor(TextStyle theme) { if (AttemptToChangeCurrentLineColorAccordingToTheme) { PreferenceConverter.setValue( // getPreferenceStore(), // PreferenceConstants.CUSTOM_CURRENT_LINE_COLOR, theme.getCurrentLineHighlight()); } }
/** {@inheritDoc} */ @Override public boolean performOk() { if (isControlCreated()) { RGB rgb = backgroundColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_BACKGROUND, rgb); rgb = commentColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_COMMENT, rgb); rgb = commonVariableColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_COMMON_VARIABLE, rgb); rgb = defaultColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_DEFAULT, rgb); rgb = keywordColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_KEYWORD, rgb); rgb = literalColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_LITERAL, rgb); rgb = hyperlinkColorField.getColorSelector().getColorValue(); PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_HYPERLINK, rgb); } return super.performOk(); }
private void addColor(String colorKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey); if (fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext = (IColorManagerExtension) fColorManager; ext.unbindColor(colorKey); ext.bindColor(colorKey, rgb); } } }
/** * Initializes the default colors. * * @since 3.3 */ private void initializeDefaultColors() { if (getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) { Display display = fAppearanceColorList.getDisplay(); RGB rgb = SourceViewerInformationControl.getVisibleBackgroundColor(display); if (rgb == null) rgb = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); PreferenceConverter.setValue( getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb); } }
protected void updatePreferences() { IPreferenceStore store = SimulationActivator.getDefault().getPreferenceStore(); // read out the new colors RGB foregroundColor = PreferenceConverter.getColor(store, STATE_FOREGROUND_HIGHLIGHTING_COLOR); RGB backgroundColor = PreferenceConverter.getColor(store, STATE_BACKGROUND_HIGHLIGHTING_COLOR); RGB vertexForegroundColor = PreferenceConverter.getColor(store, VERTEX_FOREGROUND_TRANSIENT_COLOR); RGB vertexBackgroundColor = PreferenceConverter.getColor(store, VERTEX_BACKGROUND_TRANSIENT_COLOR); RGB transitionColor = PreferenceConverter.getColor(store, TRANSITION_HIGHLIGHTING_COLOR); // Set the new colors STATE_HIGHLIGHT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), foregroundColor); STATE_HIGHLIGHT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), backgroundColor); VERTEX_TRANSIENT_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), vertexForegroundColor); VERTEX_TRANSIENT_PARAMS.backgroundFadingColor = new Color(Display.getDefault(), vertexBackgroundColor); TRANSITION_PARAMS.foregroundFadingColor = new Color(Display.getDefault(), transitionColor); }
/** * Installs the given font in the preference store and optionally the font registry. * * @param definition the font definition * @param registry the font registry * @param store the preference store from which to set and obtain font data * @param setInRegistry whether the color should be put into the registry as well as having its * default preference set */ private static void installFont( FontDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) { FontRegistry registry = theme.getFontRegistry(); String id = definition.getId(); String key = createPreferenceKey(theme, id); FontData[] prefFont = store != null ? PreferenceConverter.getFontDataArray(store, key) : null; FontData[] defaultFont = null; if (definition.getValue() != null) { defaultFont = definition.getValue(); } else if (definition.getDefaultsTo() != null) { defaultFont = registry.filterData( registry.getFontData(definition.getDefaultsTo()), Workbench.getInstance().getDisplay()); } else { // values pushed in from jface property files. Very ugly. Display display = Workbench.getInstance().getDisplay(); // If in high contrast, ignore the defaults in jface and use the default (system) font. // This is a hack to address bug #205474. See bug #228207 for a future fix. FontData[] fontData = JFaceResources.getFontRegistry() .getFontData(display.getHighContrast() ? JFaceResources.DEFAULT_FONT : id); defaultFont = registry.bestDataArray(fontData, display); } if (setInRegistry) { if (prefFont == null || prefFont == PreferenceConverter.FONTDATA_ARRAY_DEFAULT_DEFAULT) { prefFont = defaultFont; } if (prefFont != null) { registry.put(id, prefFont); } } if (defaultFont != null && store != null) { PreferenceConverter.setDefault(store, key, defaultFont); } }
/** Constructs a well renderer model with default properties. */ public WellRendererModel() { super(); // Initialize the default renderer settings from the preferences. final IPreferenceStore preferences = WellRendererPreferencePage.PREFERENCE_STORE; final int boreRadius = preferences.getInt(WELL_BORE_RADIUS); final RGB boreColor = PreferenceConverter.getColor(preferences, WELL_BORE_COLOR); _size = addIntegerProperty(WELL_BORE_RADIUS, boreRadius); _color = addColorProperty(WELL_BORE_COLOR, boreColor); }
/** * Initializes the default preference values for this preference store. * * @param store */ public static void initDefaults(IPreferenceStore store) { setDefaultFontPreference(store); Color fontColor = ColorConstants.black; PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_FONT_COLOR, fontColor.getRGB()); Color fillColor = LogicColorConstants.logicGreen; PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_FILL_COLOR, fillColor.getRGB()); Color lineColor = LogicColorConstants.connectorGreen; PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_LINE_COLOR, lineColor.getRGB()); Color noteFillColor = DiagramColorConstants.diagramLightYellow; PreferenceConverter.setDefault( store, IPreferenceConstants.PREF_NOTE_FILL_COLOR, noteFillColor.getRGB()); Color noteLineColor = DiagramColorConstants.diagramDarkYellow; PreferenceConverter.setDefault( store, IPreferenceConstants.PREF_NOTE_LINE_COLOR, noteLineColor.getRGB()); }
private void updateBackgroundColor() { boolean defaultBackgroundColor = preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); if (defaultBackgroundColor) { setBackgroundColor(null); } else { RGB backgroundColor = PreferenceConverter.getColor( preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); setBackgroundColor(backgroundColor); } }
/** Resets the changed values after setting the preference pages. */ public void resetValues() { isHighlightBrackets = preferenceStore.getBoolean( bento.language.bentocomp.resource.bento.ui.BentoPreferenceConstants .EDITOR_MATCHING_BRACKETS_CHECKBOX); bracketColor = colorManager.getColor( org.eclipse.jface.preference.PreferenceConverter.getColor( preferenceStore, bento.language.bentocomp.resource.bento.ui.BentoPreferenceConstants .EDITOR_MATCHING_BRACKETS_COLOR)); bracketSet.resetBrackets(); }
/** * initialize the font 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 initFontStyleFromPrefs( View view, final IPreferenceStore store, String elementName) { if (!usePreferenceInitializer(view)) { return; } String fontConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.FONT); String fontColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FONT); FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE); if (viewFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(store, fontConstant); viewFontStyle.setFontName(fontData.getName()); viewFontStyle.setFontHeight(fontData.getHeight()); viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant); viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } }