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.goko.log.part.model.ProblemTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    if (element == null) {
        super.update(cell);
        return;/*from  w  w w  .ja  va 2s .co  m*/
    }
    JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, HYPERLINK_COLOR);
    StyledString styledString = new StyledString();

    if (element instanceof LogLevelNode) {
        LogLevelNode logNode = (LogLevelNode) element;
        if (targetColumn == COLUMN_DESCRIPTION) {
            styledString.append(logNode.getLabel());
            styledString.append(" (" + CollectionUtils.size(logNode.getMessages()) + ")",
                    StyledString.COUNTER_STYLER);
            cell.setImage(getImage(element));

        }
    } else if (element instanceof ApplicativeLogEvent) {
        ApplicativeLogEvent event = (ApplicativeLogEvent) element;
        if (targetColumn == COLUMN_DESCRIPTION) {
            styledString.append(event.getMessage());
        } else if (targetColumn == COLUMN_SOURCE) {
            styledString.append(event.getSource());
        } else if (targetColumn == COLUMN_DATE) {
            DateFormat df = new SimpleDateFormat("HH:mm:ss");
            styledString.append(df.format(event.getDate()));
        }
    } else {
        styledString.append(String.valueOf(element));
    }

    cell.setText(styledString.getString());
    cell.setStyleRanges(styledString.getStyleRanges());

    super.update(cell);
}

From source file:org.hibernate.eclipse.console.wizards.ConsoleConfigurationWizardPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//*from w ww  .  j  av  a 2 s  .c  o  m*/
public void createControl(Composite parent) {
    final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);

    Composite container = new Composite(sc, SWT.NONE);

    GridLayout layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    layout.horizontalSpacing = 5;
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(gd);

    nameLabel = new Label(container, SWT.HORIZONTAL | SWT.LEFT);
    nameLabel.setText(HibernateConsoleMessages.ConsoleConfigurationWizardPage_name);
    nameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));

    nameWidget = new Text(container, SWT.SINGLE | SWT.BORDER);
    nameWidget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    tabFolder = new CTabFolder(container, SWT.TOP | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    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$
    tabFolder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    tabFolder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
    tabFolder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
    tabFolder.setLayoutData(gd);
    tabFolder.setBorderVisible(true);
    tabFolder.setFont(parent.getFont());

    sc.setContent(container);

    initTabs(tabFolder);

    try {
        performStart();
    } catch (CoreException ce) {
        HibernateConsolePlugin.getDefault().showError(getShell(),
                HibernateConsoleMessages.AddConfigurationAction_problem_add_console_config, ce);
    }
    try {
        initialize(currentLaunchConfig, selection);
    } catch (CoreException ce) {
        HibernateConsolePlugin.getDefault().logErrorMessage(
                HibernateConsoleMessages.ConsoleConfigurationWizardPage_problem_while_initializing_cc, ce);
    }
    performInit();

    ModifyListener modifyListener = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    };
    nameWidget.addModifyListener(modifyListener);

    setActiveTab(0);
    sc.setMinSize(tabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    setControl(sc);
    dialogChanged();
    parent.layout(true, false);
}

From source file:org.jboss.reddeer.jface.test.viewer.PrepareTreeWithStyledItems.java

License:Open Source License

@Before
public void setUp() {
    org.jboss.reddeer.core.util.Display.syncExec(new Runnable() {
        @Override// w w  w. j  a  v  a 2  s .  c om
        public void run() {
            JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, new RGB(0, 127, 174));

            Shell shell = new Shell(Display.getDefault(), SWT.CLOSE | SWT.RESIZE);
            shell.setText(title);
            shell.setSize(400, 450);
            shell.setLayout(new GridLayout(1, true));

            Composite composite = createPartControl(shell);
            composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

            shell.open();
        }
    });
}

From source file:org.jboss.reddeer.jface.test.viewer.TreeViewerHandlerTest.java

License:Open Source License

@Before
public void setUp() {
    org.jboss.reddeer.core.util.Display.syncExec(new Runnable() {
        @Override//from  w w w .  j  a v  a2  s.  c om
        public void run() {
            JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, new RGB(0, 127, 174));

            Shell shell = new Shell(Display.getDefault(), SWT.CLOSE | SWT.RESIZE);
            shell.setText(title);
            shell.setSize(400, 400);
            shell.setLayout(new GridLayout(2, false));

            Composite composite = createPartControl(shell);
            composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

            shell.open();
        }
    });
}

From source file:org.jboss.tools.central.editors.xpl.ConnectorDescriptorItemUi.java

License:Open Source License

public ConnectorDescriptorItemUi(DiscoveryViewer discoveryViewer, final DiscoveryConnector connector,
        Composite categoryChildrenContainer, Color background, Font titleFont, Image infoImage) {

    if (colorDisabled == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_DARK_GRAY)) {
            colorRegistry.put(COLOR_DARK_GRAY, new RGB(0x69, 0x69, 0x69));
        }/*  w ww  .  j  a va  2s .c  om*/
        colorDisabled = colorRegistry.get(COLOR_DARK_GRAY);
    }

    this.discoveryViewer = discoveryViewer;
    this.titleFont = titleFont;
    this.connector = connector;
    this.infoImage = infoImage;

    display = categoryChildrenContainer.getDisplay();
    connector.addPropertyChangeListener(this);

    connectorContainer = new Composite(categoryChildrenContainer, SWT.NULL);

    connectorContainer.setBackground(background);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(connectorContainer);
    GridLayout layout = new GridLayout(5, false);
    layout.marginLeft = 7;
    layout.marginTop = 2;
    layout.marginBottom = 2;
    connectorContainer.setLayout(layout);

    checkboxContainer = new Composite(connectorContainer, SWT.NULL);
    checkboxContainer.setBackground(background);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.BEGINNING).span(1, 2).applyTo(checkboxContainer);
    GridLayoutFactory.fillDefaults().spacing(1, 1).numColumns(2).applyTo(checkboxContainer);

    checkbox = new Button(checkboxContainer, SWT.CHECK);
    checkbox.setText(" "); //$NON-NLS-1$
    // help UI tests
    checkbox.setData("connectorId", connector.getId()); //$NON-NLS-1$
    checkbox.setVisible(connector.isInstallable());
    checkbox.setSelection(connector.isSelected());
    checkbox.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            ConnectorDescriptorItemUi.this.discoveryViewer.showConnectorControl(ConnectorDescriptorItemUi.this);
        }
    });
    this.isRealConnector = JBossDiscoveryUi.isInstallableConnector(connector);
    checkbox.setVisible(this.isRealConnector);
    checkbox.setEnabled(this.isRealConnector);

    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(checkbox);

    iconLabel = new Label(checkboxContainer, SWT.NULL);
    iconLabel.setBackground(background);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(iconLabel);

    if (connector.getIcon() != null) {
        iconImage = DiscoveryViewer.computeIconImage(connector.getSource(), connector.getIcon(), 32, false);
        this.disposables.add(iconImage);
        if (iconImage != null) {
            iconLabel.setImage(iconImage);
        }
    }

    nameLabel = new Label(connectorContainer, SWT.NULL);
    nameLabel.setBackground(background);
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(nameLabel);
    nameLabel.setFont(this.titleFont);
    nameLabel.setText(connector.getName());

    this.statusLabel = new Label(connectorContainer, SWT.NULL);
    this.statusLabel.setBackground(background);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(this.statusLabel);
    setUpToDateStatus();
    // As resolution of version is a long operation, we create a job for that
    if (this.connector.isInstalled()) {
        createAndScheduleConnectorUnitJob();
    }

    providerLabel = new Link(connectorContainer, SWT.RIGHT);
    providerLabel.setBackground(background);
    GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(providerLabel);
    if (connector.getCertification() != null) {
        providerLabel.setText(NLS.bind(org.jboss.tools.central.Messages.DiscoveryViewer_Certification_Label0,
                new String[] { connector.getProvider(), connector.getLicense(),
                        connector.getCertification().getName() }));
        if (connector.getCertification().getUrl() != null) {
            providerLabel.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    BrowserUtil.openUrl(connector.getCertification().getUrl(),
                            IWorkbenchBrowserSupport.AS_EXTERNAL);
                }
            });
        }
        Overview overview = new Overview();
        overview.setSummary(connector.getCertification().getDescription());
        overview.setUrl(connector.getCertification().getUrl());
        Image image = DiscoveryViewer.computeIconImage(connector.getSource(),
                connector.getCertification().getIcon(), 48, true);
        DiscoveryViewer.hookTooltip(providerLabel, providerLabel, connectorContainer, providerLabel,
                connector.getSource(), overview, image);
    } else {
        providerLabel.setText(NLS.bind(Messages.ConnectorDiscoveryWizardMainPage_provider_and_license,
                connector.getProvider(), connector.getLicense()));
    }

    if (hasTooltip(connector)) {
        ToolBar toolBar = new ToolBar(connectorContainer, SWT.FLAT);
        toolBar.setBackground(background);

        infoButton = new ToolItem(toolBar, SWT.PUSH);
        infoButton.setImage(this.infoImage);
        infoButton.setToolTipText(Messages.ConnectorDiscoveryWizardMainPage_tooltip_showOverview);
        DiscoveryViewer.hookTooltip(toolBar, infoButton, connectorContainer, nameLabel, connector.getSource(),
                connector.getOverview(), null);
        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar);
    } else {
        Label label = new Label(connectorContainer, SWT.NULL);
        label.setText(" "); //$NON-NLS-1$
        label.setBackground(background);
    }

    description = new Label(connectorContainer, SWT.NULL | SWT.WRAP);
    description.setBackground(background);

    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).hint(100, SWT.DEFAULT).applyTo(description);
    String descriptionText = connector.getDescription();
    int maxDescriptionLength = 162;
    if (descriptionText.length() > maxDescriptionLength) {
        descriptionText = descriptionText.substring(0, maxDescriptionLength);
    }
    description.setText(descriptionText.replaceAll("(\\r\\n)|\\n|\\r", " ")); //$NON-NLS-1$ //$NON-NLS-2$

    // always disabled color to make it less prominent
    providerLabel.setForeground(this.colorDisabled);

    if (this.isRealConnector) {
        checkbox.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }

            public void widgetSelected(SelectionEvent e) {
                boolean selected = checkbox.getSelection();
                maybeModifySelection(selected);
            }
        });
        MouseListener connectorItemMouseListener = new MouseAdapter() {
            @Override
            public void mouseUp(MouseEvent e) {
                boolean selected = !checkbox.getSelection();
                if (maybeModifySelection(selected)) {
                    checkbox.setSelection(selected);
                }
            }
        };
        checkboxContainer.addMouseListener(connectorItemMouseListener);
        connectorContainer.addMouseListener(connectorItemMouseListener);
        iconLabel.addMouseListener(connectorItemMouseListener);
        nameLabel.addMouseListener(connectorItemMouseListener);
        // the provider has clickable links
        // providerLabel.addMouseListener(connectorItemMouseListener);
        description.addMouseListener(connectorItemMouseListener);
    }
}

From source file:org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyValueCellLabelProvider.java

License:Open Source License

protected void createLink(IProperty property, final ViewerCell cell) {
    if (StringUtils.isEmpty(property.getValue())) {
        return;//from  ww  w .  j a va 2s . c  om
    }
    final Hyperlink link = new Hyperlink((Tree) cell.getControl(), SWT.NONE); // SWT.NO_BACKGROUND
    link.setBackground(cell.getBackground());
    link.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR));
    link.setFont(cell.getFont());
    link.setUnderlined(true);
    link.setText(property.getValue());
    link.setBackground(cell.getBackground());
    link.addMouseListener(onLinkClicked(property.getValue()));

    TreeUtils.createTreeEditor(link, property.getValue(), cell);
}

From source file:org.jboss.tools.windup.ui.internal.rules.delegate.BaseTabStack.java

License:Open Source License

protected void createFolder(Composite parent) {
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    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$
    folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.FLAT);
    folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    folder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
    folder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
    folder.setBorderVisible(true);//ww  w  .j  a  va2  s .  c  om
    GridDataFactory.fillDefaults().grab(true, true).applyTo(folder);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    folder.setLayoutData(gd);
    folder.setFont(parent.getFont());
    folder.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            CTabItem item = folder.getSelection();
            tabItemSelected(item);
        }
    });
}

From source file:org.jboss.tools.windup.ui.internal.rules.delegate.ClassificationDescriptionTab.java

License:Open Source License

private CTabFolder createDescriptionSection(Composite parent) {
    parent = toolkit.createComposite(parent);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5).applyTo(parent);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);

    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$
    CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.FLAT);
    folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    folder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
    folder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
    folder.setBorderVisible(true);//from   w  w  w. j a va 2 s  .  c  o m
    GridDataFactory.fillDefaults().grab(true, true).applyTo(folder);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    folder.setLayoutData(gd);
    folder.setFont(parent.getFont());
    return folder;
}

From source file:org.jboss.tools.windup.ui.internal.rules.delegate.HintMessageTab.java

License:Open Source License

private CTabFolder createMessagesSection(Composite parent) {
    parent = toolkit.createComposite(parent);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5).applyTo(parent);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);

    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$
    CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.FLAT);
    folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    folder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$
    folder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
    folder.setBorderVisible(true);/* w  w w .j  av a2 s. c  o  m*/
    GridDataFactory.fillDefaults().grab(true, true).applyTo(folder);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    folder.setLayoutData(gd);
    folder.setFont(parent.getFont());
    return folder;
}

From source file:org.jeelee.utils.MessageTooltips.java

License:Open Source License

@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    setColor(comp);/*ww w .  j  a  v  a2s .  co m*/

    GridLayout gl = new GridLayout(1, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    gl.verticalSpacing = 1;
    comp.setLayout(gl);

    Composite topArea = new Composite(comp, SWT.NONE);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.widthHint = 200;
    topArea.setLayoutData(data);
    setColor(topArea);

    gl = new GridLayout(2, false);
    gl.marginBottom = 2;
    gl.marginTop = 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 5;
    gl.marginRight = 2;

    topArea.setLayout(gl);

    titleLabel = new CLabel(topArea, SWT.NONE);
    titleLabel.setText(title);
    titleLabel.setFont(JFaceResources.getFontRegistry().get("org.eclipse.jface.TOOLTIP_HEAD_FONT"));
    titleLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
    titleLabel.addMouseListener(mouseListener);
    setColor(titleLabel);

    Composite iconComp = new Composite(topArea, SWT.NONE);
    iconComp.setLayoutData(new GridData());
    iconComp.setLayout(new GridLayout(2, false));
    setColor(iconComp);

    gl = new GridLayout(2, false);
    gl.marginBottom = 0;
    gl.marginTop = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.marginLeft = 0;
    gl.marginRight = 0;
    iconComp.setLayout(gl);

    PluginResources r = SharedResources.getResources();

    if ((style & ShowHelpIcon) != 0) {
        Label helpIcon = new Label(iconComp, SWT.NONE);
        helpIcon.setBackground(
                JFaceResources.getColorRegistry().get("org.eclipse.jface.TOOLTIP_HEAD_BG_COLOR"));
        helpIcon.setImage(r.getImage("help"));
        helpIcon.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                hide();
            }
        });
        setColor(helpIcon);
    }

    Label closeIcon = new Label(iconComp, SWT.NONE);
    closeIcon.setImage(r.getImage("close"));
    closeIcon.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            parentShell.setFocus();
            hide();
        }
    });
    setColor(closeIcon);

    Composite messageComposite = new Composite(comp, SWT.NONE);
    messageComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    FillLayout layout = new FillLayout();
    layout.marginWidth = 5;
    messageComposite.setLayout(layout);

    messageLabel = new CLabel(messageComposite, SWT.NONE);
    messageLabel.setText(message);
    messageLabel.addMouseListener(mouseListener);
    setColor(messageLabel);

    return comp;
}