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

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

Introduction

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

Prototype

public static Font getTextFont() 

Source Link

Document

Returns JFace's text font.

Usage

From source file:com.google.eclipse.elt.view.preferences.PreferenceInitializer.java

License:Open Source License

@Override
public void initializeDefaultPreferences() {
    preferenceStore().setDefault(BUFFER_LINE_COUNT, 1000);
    preferenceStore().setDefault(CLOSE_VIEW_ON_EXIT, true);
    preferenceStore().setDefault(WARN_ON_CLOSE, true);
    setDefault(BACKGROUND_COLOR, new RGB(0, 0, 0));
    setDefault(FOREGROUND_COLOR, new RGB(229, 229, 229));
    preferenceStore().setDefault(USE_CUSTOM_FONT, false);
    preferenceStore().setDefault(USE_BLINKING_CURSOR, true);
    PreferenceConverter.setDefault(preferenceStore(), CUSTOM_FONT_DATA,
            JFaceResources.getTextFont().getFontData());
}

From source file:com.google.eclipse.elt.view.ui.TerminalView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    terminalWidget = new TerminalWidget(parent, getViewSite());
    terminalWidget.setLifeCycleListener(new LifeCycleListener() {
        @Override/*ww  w  . j  a  va  2s  .  c  o  m*/
        public void executionFinished() {
            closeViewOnExitIfPossible();
        }
    });
    terminalWidget.setTerminalListener(new ITerminalListener() {
        @Override
        public void setTerminalTitle(final String title) {
            updatePartName(title);
        }

        @Override
        public void setState(TerminalState state) {
        }
    });
    IViewSite viewSite = getViewSite();
    preferencesChangeListener = new AbstractPreferencesChangeListener() {
        @Override
        protected void onBufferLineCountChanged() {
            updateBufferLineCount();
        }

        @Override
        protected void onColorChanged() {
            updateColors();
        }

        @Override
        protected void onFontChanged() {
            updateFont();
        }

        @Override
        protected void onUseBlinkingCursorChanged() {
            updateUsageOfBlinkingCursor();
        }
    };
    preferenceStore().addPropertyChangeListener(preferencesChangeListener);
    updateBufferLineCount();
    updateColors();
    updateUsageOfBlinkingCursor();
    textFontChangeListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (TEXT_FONT.equals(event.getProperty())) {
                if (!useCustomFont()) {
                    setFont(JFaceResources.getTextFont());
                }
            }
        }
    };
    JFaceResources.getFontRegistry().addListener(textFontChangeListener);
    updateFont();
    setupToolBarActions();
    IContextService contextService = contextService();
    if (contextService != null) {
        contextActivation = contextService
                .activateContext("com.google.eclipse.terminal.local.context.localTerminal");
    }
    if (savedState != null) {
        updateScrollLockUsingSavedState();
        connectUsingSavedState();
        return;
    }
    if (viewSite.getSecondaryId() == null) {
        setPartName(defaultViewTitle);
        open(userHomeDirectory());
    }
    enableScrollLock(scrollLockAction.isChecked());
}

From source file:com.google.eclipse.elt.view.ui.TerminalView.java

License:Open Source License

private Font terminalFont() {
    if (useCustomFont()) {
        return new Font(Display.getDefault(), customFontData());
    }//from  ww w.ja v a  2s .com
    return JFaceResources.getTextFont();
}

From source file:com.ibm.xsp.extlib.designer.bluemix.wizard.ManifestBluemixWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    super.createControl(parent);

    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = WizardUtils.createGridLayout(1, 5);
    container.setLayout(layout);/*from  www .  ja v a  2  s.  c  om*/

    _overwriteRadio = WizardUtils.createRadio(container, "Create a new Manifest", 1, this, 0); // $NLX-ManifestBluemixWizardPage.CreateanewManifest-1$
    _useExistingRadio = WizardUtils.createRadio(container, "Use the existing Manifest", 1, this, 0); // $NLX-ManifestBluemixWizardPage.UsetheexistingManifest-1$

    _fileLabel = WizardUtils.createText(container,
            SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY, 1, 20, GridData.FILL_BOTH);
    _fileLabel.setFont(JFaceResources.getTextFont());
    _fileLabel.setBackground(_wiz.getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

    setControl(container);
}

From source file:com.iw.plugins.spindle.editors.SummarySourceViewer.java

License:Mozilla Public License

private void initializeWidgetFont(StyledText styledText) {
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {

        FontData data = null;/*from  w w w  .  j a v a  2 s . co m*/

        if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
            data = PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
        } else {
            data = PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
        }

        if (data != null) {
            Font font = new Font(styledText.getDisplay(), data);
            styledText.setFont(font);

            if (currentFont != null)
                currentFont.dispose();

            currentFont = font;
            return;
        }
    }

    // if all the preferences failed
    styledText.setFont(JFaceResources.getTextFont());
}

From source file:com.mentor.nucleus.bp.debug.ui.propertypages.BreakpointConditionEditor.java

License:Open Source License

public BreakpointConditionEditor(Group parent, BPBreakpointPage page) {
    fPage = page;//from  w  ww.j a  va2s  .com
    fBreakpoint = (IBPBreakpoint) fPage.getBreakpoint();
    String condition;
    try {
        condition = fBreakpoint.getCondition();
    } catch (CoreException e) {
        BPDebugUIPlugin.logError("Unable to get breakpoint condition", e);
        return;
    }
    fErrorMessage = "Enter a condition";
    fOldValue = ""; //$NON-NLS-1$

    // the source viewer
    fViewer = new TextViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    fViewer.setInput(parent);

    IDocument document = new Document();
    fViewer.setEditable(true);
    fViewer.setDocument(document);
    final IUndoManager undoManager = new DefaultUndoManager(10);
    fViewer.setUndoManager(undoManager);
    undoManager.connect(fViewer);

    fViewer.getTextWidget().setFont(JFaceResources.getTextFont());

    Control control = fViewer.getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(gd);

    // listener for check the value
    fDocumentListener = new IDocumentListener() {
        public void documentAboutToBeChanged(DocumentEvent event) {
        }

        public void documentChanged(DocumentEvent event) {
            valueChanged();
        }
    };
    fViewer.getDocument().addDocumentListener(fDocumentListener);

    gd = (GridData) fViewer.getControl().getLayoutData();
    gd.heightHint = fPage.convertHeightInCharsToPixels(10);
    gd.widthHint = fPage.convertWidthInCharsToPixels(40);
    document.set(condition);
    valueChanged();

}

From source file:com.microsoft.tfs.client.common.ui.controls.eula.EULAControl.java

License:Open Source License

public EULAControl(final Composite parent, final int style) {
    super(parent, style);

    final GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing();
    layout.marginWidth = 0;//from   w w w.j  a  va  2  s .com
    layout.marginHeight = 0;
    setLayout(layout);

    final Label descriptionText = new Label(this, SWT.WRAP | SWT.READ_ONLY);
    descriptionText.setText(Messages.getString("EulaControl.DescriptionText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(descriptionText);

    final Text eulaText = new Text(this, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    AutomationIDHelper.setWidgetID(eulaText, EULA_TEXTBOX_ID);
    eulaText.setText(EULAText.getEULAText());
    eulaText.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    eulaText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
    GridDataBuilder.newInstance().hGrab().hFill().vGrab().vFill().applyTo(eulaText);

    final Font font = JFaceResources.getTextFont();

    if (font != null) {
        eulaText.setFont(font);
    }

    ControlSize.setCharHeightHint(eulaText, 10);
    ControlSize.setCharWidthHint(eulaText, 80);

    // TODO: This is a work around for a linux layout problem. We may have
    // to revisit this and other issues with the wizard when we update for
    // localization.
    ControlSize.setCharHeightHint(descriptionText, 3);
    ControlSize.setCharWidthHint(descriptionText, 80);

    acceptButton = new Button(this, SWT.CHECK);
    AutomationIDHelper.setWidgetID(acceptButton, ACCEPT_CHECKBOX_ID);
    acceptButton.setText(Messages.getString("EulaControl.AcceptButtonText")); //$NON-NLS-1$
    acceptButton.setSelection(accepted);
    acceptButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            accepted = acceptButton.getSelection();

            notifyListeners();
        }
    });
    GridDataBuilder.newInstance().hGrab().applyTo(acceptButton);
}

From source file:com.mmkarton.mx7.reportgenerator.wizards.BIRTSQLWizardPage.java

License:Open Source License

private Control createTextualQueryComposite(Composite parent) {

    Composite composite = new Composite(parent, SWT.FILL | SWT.LEFT_TO_RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;//from   ww w  . ja  va2 s  .c  o m
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    CompositeRuler ruler = new CompositeRuler();
    LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
    ruler.addDecorator(0, lineNumbers);
    viewer = new SourceViewer(composite, ruler, SWT.H_SCROLL | SWT.V_SCROLL);

    SourceViewerConfiguration svc = new SQLSourceViewerConfiguration(null);
    //SourceViewerConfiguration svc = new SourceViewerConfiguration();
    viewer.configure(svc);

    //doc = new Document( getQueryText( ) );
    doc = new Document("select \n from ");

    FastPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(), new String[] {
            SQLPartitionScanner.QUOTE_STRING, SQLPartitionScanner.COMMENT, IDocument.DEFAULT_CONTENT_TYPE });
    partitioner.connect(doc);
    doc.setDocumentPartitioner(partitioner);
    viewer.setDocument(doc);
    viewer.getTextWidget().setFont(JFaceResources.getTextFont());
    viewer.getTextWidget().addBidiSegmentListener(new BidiSegmentListener() {

        /*
        * @see
        * org.eclipse.swt.custom.BidiSegmentListener#lineGetSegments
        * (org.eclipse.swt.custom.BidiSegmentEvent)
        */
        public void lineGetSegments(BidiSegmentEvent event) {
            event.segments = SQLUtility.getBidiLineSegments(event.lineText);
        }
    });
    attachMenus(viewer);

    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 500;
    viewer.getControl().setLayoutData(data);

    // Add drop support to the viewer
    addDropSupportToViewer();

    // add support of additional accelerated key
    viewer.getTextWidget().addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (isUndoKeyPress(e)) {
                viewer.doOperation(ITextOperationTarget.UNDO);
            } else if (isRedoKeyPress(e)) {
                viewer.doOperation(ITextOperationTarget.REDO);
            }
        }

        private boolean isUndoKeyPress(KeyEvent e) {
            // CTRL + z
            return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'z') || (e.keyCode == 'Z'));
        }

        private boolean isRedoKeyPress(KeyEvent e) {
            // CTRL + y
            return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'y') || (e.keyCode == 'Y'));
        }

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

From source file:com.siteview.mde.internal.ui.editor.feature.InfoSection.java

License:Open Source License

/**
 * @param toolkit//from   www  . j  a va 2s. co m
 * @param parent
 */
private Control createInfoPage(FormToolkit toolkit, Composite parent) {
    Composite page = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 5;
    layout.verticalSpacing = 8;
    page.setLayout(layout);

    GridData gd;
    Label label = toolkit.createLabel(page, MDEUIMessages.FeatureEditor_InfoSection_url);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    fUrlText = toolkit.createText(page, null, SWT.SINGLE);
    fUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            infoModified();
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fUrlText.setLayoutData(gd);
    label = toolkit.createLabel(page, MDEUIMessages.FeatureEditor_InfoSection_text);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    label.setLayoutData(gd);
    int styles = SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL;
    fSourceViewer = new SourceViewer(page, null, styles);
    fSourceViewer.configure(fSourceConfiguration);
    fSourceViewer.setDocument(fDocument);
    fSourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelection(event.getSelection());
        }
    });
    StyledText styledText = fSourceViewer.getTextWidget();
    styledText.setFont(JFaceResources.getTextFont());
    styledText.setMenu(getPage().getMDEEditor().getContextMenu());
    styledText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    //
    if (SWT.getPlatform().equals("motif") == false) //$NON-NLS-1$
        toolkit.paintBordersFor(page);
    Control[] children = page.getChildren();
    Control control = children[children.length - 1];
    gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    gd.widthHint = 50;
    gd.heightHint = 50;
    control.setLayoutData(gd);

    return page;
}

From source file:com.siteview.mde.internal.ui.editor.feature.LicenseFeatureSection.java

License:Open Source License

/**
 * Creates the UI in the given section using the provided toolkit
 * @param toolkit//from  w w w.  ja va  2 s  .  com
 * @param parent
 */
public void createClient(Section section, FormToolkit toolkit) {
    Composite page = toolkit.createComposite(section);
    final StackLayout stackLayout = new StackLayout();

    GridLayout layout = FormLayoutFactory.createClearGridLayout(false, 2);
    layout.horizontalSpacing = 8;
    page.setLayout(layout);
    fSharedLicenseButton = toolkit.createButton(page,
            MDEUIMessages.FeatureEditor_licenseFeatureSection_sharedButton, SWT.RADIO);
    fLocalLicenseButton = toolkit.createButton(page,
            MDEUIMessages.FeatureEditor_licenseFeatureSection_localButton, SWT.RADIO);

    GridData gd = new GridData();
    gd.horizontalIndent = 5;
    fLocalLicenseButton.setLayoutData(gd);

    final Composite sectionsComposite = toolkit.createComposite(page);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    sectionsComposite.setLayoutData(gd);
    sectionsComposite.setLayout(stackLayout);

    // Shared Section

    final Composite licenseFeatureComposite = toolkit.createComposite(sectionsComposite);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    licenseFeatureComposite.setLayoutData(gd);

    layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginWidth = 2;
    layout.marginHeight = 5;
    layout.verticalSpacing = 8;
    licenseFeatureComposite.setLayout(layout);

    Label label = toolkit.createLabel(licenseFeatureComposite,
            MDEUIMessages.FeatureEditor_licenseFeatureSection_featureID);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fLicenseFeatureIDText = toolkit.createText(licenseFeatureComposite, null, SWT.SINGLE);
    fLicenseFeatureIDText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            infoModified();
        }
    });

    fLicenseFeatureIDText.setEditable(true);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fLicenseFeatureIDText.setLayoutData(gd);

    fLicenseButton = toolkit.createButton(licenseFeatureComposite,
            MDEUIMessages.FeatureEditor_licenseFeatureSection_browse, SWT.PUSH);
    fLicenseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            handleSelect();
        }
    });

    label = toolkit.createLabel(licenseFeatureComposite,
            MDEUIMessages.FeatureEditor_licenseFeatureSection_featureVersion);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fLicenseFeatureVersionText = toolkit.createText(licenseFeatureComposite, null, SWT.SINGLE);
    fLicenseFeatureVersionText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            infoModified();
        }
    });

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fLicenseFeatureVersionText.setLayoutData(gd);

    // Local Section

    final Composite localLicenseComposite = toolkit.createComposite(sectionsComposite);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    localLicenseComposite.setLayoutData(gd);

    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 5;
    layout.verticalSpacing = 8;
    localLicenseComposite.setLayout(layout);

    label = toolkit.createLabel(localLicenseComposite, MDEUIMessages.FeatureEditor_InfoSection_url);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fUrlText = toolkit.createText(localLicenseComposite, null, SWT.SINGLE);
    fUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            infoModified();
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fUrlText.setLayoutData(gd);

    label = toolkit.createLabel(localLicenseComposite, MDEUIMessages.FeatureEditor_InfoSection_text);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    label.setLayoutData(gd);

    int styles = SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL;
    fSourceViewer = new SourceViewer(localLicenseComposite, null, styles);
    fSourceViewer.configure(fSourceConfiguration);
    fSourceViewer.setDocument(fDocument);
    StyledText styledText = fSourceViewer.getTextWidget();
    styledText.setFont(JFaceResources.getTextFont());
    styledText.setMenu(getPage().getMDEEditor().getContextMenu());
    styledText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    fDocument.addDocumentListener(new IDocumentListener() {
        public void documentChanged(DocumentEvent e) {
            infoModified();
        }

        public void documentAboutToBeChanged(DocumentEvent e) {
        }
    });

    if (SWT.getPlatform().equals("motif") == false) { //$NON-NLS-1$
        toolkit.paintBordersFor(localLicenseComposite);
    }

    gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    gd.widthHint = 50;
    gd.heightHint = 50;
    styledText.setLayoutData(gd);

    fSharedLicenseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (((Button) e.widget).getSelection()) {
                stackLayout.topControl = licenseFeatureComposite;
                sectionsComposite.layout();
            }
        }
    });
    fLocalLicenseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (((Button) e.widget).getSelection()) {
                stackLayout.topControl = localLicenseComposite;
                sectionsComposite.layout();
            }
        }
    });

    section.setClient(page);

    IFeatureModel model = (IFeatureModel) getPage().getModel();
    IFeature feature = model.getFeature();
    if (feature.getLicenseFeatureID() == null || feature.getLicenseFeatureID().length() == 0) {
        fLocalLicenseButton.setSelection(true);
        fSharedLicenseButton.setSelection(false);
        stackLayout.topControl = localLicenseComposite;
    } else {
        fLocalLicenseButton.setSelection(false);
        fSharedLicenseButton.setSelection(true);
        stackLayout.topControl = licenseFeatureComposite;
    }
    model.addModelChangedListener(this);

    toolkit.paintBordersFor(licenseFeatureComposite);

}