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:com.netxforge.netxstudio.screens.monitoring.DashboardComponent.java

License:Open Source License

public void buildUI(Composite parent, Object layoutData) {

    parent.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            if (refreshSummaryJob != null) {
                refreshSummaryJob.cancel();
            }//  w  ww .  jav  a 2  s. c om
        }
    });

    content = formToolkit.createComposite(parent, showBorder ? SWT.BORDER : SWT.NONE);

    if (layoutData != null) {
        content.setLayoutData(layoutData);
    }
    formToolkit.paintBordersFor(content);
    content.setLayout(new GridLayout(4, false));

    final Label periodLabel = formToolkit.createLabel(content, "Period:", SWT.RIGHT);

    GridData gd_lblPeriod = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblPeriod.widthHint = 83;
    periodLabel.setLayoutData(gd_lblPeriod);

    formTextLastMonitor = formToolkit.createFormText(content, false);
    formTextLastMonitor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    // This is the dynamic portion.

    targetContent = formToolkit.createComposite(content, SWT.NONE);
    targetContent.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 4, 1));
    targetContent.setLayout(new FillLayout());

    // / RAG INFORMATION.
    final Composite separator = formToolkit.createCompositeSeparator(content);
    GridData gd_separator = new GridData(SWT.FILL, SWT.CENTER, true, false, 9, 1);
    gd_separator.heightHint = 2;
    separator.setLayoutData(gd_separator);
    formToolkit.paintBordersFor(separator);

    new Label(content, SWT.NONE);

    final Composite cmpRed = formToolkit.createComposite(content, SWT.NONE);
    cmpRed.setBackground(JFaceResources.getColorRegistry().get(ScreenUtil.RED_MARKER));
    GridData gd_cmpRed = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_cmpRed.heightHint = 18;
    gd_cmpRed.widthHint = 18;
    cmpRed.setLayoutData(gd_cmpRed);
    formToolkit.paintBordersFor(cmpRed);

    final Composite cmpAmber = formToolkit.createComposite(content, SWT.NONE);
    cmpAmber.setBackground(JFaceResources.getColorRegistry().get(ScreenUtil.AMBER_MARKER));
    GridData gd_cmpAmber = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_cmpAmber.widthHint = 18;
    gd_cmpAmber.heightHint = 18;
    cmpAmber.setLayoutData(gd_cmpAmber);
    formToolkit.paintBordersFor(cmpAmber);

    final Composite cmpGreen = formToolkit.createComposite(content, SWT.NONE);
    cmpGreen.setBackground(JFaceResources.getColorRegistry().get(ScreenUtil.GREEN_MARKER));
    GridData gd_cmpGreen = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_cmpGreen.widthHint = 18;
    gd_cmpGreen.heightHint = 18;
    cmpGreen.setLayoutData(gd_cmpGreen);
    formToolkit.paintBordersFor(cmpGreen);

    final Label lblRagStatus = formToolkit.createLabel(content, "RAG Status RES's:", SWT.NONE);
    lblRagStatus.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));

    formTextRed = formToolkit.createFormText(content, false);
    formToolkit.paintBordersFor(formTextRed);
    formTextRed.setText("R", false, false);

    formTextAmber = formToolkit.createFormText(content, false);
    formToolkit.paintBordersFor(formTextAmber);
    formTextAmber.setText("A", false, false);

    formTextGreen = formToolkit.createFormText(content, false);
    formToolkit.paintBordersFor(formTextGreen);
    formTextGreen.setText("G", false, false);
}

From source file:com.netxforge.screens.editing.base.util.WinForms.java

License:Open Source License

public void buildUI(Composite parent, FormToolkit toolkit) {
    this.toolkit = toolkit;
    canvas = new ScrolledComposite(parent, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);

    canvas.addListener(SWT.Activate, new Listener() {
        public void handleEvent(Event e) {
            content.setFocus();//  w  ww . ja v  a 2  s  . co  m
        }
    });

    toolkit.adapt(canvas);
    toolkit.paintBordersFor(canvas);
    canvas.setExpandVertical(true);
    canvas.setExpandHorizontal(true);

    content = toolkit.createComposite(canvas, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.spacing = 10;
    rowLayout.marginLeft = 10;
    rowLayout.marginTop = 10;
    rowLayout.marginRight = 10;

    content.setLayout(rowLayout);
    JFaceResources.getColorRegistry().put("canvas_color", new RGB(255, 250, 221));
    content.setBackground(JFaceResources.getColorRegistry().get("canvas_color"));
    toolkit.paintBordersFor(content);

    canvas.setContent(content);

    // When the row layout wraps, this changes the width of the content 
    // so we show a scrollbar when smaller than the computed width of the content.    
    canvas.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = canvas.getClientArea();
            canvas.setMinSize(content.computeSize(r.width, SWT.DEFAULT));
        }
    });

    // Add a local drop target to the content.
    // The windows will also support dropping stuff.

}

From source file:com.nokia.s60tools.imaker.internal.viewers.IMakerTabsViewer.java

License:Open Source License

/**
 * Creates the tab folder for displaying config instances
 * @param parent/*ww w. j  a  v a 2s  .com*/
 */
private void createTabFolder(Composite parent) {
    if (fTabFolder == null) {
        Composite tabComposite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout(1, false);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        tabComposite.setLayout(layout);
        tabComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
        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$
        fTabFolder = new CTabFolder(tabComposite, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT);

        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.horizontalSpan = 2;
        fTabFolder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
        fTabFolder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
        fTabFolder.setSimple(PlatformUI.getPreferenceStore()
                .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
        fTabFolder.setLayoutData(gd);
        fTabFolder.setBorderVisible(true);
        fTabFolder.setFont(tabComposite.getFont());
        fTabFolder.addSelectionListener(new SelectionListener() {

            //            @Override
            public void widgetSelected(SelectionEvent e) {
                if (e.item instanceof DebugTab) {
                    tabDebug.refesh();
                }
            }

            //            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
        createTabs(fTabFolder);
        fTabFolder.setSelection(0);
    }
}

From source file:com.rcpcompany.uibindings.extests.ColorsAndFontsTest.java

License:Open Source License

@Test
public void testColors() {
    assertNotNull(JFaceResources.getColorRegistry().get("ACTIVE_HYPERLINK_COLOR"));
    assertNotNull(JFaceResources.getColorRegistry()
            .get("com.rcpcompany.uibindings.colorDefinitions.EvenRowBackground"));
}

From source file:com.rcpcompany.uibindings.extests.manager.AlternatingRowColorsTest.java

License:Open Source License

/**
 * Tests the colors of the row alternates
 *///from  w  ww . j a v  a 2  s.c o  m
@Test
public void colorTest() {
    final TableItem[] items = myTable.getItems();
    final Color evenColor = JFaceResources.getColorRegistry()
            .get(Constants.COLOR_DEFINITIONS_EVEN_ROW_BACKGROUND);
    final Color oddColor = myTable.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    sleep(50);
    // First row is selected and therefore a different color
    for (int i = 0; i < items.length; i++) {
        final TableItem item = items[i];
        final Rectangle bounds = item.getBounds(myViewer.getFirstTableColumnOffset());

        Color c;
        if (i == 0) {
            if (myHasFocus) {
                final Color focusColor = JFaceResources.getColorRegistry()
                        .get(Constants.COLOR_DEFINITIONS_SELECTION_FOCUS_BACKGROUND);
                c = focusColor;
            } else {
                c = JFaceResources.getColorRegistry()
                        .get(Constants.COLOR_DEFINITIONS_SELECTION_NO_FOCUS_BACKGROUND);
            }
        } else if (i % 2 == 0 && myEnable) {
            c = evenColor;
        } else {
            c = oddColor;
        }
        assertPixelColor("enabled=" + myEnable + ", hasFocus=" + myHasFocus, myTable, bounds.x + 3,
                bounds.y + 3, c.getRGB());
    }
}

From source file:com.rcpcompany.uibindings.internal.validators.ViewerBindingMessageCollectionTest.java

License:Open Source License

@Before
public void before() {
    BaseUIBTestUtils.resetAll();/*from w w w  .  j  a  va  2s  .  c o m*/

    myValidatorManager = IValidatorAdapterManager.Factory.getManager();

    final IManager manager = IManager.Factory.getManager();
    manager.setTextCommitStrategy(TextCommitStrategy.ON_MODIFY);
    manager.setValidationErrorsAreFatal(myEIV);
    manager.setValidationDelay(VD);
    manager.setEditCellSingleClick(false);

    myNoFocusRGB = JFaceResources.getColorRegistry()
            .getRGB(Constants.COLOR_DEFINITIONS_SELECTION_NO_FOCUS_BACKGROUND);
    myEvenRGB = JFaceResources.getColorRegistry().getRGB(Constants.COLOR_DEFINITIONS_EVEN_ROW_BACKGROUND);

    createModel();
    createView();
}

From source file:com.rcpcompany.uibindings.uiAttributes.UIAttributePainter.java

License:Open Source License

/**
 * Constructs and returns a new UI Attribute painter for the specified parent control.
 * //  w  ww  .j av  a2 s  . c  om
 * @param parentControl the parent control
 * @param attribute the UI attribute
 */
public UIAttributePainter(Control parentControl, IUIAttribute attribute) {
    myParentControl = parentControl;
    myAttribute = attribute;

    /*
     * Here - and not static - as the Display may not be setup correctly before now
     */
    if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) {
        JFaceResources.getImageRegistry().put(UNCHECKED_KEY, makeShot(parentControl, false));
        JFaceResources.getImageRegistry().put(CHECKED_KEY, makeShot(parentControl, true));
    }
    final FormColors colors = IManager.Factory.getManager().getFormToolkit(parentControl).getColors();

    mySelectionBackground = JFaceResources.getColorRegistry()
            .get(Constants.COLOR_DEFINITIONS_SELECTION_FOCUS_BACKGROUND);
    mySelectionNoFocusBackground = JFaceResources.getColorRegistry()
            .get(Constants.COLOR_DEFINITIONS_SELECTION_NO_FOCUS_BACKGROUND);
    mySelectionForeground = myParentControl.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);

    myFocusBorder = colors.getBorderColor();
}

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

License:Open Source License

public void installColoredLabels(final ColoringLabelProvider labelProvider) {
    if (fManagedLabelProviders.contains(labelProvider))
        return;/*from w ww .j av a2s .co m*/

    if (fManagedLabelProviders.isEmpty()) {
        // first lp installed
        PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
        JFaceResources.getColorRegistry().addListener(this);
    }
    fManagedLabelProviders.add(labelProvider);
}

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

License:Open Source License

public void uninstallColoredLabels(final ColoringLabelProvider labelProvider) {
    if (!fManagedLabelProviders.remove(labelProvider))
        return; // not installed

    if (fManagedLabelProviders.isEmpty()) {
        PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
        JFaceResources.getColorRegistry().removeListener(this);
        // last viewer uninstalled
    }//from   w  ww.j a  v  a 2 s . c  o m
}

From source file:com.vectrace.MercurialEclipse.search.DecoratingMercurialTextSearchLabelProvider.java

License:Open Source License

@Override
public void dispose() {
    super.dispose();
    PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
    JFaceResources.getColorRegistry().removeListener(this);
}