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

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

Introduction

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

Prototype

public static Font getFont(String symbolicName) 

Source Link

Document

Returns the font in JFace's font registry with the given symbolic font name.

Usage

From source file:com.siteview.mde.internal.ui.preferences.SyntaxColorTab.java

License:Open Source License

private void createPreviewer(Composite parent) {
    Composite previewComp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    previewComp.setLayout(layout);//  www .  j a v  a  2 s .  c om
    previewComp.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label label = new Label(previewComp, SWT.NONE);
    label.setText(MDEUIMessages.SyntaxColorTab_preview);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fPreviewViewer = new SourceViewer(previewComp, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    fSourceViewerConfiguration = getSourceViewerConfiguration();

    if (fSourceViewerConfiguration != null)
        fPreviewViewer.configure(fSourceViewerConfiguration);

    fPreviewViewer.setEditable(false);
    fPreviewViewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    fPreviewViewer.setDocument(getDocument());

    Control control = fPreviewViewer.getControl();
    control.setLayoutData(new GridData(GridData.FILL_BOTH));
}

From source file:com.twinsoft.convertigo.eclipse.views.loggers.EngineLogViewLabelProvider.java

License:Open Source License

public Font getFont(Object element, int columnIndex) {
    return JFaceResources.getFont(JFaceResources.TEXT_FONT);
}

From source file:com.twinsoft.convertigo.eclipse.wizards.setup.LicensePage.java

License:Open Source License

public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(1, true));

    Text licenseText = new Text(container, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    licenseText.setEditable(false);//ww  w.j  a v  a  2 s  .c  o m
    Font terminalFont = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    licenseText.setFont(terminalFont);
    GridData gd = new GridData(GridData.FILL_BOTH);
    licenseText.setLayoutData(gd);

    try {
        licenseText.setText(IOUtils.toString(this.getClass().getResourceAsStream("license.txt"), "utf8"));
    } catch (Exception e) {
        licenseText.setText("Unable to get the license text!\n" + e.getMessage());
    }

    Label acceptation = new Label(container, SWT.WRAP);
    acceptation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    acceptation.setText("BY INDICATING YOUR ACCEPTANCE BY CLICKING Accept license? BELOW, "
            + "OR INSTALLING OR USING THE SOFTWARE, YOU ARE AGREEING TO BE BOUND "
            + "BY THE TERMS OF THIS AGREEMENT.");

    Button acceptLicense = new Button(container, SWT.CHECK);
    acceptLicense.setText("Accept license");
    acceptLicense.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            setPageComplete(((Button) e.widget).getSelection());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }

    });

    setControl(container);
    setPageComplete(false);
}

From source file:com.vectrace.MercurialEclipse.annotations.SourceViewerInformationControl.java

License:Open Source License

/**
 * Creates a source viewer information control with the given shell as
 * parent. The given shell styles are applied to the created shell. The
 * given styles are applied to the created styled text widget. The text
 * widget will be initialized with the given font. The status field will
 * contain the given text or be hidden./*www  .ja va 2s  .  c o m*/
 *
 * @param parent the parent shell
 * @param shellStyle the additional styles for the shell
 * @param style the additional styles for the styled text widget
 * @param symbolicFontName the symbolic font name
 * @param statusFieldText the text to be used in the optional status field
 *            or <code>null</code> if the status field should be hidden
 */
public SourceViewerInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName,
        String statusFieldText) {
    GridLayout layout;
    GridData gd;

    fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
    Display display = fShell.getDisplay();
    fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));

    Composite composite = fShell;
    layout = new GridLayout(1, false);
    int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
    layout.marginHeight = border;
    layout.marginWidth = border;
    composite.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    composite.setLayoutData(gd);

    if (statusFieldText != null) {
        composite = new Composite(composite, SWT.NONE);
        layout = new GridLayout(1, false);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        composite.setLayout(layout);
        gd = new GridData(GridData.FILL_BOTH);
        composite.setLayoutData(gd);
        composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
        composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    // Source viewer
    fViewer = new SourceViewer(composite, null, style);
    fViewer.setEditable(false);

    // configure hyperlink detectors
    // fViewer.configure(new SourceViewerConfiguration());
    fViewer.configure(new HgTextSourceViewerConfiguration(EditorsUI.getPreferenceStore()));

    fText = fViewer.getTextWidget();
    gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
    fText.setLayoutData(gd);
    fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    fText.setFont(JFaceResources.getFont(symbolicFontName));

    fText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) {
                fShell.dispose();
            }
        }

        public void keyReleased(KeyEvent e) {
        }
    });

    // Status field
    if (statusFieldText != null) {

        // Horizontal separator line
        fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
        fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        // Status field label
        fStatusField = new Label(composite, SWT.RIGHT);
        fStatusField.setText(statusFieldText);
        Font font = fStatusField.getFont();
        FontData[] fontDatas = font.getFontData();
        for (int i = 0; i < fontDatas.length; i++) {
            fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
        }
        fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas);
        fStatusField.setFont(fStatusTextFont);
        GridData gd2 = new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
        fStatusField.setLayoutData(gd2);

        // Regarding the color see bug 41128
        fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));

        fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    addDisposeListener(this);
}

From source file:de.babe.eclipse.plugins.quickREx.editors.RELibraryEntryFormPage.java

License:Open Source License

protected void createFormContent(IManagedForm managedForm) {
    FormToolkit tk = managedForm.getToolkit();
    ScrolledForm form = managedForm.getForm();
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;// ww w .  ja  v a  2  s.  c o m
    form.getBody().setLayout(layout);

    GridData gd;
    // First row...
    Label titleLabel = tk.createLabel(form.getBody(),
            Messages.getString("editors.RELibraryEntryFormPage.title.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    titleLabel.setLayoutData(gd);
    titleText = new Text(form.getBody(), SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    titleText.setEditable(!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly());
    titleText.setText(((RELibraryEntryEditorInput) getEditorInput()).getRELibraryEntry().getTitle());
    titleText.addModifyListener(new ModifyListener() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        public void modifyText(ModifyEvent e) {
            ((RELibraryEntryEditor) getEditor()).setIsDirty(true);
        }
    });
    titleText.setFont(JFaceResources.getFont(QuickRExView.EDITOR_FONT_KEY));
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = true;
    titleText.setLayoutData(gd);
    tk.adapt(titleText, true, true);

    // Second row...
    Label regExpLabel = tk.createLabel(form.getBody(),
            Messages.getString("editors.RELibraryEntryFormPage.re.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    regExpLabel.setLayoutData(gd);
    regExpText = new Text(form.getBody(), SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    regExpText.setEditable(!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly());
    regExpText.setText(((RELibraryEntryEditorInput) getEditorInput()).getRELibraryEntry().getRe());
    regExpText.addModifyListener(new ModifyListener() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        public void modifyText(ModifyEvent e) {
            ((RELibraryEntryEditor) getEditor()).setIsDirty(true);
        }
    });
    regExpText.setFont(JFaceResources.getFont(QuickRExView.EDITOR_FONT_KEY));
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = true;
    regExpText.setLayoutData(gd);
    tk.adapt(regExpText, true, true);
    if (!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly()) {
        createRegExpContentAssist();
    }

    // Third row...
    Label testTextLabel = tk.createLabel(form.getBody(),
            Messages.getString("editors.RELibraryEntryFormPage.testtext.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    testTextLabel.setLayoutData(gd);
    testTextText = new Text(form.getBody(), SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    testTextText.setEditable(!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly());
    testTextText.setText(((RELibraryEntryEditorInput) getEditorInput()).getRELibraryEntry().getTesttext());
    testTextText.addModifyListener(new ModifyListener() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        public void modifyText(ModifyEvent e) {
            ((RELibraryEntryEditor) getEditor()).setIsDirty(true);
        }
    });
    testTextText.setFont(JFaceResources.getFont(QuickRExView.EDITOR_FONT_KEY));
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = true;
    testTextText.setLayoutData(gd);
    tk.adapt(testTextText, true, true);

    // Fourth row...
    Label descriptionLabel = tk.createLabel(form.getBody(),
            Messages.getString("editors.RELibraryEntryFormPage.desc.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    descriptionLabel.setLayoutData(gd);
    descriptionText = new Text(form.getBody(), SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    descriptionText.setEditable(!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly());
    descriptionText
            .setText(((RELibraryEntryEditorInput) getEditorInput()).getRELibraryEntry().getDescription());
    descriptionText.addModifyListener(new ModifyListener() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        public void modifyText(ModifyEvent e) {
            ((RELibraryEntryEditor) getEditor()).setIsDirty(true);
        }
    });
    descriptionText.setFont(JFaceResources.getFont(QuickRExView.EDITOR_FONT_KEY));
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = true;
    descriptionText.setLayoutData(gd);
    tk.adapt(descriptionText, true, true);

    // Fifth row...
    Label sourceLabel = tk.createLabel(form.getBody(),
            Messages.getString("editors.RELibraryEntryFormPage.source.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    sourceLabel.setLayoutData(gd);
    sourceText = new Text(form.getBody(), SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    sourceText.setEditable(!((RELibraryEntryEditorInput) getEditorInput()).isReadOnly());
    sourceText.setText(((RELibraryEntryEditorInput) getEditorInput()).getRELibraryEntry().getSource());
    sourceText.addModifyListener(new ModifyListener() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        public void modifyText(ModifyEvent e) {
            ((RELibraryEntryEditor) getEditor()).setIsDirty(true);
        }
    });
    sourceText.setFont(JFaceResources.getFont(QuickRExView.EDITOR_FONT_KEY));
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = true;
    sourceText.setLayoutData(gd);
    tk.adapt(sourceText, true, true);
}

From source file:de.babe.eclipse.plugins.quickREx.views.QuickRExView.java

License:Open Source License

private void createSecondRow(FormToolkit tk, Form form) {
    GridData gd;//from ww w.j a  v a 2s .  c o  m
    // Second row
    Label testTextEnter = tk.createLabel(form.getBody(),
            Messages.getString("views.QuickRExView.secondrow.label")); //$NON-NLS-1$
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
    gd.grabExcessHorizontalSpace = false;
    testTextEnter.setLayoutData(gd);
    testText = new StyledText(form.getBody(), SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    testText.setFont(JFaceResources.getFont(EDITOR_FONT_KEY));
    gd = new GridData(GridData.FILL_BOTH);
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;

    gd.horizontalSpan = 3;
    testText.setLayoutData(gd);
    testText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent event) {
            handleTestTextModified();
        }
    });
    tk.adapt(testText, true, true);
}

From source file:de.babe.eclipse.plugins.quickREx.views.QuickRExView.java

License:Open Source License

private void createFirstRow(FormToolkit tk, Form form) {
    GridData gd;/*from  w ww  . j a v a 2 s . com*/
    // First row...
    Label regExpEnter = tk.createLabel(form.getBody(), Messages.getString("views.QuickRExView.firstrow.label")); //$NON-NLS-1$
    gd = new GridData();
    gd.horizontalAlignment = GridData.END;
    gd.grabExcessHorizontalSpace = false;
    regExpEnter.setLayoutData(gd);
    regExpCombo = new Combo(form.getBody(), SWT.DROP_DOWN);
    regExpCombo.setItems(new String[0]);
    regExpCombo.setFont(JFaceResources.getFont(EDITOR_FONT_KEY));
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    gd.horizontalSpan = 2;
    gd.grabExcessHorizontalSpace = true;
    regExpCombo.setLayoutData(gd);
    regExpCombo.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent event) {
            handleRegExpModified();
        }
    });
    regExpCombo.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(FocusEvent event) {
            // This is a hack to keep the Previous- and Next-Buttons from generating
            // selections in the component...
            regExpCombo.clearSelection();
        }

        @Override
        public void focusLost(FocusEvent event) {
            // This is a hack to keep the Previous- and Next-Buttons from generating
            // selections in the component...
            regExpCombo.clearSelection();
        }
    });
    regExpCombo.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent e) {
            lastRESelection = regExpCombo.getSelection();
        }

        @Override
        public void keyReleased(KeyEvent e) {
            lastRESelection = regExpCombo.getSelection();
        }
    });
    regExpCombo.addMouseListener(new MouseListener() {
        @Override
        public void mouseDoubleClick(MouseEvent e) {
        }

        @Override
        public void mouseDown(MouseEvent e) {
            lastRESelection = regExpCombo.getSelection();
        }

        @Override
        public void mouseUp(MouseEvent e) {
        }
    });
    tk.adapt(regExpCombo, true, true);

    stopButton = tk.createButton(form.getBody(), "", SWT.PUSH);
    stopButton.setEnabled(false);
    gd = new GridData();
    gd.horizontalAlignment = GridData.END;
    gd.horizontalSpan = 1;
    gd.grabExcessHorizontalSpace = false;
    stopButton.setLayoutData(gd);
    PluginImageRegistry imageRegistry = (PluginImageRegistry) QuickRExPlugin.getDefault().getImageRegistry();
    stopButton.setImage(imageRegistry.getDescriptor(PluginImageRegistry.IMG_STOP).createImage());
    stopButton.setToolTipText(Messages.getString("views.QuickRExView.stopButton.tooltip"));
    stopButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleStopButtonPressed();
        }

    });

    createRegExpContentAssist();
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.sheet.ChangedAbstractBasicTextPropertySection.java

License:Open Source License

/**
 * Instantiate a text widget/*from   www  .  ja  v  a  2  s  .c  o  m*/
 * 
 * @param parent
 *            - parent composite
 * @return - a text widget to display and edit the property
 */
protected final MarkableStyledText createTextWidget(final Composite parent) {
    getSectionComposite().getSize();

    final MarkableStyledText st = new MarkableStyledText(parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);

    final Font userFont = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    st.setFont(userFont);

    final FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.height = START_HEIGHT;
    st.setLayoutData(data);

    st.setBackground(EditorsUI.getSharedTextColors().getColor(PreferenceConverter
            .getColor(EditorsUI.getPreferenceStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)));

    if (isReadOnly()) {
        st.setEditable(false);
    }

    return st;
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.sheet.SimpleChangedAbstractBasicTextPropertySection.java

License:Open Source License

/**
 * Instantiate a text widget/*from w  ww . j a v a2s . c  om*/
 * 
 * @param parent
 *            - parent composite
 * @return - a text widget to display and edit the property
 */
protected final StyledText createTextWidget(final Composite parent) {
    getSectionComposite().getSize();

    final StyledText st = new StyledText(parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);

    final Font userFont = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    st.setFont(userFont);

    final FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.height = startHeight;
    st.setLayoutData(data);

    st.setBackground(EditorsUI.getSharedTextColors().getColor(PreferenceConverter
            .getColor(EditorsUI.getPreferenceStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)));

    if (isReadOnly()) {
        st.setEditable(false);
    }

    return st;
}

From source file:de.walware.docmlet.tex.internal.ui.preferences.LtxEditorTemplatesPreferencePage.java

License:Open Source License

@Override
protected SourceViewer createViewer(final Composite parent) {
    final SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    viewer.setEditable(false);/* w w w.  j a  v  a 2s  .  c o  m*/
    viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));

    final ViewerSourceEditorAdapter adapter = new ViewerSourceEditorAdapter(viewer, null);
    fViewerConfigurator.setTarget(adapter);
    // updater
    new SettingsUpdater(fViewerConfigurator, viewer.getControl());
    new TextViewerJFaceUpdater(viewer, fViewerConfigurator.getSourceViewerConfiguration().getPreferences());
    new TextViewerEditorColorUpdater(viewer,
            fViewerConfigurator.getSourceViewerConfiguration().getPreferences());

    final IDocument document = new Document();
    fViewerConfigurator.getDocumentSetupParticipant().setup(document);
    viewer.setDocument(document);

    return viewer;
}