Search in sources :

Example 36 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project webtools.sourceediting by eclipse.

the class XSLUIPreferenceInitializer method initializeDefaultPreferences.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
	 */
@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = XSLUIPlugin.getDefault().getPreferenceStore();
    ColorRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    // XSL Style Preferences
    // $NON-NLS-1$
    String BOLD = " | null | true";
    // $NON-NLS-1$
    String JUSTITALIC = " | null | false | true";
    String styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXSL.TAG_ATTRIBUTE_NAME, 127, 0, 127) + BOLD;
    store.setDefault(IStyleConstantsXSL.TAG_ATTRIBUTE_NAME, styleValue);
    styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXSL.TAG_ATTRIBUTE_VALUE, 42, 0, 255) + JUSTITALIC;
    store.setDefault(IStyleConstantsXSL.TAG_ATTRIBUTE_VALUE, styleValue);
    styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXSL.TAG_BORDER, 0, 128, 128) + BOLD;
    store.setDefault(IStyleConstantsXSL.TAG_BORDER, styleValue);
    styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXSL.TAG_NAME, 63, 127, 127) + BOLD;
    store.setDefault(IStyleConstantsXSL.TAG_NAME, styleValue);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.tag.bold", true);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.tag.italic", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.tag.strikethrough", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.tag.underline", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.tag.enabled", true);
    // $NON-NLS-1$ //$NON-NLS-2$
    store.setDefault("xsl.ui.highlighting.tag.color", "#FF00FF");
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.attr.bold", true);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.attr.italic", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.attr.strikethrough", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.attr.underline", false);
    // $NON-NLS-1$
    store.setDefault("xsl.ui.highlighting.attr.enabled", true);
    // $NON-NLS-1$ //$NON-NLS-2$
    store.setDefault("xsl.ui.highlighting.attr.color", "#FF00FF");
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 37 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project arduino-eclipse-plugin by Sloeber.

the class PlotterView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    ITheme currentTheme = themeManager.getCurrentTheme();
    ColorRegistry colorRegistry = currentTheme.getColorRegistry();
    this.myPlotter = new // $NON-NLS-1$
    MyPlotter(// $NON-NLS-1$
    6, // $NON-NLS-1$
    parent, // $NON-NLS-1$
    SWT.NONE, // $NON-NLS-1$
    colorRegistry.get("io.sloeber.plotter.color.background"), // $NON-NLS-1$
    colorRegistry.get("io.sloeber.plotter.color.foreground"), // $NON-NLS-1$
    colorRegistry.get("io.sloeber.plotter.color.grid"));
    GridData theGriddata = new GridData(SWT.FILL, SWT.FILL, true, true);
    theGriddata.horizontalSpan = 7;
    this.myPlotter.setLayoutData(theGriddata);
    for (int i = 0; i < this.myPlotter.getChannels(); i++) {
        // $NON-NLS-1$
        String colorID = "io.sloeber.plotter.color." + (1 + i);
        Color color = colorRegistry.get(colorID);
        this.myPlotter.setForeground(i, color);
    }
    int steadyPosition = this.myPlotter.getSize().x;
    int tailSize = this.myPlotter.getSize().x - 10;
    if (tailSize < -3) {
        tailSize = -2;
    }
    for (int i = 0; i < 6; i++) {
        this.myPlotter.setPercentage(i, false);
        this.myPlotter.setSteady(i, true, steadyPosition);
        this.myPlotter.setFade(i, false);
        this.myPlotter.setTailFade(i, 0);
        this.myPlotter.setConnect(i, false);
        this.myPlotter.setLineWidth(i, 1);
        this.myPlotter.setBaseOffset(i, 0);
        this.myPlotter.setTailSize(i, tailSize);
        this.myPlotter.SetChannelName(i, Messages.plotterViewChannel + Integer.toString(i));
    }
    PlotterView.this.myPlotter.setShowLabels(true);
    Listener listener = new Listener() {

        boolean inDrag = false;

        boolean inSize = false;

        int orgLowRange = 0;

        int orgHighRange = 0;

        int orgY = 0;

        double valueAtScrollPoint = 0;

        double scale = 1;

        double orgHeight;

        double scrollPointPercentage;

        @Override
        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.MouseDown:
                    if (!(this.inDrag || this.inSize)) {
                        this.orgLowRange = PlotterView.this.myPlotter.getRangeLowValue();
                        this.orgHighRange = PlotterView.this.myPlotter.getRangeHighValue();
                        this.scale = (((float) (PlotterView.this.myPlotter.getRangeHighValue() - PlotterView.this.myPlotter.getRangeLowValue())) / (float) PlotterView.this.myPlotter.getSize().y);
                        this.orgY = event.y;
                        switch(event.button) {
                            case 1:
                                this.inDrag = true;
                                break;
                            case 3:
                                this.orgHeight = (double) this.orgHighRange - this.orgLowRange;
                                this.scrollPointPercentage = (double) event.y / (double) PlotterView.this.myPlotter.getSize().y;
                                this.valueAtScrollPoint = this.orgHighRange - this.scrollPointPercentage * this.orgHeight;
                                this.inSize = true;
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case SWT.MouseMove:
                    if (this.inDrag) {
                        PlotterView.this.myPlotter.setRange((int) (this.orgLowRange - (this.orgY - event.y) * this.scale), (int) (this.orgHighRange - (this.orgY - event.y) * this.scale));
                        PlotterView.this.myPlotter.setnewBackgroundImage();
                    }
                    if (this.inSize) {
                        double newscale = Math.max(this.scale * (1.0 + (this.orgY - event.y) * 0.01), 1.0);
                        int newHeight = (int) (this.orgHeight / this.scale * newscale);
                        int newHighValue = (int) (this.valueAtScrollPoint + this.scrollPointPercentage * newHeight);
                        PlotterView.this.myPlotter.setRange(newHighValue - newHeight, newHighValue);
                        PlotterView.this.myPlotter.setnewBackgroundImage();
                    }
                    break;
                case SWT.MouseUp:
                    this.inDrag = false;
                    this.inSize = false;
                    break;
                case SWT.MouseDoubleClick:
                    // save the data
                    FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.SAVE);
                    // $NON-NLS-1$
                    dialog.setFilterExtensions(new String[] { "*.csv" });
                    String fileName = dialog.open();
                    if (fileName != null && !fileName.isEmpty()) {
                        PlotterView.this.myPlotter.saveData(fileName);
                    }
                    this.inDrag = false;
                    this.inSize = false;
                    break;
                default:
                    break;
            }
        }
    };
    this.myPlotter.addListener(SWT.MouseDown, listener);
    this.myPlotter.addListener(SWT.MouseUp, listener);
    this.myPlotter.addListener(SWT.MouseMove, listener);
    this.myPlotter.addListener(SWT.MouseDoubleClick, listener);
    this.myPlotter.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            int plotterWidth = PlotterView.this.myPlotter.getSize().x - 10;
            for (int i = 0; i < PlotterView.this.myPlotter.getChannels(); i++) {
                PlotterView.this.myPlotter.setSteady(i, true, plotterWidth);
                PlotterView.this.myPlotter.setTailSize(i, plotterWidth);
            }
            PlotterView.this.myPlotter.setnewBackgroundImage();
            PlotterView.this.myPlotter.redraw();
        }
    });
    // I set this as starting range
    this.myPlotter.setRange(0, 1050);
    // $NON-NLS-1$
    this.myPlotter.setStatus("Use the serial monitor to connect to a Serial port.");
    this.myPlotter.setShowLabels(false);
    this.myPlotter.setnewBackgroundImage();
    registerSerialTracker();
}
Also used : ITheme(org.eclipse.ui.themes.ITheme) Listener(org.eclipse.swt.widgets.Listener) ServiceListener(org.osgi.framework.ServiceListener) PlotterListener(io.sloeber.ui.monitor.internal.PlotterListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) Color(org.eclipse.swt.graphics.Color) IThemeManager(org.eclipse.ui.themes.IThemeManager) GridLayout(org.eclipse.swt.layout.GridLayout) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) GridData(org.eclipse.swt.layout.GridData) ServiceEvent(org.osgi.framework.ServiceEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 38 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project abstools by abstools.

the class Activator method initializeColors.

// -------------------- INIT ------------------------------------------------------------------------------
public static void initializeColors() {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    colorRegistry.put(STYLER_COLOR_BLACK, STYLER_COLOR_BLACK_RGB);
    colorRegistry.put(STYLER_COLOR_GREY, STYLER_COLOR_GREY_RGB);
    colorRegistry.put(STYLER_COLOR_TYPES, STYLER_COLOR_TYPES_RGB);
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry)

Example 39 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project bndtools by bndtools.

the class ItalicStyler method applyStyles.

@Override
public void applyStyles(TextStyle textStyle) {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    Font font = JFaceResources.getFontRegistry().getItalic(fontName);
    if (fForegroundColorName != null) {
        textStyle.foreground = colorRegistry.get(fForegroundColorName);
    }
    if (fBackgroundColorName != null) {
        textStyle.background = colorRegistry.get(fBackgroundColorName);
    }
    textStyle.font = font;
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry) Font(org.eclipse.swt.graphics.Font)

Example 40 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project dbeaver by serge-rider.

the class EntityFigure method add.

@Override
public void add(IFigure figure, Object constraint, int index) {
    if (figure instanceof AttributeItemFigure) {
        ColorRegistry colorRegistry = UIUtils.getColorRegistry();
        figure.setForegroundColor(colorRegistry.get(ERDUIConstants.COLOR_ERD_ATTR_FOREGROUND));
        figure.setBackgroundColor(colorRegistry.get(ERDUIConstants.COLOR_ERD_ATTR_BACKGROUND));
        IFigure attrExtra = createRightPanel();
        AttributeItemFigure attributeItemFigure = (AttributeItemFigure) figure;
        attributeItemFigure.setRightPanel(attrExtra);
        if (attributeItemFigure.getAttribute().isInPrimaryKey()) {
            keyFigure.add(figure, new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
            keyFigure.add(attrExtra, new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
        } else {
            attributeFigure.add(figure, new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
            attributeFigure.add(attrExtra, new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
        }
    } else {
        super.add(figure, constraint, index);
    }
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry)

Aggregations

ColorRegistry (org.eclipse.jface.resource.ColorRegistry)48 Color (org.eclipse.swt.graphics.Color)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)8 RGB (org.eclipse.swt.graphics.RGB)6 TextAttribute (org.eclipse.jface.text.TextAttribute)5 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 java.awt (java.awt)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)2 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)2 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 Display (org.eclipse.swt.widgets.Display)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 ITheme (org.eclipse.ui.themes.ITheme)2 PlotterListener (io.sloeber.ui.monitor.internal.PlotterListener)1 CoreException (org.eclipse.core.runtime.CoreException)1