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

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

Introduction

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

Prototype

String DEFAULT_FONT

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

Click Source Link

Document

The symbolic font name for the standard font (value "org.eclipse.jface.defaultfont").

Usage

From source file:org.eclipse.cdt.utils.ui.controls.ControlFactory.java

License:Open Source License

/**
 * Creates a composite with a highlighted Note entry and a message text.
 * This is designed to take up the full width of the page.
 *
 * @param font the font to use//from   www  . j av a  2s .  c o  m
 * @param composite the parent composite
 * @param title the title of the note
 * @param message the message for the note
 * @return the composite for the note
 */
public static Composite createNoteComposite(Font font, Composite composite, String title, String message) {
    Composite messageComposite = new Composite(composite, SWT.NONE);
    GridLayout messageLayout = new GridLayout();
    messageLayout.numColumns = 2;
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    messageComposite.setLayout(messageLayout);
    messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    messageComposite.setFont(font);

    final Label noteLabel = new Label(messageComposite, SWT.BOLD);
    noteLabel.setText(title);
    noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
                noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
            }
        }
    };
    JFaceResources.getFontRegistry().addListener(fontListener);
    noteLabel.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
        }
    });

    Label messageLabel = new Label(messageComposite, SWT.WRAP);
    messageLabel.setText(message);
    messageLabel.setFont(font);
    return messageComposite;
}

From source file:org.eclipse.e4.demo.cssbridge.ui.views.FolderPreviewView.java

License:Open Source License

private void createMessageBodyComposite(Composite parent) {
    messageBodyComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;//from  w w  w  . ja  va2  s . c  o m
    layout.marginWidth = 0;
    messageBodyComposite.setLayout(layout);

    // top banner
    Composite banner = new Composite(messageBodyComposite, SWT.NONE);
    banner.setLayoutData(
            new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
    layout = new GridLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 10;
    layout.numColumns = 2;
    banner.setLayout(layout);

    // setup bold font
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);

    Label l = new Label(banner, SWT.NONE);
    l.setText("Subject:");
    l.setFont(boldFont);
    l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));

    GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false);
    gridData.minimumWidth = 100;

    subjectLabel = new Label(banner, SWT.WRAP);
    subjectLabel.setLayoutData(gridData);
    subjectLabel.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));

    l = new Label(banner, SWT.NONE);
    l.setText("From:");
    l.setFont(boldFont);
    l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));

    senderLink = new Link(banner, SWT.NONE);
    senderLink.addSelectionListener(senderLinkSelectionAdapter);
    senderLink.setLayoutData(gridData);
    senderLink.addPaintListener(senderLinkPaintListener);

    l = new Label(banner, SWT.NONE);
    l.setText("Date:");
    l.setFont(boldFont);
    l.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    l.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));

    dateLabel = new Label(banner, SWT.WRAP);
    dateLabel.setLayoutData(gridData);
    dateLabel.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));

    // message contents
    messageText = new Text(messageBodyComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    messageText.setLayoutData(new GridData(GridData.FILL_BOTH));
    messageText.setEditable(false);
    messageText.setBackground(messageText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    messageText.setForeground(Theme.getColor(Theme.Shell.TEXT_AND_LABEL_FOREGROUND));
    messageText.setBackground(viewer.getTable().getBackground());
}

From source file:org.eclipse.e4.demo.cssbridge.ui.views.Theme.java

License:Open Source License

public static Font getFont(String id) {
    try {/* ww w.ja va2  s  .c o m*/
        return getCurrentTheme().getFontRegistry().get(id);

        // Temporary fix for the M6 build. The issue has been fixed with the
        // Bug 429796
        // and it is available in one of the latest I-builds
    } catch (NullPointerException exc) {
        return getCurrentTheme().getFontRegistry().get(JFaceResources.DEFAULT_FONT);
    }
}

From source file:org.eclipse.edt.ide.rui.visualeditor.internal.util.ColorSelectionDialog.java

License:Open Source License

/**
 * Creates an image for each named color.
 *///from w  w  w  .j  av  a 2 s . c  o m
protected void initializeColorImages() {

    GC gc = new GC(getShell());
    Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
    gc.setFont(f);
    int iImageHeight = gc.getFontMetrics().getHeight();
    gc.dispose();

    Color colorBlack = getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK);

    String[] straColors = ColorUtil.getColorNames();
    String[] straHex = ColorUtil.getColorHexValues();

    _colors = new Color[straColors.length];
    _images = new Image[straColors.length];

    for (int i = 0; i < straHex.length; i++) {
        // Convert to decimal
        //-------------------
        String strR = straHex[i].substring(0, 2);
        String strG = straHex[i].substring(2, 4);
        String strB = straHex[i].substring(4);

        int iR = Integer.parseInt(strR, 16);
        int iG = Integer.parseInt(strG, 16);
        int iB = Integer.parseInt(strB, 16);

        RGB rgb = new RGB(iR, iG, iB);

        _colors[i] = new Color(getShell().getDisplay(), rgb);
        _images[i] = new Image(getShell().getDisplay(), IMAGE_WIDTH, iImageHeight);

        // Fill the background with the button color
        //------------------------------------------
        gc = new GC(_images[i]);
        gc.setBackground(_colors[i]);
        gc.fillRectangle(0, 0, IMAGE_WIDTH, iImageHeight);
        gc.setBackground(colorBlack);
        gc.drawRectangle(0, 0, IMAGE_WIDTH - 1, iImageHeight - 1);
        gc.dispose();
    }
}

From source file:org.eclipse.egit.ui.internal.blame.BlameInformationControl.java

License:Open Source License

protected void createContent(Composite parent) {
    scrolls = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolls.setExpandHorizontal(true);/*from ww w.ja v  a  2s  . c  o m*/
    scrolls.setExpandVertical(true);
    displayArea = new Composite(scrolls, SWT.NONE);
    scrolls.setContent(displayArea);
    displayArea.setForeground(parent.getForeground());
    displayArea.setBackground(parent.getBackground());
    displayArea.setBackgroundMode(SWT.INHERIT_FORCE);
    GridLayoutFactory.swtDefaults().equalWidth(true).applyTo(displayArea);

    commitLink = new StyledText(displayArea, SWT.READ_ONLY);
    commitLink.addMouseListener(new MouseAdapter() {

        public void mouseUp(MouseEvent e) {
            if (commitLink.getSelectionText().length() != 0)
                return;
            try {
                getShell().dispose();
                CommitEditor.open(new RepositoryCommit(revision.getRepository(), revision.getCommit()));
            } catch (PartInitException pie) {
                Activator.logError(pie.getLocalizedMessage(), pie);
            }
        }
    });
    commitLink.setFont(JFaceResources.getBannerFont());
    commitLink.setForeground(JFaceColors.getHyperlinkText(commitLink.getDisplay()));
    Cursor handCursor = new Cursor(commitLink.getDisplay(), SWT.CURSOR_HAND);
    UIUtils.hookDisposal(commitLink, handCursor);
    commitLink.setCursor(handCursor);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(commitLink);

    authorLabel = new Label(displayArea, SWT.NONE);
    authorLabel.setForeground(parent.getForeground());
    authorLabel.setBackground(parent.getBackground());
    authorLabel.setFont(UIUtils.getItalicFont(JFaceResources.DEFAULT_FONT));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(authorLabel);

    committerLabel = new Label(displayArea, SWT.NONE);
    committerLabel.setForeground(parent.getForeground());
    committerLabel.setBackground(parent.getBackground());
    committerLabel.setFont(UIUtils.getItalicFont(JFaceResources.DEFAULT_FONT));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(committerLabel);

    Label separator = new Label(displayArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(separator);

    messageText = new StyledText(displayArea, SWT.NONE);
    messageText.setForeground(parent.getForeground());
    messageText.setBackground(parent.getBackground());
    messageText.setEditable(false);
    messageText.setFont(UIUtils.getFont(UIPreferences.THEME_CommitMessageFont));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(messageText);
}

From source file:org.eclipse.emf.ecoretools.design.properties.BindingViewHelper.java

License:Open Source License

/**
 * {@inheritDoc}/*from  ww w.jav a2s  . c o  m*/
 * @see org.eclipse.emf.eef.runtime.ui.parts.ViewHelper#createLabel(org.eclipse.swt.widgets.Composite, java.lang.Object, java.lang.String)
 */
public Label createLabel(Composite parent, Object editor, String alternate) {
    IPropertiesEditionComponent propertiesEditingComponent = context.getPropertiesEditingComponent();
    String text = getDescription(editor, alternate);
    if (!text.endsWith(": ") && !text.endsWith(":")) {
        text += ": ";
    }
    Label label;
    if (toolkit != null) {
        label = toolkit.createLabel(parent, text);
    } else {
        label = new Label(parent, SWT.NONE);
        label.setText(text);
    }
    // Asserting that toolkit is setted => kind == Form
    if (propertiesEditingComponent != null
            && propertiesEditingComponent.isRequired(editor, toolkit == null ? 0 : 1)) {
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    }
    return label;
}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.ContainmentPropertiesEditingViewer.java

License:Open Source License

/**
 * @param required whether the feature is required or not.
 *///from  w ww. jav  a 2  s  . c  o m
public void setRequired(boolean required) {
    if (required) {
        title.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    } else {
        title.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
    }
}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.FormUtils.java

License:Open Source License

/**
 * Create a label describing a properties of the view
 * //  w  w w  .  ja  v a 2s . com
 * @param parent
 *            the parent composite
 * @param text
 *            the label text
 * @param required
 *            defines if the associated properties is required or not
 */
public static Label createPartLabel(FormToolkit widgetFactory, Composite parent, String text,
        boolean required) {
    Label label = widgetFactory.createLabel(parent, text);
    if (required)
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    return label;
}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.SingleCompositionViewer.java

License:Open Source License

/**
 * Creates the label on the top left-side.
 * //from w  w w  .  j  av  a2s. c o m
 * @param label
 *            The text to display.
 * @param top
 *            the top part.
 */
private void createLabel(String label, Composite top) {
    this.label = new Label(top, SWT.NONE);
    if (isRequired)
        this.label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    this.label.setText(label);

}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.SWTUtils.java

License:Open Source License

/**
 * Create a label describing a properties of the view
 * // ww  w . j  av  a2 s . c  o  m
 * @param parent
 *            the parent composite
 * @param text
 *            the label text
 * @param required
 *            defines if the associated properties is required or not
 */
public static Label createPartLabel(Composite parent, String text, boolean required) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(text);
    if (required)
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    return label;
}