Example usage for org.eclipse.jface.resource JFaceResources getColorRegistry

List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getColorRegistry.

Prototype

public static ColorRegistry getColorRegistry() 

Source Link

Document

Returns the color registry for JFace itself.

Usage

From source file:org.eclipse.scada.core.ui.styles.generator.SimpleRuleStyleGenerator.java

License:Open Source License

@Override
public void dispose() {
    JFaceResources.getColorRegistry().removeListener(this.listener);
    this.resourceManager.dispose();
}

From source file:org.eclipse.tcf.internal.debug.ui.trace.TraceView.java

License:Open Source License

private void showTabs() {
    boolean b = false;
    if (no_data != null) {
        no_data.dispose();//from www  . ja va  2s .c om
        no_data = null;
        b = true;
    }
    if (tabs == null && !parent.isDisposed()) {
        tabs = new CTabFolder(parent, SWT.FLAT | SWT.CLOSE);
        ColorRegistry reg = JFaceResources.getColorRegistry();
        Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"); //$NON-NLS-1$
        Color c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); //$NON-NLS-1$
        tabs.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
        tabs.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
        tabs.setSimple(PlatformUI.getPreferenceStore()
                .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
        tabs.addCTabFolder2Listener(new CTabFolder2Adapter() {
            public void close(CTabFolderEvent event) {
                CTabItem s = (CTabItem) event.item;
                Page p = tab2page.get(s);
                if (p != null)
                    p.dispose();
                else
                    s.dispose();
                event.doit = false;
            }
        });
        Menu menu = new Menu(tabs);
        MenuItem mi_close = new MenuItem(menu, SWT.NONE);
        mi_close.setText("Close");
        mi_close.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                if (tabs == null)
                    return;
                CTabItem s = tabs.getSelection();
                Page p = tab2page.get(s);
                if (p != null)
                    p.dispose();
                else
                    s.dispose();
            }
        });
        MenuItem mi_close_all = new MenuItem(menu, SWT.NONE);
        mi_close_all.setText("Close All");
        mi_close_all.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                if (tabs == null)
                    return;
                CTabItem[] s = tabs.getItems();
                for (CTabItem i : s) {
                    Page p = tab2page.get(i);
                    if (p != null)
                        p.dispose();
                    else
                        i.dispose();
                }
            }
        });
        tabs.setMenu(menu);
        b = true;
    }
    if (b)
        parent.layout();
}

From source file:org.eclipse.team.svn.ui.discovery.wizards.ConnectorDiscoveryWizardMainPage.java

License:Open Source License

private void initializeColors() {
    if (colorWhite == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_WHITE)) {
            colorRegistry.put(COLOR_WHITE, new RGB(255, 255, 255));
        }//ww w.  j av a 2 s  .c  o m
        colorWhite = colorRegistry.get(COLOR_WHITE);
    }
    if (colorDisabled == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_DARK_GRAY)) {
            colorRegistry.put(COLOR_DARK_GRAY, new RGB(0x69, 0x69, 0x69));
        }
        colorDisabled = colorRegistry.get(COLOR_DARK_GRAY);
    }

    if (colorCategoryGradientStart == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_CATEGORY_GRADIENT_START)) {
            colorRegistry.put(COLOR_CATEGORY_GRADIENT_START, new RGB(240, 240, 240));
        }
        colorCategoryGradientStart = colorRegistry.get(COLOR_CATEGORY_GRADIENT_START);
    }

    if (colorCategoryGradientEnd == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_CATEGORY_GRADIENT_END)) {
            colorRegistry.put(COLOR_CATEGORY_GRADIENT_END, new RGB(220, 220, 220));
        }
        colorCategoryGradientEnd = colorRegistry.get(COLOR_CATEGORY_GRADIENT_END);
    }
}

From source file:org.eclipse.team.svn.ui.discovery.wizards.OverviewToolTip.java

License:Open Source License

@Override
protected Composite createToolTipArea(Event event, final Composite parent) {
    if (colorBlack == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_BLACK)) {
            colorRegistry.put(COLOR_BLACK, new RGB(0, 0, 0));
        }//from   w ww. j  ava2  s.c om
        colorBlack = colorRegistry.get(COLOR_BLACK);
    }

    GridLayoutFactory.fillDefaults().applyTo(parent);

    Composite container = new Composite(parent, SWT.NULL);
    container.setBackground(null);

    Image image = null;
    if (overview.getScreenshot() != null) {
        image = computeImage(source, overview.getScreenshot());
        if (image != null) {
            final Image fimage = image;
            container.addDisposeListener(new DisposeListener() {
                public void widgetDisposed(DisposeEvent e) {
                    fimage.dispose();
                }
            });
        }
    }
    final boolean hasLearnMoreLink = overview.getUrl() != null && overview.getUrl().length() > 0;

    final int borderWidth = 1;
    final int fixedImageHeight = 240;
    final int fixedImageWidth = 320;
    final int heightHint = fixedImageHeight + (borderWidth * 2);
    final int widthHint = fixedImageWidth;

    final int containerWidthHintWithImage = 650;
    final int containerWidthHintWithoutImage = 500;

    GridDataFactory.fillDefaults().grab(true, true)
            .hint(image == null ? containerWidthHintWithoutImage : containerWidthHintWithImage, SWT.DEFAULT)
            .applyTo(container);

    GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).spacing(3, 0).applyTo(container);

    String summary = overview.getSummary();

    Composite summaryContainer = new Composite(container, SWT.NULL);
    summaryContainer.setBackground(null);
    GridLayoutFactory.fillDefaults().applyTo(summaryContainer);

    GridDataFactory gridDataFactory = GridDataFactory.fillDefaults().grab(true, true)
            .span(image == null ? 2 : 1, 1);
    if (image != null) {
        gridDataFactory.hint(widthHint, heightHint);
    }
    gridDataFactory.applyTo(summaryContainer);

    Label summaryLabel = new Label(summaryContainer, SWT.WRAP);
    summaryLabel.setText(summary);
    summaryLabel.setBackground(null);

    GridDataFactory.fillDefaults().grab(true, true).align(SWT.BEGINNING, SWT.BEGINNING).applyTo(summaryLabel);

    if (image != null) {
        final Composite imageContainer = new Composite(container, SWT.BORDER);
        GridLayoutFactory.fillDefaults().applyTo(imageContainer);

        GridDataFactory.fillDefaults().grab(false, false).align(SWT.CENTER, SWT.BEGINNING)
                .hint(widthHint + (borderWidth * 2), heightHint).applyTo(imageContainer);

        Label imageLabel = new Label(imageContainer, SWT.NULL);
        GridDataFactory.fillDefaults().hint(widthHint, fixedImageHeight).indent(borderWidth, borderWidth)
                .applyTo(imageLabel);
        imageLabel.setImage(image);
        imageLabel.setBackground(null);
        imageLabel.setSize(widthHint, fixedImageHeight);

        // creates a border
        imageContainer.setBackground(colorBlack);
    }

    if (hasLearnMoreLink) {
        Link link = new Link(summaryContainer, SWT.NULL);
        GridDataFactory.fillDefaults().grab(false, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(link);
        link.setText(SVNUIMessages.ConnectorDescriptorToolTip_detailsLink);
        link.setBackground(null);
        link.setToolTipText(SVNUIMessages.format(SVNUIMessages.ConnectorDescriptorToolTip_detailsLink_tooltip,
                overview.getUrl()));
        link.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e) {
                WorkbenchUtil.openUrl(overview.getUrl(), IWorkbenchBrowserSupport.AS_EXTERNAL);
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
    }

    if (image == null) {
        // prevent overviews with no image from providing unlimited text.
        Point optimalSize = summaryContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        if (optimalSize.y > (heightHint + 10)) {
            ((GridData) summaryContainer.getLayoutData()).heightHint = heightHint;
            container.layout(true);
        }
    }
    // hack: cause the tooltip to gain focus so that we can capture the escape key
    //       this must be done async since the tooltip is not yet visible.
    Display.getCurrent().asyncExec(new Runnable() {
        public void run() {
            if (!parent.isDisposed()) {
                parent.setFocus();
            }
        }
    });
    return container;
}

From source file:org.eclipse.tm.internal.terminal.textcanvas.StyleMap.java

License:Open Source License

private void setColor(Map colorMap, String name, int r, int g, int b) {
    String colorName = PREFIX + r + "-" + g + "-" + b; //$NON-NLS-1$//$NON-NLS-2$
    Color color = JFaceResources.getColorRegistry().get(colorName);
    if (color == null) {
        JFaceResources.getColorRegistry().put(colorName, new RGB(r, g, b));
        color = JFaceResources.getColorRegistry().get(colorName);
    }/*w  ww  .  ja v  a  2  s .  c  om*/
    colorMap.put(StyleColor.getStyleColor(name), color);
    colorMap.put(StyleColor.getStyleColor(name.toUpperCase()), color);
}

From source file:org.eclipse.tm.te.ui.terminals.view.TerminalsView.java

License:Open Source License

/**
 * Configures the tab folder control./*from  w  w w  .  j a  va2 s . com*/
 *
 * @param tabFolder The tab folder control. Must not be <code>null</code>.
 */
protected void doConfigureTabFolderControl(CTabFolder tabFolder) {
    Assert.isNotNull(tabFolder);

    // Set the layout data
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Set the tab gradient coloring from the global preferences
    if (useGradientTabBackgroundColor()) {
        tabFolder.setSelectionBackground(new Color[] {
                JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$
                JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END") //$NON-NLS-1$
        }, new int[] { 100 }, true);
    }
    // Apply the tab folder selection foreground color
    tabFolder.setSelectionForeground(
            JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$

    // Set the tab style from the global preferences
    tabFolder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
}

From source file:org.eclipse.tm.terminal.view.ui.view.TerminalsView.java

License:Open Source License

/**
 * Configures the tab folder control.//w w  w.jav a  2s  .c  o m
 *
 * @param tabFolder The tab folder control. Must not be <code>null</code>.
 */
protected void doConfigureTabFolderControl(final CTabFolder tabFolder) {
    Assert.isNotNull(tabFolder);

    // Set the layout data
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Set the tab gradient coloring from the global preferences
    if (useGradientTabBackgroundColor()) {
        tabFolder.setSelectionBackground(new Color[] {
                JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$
                JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END") //$NON-NLS-1$
        }, new int[] { 100 }, true);
    }
    // Apply the tab folder selection foreground color
    tabFolder.setSelectionForeground(
            JFaceResources.getColorRegistry().get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$

    // Set the tab style from the global preferences
    tabFolder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));

    // Attach the mouse listener
    tabFolder.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            if (e.button == 2) {
                // middle mouse button click - close tab
                CTabItem item = tabFolder.getItem(new Point(e.x, e.y));
                if (item != null)
                    item.dispose();
            }
        }
    });
}

From source file:org.eclipse.ui.console.TextConsoleViewer.java

License:Open Source License

/**
 * Constructs a new viewer in the given parent for the specified console.
 * //  ww w .ja v a 2  s  .c o m
 * @param parent
 *            containing widget
 * @param console
 *            text console
 */
public TextConsoleViewer(Composite parent, TextConsole console) {
    super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL);
    this.console = console;

    IDocument document = console.getDocument();
    setDocument(document);

    StyledText styledText = getTextWidget();
    styledText.setDoubleClickEnabled(true);
    styledText.addLineStyleListener(this);
    styledText.addLineBackgroundListener(this);
    styledText.setEditable(true);
    setFont(console.getFont());
    styledText.addMouseTrackListener(this);
    styledText.addListener(SWT.MouseUp, mouseUpListener);

    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    propertyChangeListener = new HyperlinkColorChangeListener();
    colorRegistry.addListener(propertyChangeListener);

    revealJob.setSystem(true);
    document.addDocumentListener(documentListener);
    document.addPositionUpdater(positionUpdater);
}

From source file:org.eclipse.ui.console.TextConsoleViewer.java

License:Open Source License

protected void handleDispose() {
    IDocument document = getDocument();/*  w  ww .  j  a  v a 2  s.c  o m*/
    if (document != null) {
        document.removeDocumentListener(documentListener);
        document.removePositionUpdater(positionUpdater);
    }

    StyledText styledText = getTextWidget();
    styledText.removeLineStyleListener(this);
    styledText.removeLineBackgroundListener(this);
    styledText.removeMouseTrackListener(this);

    if (handCursor != null) {
        handCursor.dispose();
    }
    handCursor = null;
    if (textCursor != null) {
        textCursor.dispose();
    }
    textCursor = null;
    hyperlink = null;
    console = null;

    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    colorRegistry.removeListener(propertyChangeListener);

    super.handleDispose();
}

From source file:org.eclipse.ui.internal.navigator.filters.CommonFilterSelectionDialog.java

License:Open Source License

private void customize() {
    ColorRegistry reg = JFaceResources.getColorRegistry();
    Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$
            c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); //$NON-NLS-1$
    customizationsTabFolder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    customizationsTabFolder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
    customizationsTabFolder.setSimple(true);
}