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

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

Introduction

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

Prototype

String DIALOG_FONT

To view the source code for org.eclipse.jface.resource JFaceResources DIALOG_FONT.

Click Source Link

Document

The symbolic font name for the dialog font (value "org.eclipse.jface.dialogfont").

Usage

From source file:au.gov.ga.earthsci.discovery.ui.DiscoveryResultInformationControlCreator.java

License:Apache License

@Override
public IInformationControl createInformationControl(Shell parent) {
    if (BrowserInformationControl.isAvailable(parent)) {
        return new FocusableBrowserInformationControl(parent, JFaceResources.DIALOG_FONT, null, null);
    }/*from   w  ww .  j av a 2s .  co m*/
    return new DefaultInformationControl(parent, false);
}

From source file:au.gov.ga.earthsci.discovery.ui.DiscoveryResultInformationProvider.java

License:Apache License

/**
 * Load the named style sheet resource to a string.
 * //w w  w.  j  a va  2  s  .  c o  m
 * @param styleSheetName
 *            Style sheet filename to load
 * @return Style sheet content as a string
 */
public static String loadStyleSheet(String styleSheetName) {
    InputStream stream = DiscoveryResultInformationProvider.class.getResourceAsStream(styleSheetName);
    if (stream == null) {
        return null;
    }

    try {
        String sheet = Util.readStreamToString(stream, "UTF-8"); //$NON-NLS-1$
        FontData fontData = JFaceResources.getFontRegistry().getFontData(JFaceResources.DIALOG_FONT)[0];
        return HTMLPrinter.convertTopLevelFont(sheet, fontData);
    } catch (IOException ex) {
        return ""; //$NON-NLS-1$
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
            //ignore
        }
    }
}

From source file:au.gov.ga.earthsci.jface.extras.information.html.BrowserInformationControl.java

License:Open Source License

/**
 * Creates and initializes the text layout used
 * to compute the size hint.//from  w w w .ja v a 2s .  com
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout = new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName = fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    "); //$NON-NLS-1$
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] { tabWidth });
    fTextLayout.setText(""); //$NON-NLS-1$
}

From source file:bndtools.utils.MessagesPopupDialog.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*  w  w  w  .  j  a  v  a  2  s  .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:ccw.editors.clojure.hovers.CCWBrowserInformationControl.java

License:Open Source License

private void createTestWidget() {
    fTestWidget = new TextLayout(getShell().getDisplay());

    // Initialize fonts
    Font font = JFaceResources/*from w w  w  .ja  v  a  2s . com*/
            .getFont(fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName);
    fTestWidget.setFont(font);
    fTestWidget.setWidth(-1);

    // Compute and set tab width
    fTestWidget.setText("    "); //$NON-NLS-1$
    int tabWidth = fTestWidget.getBounds().width;
    fTestWidget.setTabs(new int[] { tabWidth });
    fTestWidget.setText(""); //$NON-NLS-1$
}

From source file:chuck.terran.admin.ui.jface.LineSelector.java

License:Open Source License

/**
 * Compute the size of the image to be displayed.
 *
 * @param window -/*from   w w w  .j a va  2 s  .  c om*/
 *            the window used to calculate
 * @return <code>Point</code>
 */
private Point computeImageSize(Control window) {
    GC gc = new GC(window);
    Font f = JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT);
    gc.setFont(f);
    int height = gc.getFontMetrics().getHeight();
    gc.dispose();
    Point p = new Point(height * 3 - 6, height);
    return p;
}

From source file:com.amalto.workbench.widgets.FilteredCheckboxTree.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  a  2s . com*/
 * @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(Object element, FilteredCheckboxTree tree, PatternFilter filter) {
    String filterText = tree.getFilterString();

    if (filterText == null) {
        return null;
    }

    // Do nothing if it's empty string
    String initialText = tree.getInitialText();
    if (!("".equals(filterText) || initialText.equals(filterText))) {//$NON-NLS-1$
        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)) {
            return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
        }
    }
    return null;
}

From source file:com.aptana.editor.html.validator.HTMLTidyValidatorPreferenceCompositeFactory.java

License:Open Source License

public Composite createPreferenceComposite(Composite parent, IBuildParticipantWorkingCopy participant) {
    this.participant = participant;

    Composite mainComp = new Composite(parent, SWT.NONE);
    mainComp.setFont(parent.getFont());//from w  ww  . ja  v a2  s.  c o  m
    mainComp.setLayout(new FillLayout());

    final ScrolledPageContent pageContent = new ScrolledPageContent(mainComp);

    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    Composite composite = pageContent.getBody();
    composite.setLayout(layout);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    EnumMap<ProblemCategory, List<ProblemType>> map = new EnumMap<HTMLTidyValidator.ProblemCategory, List<HTMLTidyValidator.ProblemType>>(
            ProblemCategory.class);
    for (ProblemType type : HTMLTidyValidator.ProblemType.values()) {
        List<ProblemType> types;
        if (map.containsKey(type.category())) {
            types = map.get(type.category());
            types.add(type);
        } else {
            types = CollectionsUtil.newList(type);
        }
        map.put(type.category(), types);
    }

    for (Entry<ProblemCategory, List<ProblemType>> entry : map.entrySet()) {
        ExpandableComposite excomposite = new ExpandableComposite(composite, SWT.NONE,
                ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
        excomposite.setText(entry.getKey().label());
        excomposite.setExpanded(false);
        excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
        excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
        excomposite.addExpansionListener(new ExpansionAdapter() {
            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                expandedStateChanged((ExpandableComposite) e.getSource());
            }
        });
        // fExpandableComposites.add(excomposite);
        makeScrollableCompositeAware(excomposite);

        Composite othersComposite = new Composite(excomposite, SWT.NONE);
        excomposite.setClient(othersComposite);
        othersComposite.setLayout(new GridLayout(2, false));

        // Create a label and combo box for each problem type.
        for (ProblemType type : entry.getValue()) {
            createEntry(type, othersComposite);
        }
    }
    return mainComp;
}

From source file:com.aptana.editor.php.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
    ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    excomposite.setText(label);/*from w  w  w.j a  va 2  s  . co m*/
    excomposite.setExpanded(false);
    excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
    excomposite.addExpansionListener(new ExpansionAdapter() {
        public void expansionStateChanged(ExpansionEvent e) {
            expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });
    fExpandedComposites.add(excomposite);
    makeScrollableCompositeAware(excomposite);
    return excomposite;
}

From source file:com.aptana.formatter.ui.util.SWTFactory.java

License:Open Source License

/**
 * Create an expandable widget./*from w  w  w. j  a  v  a  2s  .c o  m*/
 * 
 * @param parent
 * @param label
 * @param nColumns
 * @param expanded
 *            Initial expansion state of the composite.
 * @return an {@link ExpandableComposite}
 */
public static ExpandableComposite createExpandibleComposite(Composite parent, String label, int nColumns,
        boolean expanded) {
    ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    excomposite.setText(label);
    excomposite.setExpanded(expanded);
    excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
    excomposite.addExpansionListener(new IExpansionListener() {
        public void expansionStateChanging(ExpansionEvent e) {
        }

        public void expansionStateChanged(ExpansionEvent e) {
            ScrolledPageContent scrolledComposite = getParentScrolledComposite((Control) e.getSource());
            if (scrolledComposite != null) {
                scrolledComposite.reflow(true);
                scrolledComposite.layout(true, true);
            }
        }
    });
    makeScrollableCompositeAware(excomposite);
    return excomposite;
}