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

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

Introduction

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

Prototype

public static FontRegistry getFontRegistry() 

Source Link

Document

Returns the font registry for JFace itself.

Usage

From source file:org.eclipse.graphiti.ui.internal.util.draw2d.Tooltip.java

License:Open Source License

private Font getBoldFont() {
    return JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
}

From source file:org.eclipse.gyrex.admin.ui.internal.widgets.FilteredTree.java

License:Open Source License

/**
 * Return a bold font if the given element matches the given pattern.
 * Clients can opt to call this method from a Viewer's label provider to get
 * a bold font for which to highlight the given element in the tree.
 * /*from  w w  w .j a  v a2s . c o  m*/
 * @param element
 *            element for which a match should be determined
 * @param tree
 *            FilteredTree in which the element resides
 * @param filter
 *            PatternFilter which determines a match
 * @return bold font
 */
public static Font getBoldFont(final Object element, final FilteredTree tree, final PatternFilter filter) {
    final String filterText = tree.getFilterString();

    if (filterText == null)
        return null;

    // Do nothing if it's empty string
    final String initialText = tree.getInitialText();
    if (!filterText.equals("") && !filterText.equals(initialText)) {//$NON-NLS-1$
        if (tree.getPatternFilter() != filter) {
            final boolean initial = (initialText != null) && initialText.equals(filterText);
            if (initial) {
                filter.setPattern(null);
            } else if (filterText != null) {
                filter.setPattern(filterText);
            }
        }
        if (filter.isElementVisible(tree.getViewer(), element) && filter.isLeafMatch(tree.getViewer(), element))
            return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
    }
    return null;
}

From source file:org.eclipse.incquery.tooling.localsearch.ui.debugger.provider.MatchesTableLabelProvider.java

License:Open Source License

public MatchesTableLabelProvider(int i, boolean parameter, TableViewer viewer) {
    this.columnIndex = i;
    this.viewer = viewer;
    if (parameter) {
        FontRegistry fregistry = JFaceResources.getFontRegistry();
        boldFont = fregistry.getBold(JFaceResources.DEFAULT_FONT);
    }// ww  w.ja  v  a  2  s . com
}

From source file:org.eclipse.jdt.internal.debug.ui.console.JavaStackTraceConsole.java

License:Open Source License

/**
 * @see org.eclipse.ui.console.TextConsole#dispose()
 *///  w  w  w .j  av  a  2s  .  c o  m
@Override
protected void dispose() {
    saveDocument();
    JFaceResources.getFontRegistry().removeListener(propertyListener);
    super.dispose();
}

From source file:org.eclipse.jface.snippets.window.Snippet020CustomizedControlTooltips.java

License:Open Source License

public Snippet020CustomizedControlTooltips(final Shell parent) {
    JFaceResources.getColorRegistry().put(MyToolTip.HEADER_BG_COLOR, new RGB(255, 255, 255));
    JFaceResources.getFontRegistry().put(MyToolTip.HEADER_FONT, JFaceResources.getFontRegistry()
            .getBold(JFaceResources.getDefaultFont().getFontData()[0].getName()).getFontData());

    JFaceResources.getImageRegistry().put(MyToolTip.HEADER_CLOSE_ICON,
            ImageDescriptor.createFromFile(Snippet020CustomizedControlTooltips.class, "showerr_tsk.gif"));
    JFaceResources.getImageRegistry().put(MyToolTip.HEADER_HELP_ICON,
            ImageDescriptor.createFromFile(Snippet020CustomizedControlTooltips.class, "linkto_help.gif"));

    Text text = new Text(parent, SWT.BORDER);
    text.setText("Hello World");

    MyToolTip myTooltipLabel = new MyToolTip(text) {

        @Override//from ww w  .j  a v  a2  s  .c o m
        protected Composite createContentArea(Composite parent) {
            Composite comp = super.createContentArea(parent);
            comp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
            FillLayout layout = new FillLayout();
            layout.marginWidth = 5;
            comp.setLayout(layout);
            Link l = new Link(comp, SWT.NONE);
            l.setText(
                    "This a custom tooltip you can: \n- pop up any control you want\n- define delays\n - ... \nGo and get Eclipse from <a>http://www.eclipse.org</a>");
            l.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
            l.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    openURL();
                }
            });
            return comp;
        }

        protected void openURL() {
            MessageBox box = new MessageBox(parent, SWT.ICON_INFORMATION);
            box.setText("Eclipse.org");
            box.setMessage("Here is where we'd open the URL.");
            box.open();
        }

        @Override
        protected void openHelp() {
            MessageBox box = new MessageBox(parent, SWT.ICON_INFORMATION);
            box.setText("Info");
            box.setMessage("Here is where we'd show some information.");
            box.open();
        }

    };
    myTooltipLabel.setShift(new Point(-5, -5));
    myTooltipLabel.setHideOnMouseDown(false);
    myTooltipLabel.activate();

    text = new Text(parent, SWT.BORDER);
    text.setText("Hello World");
    DefaultToolTip toolTip = new DefaultToolTip(text);
    toolTip.setText("Hello World\nHello World");
    toolTip.setBackgroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_RED));

    Button b = new Button(parent, SWT.PUSH);
    b.setText("Popup on press");

    final DefaultToolTip toolTipDelayed = new DefaultToolTip(b, ToolTip.RECREATE, true);
    toolTipDelayed.setText("Hello World\nHello World");
    toolTipDelayed.setBackgroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
    toolTipDelayed.setHideDelay(2000);

    b.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            toolTipDelayed.show(new Point(0, 0));
        }
    });

}

From source file:org.eclipse.jpt.common.ui.internal.prefs.JptProblemSeveritiesPage.java

License:Open Source License

/**
 * Creates and adds to the given <code>Composite</code> an expandable pane
 * where its content can be shown or hidden depending on the expansion state.
 *
 * @param parent The parent container//from   w  w w .j  a  va  2 s.  co  m
 * @param text The title of the expandable section
 * @return The container to which widgets can be added, which is a child of
 * the expandable pane
 */
private Composite addExpandableSection(Composite parent, String text, GridData gridData) {
    int expansionStype = ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT;
    ExpandableComposite expandablePane = new ExpandableComposite(parent, SWT.NONE, expansionStype);

    expandablePane.setText(text);
    expandablePane.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    expandablePane.setLayoutData(gridData);
    expandablePane.addExpansionListener(this.buildExpansionListener());

    this.mainComposite.adaptChild(expandablePane);
    this.expandablePanes.add(expandablePane);

    parent = new Composite(expandablePane, SWT.NONE);
    parent.setLayout(new GridLayout(2, false));
    expandablePane.setClient(parent);

    return parent;
}

From source file:org.eclipse.jst.j2ee.internal.ui.JavaEEDeploymentAssemblyAdvancedSectionBuilder.java

License:Open Source License

private Composite createAdvancedSection(Composite parent) {

    // Build the expandable composite
    ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
    excomposite.setText(Messages.J2EEModuleDependenciesPropertyPage_ADVANCED);
    excomposite.setExpanded(false);//  ww w.ja v a2  s .  co m
    excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
    excomposite.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });

    // Build the composite has the contents of the expandable widget
    Composite innerComposite = new Composite(excomposite, SWT.NONE);
    excomposite.setClient(innerComposite);
    GridLayout gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    innerComposite.setLayout(gl);
    return innerComposite;
}

From source file:org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo.java

License:Open Source License

/**
 * Sets the receiver's list to be the given array of items.
 * // w  w w. j  a va 2  s  . co m
 * @param items
 *            the array of items
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
 *                <li>ERROR_INVALID_ARGUMENT - if an item in the items
 *                array is null</li>
 *                </ul>
 * @exception org.eclipse.swt.SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public void setItems(String[] items) {
    checkWidget();
    if (items == null) {
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
    }

    for (int i = 0; i < items.length; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        if (items[i].equals(defaultValue)) {
            item.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
        }
        item.setText(0, items[i]);
    }
}

From source file:org.eclipse.jst.jsf.common.ui.internal.utils.StyleCombo.java

License:Open Source License

/**
 * @param defaultValue//from ww w.  j  ava2s  . co  m
 */
public void setDefaultValue(String defaultValue) {
    this.defaultValue = defaultValue;
    int index = Arrays.asList(getTableItems()).indexOf(defaultValue);
    if (index != -1) {
        table.getItem(index).setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    }
}

From source file:org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure.java

License:Open Source License

/**
 * get the labe's font from preference./*from w  ww. j  a v a  2 s. com*/
 * 
 * @return
 */
private Font getLabelFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, GEMPreferences.FIGURE_LABEL_FONT);
    if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
        return registry.get(fontData.toString());

    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
}