Java Code Examples for org.eclipse.jface.preference.PreferenceConverter

The following examples show how to use org.eclipse.jface.preference.PreferenceConverter. These examples are extracted from open source projects. 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
@Override
public Object getPreferredValue(EStructuralFeature feature) {
       Object preferenceStore = getDiagramPreferencesHint().getPreferenceStore();
       if (preferenceStore instanceof IPreferenceStore) {
           if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(44,109,163));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFontStyle_FontColor()) {
               
               return FigureUtilities.RGBToInteger(PreferenceConverter
                   .getColor((IPreferenceStore) preferenceStore,
                       IPreferenceConstants.PREF_FONT_COLOR));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFillStyle_FillColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(184,185,218));
               
           }
       }

       return getStructuralFeatureValue(feature);
   }
 
Example 2
@Override
public Object getPreferredValue(EStructuralFeature feature) {
       Object preferenceStore = getDiagramPreferencesHint().getPreferenceStore();
       if (preferenceStore instanceof IPreferenceStore) {
           if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(44,109,163));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFontStyle_FontColor()) {
               
               return FigureUtilities.RGBToInteger(PreferenceConverter
                   .getColor((IPreferenceStore) preferenceStore,
                       IPreferenceConstants.PREF_FONT_COLOR));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFillStyle_FillColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(184,185,218));
               
           }
       }

       return getStructuralFeatureValue(feature);
   }
 
Example 3
Source Project: birt   Source File: UIUtil.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static 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;
}
 
Example 4
Source Project: Pydev   Source File: PythonSourceViewer.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the viewer's font to match the preferences.
 */
private void updateViewerFont() {
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {
        FontData data = null;
        if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
            data = PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
        } else {
            data = PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
        }
        if (data != null) {
            Font font = new Font(getTextWidget().getDisplay(), data);
            applyFont(font);
            if (getFont() != null) {
                getFont().dispose();
            }
            setFont(font);
            return;
        }
    }
    // if all the preferences failed
    applyFont(JFaceResources.getTextFont());
}
 
Example 5
Source Project: statecharts   Source File: RegionViewFactory.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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));
}
 
Example 6
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);
	SUSPENDED_PARAMS.backgroundFadingColor = STATE_HIGHLIGHT_PARAMS.backgroundFadingColor;
	SUSPENDED_PARAMS.foregroundFadingColor = green;
	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);
}
 
Example 7
Source Project: LogViewer   Source File: LogFileViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public LogFileViewer(Composite parent, int style) {
    store = LogViewerPlugin.getDefault().getPreferenceStore();
    if (store.getBoolean(ILogViewerConstants.PREF_WORD_WRAP))
        style |= SWT.WRAP;
    showWhenUpdated = store.getBoolean(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED);
    showTopOfFile = store.getBoolean(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE);
    txtViewer = new SourceViewer(parent,null,style);
    FontData[] fontData = PreferenceConverter.getFontDataArray(store,ILogViewerConstants.PREF_EDITOR_FONT_STYLE);
    if(fontData == null) {
        fontData = JFaceResources.getDefaultFont().getFontData();
    }
    txtViewer.getTextWidget().setFont(new Font(Display.getCurrent(),fontData));
    propertyChangeListener = new PropertyChangeListener();
    store.addPropertyChangeListener(propertyChangeListener);
    createCursorLinePainter();
    createAndInstallPresentationReconciler();
}
 
Example 8
Source Project: goclipse   Source File: ViewerColorUpdater.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected 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;
}
 
Example 9
Source Project: birt   Source File: ExpressionBuilder.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference
 * store. Returns <code>null</code> if there is no such information
 * available.
 */
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;
}
 
Example 10
Source Project: gama   Source File: AutoStartup.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void earlyStartup() {
	GamaPreferences.Modeling.EDITOR_BASE_FONT.init(() -> getDefaultFontData()).onChange(font -> {
		try {
			final FontData newValue = new FontData(font.getName(), font.getSize(), font.getStyle());
			setValue(EditorsPlugin.getDefault().getPreferenceStore(), TEXT_FONT, newValue);
		} catch (final Exception e) {}
	});
	GamaPreferences.Modeling.EDITOR_BACKGROUND_COLOR.init(() -> getDefaultBackground()).onChange(c -> {
		final RGB rgb = new RGB(c.getRed(), c.getGreen(), c.getBlue());
		PreferenceConverter.setValue(EditorsPlugin.getDefault().getPreferenceStore(),
				AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, rgb);
		GamaPreferences.Modeling.OPERATORS_MENU_SORT
				.onChange(newValue -> OperatorsReferenceMenu.byName = newValue.equals("Name"));
	});
	GamlRuntimeModule.staticInitialize();
	GamlEditorBindings.install();
	GamlReferenceSearch.install();
}
 
Example 11
@Override
public Object getPreferredValue(EStructuralFeature feature) {
    final Object preferenceStore = getDiagramPreferencesHint().getPreferenceStore();
    if (preferenceStore instanceof IPreferenceStore) {
        if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
            return FigureUtilities.RGBToInteger(new RGB(44, 109, 163));
        } else if (feature == NotationPackage.eINSTANCE
                .getFontStyle_FontColor()) {
            return FigureUtilities.RGBToInteger(PreferenceConverter
                    .getColor((IPreferenceStore) preferenceStore,
                            IPreferenceConstants.PREF_FONT_COLOR));
        } else if (feature == NotationPackage.eINSTANCE
                .getFillStyle_FillColor()) {
            return FigureUtilities.RGBToInteger(new RGB(184, 185, 218));
        }
    }

    return getStructuralFeatureValue(feature);
}
 
Example 12
/**
 * 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;
}
 
Example 13
private void initializeColors() {
	IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
	RGB bgRGB;
	if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
		bgRGB= getVisibleBackgroundColor(fShell.getDisplay());
	} else {
		bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
	}
	if (bgRGB != null) {
		fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
		fIsSystemBackgroundColor= false;
	} else {
		fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
		fIsSystemBackgroundColor= true;
	}
}
 
Example 14
@Override
public Object getPreferredValue(EStructuralFeature feature) {
	Object preferenceStore = getDiagramPreferencesHint().getPreferenceStore();
	if (preferenceStore instanceof IPreferenceStore) {
		if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {

			return FigureUtilities.RGBToInteger(new RGB(44,109,163));

		} else if (feature == NotationPackage.eINSTANCE
				.getFontStyle_FontColor()) {

			return FigureUtilities.RGBToInteger(PreferenceConverter
					.getColor((IPreferenceStore) preferenceStore,
							IPreferenceConstants.PREF_FONT_COLOR));

		} else if (feature == NotationPackage.eINSTANCE
				.getFillStyle_FillColor()) {

			return FigureUtilities.RGBToInteger(new RGB(184,185,218));

		}
	}

	return getStructuralFeatureValue(feature);
}
 
Example 15
private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
	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);
		}
	}

	if (!fNeedsLazyColorLoading)
		fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)));
	else {
		Token token= fTokenMap.get(colorKey);
		if (token != null)
			token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey));
	}
}
 
Example 16
/**
 * Sets the default value and fires a property
 * change event if necessary.
 *
 * @param store	the preference store
 * @param key the preference key
 * @param newValue the new value
 * @param fireEvent <code>false</code> if no event should be fired
 * @since 3.4
 */
private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) {
	if (!fireEvent) {
		PreferenceConverter.setDefault(store, key, newValue);
		return;
	}

	RGB oldValue= null;
	if (store.isDefault(key))
		oldValue= PreferenceConverter.getDefaultColor(store, key);

	PreferenceConverter.setDefault(store, key, newValue);

	if (oldValue != null && !oldValue.equals(newValue))
		store.firePropertyChangeEvent(key, oldValue, newValue);
}
 
Example 17
@Override
public Object getPreferredValue(EStructuralFeature feature) {
       Object preferenceStore = getDiagramPreferencesHint().getPreferenceStore();
       if (preferenceStore instanceof IPreferenceStore) {
           if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(44,109,163));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFontStyle_FontColor()) {
               
               return FigureUtilities.RGBToInteger(PreferenceConverter
                   .getColor((IPreferenceStore) preferenceStore,
                       IPreferenceConstants.PREF_FONT_COLOR));
               
           } else if (feature == NotationPackage.eINSTANCE
               .getFillStyle_FillColor()) {
               
               return FigureUtilities.RGBToInteger(new RGB(184,185,218));
               
           }
       }

       return getStructuralFeatureValue(feature);
   }
 
Example 18
private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey,
		String underlineKey) {
	if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
		RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey);
		IColorManager ext = (IColorManager) fColorManager;
		ext.unbindColor(colorKey);
		ext.bindColor(colorKey, rgb);
	}

	if (!fNeedsLazyColorLoading)
		fTokenMap.put(colorKey,
				new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)));
	else {
		Token token = fTokenMap.get(colorKey);
		if (token != null)
			token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey));
	}
}
 
Example 19
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createCsvSource_2001(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(CsvSourceEditPart.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 label5001 = createLabel(node, CrossflowVisualIDRegistry.getType(CsvSourceNameEditPart.VISUAL_ID));
	return node;
}
 
Example 20
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createCsvSink_2002(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(CsvSinkEditPart.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 label5002 = createLabel(node, CrossflowVisualIDRegistry.getType(CsvSinkNameEditPart.VISUAL_ID));
	return node;
}
 
Example 21
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createTopic_2003(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(TopicEditPart.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 label5003 = createLabel(node, CrossflowVisualIDRegistry.getType(TopicNameEditPart.VISUAL_ID));
	return node;
}
 
Example 22
Source Project: Pydev   Source File: ColorManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 *
 * @param type: see constants at {@link PydevConsoleConstants}
 * @return a color to be used.
 */
public Color getPreferenceColor(String type) {
    if (SharedCorePlugin.inTestMode()) {
        return null;
    }
    PydevDebugPlugin plugin = PydevDebugPlugin.getDefault();
    IPreferenceStore preferenceStore = plugin.getPreferenceStore();
    return getColor(PreferenceConverter.getColor(preferenceStore, type));
}
 
Example 23
Source Project: Pydev   Source File: PythonSourceViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference store. Returns <code>null</code> if there is no such information available.
 */
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;
}
 
Example 24
/**
* @generated
*/
public Node createNonInterruptingBoundaryTimerEvent_3064(EObject domainElement, View containerView, int index,
		boolean persisted, PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(ProcessVisualIDRegistry.getType(NonInterruptingBoundaryTimerEventEditPart.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 label5094 = createLabel(node,
			ProcessVisualIDRegistry.getType(NonInterruptingBoundaryTimerEventNameEditPart.VISUAL_ID));
	label5094.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
	Location location5094 = (Location) label5094.getLayoutConstraint();
	location5094.setX(0);
	location5094.setY(5);
	return node;
}
 
Example 25
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createCommitmentTask_2007(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(CommitmentTaskEditPart.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 label5007 = createLabel(node, CrossflowVisualIDRegistry.getType(CommitmentTaskNameEditPart.VISUAL_ID));
	return node;
}
 
Example 26
/**
* @generated
*/
public Node createIntermediateErrorCatchEvent_3032(EObject domainElement, View containerView, int index,
		boolean persisted, PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(ProcessVisualIDRegistry.getType(IntermediateErrorCatchEvent4EditPart.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 label5062 = createLabel(node,
			ProcessVisualIDRegistry.getType(IntermediateErrorCatchEventLabel4EditPart.VISUAL_ID));
	label5062.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
	Location location5062 = (Location) label5062.getLayoutConstraint();
	location5062.setX(0);
	location5062.setY(5);
	return node;
}
 
Example 27
/**
* @generated
*/
public Node createSubProcessEvent_2031(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(ProcessVisualIDRegistry.getType(SubProcessEventEditPart.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 label5081 = createLabel(node, ProcessVisualIDRegistry.getType(SubProcessEventLabelEditPart.VISUAL_ID));
	createCompartment(node, ProcessVisualIDRegistry.getType(SubProcessEventSubProcessCompartmentEditPart.VISUAL_ID),
			true, false, false, false);
	return node;
}
 
Example 28
/**
* @generated
*/
public Node createEndTerminatedEvent_3062(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(ProcessVisualIDRegistry.getType(EndTerminatedEvent2EditPart.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 label5090 = createLabel(node, ProcessVisualIDRegistry.getType(EndTerminatedEventLabel2EditPart.VISUAL_ID));
	label5090.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
	Location location5090 = (Location) label5090.getLayoutConstraint();
	location5090.setX(0);
	location5090.setY(5);
	return node;
}
 
Example 29
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createType_2011(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.getStyles().add(NotationFactory.eINSTANCE.createHintedDiagramLinkStyle());
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(TypeEditPart.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 label5012 = createLabel(node, CrossflowVisualIDRegistry.getType(TypeNameEditPart.VISUAL_ID));
	createCompartment(node, CrossflowVisualIDRegistry.getType(TypeTypeFieldsCompartmentEditPart.VISUAL_ID), false,
			false, true, true);
	return node;
}
 
Example 30
Source Project: scava   Source File: CrossflowViewProvider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public Node createField_2014(EObject domainElement, View containerView, int index, boolean persisted,
		PreferencesHint preferencesHint) {
	Shape node = NotationFactory.eINSTANCE.createShape();
	node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
	node.setType(CrossflowVisualIDRegistry.getType(FieldEditPart.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 label5016 = createLabel(node, CrossflowVisualIDRegistry.getType(FieldNameTypeEditPart.VISUAL_ID));
	return node;
}