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:com.aptana.ide.logging.LoggingPreferences.java

License:Open Source License

/**
 * Initializes default font./*from w w  w.  j a  v a 2 s .c o  m*/
 */
private void initializeDefaultFont() {
    Font defaultFont = JFaceResources.getDefaultFont();

    FontData[] data = defaultFont.getFontData();

    String osName = System.getProperty("os.name", "Windows"); //$NON-NLS-1$ //$NON-NLS-2$

    int height = data[0].getHeight();
    if (data != null && data.length > 0) {
        if (osName.startsWith("Windows")) //$NON-NLS-1$
        {
            height = WINDOWS_DEFAULT_FONT_SIZE;
        } else if (osName.startsWith("Linux")) //$NON-NLS-1$
        {
            height = LINUX_DEFAULT_FONT_SIZE;
        } else if (osName.startsWith("Mac OS")) //$NON-NLS-1$
        {
            height = MAC_OS_DEFAULT_FONT_SIZE;
        }
    }
    data[0].setHeight(height);
    if (supports(DEFAULT_FONT_FAMILY, height)) {
        data[0].setName(DEFAULT_FONT_FAMILY);
    }

    PreferenceConverter.setDefault(getPreferenceStore(), MAIN_TEXT_FONT_KEY, data);
}

From source file:com.aptana.ide.server.configuration.ui.BasicServerComposite.java

License:Open Source License

/**
 * Adds an example text label. /*from   w w  w.  j  a  v  a 2 s  .  c o  m*/
 */
protected void addExampleText(Composite parent, String text) {
    new Label(parent, SWT.NONE);
    Label banner = new Label(this, SWT.NONE);
    banner.setText(text);
    Font defaultFont = JFaceResources.getDefaultFont();
    final Font smallFont = new Font(banner.getDisplay(), defaultFont.getFontData()[0].getName(), 8, SWT.NONE);
    banner.setFont(smallFont);
    banner.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            smallFont.dispose();
        }

    });
    GridData gds = new GridData(GridData.FILL_HORIZONTAL);
    gds.horizontalSpan = 2;
    gds.verticalIndent = -3;
    gds.verticalAlignment = SWT.TOP;
    banner.setLayoutData(gds);
}

From source file:com.aptana.internal.ui.text.spelling.SWTUtil.java

License:Open Source License

public static int getTableHeightHint(Table table, int rows) {
    if (table.getFont().equals(JFaceResources.getDefaultFont())) {
        table.setFont(JFaceResources.getDialogFont());
    }// www.j a v a2 s.c  o m
    int result = table.getItemHeight() * rows + table.getHeaderHeight();
    if (table.getLinesVisible()) {
        result += table.getGridLineWidth() * (rows - 1);
    }
    return result;
}

From source file:com.aptana.php.debug.ui.phpini.PHPIniEditor.java

License:Open Source License

public PHPIniEditor() {
    COMMENT_FOREGROUND = new Color(Display.getCurrent(), COMMENT_FOREGROUND_RGB);
    SECTION_BACKGROUND = new Color(Display.getCurrent(), SECTION_BACKGROUND_RGB);
    Font defaultFont = JFaceResources.getDefaultFont();
    FontData data = new FontData(defaultFont.getFontData()[0].getName(),
            defaultFont.getFontData()[0].getHeight(), SWT.ITALIC);
    COMMENT_FONT = new Font(Display.getDefault(), data);
    extensionsOnlyFilter = new ExtensionsOnlyFilter();
}

From source file:com.bdaum.zoom.css.ZColumnLabelProvider.java

License:Open Source License

protected void paint(Event event, Object element) {
    GC gc = event.gc;/*from w w  w  .ja  v  a  2  s.  c om*/
    tooltip = null;
    Rectangle iconSize = getIconBounds();
    Image image = getImage(element);
    int iconWidth = iconSize != null ? iconSize.width : -1;
    int iconHeight = iconSize != null ? iconSize.height : -1;
    int rowHeight = Math.max(iconHeight, event.height);
    double fac = 1d;
    if (image != null) {
        if (iconSize == null) {
            iconSize = image.getBounds();
            iconWidth = iconSize.width;
            iconHeight = iconSize.height;
            rowHeight = Math.max(iconHeight, event.height);
        } else {
            Rectangle bounds = image.getBounds();
            fac = Math.min(((double) iconWidth) / bounds.width, ((double) iconHeight) / bounds.height);
            iconSize = bounds;
            iconWidth = iconSize.width;
            iconHeight = iconSize.height;
            rowHeight = Math.max(iconHeight, event.height);
        }
    }
    String text = getText(element);
    if (text != null) {
        Font customFont;
        Color foreground, background;
        if ((event.detail & SWT.SELECTED) != 0) {
            customFont = getSelectionFont(element);
            foreground = getSelectedForeground(element);
            background = getSelectedBackground(element);
        } else {
            customFont = getFont(element);
            foreground = getForeground(element);
            background = getBackground(element);
        }
        if (customFont != null)
            gc.setFont(customFont);
        else if ((event.detail & SWT.SELECTED) != 0)
            gc.setFont(JFaceResources.getFontRegistry().get("com.bdaum.zoom.selectionFont")); //$NON-NLS-1$
        else
            gc.setFont(JFaceResources.getDefaultFont());
        gc.setForeground(foreground);
        gc.setBackground(background);
        Point textExtent = gc.textExtent(text);
        if (iconHeight < 0)
            iconHeight = event.height;
        int x = (int) (event.x + iconWidth * fac + 4);
        int mxWidth = getColumnWidth() - x + getColumnXOrigin();
        String shortened = shortenText(element, text, textExtent.x, gc, mxWidth);
        if (shortened.length() < text.length())
            tooltip = text;
        int ty = event.y + (rowHeight - textExtent.y) / 2;
        if (element instanceof ITitle) {
            Point tx = gc.stringExtent(shortened);
            int len = tx.x;
            if (len < mxWidth)
                x += (mxWidth - len) / 2;
            int th = ty + tx.y / 2;
            gc.drawLine(0, th, mxWidth, th);
            gc.drawLine(0, th + 2, mxWidth, th + 2);
        }
        gc.drawText(shortened, x, ty, (event.detail & SWT.SELECTED) != 0);
    }
    if (image != null) {
        if (iconSize == null)
            gc.drawImage(image, event.x, (rowHeight - iconHeight) / 2);
        else {
            int w = (int) (iconWidth * fac);
            int h = (int) (iconHeight * fac);
            gc.drawImage(image, 0, 0, iconWidth, iconHeight, event.x + (iconWidth - w) / 2,
                    event.y + (rowHeight - h) / 2, w, h);
        }
    }
    viewerControl.setToolTipText(tooltip);
}

From source file:com.bdaum.zoom.rcp.internal.intro.Intro.java

License:Open Source License

public void standbyStateChanged(boolean sb) {
    this.standby = sb;
    if (sb) {/*ww w  .j a  v  a 2  s .  c  o  m*/
        sectionGroupLayout.minNumColumns = sectionGroupLayout.maxNumColumns = 1;
        sectionGroupLayout.bottomMargin = sectionGroupLayout.leftMargin = sectionGroupLayout.topMargin = sectionGroupLayout.rightMargin = 3;
        buttonCanvas.setVisible(false);
        boolean firstOpen = false;
        for (Section section : sections) {
            if (section.isExpanded())
                if (firstOpen)
                    section.setExpanded(false);
                else
                    firstOpen = true;
            ((ColumnLayoutData) section.getLayoutData()).widthHint = 250;
            ((FormText) section.getClient()).setFont(JFaceResources.getDefaultFont());
        }
        form.setText(Constants.APPLICATION_NAME);
        form.setImage(titleImage32);
        form.setSeparatorVisible(false);
        form.setHeadClient(null);
        ((TableWrapLayout) form.getBody().getLayout()).topMargin = 3;
    } else {
        sectionGroupLayout.minNumColumns = 2;
        sectionGroupLayout.maxNumColumns = 4;
        sectionGroupLayout.bottomMargin = sectionGroupLayout.leftMargin = sectionGroupLayout.topMargin = sectionGroupLayout.rightMargin = 10;
        buttonCanvas.setVisible(true);
        for (Section section : sections) {
            ((ColumnLayoutData) section.getLayoutData()).widthHint = 400;
            ((FormText) section.getClient()).setFont(JFaceResources.getDialogFont());
        }
        form.setText(NLS.bind('\n' + Messages.Intro_welcome, Constants.APPLICATION_NAME));
        form.setImage(titleImage64);
        form.setSeparatorVisible(true);
        form.setHeadClient(subtitle);
        ((TableWrapLayout) form.getBody().getLayout()).topMargin = 10;
    }
    form.getBody().layout();
    form.redraw();
}

From source file:com.bdaum.zoom.ui.dialogs.ZTitleAreaDialog.java

License:Open Source License

@Override
public void create() {
    super.create();
    CssActivator.getDefault().setColors(getShell());
    if (helpId != null)
        setHelpId(helpId);//from www .  j  a  v a 2  s. co m
    if (workArea != null) {
        // The workarea has been captured earlier in createDialogArea()
        Object layoutData = workArea.getLayoutData();
        if (layoutData instanceof FormData) {
            // Because the workarea is attached to the title message label,
            // we can grab the messageLabel from the FormAttachment
            messageLabel = ((FormData) layoutData).top.control;
            messageLabel.setFont(JFaceResources.getDefaultFont());
            if (messageLabel instanceof Scrollable)
                xTrim = ((Scrollable) messageLabel).computeTrim(0, 0, 100, 100).width - 100;
        }
    }
}

From source file:com.bdaum.zoom.ui.internal.dialogs.EditMetaDialog.java

License:Open Source License

protected void updateTabItems() {
    CTabItem selection = tabFolder.getSelection();
    for (CTabItem item : tabFolder.getItems())
        item.setFont(selection == item ? JFaceResources.getBannerFont() : JFaceResources.getDefaultFont());
}

From source file:com.bdaum.zoom.ui.internal.preferences.PreferenceInitializer.java

License:Open Source License

@Override
public void initializeDefaultPreferences() {
    IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(UiActivator.PLUGIN_ID);
    defaultNode.put(PreferenceConstants.BACKGROUNDCOLOR, PreferenceConstants.BACKGROUNDCOLOR_DARKGREY);
    defaultNode.put(PreferenceConstants.DISTANCEUNIT, "k"); //$NON-NLS-1$
    defaultNode.put(PreferenceConstants.DIMUNIT, "c"); //$NON-NLS-1$
    defaultNode.putBoolean(PreferenceConstants.AUTOEXPORT, true);
    defaultNode.put(PreferenceConstants.DERIVERELATIONS, Constants.DERIVE_ALL);
    defaultNode.put(PreferenceConstants.SHOWRATING, PreferenceConstants.SHOWRATING_SIZE);
    defaultNode.putBoolean(PreferenceConstants.SHOWLOCATION, true);
    defaultNode.putBoolean(PreferenceConstants.SHOWROTATEBUTTONS, true);
    defaultNode.putBoolean(PreferenceConstants.SHOWVOICENOTE, true);
    defaultNode.putBoolean(PreferenceConstants.SHOWEXPANDCOLLAPSE, true);
    defaultNode.put(PreferenceConstants.SHOWCOLORCODE, PreferenceConstants.COLORCODE_MANUAL);
    defaultNode.putBoolean(PreferenceConstants.SHOWDONEMARK, true);
    defaultNode.put(PreferenceConstants.THUMBNAILTEMPLATE, "{creationDate} {meta=exposureTime} {meta=fNumber}"); //$NON-NLS-1$
    defaultNode.putInt(PreferenceConstants.LABELFONTSIZE,
            JFaceResources.getDefaultFont().getFontData()[0].getHeight());
    defaultNode.putInt(PreferenceConstants.SHOWLABEL, Constants.TITLE_LABEL);
    defaultNode.putInt(PreferenceConstants.HOVERDELAY, 200);
    defaultNode.putInt(PreferenceConstants.HOVERBASETIME, 1000);
    defaultNode.putInt(PreferenceConstants.HOVERCHARTIME, 25);
    defaultNode.put(PreferenceConstants.WATCHFILTER, DEFAULTWATCHFILTER);
    defaultNode.put(PreferenceConstants.KEYWORDFILTER, DEFAULTKEYWORDFILTER);
    defaultNode.put(PreferenceConstants.RAWIMPORT,
            Constants.WIN32 || Constants.OSX ? Constants.RAWIMPORT_BOTH : Constants.RAWIMPORT_ONLYRAW);
    defaultNode.putInt(PreferenceConstants.BACKUPINTERVAL, 7);
    defaultNode.putInt(PreferenceConstants.BACKUPGENERATIONS, Integer.MAX_VALUE);
    defaultNode.putInt(PreferenceConstants.INACTIVITYINTERVAL, 15);
    defaultNode.putBoolean(PreferenceConstants.ALARMONFINISH, true);
    defaultNode.putBoolean(PreferenceConstants.ALARMONPROMPT, true);
    defaultNode.putBoolean(PreferenceConstants.ADVANCEDGRAPHICS, false);
    defaultNode.putBoolean(PreferenceConstants.AUTODERIVE, true);
    defaultNode.putBoolean(PreferenceConstants.APPLYXMPTODERIVATES, true);
    defaultNode.putBoolean(PreferenceConstants.IMPORTMAKERNOTES, true);
    defaultNode.putBoolean(PreferenceConstants.IMPORTFACEDATA, true);
    defaultNode.putInt(PreferenceConstants.COLORPROFILE, ImageConstants.SRGB);
    defaultNode.put(PreferenceConstants.BWFILTER, StringConverter.asString(new RGB(64, 128, 64)));
    defaultNode.put(PreferenceConstants.DNGFOLDER, "dng"); //$NON-NLS-1$

    defaultNode.put(PreferenceConstants.FILEASSOCIATION, FileAssociationsPreferencePage.DFLTMAPPINGS);
    StringBuilder sb = new StringBuilder();
    StringBuilder sbh = new StringBuilder();
    StringBuilder sbt = new StringBuilder();
    StringBuilder sbe = new StringBuilder();
    for (QueryField qfield : QueryField.getQueryFields())
        if (qfield.hasLabel() && qfield.getChildren().length == 0) {
            String id = qfield.getId();
            sbe.append(id).append('\n');
            if (qfield.isEssential())
                sb.append(id).append('\n');
            if (qfield.isHover())
                sbh.append(id).append('\n');
            if (qfield.getTolerance() != 0f)
                sbt.append(id).append("=").append(qfield.getTolerance()).append('\n'); //$NON-NLS-1$
        }/*from  ww w .j  a v a2s.  com*/
    defaultNode.put(PreferenceConstants.ESSENTIALMETADATA, sb.toString());
    defaultNode.put(PreferenceConstants.HOVERMETADATA, sbh.toString());
    defaultNode.put(PreferenceConstants.METADATATOLERANCES, sbt.toString());
    defaultNode.put(PreferenceConstants.EXPORTMETADATA, sbe.toString());
    defaultNode.put(PreferenceConstants.METADATATUNING, Core.getCore().getDbFactory().getDefaultTuning());
    sb.setLength(0);
    sb.append(QueryField.NAME.getKey()).append('\n').append(QueryField.FORMAT.getKey()).append('\n')
            .append(QueryField.EXIF_DATETIMEORIGINAL.getKey()).append('\n')
            .append(QueryField.IPTC_TITLE.getKey()).append('\n')
            .append(QueryField.EXIF_FOCALLENGTHIN35MMFILM.getKey()).append('\n')
            .append(QueryField.EXIF_EXPOSURETIME.getKey()).append('\n').append(QueryField.EXIF_FNUMBER.getKey())
            .append('\n');
    defaultNode.put(PreferenceConstants.TABLECOLUMNS, sb.toString());
    defaultNode.putInt(PreferenceConstants.UNDOLEVELS, 9);
    defaultNode.putDouble(PreferenceConstants.AUDIOSAMPLINGRATE, PreferenceConstants.AUDIO22KHZ);
    defaultNode.putInt(PreferenceConstants.AUDIOBITDEPTH, PreferenceConstants.AUDIO8BIT);
    Map<String, IRawConverter> rawConverters = BatchActivator.getDefault().getRawConverters();
    for (IRawConverter rc : rawConverters.values()) {
        for (IRawConverter.RawProperty prop : rc.getProperties())
            if (prop.dflt != null)
                defaultNode.put(prop.id, prop.dflt);
        File path = rc.findModule(null);
        if (path != null)
            defaultNode.put(rc.getPathId(), path.getAbsolutePath());
    }
    defaultNode.put(PreferenceConstants.UPDATEPOLICY, PreferenceConstants.UPDATEPOLICY_WITHBACKUP);
    defaultNode.putInt(PreferenceConstants.MOUSE_SPEED, 10);
    defaultNode.putInt(PreferenceConstants.ZOOMKEY,
            Constants.WIN32 ? PreferenceConstants.ZOOMALT : PreferenceConstants.ZOOMSHIFT);
    defaultNode.putInt(PreferenceConstants.WHEELSOFTNESS, 50);
    defaultNode.putInt(PreferenceConstants.MAXIMPORTS, 99);
    defaultNode.putBoolean(PreferenceConstants.ADDNOISE, true);
    defaultNode.putInt(PreferenceConstants.MAXREGIONS, 12);
    defaultNode.putBoolean(PreferenceConstants.FORCEDELETETRASH, true);
    defaultNode.put(PreferenceConstants.AUTORULES,
            new StringBuilder().append(QueryField.STATUS.getId()).append(':').append(Constants.STATE_TODO)
                    .append('\n').append(QueryField.IPTC_KEYWORDS.getId()).append(":") //$NON-NLS-1$
                    .append('\n').append(QueryField.MODIFIED_SINCE.getId()).append(":2;30;365").toString()); //$NON-NLS-1$
    defaultNode.putBoolean(PreferenceConstants.HIDE_MENU_BAR, false);
    defaultNode.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, false);
}

From source file:com.bdaum.zoom.ui.internal.views.LightboxView.java

License:Open Source License

@Override
protected boolean doRedrawCollection(Collection<? extends Asset> assets, QueryField node) {
    if (gallery == null || gallery.isDisposed())
        return false;
    int labelFontsize = 0;
    IAssetProvider assetProvider = getAssetProvider();
    if (assetProvider != null) {
        SmartCollection coll = assetProvider.getCurrentCollection();
        if (coll != null) {
            while (true) {
                showLabel = coll.getShowLabel();
                if (showLabel != Constants.INHERIT_LABEL) {
                    labelTemplate = coll.getLabelTemplate();
                    labelFontsize = coll.getFontSize();
                    break;
                }/*from  ww  w  . ja  v a2 s  .  co m*/
                if (coll.getSmartCollection_subSelection_parent() == null)
                    break;
                coll = coll.getSmartCollection_subSelection_parent();
            }
            if (showLabel == Constants.INHERIT_LABEL) {
                String groupId = coll.getGroup_rootCollection_parent();
                Group group = Core.getCore().getDbManager().obtainById(GroupImpl.class, groupId);
                while (group != null) {
                    showLabel = group.getShowLabel();
                    if (showLabel != Constants.INHERIT_LABEL) {
                        labelTemplate = group.getLabelTemplate();
                        labelFontsize = coll.getFontSize();
                        break;
                    }
                    group = group.getGroup_subgroup_parent();
                }
            }
        }
    }
    if (showLabel == Constants.INHERIT_LABEL) {
        showLabel = showLabelDflt;
        labelTemplate = labelTemplateDflt;
        labelFontsize = labelFontsizeDflt;
    }
    itemRenderer.setShowLabels(showLabel != Constants.NO_LABEL);
    gallery.setFont(showLabel == Constants.CUSTOM_LABEL && labelFontsize != 0 ? getSmallFont(labelFontsize)
            : JFaceResources.getDefaultFont());
    if (assets == null) {
        if (fetchAssets()) {
            scoreFormatter = assetProvider.getScoreFormatter();
            gallery.getItem(0).setItemCount(assetProvider.getAssetCount());
            gallery.clearAll();
            gallery.redraw();
            AssetSelection oldSelection = (AssetSelection) (selection == null ? AssetSelection.EMPTY
                    : selection);
            if (oldSelection.isPicked()) {
                List<Asset> selectedAssets = new ArrayList<Asset>(oldSelection.size());
                List<GalleryItem> items = new ArrayList<GalleryItem>(oldSelection.size());
                for (Asset asset : oldSelection.getAssets()) {
                    GalleryItem item = getGalleryItem(asset);
                    if (item != null) {
                        items.add(item);
                        selectedAssets.add(asset);
                    }
                }
                galleryMap.clear();
                gallery.setSelection(items.toArray(new GalleryItem[items.size()]));
                selection = new AssetSelection(selectedAssets);
            } else {
                galleryMap.clear();
                selection = new AssetSelection(assetProvider);
                gallery.redraw();
            }
        }
    } else {
        if (assets.size() == 1) {
            GalleryItem item = getGalleryItem(assets.iterator().next());
            if (item != null) {
                if (node == null) {
                    item.setImage(placeHolder);
                    item.setData(ROT, null);
                }
                gallery.redraw(item);
            }
        } else {
            if (node == null)
                for (Asset asset : assets) {
                    GalleryItem item = getGalleryItem(asset);
                    if (item != null)
                        item.setImage(placeHolder);
                }
            gallery.redraw();
        }
    }
    return true;
}