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

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

Introduction

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

Prototype

public static Font getDefaultFont() 

Source Link

Document

Returns JFace's standard font.

Usage

From source file:org.xmind.ui.internal.decorators.LabelDecorator.java

License:Open Source License

public void activate(IGraphicalPart part, IFigure figure) {
    super.activate(part, figure);
    figure.setOpaque(true);// ww  w  .  j av a2 s .  c  om
    RotatableLineBorder border = new RotatableLineBorder(1);
    figure.setBorder(border);
    figure.setFont(JFaceResources.getDefaultFont());
    if (figure instanceof RotatableWrapLabel) {
        ((RotatableWrapLabel) figure).setSingleLine(true);
    }
}

From source file:org.xmind.ui.internal.decorators.LegendItemDecorator.java

License:LGPL

public void activate(IGraphicalPart part, IFigure figure) {
    super.activate(part, figure);
    figure.setFont(FontUtils.getNewHeight(JFaceResources.getDefaultFont(), Util.isMac() ? 10 : 8));
    figure.setForegroundColor(ColorConstants.black);
    if (figure instanceof LegendItemFigure) {
        ((LegendItemFigure) figure).getIcon().setPreferredSize(15, 15);
    }//from  www. ja v  a  2 s.  c  om
}

From source file:org.xmind.ui.internal.decorators.NumberingDecorator.java

License:Open Source License

protected void decorateTextFigure(IGraphicalPart ownerPart, IStyleSelector ss, ITextFigure figure) {
    TextStyle style = getTextStyle(ownerPart, ss);
    if (style != null) {
        figure.setStyle(style);/*from w ww  .ja  v  a  2 s .c o m*/
    } else {
        figure.setFont(getCompositeFont(ownerPart, ss, JFaceResources.getDefaultFont()));
        figure.setForegroundColor(
                StyleUtils.getColor(ownerPart, ss, Styles.TextColor, null, Styles.DEF_TEXT_COLOR));
    }
}

From source file:org.xmind.ui.internal.mindmap.MarkerPart.java

License:Open Source License

private Dimension calculateSVGPreferredSize() {
    ITopicPart tp = getTopicPart();//from ww w. j a  v  a 2 s .  c  o  m
    if (tp == null)
        return null;
    IStyleSelector ss = (IStyleSelector) tp.getAdapter(IStyleSelector.class);
    TextStyleData data = StyleUtils.getTextStyleData(tp, ss, null);
    int leading = GraphicsUtils.getAdvanced().getFontMetrics(JFaceResources.getDefaultFont()).getLeading();

    return new Dimension(data.height + leading, data.height + leading);
}

From source file:org.xmind.ui.internal.notes.RichDocumentBuilder.java

License:Open Source License

private StyleRange createTextStyle(IStyle style) {
    StyleRange textStyle = newTextStyle();
    if (style == null)
        return textStyle;

    String name = style.getProperty(Styles.FontFamily);
    String availableFontName = FontUtils.getAAvailableFontNameFor(name);
    name = availableFontName != null ? availableFontName : name;

    if (Styles.SYSTEM.equals(name)) {
        name = JFaceResources.getDefaultFont().getFontData()[0].getName();
    }//from   www.  j a v  a  2 s  .  c o m
    String height = style.getProperty(Styles.FontSize);
    String weight = style.getProperty(Styles.FontWeight);
    String fontStyle = style.getProperty(Styles.FontStyle);
    String foreground = style.getProperty(Styles.TextColor);
    String background = style.getProperty(Styles.BackgroundColor);
    String decoration = style.getProperty(Styles.TextDecoration);
    if (name == null && height == null && weight == null && fontStyle == null && foreground == null
            && background == null && decoration == null)
        return textStyle;

    if (name == null)
        name = RichTextUtils.DEFAULT_FONT_DATA.getName();
    int size = NumberUtils.safeParseInt(StyleUtils.trimNumber(height),
            RichTextUtils.DEFAULT_FONT_DATA.getHeight());
    boolean bold = weight != null && weight.contains(Styles.FONT_WEIGHT_BOLD);
    boolean italic = fontStyle != null && fontStyle.contains(Styles.FONT_STYLE_ITALIC);

    if (textStyle == null)
        textStyle = new StyleRange();
    textStyle.font = FontUtils.getFont(name, size, bold, italic);
    textStyle.foreground = ColorUtils.getColor(foreground);
    textStyle.background = ColorUtils.getColor(background);
    textStyle.underline = decoration != null && decoration.contains(Styles.TEXT_DECORATION_UNDERLINE);
    textStyle.strikeout = decoration != null && decoration.contains(Styles.TEXT_DECORATION_LINE_THROUGH);
    return textStyle;
}

From source file:org.xmind.ui.internal.properties.NumberingPropertySectionPart.java

License:Open Source License

protected void doRefresh() {
    Object o = ((IStructuredSelection) getCurrentSelection()).getFirstElement();
    if (o instanceof ITopic) {
        ITopic topic = (ITopic) o;// w w  w  .  j a  v a 2 s  . c  o m
        ITopic parent = topic.getParent();
        if (parent == null)
            parent = topic;
        INumbering numbering;
        if (ITopic.ATTACHED.equals(topic.getType())) {
            numbering = parent.getNumbering();
        } else {
            numbering = null;
        }
        boolean hasFormat = false;
        if (formatViewer != null && !formatViewer.getControl().isDisposed()) {
            String format = numbering == null ? null : numbering.getComputedFormat();
            if (format == null) {
                format = MindMapUI.DEFAULT_NUMBER_FORMAT;
            } else if (parent.getNumbering().getNumberFormat() == null
                    && !topic.getNumbering().isInherited(0)) {
                format = MindMapUI.DEFAULT_NUMBER_FORMAT;
            } else {
                hasFormat = !MindMapUI.DEFAULT_NUMBER_FORMAT.equals(format);
            }
            INumberFormatDescriptor descriptor = MindMapUI.getNumberFormatManager().getDescriptor(format);
            formatViewer.setSelection(
                    descriptor == null ? StructuredSelection.EMPTY : new StructuredSelection(descriptor));
        }
        if (depthViewer != null && !depthViewer.getControl().isDisposed()) {
            Object select = INHERIT;
            if (numbering != null) {
                if (numbering.getDepth() != null)
                    select = numbering.getDepth();
                else if (numbering.getNumberFormat() != null && !numbering.isInherited(1))
                    select = "3"; //$NON-NLS-1$

                depthViewer.setSelection(new StructuredSelection(select));

                if (MindMapUI.DEFAULT_NUMBER_FORMAT.equals(numbering.getNumberFormat())) {
                    depthViewer.setEnabled(false);
                } else {
                    depthViewer.setEnabled(
                            numbering.getNumberFormat() != null || topic.getNumbering().isInherited(0));
                }
            }
        }
        if (separatorViewer != null && !separatorViewer.getControl().isDisposed()) {
            String separator = numbering == null ? null : numbering.getComputedSeparator();
            if (separator == null)
                separator = MindMapUI.DEFAULT_NUMBER_SEPARATOR;
            INumberSeparatorDescriptor descriptor = MindMapUI.getNumberSeparatorManager()
                    .getDescriptor(separator);
            separatorViewer.setSelection(
                    descriptor == null ? StructuredSelection.EMPTY : new StructuredSelection(descriptor));
        }
        if (tieredCheck != null) {
            tieredCheck.setSelection(numbering != null && numbering.prependsParentNumbers());
        }
        if (prefixInput != null && !prefixInput.isDisposed()) {
            String prefix = numbering == null ? null : numbering.getPrefix();
            prefixInput.setText(prefix == null ? "" : prefix); //$NON-NLS-1$
        }
        if (suffixInput != null && !suffixInput.isDisposed()) {
            String suffix = numbering == null ? null : numbering.getSuffix();
            suffixInput.setText(suffix == null ? "" : suffix); //$NON-NLS-1$
        }
        if (numberLabel != null && !numberLabel.isDisposed()) {
            String number;
            number = MindMapUtils.getNumberingText(topic, hasFormat ? null : MindMapUI.PREVIEW_NUMBER_FORMAT,
                    hasFormat ? null : MindMapUI.DEFAULT_NUMBER_SEPARATOR);
            if (number == null || "".equals(number)) { //$NON-NLS-1$
                numberLabel.setText(" "); //$NON-NLS-1$
            } else {
                number = GraphicsUtils.getNormal().constrain(number, 100, JFaceResources.getDefaultFont(),
                        GraphicsUtils.TRAIL);
                numberLabel.setText(number);
            }
            if (hasFormat) {
                numberLabel.setForeground(numberLabel.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
            } else {
                numberLabel.setForeground(numberLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
            }
        }
    }
}

From source file:org.xmind.ui.internal.sharing.LocalNetworkSharingPrefPage.java

License:Open Source License

private void fillLibraryNameSection(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
    label.setFont(JFaceResources.getDefaultFont());
    label.setText(SharingMessages.PreferencePage_Form_Name_label);

    libraryNameEditor = createLibraryNameEditor(parent);
    libraryNameEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}

From source file:org.xmind.ui.internal.sharing.LocalNetworkSharingPrefPage.java

License:Open Source License

private void fillStatusSection(Composite parent) {
    Label titleLabel = new Label(parent, SWT.NONE);
    titleLabel.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
    titleLabel.setFont(JFaceResources.getDefaultFont());
    titleLabel.setText(SharingMessages.PreferencePage_Form_Status_label);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;/*from   w w w .j ava  2 s  .co m*/
    layout.marginHeight = 0;
    layout.verticalSpacing = 5;
    layout.horizontalSpacing = 5;
    composite.setLayout(layout);

    Composite statusComposite = new Composite(composite, SWT.NONE);
    statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout statusLayout = new GridLayout(2, false);
    statusLayout.marginWidth = 0;
    statusLayout.marginHeight = 0;
    statusLayout.verticalSpacing = 5;
    statusLayout.horizontalSpacing = 5;
    statusComposite.setLayout(statusLayout);

    statusLabel = new Label(statusComposite, SWT.LEFT);
    statusLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true));
    statusLabel.setFont(FontUtils.getBold(JFaceResources.DEFAULT_FONT));
    statusLabel.setText(""); //$NON-NLS-1$

    Composite noBonjourWidget = new Composite(statusComposite, SWT.NONE);
    this.noBonjourWidget = noBonjourWidget;
    noBonjourWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout noBonjourLayout = new GridLayout(2, false);
    noBonjourLayout.marginWidth = 0;
    noBonjourLayout.marginHeight = 0;
    noBonjourLayout.verticalSpacing = 3;
    noBonjourLayout.horizontalSpacing = 3;
    noBonjourWidget.setLayout(noBonjourLayout);

    Label noBonjourWarningImage = new Label(noBonjourWidget, SWT.NONE);
    noBonjourWarningImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
    noBonjourWarningImage
            .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));

    Label noBonjourWarningLabel = new Label(noBonjourWidget, SWT.WRAP);
    noBonjourWarningLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
    noBonjourWarningLabel.setText(SharingMessages.PreferencePage_Form_Status_DisplayArea_NoBonjour_warningText);

    changeStatusButton = new Button(composite, SWT.PUSH | SWT.CENTER);
    changeStatusButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    changeStatusButton.setText(""); //$NON-NLS-1$
    changeStatusButton.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            changeServiceStatus();
        }
    });
}

From source file:org.xmind.ui.internal.sharing.SharedMapLabelProvider.java

License:Open Source License

public IFigure getToolTipFigure(Object element) {
    if (element instanceof ISharedMap) {
        ISharedMap map = (ISharedMap) element;
        if (map.getSharedLibrary().isLocal() && map instanceof ILocalSharedMap) {
            ILocalSharedMap localMap = (ILocalSharedMap) map;
            String path = localMap.getResourcePath();
            long modifiedTime = localMap.getResourceModifiedTime();
            long addedTime = localMap.getAddedTime();
            boolean missing = localMap.isMissing();

            IFigure tooltip = new Figure();
            ToolbarLayout layout = new ToolbarLayout(false);
            layout.setSpacing(1);//  w ww  .ja v a  2 s  . c  o  m
            tooltip.setLayoutManager(layout);
            if (missing) {
                Label statusFigure = new Label(SharingMessages.SharedMap_tooltip_MapIsMissing_warningText);
                statusFigure.setFont(FontUtils.getBold(JFaceResources.DEFAULT_FONT));
                tooltip.add(statusFigure);
            }

            Label pathLabel = new Label(path);
            pathLabel.setFont(JFaceResources.getDefaultFont());
            tooltip.add(pathLabel);

            IFigure attrsFigure = new Figure();
            attrsFigure.setBorder(new MarginBorder(7, 0, 0, 0));
            ToolbarLayout attrLayout = new ToolbarLayout(false);
            attrLayout.setSpacing(1);
            attrsFigure.setLayoutManager(attrLayout);
            Font attrFont = FontUtils.getRelativeHeight(JFaceResources.DEFAULT_FONT, -2);
            Label addedLabel = new Label(
                    NLS.bind(SharingMessages.SharedMap_tooltip_AddedTime_text_withTime, formatTime(addedTime)));
            addedLabel.setFont(attrFont);
            attrsFigure.add(addedLabel);
            if (!missing) {
                Label modifiedLabel = new Label(
                        NLS.bind(SharingMessages.SharedMap_tooltip_ModifiedTime_text_withTime,
                                formatTime(modifiedTime)));
                modifiedLabel.setFont(attrFont);
                attrsFigure.add(modifiedLabel);
            }
            tooltip.add(attrsFigure);
            return tooltip;
        }
    }
    return null;
}

From source file:org.xmind.ui.internal.spreadsheet.structures.ColumnHead.java

License:Open Source License

private Font calcFont() {
    return JFaceResources.getDefaultFont();
}