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:net.sf.sveditor.ui.pref.TemplatePropertyDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Label l;/*  w  w w.j  a  va2 s.  c  o  m*/
    Composite frame = new Composite(parent, SWT.NONE);
    frame.setLayout(new GridLayout(2, false));

    GridData gd;

    l = new Label(frame, SWT.NONE);
    l.setText("Parameter:");
    fParameterId = new Text(frame, SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 250;
    fParameterId.setLayoutData(gd);
    fParameterId.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            fParameterIdStr = fParameterId.getText();
            validate();
        }
    });

    if (fParameterIdStr != null) {
        fParameterId.setText(fParameterIdStr);
    }

    if (!fCanModifyId) {
        fParameterId.setEditable(false);
        fParameterId.setEnabled(false);
    }

    fValue = new Text(frame, SWT.MULTI + SWT.BORDER + SWT.V_SCROLL);
    fValue.setFont(JFaceResources.getTextFont());
    fValue.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            fValueStr = fValue.getText();
            validate();
        }
    });

    if (fValueStr != null) {
        fValue.setText(fValueStr);
    }

    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.horizontalSpan = 2;
    gd.heightHint = 100;
    fValue.setLayoutData(gd);

    return frame;
}

From source file:net.timedoctor.ui.statistics.StatisticsViewer.java

License:Open Source License

private void createStyledText(final Composite parent) {
    styledText = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY);
    styledText.setFont(JFaceResources.getTextFont());
    styledText.setVisible(false);/*  w ww .  jav  a2s .  c o  m*/

    initStyledTextPrintOptions();
}

From source file:net.tourbook.map3.action.ActionOpenGLVersions.java

License:Open Source License

private Composite createUI_10_Content(final Composite parent) {

    _tk = new FormToolkit(parent.getDisplay());

    final Composite container = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
    GridLayoutFactory.swtDefaults().spacing(20, 0).applyTo(container);
    {//from  ww w.j  av  a2  s.  c  o  m
        _txtInfo = _tk.createText(container, UI.EMPTY_STRING, 0 //
                | SWT.MULTI
                //               | SWT.BORDER
                | SWT.READ_ONLY | SWT.V_SCROLL
        //               | SWT.H_SCROLL
        //
        );
        GridDataFactory.fillDefaults()//
                .grab(true, true).applyTo(_txtInfo);

        // set mono spaced font
        _txtInfo.setFont(JFaceResources.getTextFont());

        createUI_90_OpenGL(container);

        final Label label = new Label(container, SWT.NONE);
        GridDataFactory.fillDefaults().applyTo(label);
        label.setText("test"); //$NON-NLS-1$

    }

    return container;
}

From source file:org.brainwy.liclipsetext.shared_ui.FontUtils.java

License:Open Source License

/**
 * Select a monospaced font based on intended usage. 
 * Can be used to provide a consistend code font size between platforms.
 * //from   w ww.  j a  v a  2  s . c o m
 * @param usage intended usage. See {@link IFontUsage} for valid values.
 * @param style SWT style constants mask
 * @param useDefaultJFaceFontIfPossible
 * @return {@link FontData} object
 */
public static FontData getFontData(int usage, int style, boolean useDefaultJFaceFontIfPossible) {
    if (useDefaultJFaceFontIfPossible) {
        FontData[] textFontData = JFaceResources.getTextFont().getFontData();
        if (textFontData.length == 1) {
            return textFontData[0];
        }
    }
    Tuple<String, Integer> codeFontDetails = FontUtils.getCodeFontNameAndHeight(usage);
    String fontName = codeFontDetails.o1;
    int base = codeFontDetails.o2.intValue();
    return new FontData(fontName, base, style);
}

From source file:org.chromium.debug.ui.propertypages.JsLineBreakpointPage.java

License:Open Source License

private void createConditionControls(Composite parent) {
    conditionCheckbox = new Button(parent, SWT.CHECK);
    conditionCheckbox.setSelection(getBreakpoint().getCondition() != null);
    conditionCheckbox.addSelectionListener(new SelectionAdapter() {
        @Override//w  w  w  .  ja  va  2s .  c  om
        public void widgetSelected(SelectionEvent e) {
            conditionText.setEnabled(conditionCheckbox.getSelection());
            conditionChanged();
        }
    });
    conditionCheckbox.setText(Messages.JavascriptLineBreakpointPage_EnableCondition);
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    conditionCheckbox.setLayoutData(gd);
    conditionText = new Text(parent, SWT.MULTI | SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    conditionText.setLayoutData(gd);
    conditionText.setTextLimit(300);
    conditionText.setFont(JFaceResources.getTextFont());
    conditionText.setEnabled(conditionCheckbox.getSelection());
    conditionText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            conditionChanged();
        }
    });
    conditionText.setText(maskNull(getBreakpoint().getCondition()));
}

From source file:org.codehaus.groovy.eclipse.debug.ui.EnsureJUnitFont.java

License:Apache License

private void internalSetMonospaceFont(boolean isMonospace, TestRunnerViewPart view) {
    FailureTrace trace = view.getFailureTrace();
    Composite widget = (Composite) ReflectionUtils.getPrivateField(FailureTrace.class, "fTable", trace);

    if (isMonospace) {
        widget.setFont(JFaceResources.getTextFont());
    } else {/*from  ww w.j  a  va 2  s . c  o m*/
        widget.setFont(JFaceResources.getDefaultFont());
    }
}

From source file:org.dawnsci.common.widgets.gda.function.detail.JexlExpressionFunctionDetailPane.java

License:Open Source License

@Override
public Control createControl(Composite parent) {
    Composite composite = new Composite(parent, 0);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);

    Label fxy = new Label(composite, SWT.NONE);
    fxy.setText("f(x)=");
    FontData fontData = fxy.getFont().getFontData()[0];
    fxyFont = new Font(fxy.getDisplay(),
            new FontData(fontData.getName(), fontData.getHeight() * 3 / 2, SWT.ITALIC));
    fxy.setFont(fxyFont);/*w  ww. jav a 2 s .  com*/

    jexlTextEditor = new Text(composite, SWT.V_SCROLL | SWT.WRAP);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(jexlTextEditor);

    modifyListener = new ModifyListenerImplementation();
    jexlTextEditor.setFont(JFaceResources.getTextFont());
    jexlTextEditor.setText("");
    jexlTextEditor.addModifyListener(modifyListener);
    focusListener = new FocusAdapterExtension();
    jexlTextEditor.addFocusListener(focusListener);

    proposalProvider = new ExpressionFunctionProposalProvider(Collections.<String, Object>emptyMap());
    contentProposalAdapter = new OpenableContentAssistCommandAdapter(jexlTextEditor, new TextContentAdapter(),
            proposalProvider, null, null, true);
    contentProposalAdapter.setLabelProvider(new ContentProposalLabelProvider());
    contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE);
    contentProposalAdapter.addContentProposalListener(new JexlContentProposalListener(jexlTextEditor));

    return composite;
}

From source file:org.dawnsci.marketplace.ui.editors.DescriptionSection.java

License:Open Source License

/**
 * Fill the section./*from w  w  w .  ja v  a  2s . c om*/
 */
private void createClient(Section section, FormToolkit toolkit) {
    Composite container = toolkit.createComposite(section);

    section.setClient(container);

    container.setLayout(new GridLayout());

    MarkupLanguage language = new MarkdownLanguage();
    markupViewer = new MarkupSourceViewer(container, null, SWT.WRAP | SWT.V_SCROLL, language);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    markupViewer.getControl().setLayoutData(gridData);

    MarkupSourceViewerConfiguration configuration = new MarkupSourceViewerConfiguration(
            EditorsUI.getPreferenceStore());

    Font font = JFaceResources.getTextFont();
    markupViewer.getTextWidget().setFont(font);

    configuration.setMarkupLanguage(language);
    markupViewer.configure(configuration);
    markupViewer.setEditable(true);

    markupViewer.getTextWidget().setData("textViewer", markupViewer);
    markupViewer.getTextWidget().setData(MarkupLanguage.class.getName(), language);
    markupViewer.getTextWidget().setData(ISourceViewer.class.getName(), markupViewer);

    // install common text support such as content assist
    IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    CommonTextSupport textSupport = new CommonTextSupport(handlerService);
    textSupport.install(markupViewer, true);

    getSite().setSelectionProvider(markupViewer.getSelectionProvider());
    configure(markupViewer, new Document());
}

From source file:org.eclipse.birt.report.data.oda.jdbc.ui.editors.SQLDataSetEditorPage.java

License:Open Source License

/**
 * Creates the textual query editor// w w w.  j  a v a  2s  .c  o  m
 * 
 * @param parent
 */
private Control createTextualQueryComposite(Composite parent) {

    Composite composite = new Composite(parent, SWT.FILL | SWT.LEFT_TO_RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label queryTextLabel = new Label(composite, SWT.NONE);
    queryTextLabel.setText(JdbcPlugin.getResourceString("tablepage.label.queryText"));//$NON-NLS-1$   

    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(dataSetDesign.getDataSourceDesign(),
            timeOutLimit * 1000, enableCodeAssist);
    viewer.configure(svc);

    doc = new Document(getQueryText());
    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:org.eclipse.birt.report.designer.internal.ui.script.JSSourceViewerConfiguration.java

License:Open Source License

public static void updateSourceFont(SourceViewer sourceViewer) {
    // Always set default text font to source viewer
    sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());
}