Search in sources :

Example 46 with ColorRegistry

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

the class SpreadsheetPresentation method applyThemeSettings.

// /////////////////////////////////////////////
// Themes
@Override
protected void applyThemeSettings(ITheme currentTheme) {
    Font rsFont = currentTheme.getFontRegistry().get(ThemeConstants.FONT_SQL_RESULT_SET);
    if (rsFont != null) {
        this.spreadsheet.setFont(rsFont);
    }
    final ColorRegistry colorRegistry = currentTheme.getColorRegistry();
    Color previewBack = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_PREVIEW_BACK);
    if (previewBack != null) {
    // this.previewPane.getViewPlaceholder().setBackground(previewBack);
    // for (Control control : this.previewPane.getViewPlaceholder().getChildren()) {
    // control.setBackground(previewBack);
    // }
    }
    // this.foregroundDefault = currentTheme.getColorRegistry().get(ThemeConstants.COLOR_SQL_RESULT_CELL_FORE);
    this.backgroundAdded = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_NEW_BACK);
    this.backgroundDeleted = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_DELETED_BACK);
    this.backgroundModified = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_MODIFIED_BACK);
    this.backgroundOdd = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_ODD_BACK);
    this.backgroundReadOnly = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_READ_ONLY);
    this.foregroundSelected = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_SELECTION_FORE);
    this.backgroundSelected = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_SET_SELECTION_BACK);
    this.backgroundMatched = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_CELL_MATCHED);
    this.cellHeaderForeground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_FOREGROUND);
    this.cellHeaderBackground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_BACKGROUND);
    {
        if (this.cellHeaderSelectionBackground != null) {
            UIUtils.dispose(this.cellHeaderSelectionBackground);
            this.cellHeaderSelectionBackground = null;
        }
        Color headerSelectionBackground = colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_HEADER_SELECTED_BACKGROUND);
        RGB cellSel = UIUtils.blend(headerSelectionBackground.getRGB(), new RGB(255, 255, 255), 50);
        this.cellHeaderSelectionBackground = new Color(getSpreadsheet().getDisplay(), cellSel);
    }
    this.spreadsheet.setLineColor(colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_LINES_NORMAL));
    this.spreadsheet.setLineSelectedColor(colorRegistry.get(ThemeConstants.COLOR_SQL_RESULT_LINES_SELECTED));
    this.spreadsheet.recalculateSizes();
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry)

Example 47 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 48 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.replace(Messages.NUMBER, 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)

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