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:com.apicloud.navigator.composite.ThemeUIComposite.java

License:Open Source License

private void setFont(String fontId, FontData[] data) {
    String fdString = PreferenceConverter.getStoredRepresentation(data);

    Font existing = JFaceResources.getFont(fontId);
    String existingString = "";
    if (!(existing.isDisposed())) {
        existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
    }//from  ww  w .j  a  v  a 2 s.  c  om
    if (existingString.equals(fdString)) {
        return;
    }
    JFaceResources.getFontRegistry().put(fontId, data);

    ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
    String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
    IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
    store.setValue(key, fdString);
}

From source file:com.aptana.editor.common.hover.AbstractDocumentationHover.java

License:Open Source License

/**
 * Returns the PHP hover style sheet/*from  ww  w  . ja v a 2s  .c  o  m*/
 */
private String getStyleSheet() {
    if (styleSheet == null) {
        styleSheet = loadStyleSheet(getCSSPath());
    }
    if (styleSheet != null) {
        FontData fontData = JFaceResources.getFontRegistry().getFontData("Dialog")[0]; //$NON-NLS-1$
        return HTMLPrinter.convertTopLevelFont(styleSheet, fontData);
    }

    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  . jav  a 2 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  ww  .j a  v  a2  s. c  om*/
    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.preferences.ScriptSourcePreviewerUpdater.java

License:Open Source License

/**
 * Creates a script source preview updater for the given viewer, configuration and preference store.
 * //from  w w  w  . j a v a 2  s  .  co m
 * @param viewer
 *            the viewer
 * @param configuration
 *            the configuration
 * @param preferenceStore
 *            the preference store
 */
public ScriptSourcePreviewerUpdater(final SourceViewer viewer, final SourceViewerConfiguration configuration,
        final IPreferenceStore preferenceStore) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(configuration);
    Assert.isNotNull(preferenceStore);
    final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            final String fontKey = JFaceResources.TEXT_FONT;
            if (fontKey.equals(event.getProperty())) {
                final Font font = JFaceResources.getFont(fontKey);
                viewer.getTextWidget().setFont(font);
            }
        }
    };

    final IPreferenceChangeListener themeListener = new IPreferenceChangeListener() {

        public void preferenceChange(PreferenceChangeEvent event) {
            if (event.getKey().equals(IThemeManager.THEME_CHANGED)) {
                ColorManager colorManager = ThemePlugin.getDefault().getColorManager();
                IThemeManager themeManager = ThemePlugin.getDefault().getThemeManager();
                Color color = colorManager.getColor(themeManager.getCurrentTheme().getBackground());
                StyledText styledText = viewer.getTextWidget();
                styledText.setBackground(color);
            }
        }
    };

    // Listen to theme changes
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            // if (configuration.affectsTextPresentation(event)) {
            // configuration.handlePropertyChangeEvent(event);
            viewer.invalidateTextPresentation();
            // }
        }
    };

    viewer.getTextWidget().addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            preferenceStore.removePropertyChangeListener(propertyChangeListener);
            JFaceResources.getFontRegistry().removeListener(fontChangeListener);
            if (themeListener != null) {
                EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID)
                        .removePreferenceChangeListener(themeListener);
            }
        }
    });

    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
    EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID).addPreferenceChangeListener(themeListener);
}

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

License:Open Source License

/**
 * Create an expandable widget./*from   w  w  w.  j  av  a2 s .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;
}

From source file:com.aptana.ide.core.ui.SWTUtils.java

License:Open Source License

/**
 * Gets the default small font from the JFace font registry
 * /*from  w ww  .j a  v  a  2  s .  co m*/
 * @return - default small font
 */
public static Font getDefaultSmallFont() {
    Font small = JFaceResources.getFontRegistry().get(SMALL_FONT);
    if (small != null) {
        return small;
    }

    Font f = JFaceResources.getDefaultFont();
    FontData[] smaller = resizeFont(f, -2);
    JFaceResources.getFontRegistry().put(SMALL_FONT, smaller);
    return JFaceResources.getFontRegistry().get(SMALL_FONT);
}

From source file:com.aptana.ide.core.ui.SWTUtils.java

License:Open Source License

/**
 * Gets the default large font from the JFace font registry
 * //  www . j av  a  2  s.com
 * @return - default large font
 */
public static Font getDefaultLargeFont() {
    Font small = JFaceResources.getFontRegistry().get(LARGE_FONT);
    if (small != null) {
        return small;
    }

    Font f = JFaceResources.getDefaultFont();
    FontData[] smaller = resizeFont(f, -2);
    JFaceResources.getFontRegistry().put(LARGE_FONT, smaller);
    return JFaceResources.getFontRegistry().get(LARGE_FONT);
}

From source file:com.aptana.ide.rcp.IDEWorkbenchWindowAdvisor.java

License:Open Source License

public Control createEmptyWindowContents(Composite parent) {
    final IWorkbenchWindow window = getWindowConfigurer().getWindow();
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    Display display = composite.getDisplay();
    Color bgCol = display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND);
    composite.setBackground(bgCol);/*from   w ww  .jav a2s. co  m*/
    Label label = new Label(composite, SWT.WRAP);
    label.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
    label.setBackground(bgCol);
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    String msg = IDEWorkbenchMessages.IDEWorkbenchAdvisor_noPerspective;
    label.setText(msg);
    ToolBarManager toolBarManager = new ToolBarManager();
    // TODO: should obtain the open perspective action from ActionFactory
    openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);
    toolBarManager.add(openPerspectiveAction);
    ToolBar toolBar = toolBarManager.createControl(composite);
    toolBar.setBackground(bgCol);
    return composite;
}

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

License:Open Source License

protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
    final ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    excomposite.setText(label);//  www.  j  a v  a2 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) {
            OptionsConfigurationBlock.this.expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });
    this.fExpandedComposites.add(excomposite);
    this.makeScrollableCompositeAware(excomposite);
    return excomposite;
}