Search in sources :

Example 1 with ColorRegistry

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

the class SpreadsheetPresentation method applyThemeSettings.

///////////////////////////////////////////////
// Themes
private void applyThemeSettings() {
    ITheme currentTheme = themeManager.getCurrentTheme();
    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.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 : ITheme(org.eclipse.ui.themes.ITheme) ColorRegistry(org.eclipse.jface.resource.ColorRegistry)

Example 2 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project xtext-eclipse by eclipse.

the class DefaultEObjectHoverProvider method getHoverInfo.

protected XtextBrowserInformationControlInput getHoverInfo(EObject element, IRegion hoverRegion, XtextBrowserInformationControlInput previous) {
    String html = getHoverInfoAsHtml(element);
    if (html != null) {
        StringBuffer buffer = new StringBuffer(html);
        ColorRegistry registry = JFaceResources.getColorRegistry();
        // $NON-NLS-1$
        RGB fgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_FOREGROUND");
        // $NON-NLS-1$
        RGB bgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_BACKGROUND");
        if (fgRGB != null && bgRGB != null) {
            HTMLPrinter.insertPageProlog(buffer, 0, fgRGB, bgRGB, getStyleSheet());
        } else {
            HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet());
        }
        HTMLPrinter.addPageEpilog(buffer);
        html = buffer.toString();
        return new XtextBrowserInformationControlInput(previous, element, html, labelProvider);
    }
    return null;
}
Also used : ColorRegistry(org.eclipse.jface.resource.ColorRegistry) RGB(org.eclipse.swt.graphics.RGB)

Example 3 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project xtext-eclipse by eclipse.

the class XbaseHoverProvider method getHoverInfo.

@Override
protected XtextBrowserInformationControlInput getHoverInfo(EObject element, IRegion hoverRegion, XtextBrowserInformationControlInput previous) {
    // TODO remove this check when the typesystem works without a java project
    if (isValidationDisabled(element))
        return null;
    EObject objectToView = getObjectToView(element);
    if (objectToView == null || objectToView.eIsProxy())
        return null;
    String html = getHoverInfoAsHtml(element, objectToView, hoverRegion);
    if (html != null) {
        StringBuffer buffer = new StringBuffer(html);
        ColorRegistry registry = JFaceResources.getColorRegistry();
        // $NON-NLS-1$
        RGB fgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_FOREGROUND");
        // $NON-NLS-1$
        RGB bgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_BACKGROUND");
        if (fgRGB != null && bgRGB != null) {
            HTMLPrinter.insertPageProlog(buffer, 0, fgRGB, bgRGB, getStyleSheet());
        } else {
            HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet());
        }
        HTMLPrinter.addPageEpilog(buffer);
        html = buffer.toString();
        IJavaElement javaElement = null;
        if (objectToView != element && objectToView instanceof JvmIdentifiableElement) {
            javaElement = javaElementFinder.findElementFor((JvmIdentifiableElement) objectToView);
        }
        return new XbaseInformationControlInput(previous, objectToView, javaElement, html, labelProvider);
    }
    return null;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) EObject(org.eclipse.emf.ecore.EObject) RGB(org.eclipse.swt.graphics.RGB)

Example 4 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project xtext-eclipse by eclipse.

the class XbaseInformationControl method createContent.

/**
 * Xbase - modification+ added detailPane
 */
@Override
protected void createContent(Composite parent) {
    fSashForm = new SashForm(parent, parent.getStyle());
    fSashForm.setOrientation(SWT.VERTICAL);
    fBrowser = new Browser(fSashForm, SWT.NONE);
    fBrowser.setJavascriptEnabled(false);
    Display display = getShell().getDisplay();
    ColorRegistry registry = JFaceResources.getColorRegistry();
    // $NON-NLS-1$
    Color foreground = registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND");
    // $NON-NLS-1$
    Color background = registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND");
    if (background != null && foreground != null) {
        fBrowser.setForeground(foreground);
        fBrowser.setBackground(background);
    } else {
        fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
        fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }
    fBrowser.addProgressListener(new ProgressAdapter() {

        @Override
        public void completed(ProgressEvent event) {
            fCompleted = true;
        }
    });
    fBrowser.addOpenWindowListener(new OpenWindowListener() {

        @Override
        public void open(WindowEvent event) {
            // Cancel opening of new windows
            event.required = true;
        }
    });
    // Replace browser's built-in context menu with none
    fSashForm.setMenu(new Menu(getShell(), SWT.NONE));
    detailPaneComposite = createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
    Layout layout = detailPaneComposite.getLayout();
    if (layout instanceof GridLayout) {
        GridLayout gl = (GridLayout) layout;
        gl.marginHeight = 0;
        gl.marginWidth = 0;
        gl.numColumns = 1;
    }
    if (background != null && foreground != null) {
        detailPaneComposite.setForeground(foreground);
        detailPaneComposite.setBackground(background);
    } else {
        detailPaneComposite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
        detailPaneComposite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }
    resourceProvider = new HoverEditedResourceProvider();
    embeddedEditor = xbaseHoverConfiguration.getEditorFactory().newEditor(resourceProvider).readOnly().processIssuesBy(new IValidationIssueProcessor() {

        @Override
        public void processIssues(List<Issue> issues, IProgressMonitor monitor) {
        }
    }).withParent(detailPaneComposite);
    Control viewerControl = embeddedEditor.getViewer().getControl();
    if (background != null && foreground != null) {
        viewerControl.setForeground(foreground);
        viewerControl.setBackground(background);
    } else {
        viewerControl.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
        viewerControl.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    }
    embeddedEditor.getDocument().setValidationJob(null);
    createTextLayout();
}
Also used : Issue(org.eclipse.xtext.validation.Issue) Color(org.eclipse.swt.graphics.Color) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) IValidationIssueProcessor(org.eclipse.xtext.ui.editor.validation.IValidationIssueProcessor) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IXtextBrowserInformationControl(org.eclipse.xtext.ui.editor.hover.html.IXtextBrowserInformationControl) AbstractInformationControl(org.eclipse.jface.text.AbstractInformationControl) Control(org.eclipse.swt.widgets.Control) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) TextLayout(org.eclipse.swt.graphics.TextLayout) Layout(org.eclipse.swt.widgets.Layout) GridLayout(org.eclipse.swt.layout.GridLayout) WindowEvent(org.eclipse.swt.browser.WindowEvent) ProgressAdapter(org.eclipse.swt.browser.ProgressAdapter) Menu(org.eclipse.swt.widgets.Menu) OpenWindowListener(org.eclipse.swt.browser.OpenWindowListener) Browser(org.eclipse.swt.browser.Browser) Display(org.eclipse.swt.widgets.Display)

Example 5 with ColorRegistry

use of org.eclipse.jface.resource.ColorRegistry in project xtext-eclipse by eclipse.

the class RenameRefactoringPopup method createContent.

protected void createContent(Composite parent) {
    Display display = parent.getDisplay();
    ColorRegistry registry = JFaceResources.getColorRegistry();
    // $NON-NLS-1$
    Color foreground = registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND");
    if (foreground == null) {
        foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    }
    // $NON-NLS-1$
    Color background = registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND");
    if (background == null) {
        background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    }
    StyledText hint = new StyledText(popup, SWT.READ_ONLY | SWT.SINGLE);
    String enterKeyName = getEnterBinding();
    String hintTemplate = "Enter new name, press {0} to refactor";
    hint.setText(Messages.format(hintTemplate, enterKeyName));
    hint.setForeground(foreground);
    // $NON-NLS-1$
    hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD));
    // text must not be selectable
    hint.setEnabled(false);
    addViewMenu(parent);
    recursiveSetBackgroundColor(parent, background);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) Color(org.eclipse.swt.graphics.Color) StyleRange(org.eclipse.swt.custom.StyleRange) Display(org.eclipse.swt.widgets.Display)

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