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

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

Introduction

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

Prototype

String TEXT_FONT

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

Click Source Link

Document

The symbolic font name for the text font (value "org.eclipse.jface.textfont").

Usage

From source file:hydrograph.ui.expression.editor.sourceviewer.SourceViewer.java

License:Apache License

private void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {

    Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        support.setAnnotationPreference((AnnotationPreference) e.next());
    }// ww w. ja va 2  s. co  m

    support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR);
    support.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN);
    support.setSymbolicFontName(JFaceResources.TEXT_FONT);
}

From source file:hydrograph.ui.expression.editor.sourceviewer.SourceViewer.java

License:Apache License

private void initializeViewer(IDocument document) {
    fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    setDocument(document);/*from w  ww  .  j  a va  2s .  c o m*/
    installViewerConfiguration();
    setEditable(true);
    Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
    getTextWidget().setFont(font);
    getTextWidget().setData("document", document);
    Control control = getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(data);
    prependVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            handleVerifyKeyPressed(event);
        }
    });
    addDocumentListener(document);
}

From source file:melnorme.lang.ide.ui.text.AbstractLangBasicSourceViewerConfiguration.java

License:Open Source License

public String getFontPropertyPreferenceKey() {
    return JFaceResources.TEXT_FONT;
}

From source file:melnorme.lang.ide.ui.text.coloring.AbstractSourceColoringConfigurationBlock.java

License:Open Source License

protected ProjectionViewer createPreviewViewer(Composite parent, boolean showAnnotationsOverview, int styles,
        IPreferenceStore store) {/*  w w  w.  ja  v a 2s  .  c  om*/
    ProjectionViewer sourceViewer = new ProjectionViewer(parent, null, null, showAnnotationsOverview, styles);
    AbstractLangSourceViewerConfiguration configuration = createSimpleSourceViewerConfiguration(store);
    sourceViewer.configure(configuration);
    sourceViewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    configuration.setupViewerForTextPresentationPrefChanges(sourceViewer);
    return sourceViewer;
}

From source file:msi.gama.lang.gaml.ui.highlight.GamlHighlightingConfiguration.java

public static GamaFont getDefaultFont() {
    final FontData fd = PreferenceConverter.getFontData(EditorsPlugin.getDefault().getPreferenceStore(),
            JFaceResources.TEXT_FONT);
    return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}

From source file:msi.gama.lang.gaml.ui.XtextGui.java

License:Open Source License

public static GamaFont getDefaultFontData() {
    FontData fd = PreferenceConverter.getFontData(EditorsPlugin.getDefault().getPreferenceStore(),
            JFaceResources.TEXT_FONT);
    return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}

From source file:net.sf.colorer.eclipse.editors.ColorerSourceViewerInformationControl.java

License:LGPL

private SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, SWT.NONE);

    SourceViewerConfiguration configuration = new SourceViewerConfiguration();
    viewer.configure(configuration);/*w w  w.j av  a 2 s .co m*/
    viewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    viewer.getTextWidget().setFont(font);

    return viewer;
}

From source file:net.sf.eclipsensis.editor.text.NSISTextUtility.java

License:Open Source License

public static void hookSourceViewer(final ISourceViewer viewer) {
    final StyledText textWidget = viewer.getTextWidget();

    final FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    textWidget.setFont(fontRegistry.get(JFaceResources.TEXT_FONT));
    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(JFaceResources.TEXT_FONT)) {
                textWidget.setFont(fontRegistry.get(JFaceResources.TEXT_FONT));
            }//from ww  w  .j  a  v a2 s  . c  o m
        }
    };
    fontRegistry.addListener(fontListener);

    final Display display = textWidget.getDisplay();
    final HashMap<String, Color> map = new HashMap<String, Color>();
    final IPreferenceStore store = EditorsUI.getPreferenceStore();

    textWidget.setBackground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
            AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, display));
    textWidget.setForeground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
            AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, display));

    final IPropertyChangeListener colorListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND) || event
                    .getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
                textWidget.setBackground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
                        AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, display));
            } else if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND) || event
                    .getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)) {
                textWidget.setForeground(createColor(map, store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
                        AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, display));
            }
        }
    };
    store.addPropertyChangeListener(colorListener);
    textWidget.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            fontRegistry.removeListener(fontListener);
            store.removePropertyChangeListener(colorListener);
            for (Iterator<Color> iter = map.values().iterator(); iter.hasNext();) {
                Color color = iter.next();
                if (color != null && !color.isDisposed()) {
                    color.dispose();
                }
            }
        }
    });
}

From source file:net.sf.fjep.fatjar.wizard.FJExportWizardConfigPage.java

License:Open Source License

private void showOneJARHelp() {
    MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help",
            MessageDialog.INFORMATION, new String[] { "OK" }, 0) {

        protected Font font;

        public boolean close() {
            boolean result;
            try {
                font.dispose();/*from  w  w  w .  ja  v  a  2s  . c  o m*/
            } finally {
                result = super.close();
            }
            return result;
        }

        protected Control createCustomArea(Composite parent) {
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.widthHint = 600;
            gd.heightHint = 300;
            String resource = "one-jar-help.txt";
            StringBuffer help = null;
            try {
                help = readText(this.getClass().getResourceAsStream(resource));
            } catch (IOException iox1) {
                help = new StringBuffer();
                help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1);
            }
            Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
            FontData fd = font.getFontData()[0];
            // Reduce the font-size. TODO: Should make this configurable in
            // preferences.
            fd.setHeight(fd.getHeight() - 2);
            font = new Font(text.getDisplay(), fd);
            text.setFont(font);
            text.setEditable(false);
            text.setLayoutData(gd);
            text.setText(help.toString());

            Hyperlink href = new Hyperlink(parent, SWT.NONE);
            href.setText("http://one-jar.sourceforge.net");
            href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
            href.setUnderlined(true);
            href.addHyperlinkListener(new IHyperlinkListener() {

                public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                }

                public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                }

                public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                    try {
                        SystemBrowserFactory factory = new SystemBrowserFactory();
                        factory.createBrowser().displayURL(e.getLabel());
                    } catch (Exception x) {
                        MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(),
                                "Unable to open browser: \n" + x.getStackTrace());
                    }
                }

            });
            return text;
        }
    };
    dialog.open();

}

From source file:net.sf.fjep.fatjar.wizards.export.ConfigPage.java

License:Open Source License

private void showOneJARHelp() {
    MessageDialog dialog = new MessageDialog(getShell(), "One-JAR", null, "One-JAR Help",
            MessageDialog.INFORMATION, new String[] { "OK" }, 0) {

        protected Font font;

        public boolean close() {
            boolean result;
            try {
                font.dispose();//from   w  ww. ja v a  2 s  .  c o m
            } finally {
                result = super.close();
            }
            return result;
        }

        protected Control createCustomArea(Composite parent) {
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.widthHint = 600;
            gd.heightHint = 300;
            String resource = "one-jar-help.txt";
            StringBuffer help = null;
            try {
                help = readText(this.getClass().getResourceAsStream(resource));
            } catch (IOException iox1) {
                help = new StringBuffer();
                help.append("Unable to locate built-in help for One-JAR at: " + resource + ": " + iox1);
            }
            Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
            FontData fd = font.getFontData()[0];
            // Reduce the font-size.  TODO: Should make this configurable in preferences.
            fd.setHeight(fd.getHeight() - 2);
            font = new Font(text.getDisplay(), fd);
            text.setFont(font);
            text.setEditable(false);
            text.setLayoutData(gd);
            text.setText(help.toString());

            Hyperlink href = new Hyperlink(parent, SWT.NONE);
            href.setText("http://one-jar.sourceforge.net");
            href.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
            href.setUnderlined(true);
            href.addHyperlinkListener(new IHyperlinkListener() {

                public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                }

                public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                }

                public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                    try {
                        SystemBrowserFactory factory = new SystemBrowserFactory();
                        factory.createBrowser().displayURL(e.getLabel());
                    } catch (Exception x) {
                        MessageDialog.openError(e.display.getActiveShell(), "Unable to open " + e.getLabel(),
                                "Unable to open browser: \n" + x.getStackTrace());
                    }
                }

            });
            return text;
        }
    };
    dialog.open();

}