Example usage for org.eclipse.jface.preference JFacePreferences QUALIFIER_COLOR

List of usage examples for org.eclipse.jface.preference JFacePreferences QUALIFIER_COLOR

Introduction

In this page you can find the example usage for org.eclipse.jface.preference JFacePreferences QUALIFIER_COLOR.

Prototype

String QUALIFIER_COLOR

To view the source code for org.eclipse.jface.preference JFacePreferences QUALIFIER_COLOR.

Click Source Link

Document

Identifier for the color used to show extra informations in labels, as a qualified name.

Usage

From source file:bndtools.utils.MessagesPopupDialog.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*from   www.j ava2s.  co  m*/
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    for (int i = 0; i < messages.length; i++) {
        if (i > 0) {
            Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            separator.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
        }

        // Message Type Image Label
        Composite pnlTitle = new Composite(composite, SWT.NONE);
        pnlTitle.setLayout(new GridLayout(2, false));
        Label lblImage = new Label(pnlTitle, SWT.NONE);
        lblImage.setImage(getMessageImage(messages[i].getMessageType()));

        // Message Label
        StringBuilder builder = new StringBuilder();
        if (messages[i].getPrefix() != null) {
            builder.append(messages[i].getPrefix());
        }
        builder.append(messages[i].getMessage());
        Label lblText = new Label(pnlTitle, SWT.WRAP);
        lblText.setText(builder.toString());
        lblText.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT));
        lblText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        // Fix actions, if present
        Object data = messages[i].getData();
        IAction[] fixes;
        if (data instanceof IAction) {
            fixes = new IAction[] { (IAction) data };
        } else if (data instanceof IAction[]) {
            fixes = (IAction[]) data;
        } else {
            fixes = null;
        }

        if (fixes != null) {
            // new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            Composite pnlFixes = new Composite(composite, SWT.NONE);
            pnlFixes.setLayout(new GridLayout(3, false));

            Label lblFixes = new Label(pnlFixes, SWT.NONE);
            lblFixes.setText("Available Fixes:");
            lblFixes.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));

            for (int j = 0; j < fixes.length; j++) {
                if (j > 0)
                    new Label(pnlFixes, SWT.NONE); // Spacer

                new Label(pnlFixes, SWT.NONE).setImage(bulletImg);

                final IAction fix = fixes[j];
                Hyperlink fixLink = new Hyperlink(pnlFixes, SWT.NONE);
                hyperlinkGroup.add(fixLink);
                fixLink.setText(fix.getText());
                fixLink.setHref(fix);
                fixLink.addHyperlinkListener(new HyperlinkAdapter() {
                    @Override
                    public void linkActivated(HyperlinkEvent e) {
                        fix.run();
                        close();
                        // part.getSite().getPage().activate(part);
                        part.setFocus();
                    }
                });
                fixLink.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
            }
        }
    }

    return composite;
}

From source file:com.google.dart.tools.search.internal.ui.text.DecoratingFileSearchLabelProvider.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                refresh();// ww w. ja  v  a2 s  .  co  m
            }
        });
    }
}

From source file:com.google.dart.tools.ui.internal.viewsupport.ColoredViewersManager.java

License:Open Source License

@Override
public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(QUALIFIER_COLOR_NAME) || property.equals(COUNTER_COLOR_NAME)
            || property.equals(DECORATIONS_COLOR_NAME)
            || property.equals(AppearancePreferencePage.PREF_COLORED_LABELS)
            || property.equals(JFacePreferences.QUALIFIER_COLOR)
            || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME) || property.equals(INHERITED_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            @Override/*from w ww. j  a v a2  s .c om*/
            public void run() {
                refreshAllViewers();
            }
        });
    }
}

From source file:com.mentor.nucleus.bp.ui.search.providers.DecoratingModelSearchLabelProvider.java

License:Open Source License

@Override
public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                refresh();//  w  w  w . jav  a  2  s .  c o m
            }
        });
    }
}

From source file:com.technophobia.substeps.junit.ui.component.ColoredViewersManager.java

License:Open Source License

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME) || property.equals(INHERITED_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            @Override/*from ww w . j  a va2 s. co m*/
            public void run() {
                updateAllViewers();
            }
        });
    }
}

From source file:ext.org.eclipse.jdt.internal.ui.typehierarchy.HierarchyLabelProvider.java

License:Open Source License

@Override
public Color getForeground(Object element) {
    if (element instanceof IMethod) {
        if (fSpecialColor == null) {
            fSpecialColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
        }//from w  w w .j  a v  a  2  s  . c o  m
        return fSpecialColor;
    } else if (element instanceof IType && isInDifferentHierarchyScope((IType) element)) {
        return JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
    }
    return null;
}

From source file:ext.org.eclipse.jdt.internal.ui.viewsupport.ColoredViewersManager.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME) || property.equals(INHERITED_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                updateAllViewers();/*from  www  .j a v a2s  .com*/
            }
        });
    }
}

From source file:no.resheim.elibrarium.epub.ui.reader.EpubReader.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    Composite c = new Composite(parent, SWT.NONE);
    c.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from w w  w.ja va 2  s .  c  om
    layout.marginTop = 0;
    c.setLayout(layout);
    c.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    GridData gdHeader = new GridData(SWT.CENTER, SWT.TOP, true, false);
    gdHeader.minimumWidth = 500;
    headerLabel = new Label(c, SWT.CENTER);
    headerLabel.setLayoutData(gdHeader);
    headerLabel.setText(" ");
    headerLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));

    GridData gdBookmark = new GridData(SWT.CENTER, SWT.BEGINNING, false, false);
    gdBookmark.minimumWidth = 32;
    gdBookmark.widthHint = 32;
    gdBookmark.verticalSpan = 3;
    bookmarkLabel = new Label(c, SWT.CENTER);
    bookmarkLabel
            .setImage(EpubUiPlugin.getDefault().getImageRegistry().get(EpubUiPlugin.IMG_BOOKMARK_INACTIVE));
    bookmarkLabel.setLayoutData(gdBookmark);
    bookmarkLabel.addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent e) {
        }

        @Override
        public void mouseDown(MouseEvent e) {
            toggleBookmark();
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
        }
    });

    // We rely on having a WebKit based browser
    GridData gdBrowser = new GridData(SWT.FILL, SWT.FILL, true, true);
    browser = new Browser(c, SWT.WEBKIT);
    browser.setLayoutData(gdBrowser);
    browser.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));

    GridData gdFooter = new GridData(SWT.CENTER, SWT.BOTTOM, true, false);
    gdFooter.minimumWidth = 500;
    footerLabel = new Label(c, SWT.CENTER);
    gdFooter.horizontalSpan = 2;
    footerLabel.setLayoutData(gdFooter);
    footerLabel.setText(" ");
    footerLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));

    // Install listener to figure out when we need to re-paginate
    resizeListener = new ResizeListener();
    browser.addControlListener(resizeListener);
    browser.getDisplay().addFilter(SWT.MouseDown, resizeListener);
    browser.getDisplay().addFilter(SWT.MouseUp, resizeListener);

    // Various javascript
    installInjector();

    // Handle key-presses
    installKeyListener();

    // These events are triggered when the location of the browser has
    // changed, that is when the URL has changed. It may or may not be
    // within the document currently open. It does normally not change when
    // browsing between pages unless the chapter has been changed.
    // browser.addLocationListener(new LocationListener() {
    //
    // @Override
    // public void changed(LocationEvent event) {
    // updateLocation();
    // }
    //
    // @Override
    // public void changing(LocationEvent event) {
    // }
    // });

    browser.setCapture(false);
    if (browser != null) {
        if (initialURL != null) {
            browser.setUrl(initialURL);
        }
    }

    new MarkTextHandler(browser);

    // Create a new menu for the browser. We want this dynamically populated
    // so all items are removed when the menu is shown and it will be
    // re-populated.
    menu = new Menu(browser);
    browser.setMenu(menu);
    menu.addListener(SWT.Show, new Listener() {
        public void handleEvent(Event event) {
            MenuItem[] menuItems = menu.getItems();
            for (MenuItem menuItem : menuItems) {
                menuItem.dispose();
            }
            populateMenu();
        }
    });

}

From source file:no.resheim.elibrarium.epub.ui.reader.TOCOutlinePage.java

License:Open Source License

private void installLabelProvider(final TableViewerColumn column) {
    final PrettyTime pt = new PrettyTime();
    column.setLabelProvider(new OwnerDrawLabelProvider() {

        @Override/*  ww  w .  j  a  v  a  2  s.com*/
        protected void paint(Event event, Object element) {
            GC gc = event.gc;
            Display display = column.getViewer().getControl().getDisplay();
            Bookmark bookmark = (Bookmark) element;
            String date = pt.format(bookmark.getTimestamp());
            int width = column.getColumn().getWidth();
            // Calculate the size of the date string
            Point size = event.gc.textExtent(date, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
            int halfHeight = size.y / 2;
            int height = size.y;
            // if ((event.detail & SWT.SELECTED) != 0) {
            // Region region = new Region();
            // gc.getClipping(region);
            // region.translate(10, 10);
            // // region.add(event.x, event.y - halfHeight, width,
            // // event.height - halfHeight);
            // gc.setClipping(region);
            // region.dispose();
            //
            // Rectangle rect = event.getBounds();
            // Color foreground = gc.getForeground();
            // Color background = gc.getBackground();
            // gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
            // gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
            // gc.fillGradientRectangle(0, rect.y, 500, rect.height, false);
            // // restore colors for subsequent drawing
            // gc.setForeground(foreground);
            // gc.setBackground(background);
            // event.detail &= ~SWT.SELECTED;
            // }

            // Draw the date
            gc.setFont(getFont(DATE_FONT));
            gc.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
            gc.drawText(date, width - size.x, event.y + size.y, true);
            // Paint the page number of the bookmark
            int pageNumber = bookmark.getPage();
            String page = Integer.toString(pageNumber);
            Point pageSize = event.gc.textExtent(page, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
            gc.drawText(page, width - 16 - pageSize.x, event.y, true);
            // Draw icon
            if (bookmark instanceof TextAnnotation) {
            } else {
                int x = width - 9;
                gc.drawImage(EpubUiPlugin.getDefault().getImageRegistry().get(EpubUiPlugin.IMG_BOOKMARK), x,
                        event.y + 1);
            }
            // Draw title
            gc.setFont(getFont(TITLE_FONT));
            gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
            // Make sure text does not span to far
            Region region = new Region();
            gc.getClipping(region);
            region.subtract(width - 32 - pageSize.x, event.y, width, height);
            gc.setClipping(region);
            region.dispose();
            String text = bookmark.getText();
            if (text == null) {
                text = "<missing text>";
            }
            if (bookmark instanceof TextAnnotation) {
                if ((event.detail & SWT.SELECTED) == 0) {
                    gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
                    gc.drawText(text, event.x + 1, event.y, false);
                } else {
                    gc.drawText(text, event.x + 1, event.y, true);
                }
            } else {
                gc.drawText(text, event.x + 1, event.y, true);
            }
            // Draw separator
            drawUnderline(event, gc, width, size, halfHeight);
        }

        public Font getFont(String fontName) {
            IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
            ITheme currentTheme = themeManager.getCurrentTheme();

            FontRegistry fontRegistry = currentTheme.getFontRegistry();
            Font font = fontRegistry.get(fontName);
            return font;
        }

        /**
         * Draws a separator between the rows.
         */
        public void drawUnderline(Event event, GC gc, int width, Point size, int halfHeight) {
            int y = (event.y + size.y * 2) + halfHeight - 2;
            int center = (width / 2);
            gc.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
            gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
            gc.fillGradientRectangle(center, y, center, 1, false);
            gc.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
            gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
            gc.fillGradientRectangle(0, y, center, 1, false);
        }

        @Override
        protected void measure(Event event, Object element) {
            String text = "A";
            Point size = event.gc.textExtent(text, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
            event.width = bookmarks.getTable().getColumn(event.index).getWidth();
            // we need two lines of text and some space
            int halfHeight = size.y / 2;
            event.height = size.y * 2 + halfHeight;
        }
    });
}

From source file:org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider.java

License:Open Source License

private void initStyle() {
    italicGrey = new StyledString.Styler() {
        @Override/*from w w w  . ja va 2 s.c  o  m*/
        public void applyStyles(TextStyle textStyle) {
            textStyle.font = BonitaStudioFontRegistry.getTransientDataFont();
            textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
        }
    };
}