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:org.netxms.ui.eclipse.widgets.TextConsole.java

License:Open Source License

/**
 * @param parent// w w  w.  ja  va2  s. co m
 * @param style
 */
public TextConsole(Composite parent, int style) {
    super(parent, style);
    setLayout(new FillLayout());
    console = new StyledText(this, SWT.H_SCROLL | SWT.V_SCROLL);
    console.setFont(JFaceResources.getTextFont());
    console.setScrollOnAppend(autoScroll);
}

From source file:org.python.pydev.core.FontUtils.java

License:Open Source License

public static FontData getFontData(int usage, boolean useDefaultJFaceFontIfPossible) {
    if (useDefaultJFaceFontIfPossible) {
        FontData[] textFontData = JFaceResources.getTextFont().getFontData();
        if (textFontData.length == 1) {
            return textFontData[0];
        }/*from   w w  w  .  j  a va2  s.  c om*/
    }
    Tuple<String, Integer> codeFontDetails = FontUtils.getCodeFontNameAndHeight(IFontUsage.IMAGECACHE);
    String fontName = codeFontDetails.o1;
    int base = codeFontDetails.o2.intValue();
    return new FontData(fontName, base, SWT.BOLD);
}

From source file:org.python.pydev.debug.ui.propertypages.BreakpointConditionEditor.java

License:Open Source License

public BreakpointConditionEditor(Composite parent, PythonBreakpointPage page) {
    fPage = page;/*w w  w .  ja  v  a 2  s .co m*/
    fBreakpoint = fPage.getBreakpoint();
    String condition;
    try {
        condition = fBreakpoint.getCondition();
    } catch (DebugException e) {
        PydevDebugPlugin.log(IStatus.ERROR, "Can't read conditions", e);
        return;
    }
    fErrorMessage = "Enter a condition"; //$NON-NLS-1$
    fOldValue = ""; //$NON-NLS-1$

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

    IDocument document = new Document();
    IDocumentPartitioner partitioner = new PyPartitioner(new PyPartitionScanner(), IPythonPartitions.types);
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);
    /*
    fViewer.configure(new DisplayViewerConfiguration() {
    public IContentAssistProcessor getContentAssistantProcessor() {
            return getCompletionProcessor();
    }
    });*/
    fViewer.setEditable(true);
    fViewer.setDocument(document);
    final IUndoManager undoManager = new TextViewerUndoManager(100);
    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);

    // we can only do code assist if there is an associated type
    /*
    try {
    //getCompletionProcessor().setType(type);            
    String source= null;
    ICompilationUnit compilationUnit= type.getCompilationUnit();
    if (compilationUnit != null) {
        source= compilationUnit.getSource();
    } else {
        IClassFile classFile= type.getClassFile();
        if (classFile != null) {
            source= classFile.getSource();
        }
    }
    int lineNumber= fBreakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1);
    int position= -1;
    if (source != null && lineNumber != -1) {
        try {
            position= new Document(source).getLineOffset(lineNumber - 1);
        } catch (BadLocationException e) {
        }
    }
    //getCompletionProcessor().setPosition(position);
    } catch (CoreException e) {
    }*/

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

    IHandler handler = new AbstractHandler() {
        public Object execute(Map parameter) throws ExecutionException {
            fViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
            return null;
        }
    };
    submission = new HandlerSubmission(null, parent.getShell(), null,
            ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler, Priority.MEDIUM);
}

From source file:org.robotframework.ide.eclipse.main.plugin.navigator.actions.KeywordDocumentationComposite.java

License:Apache License

@Override
protected Composite createControl(final Composite parent) {
    setFormImage(RedImages.getKeywordImage());

    final Composite actualComposite = getToolkit().createComposite(parent);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(actualComposite);

    argumentsText = getToolkit().createFormText(actualComposite, false);
    argumentsText.setFont("monospace", JFaceResources.getTextFont());
    argumentsText.setFont("monospace_inline", JFaceResources.getTextFont());
    argumentsText.setColor("header", getToolkit().getColors().getColor(IFormColors.TITLE));
    argumentsText.setFont("header", JFaceResources.getBannerFont());
    GridDataFactory.fillDefaults().span(2, 1).hint(400, SWT.DEFAULT).grab(true, false).applyTo(argumentsText);

    scrolledFormText = new ScrolledFormText(actualComposite, SWT.V_SCROLL | SWT.H_SCROLL, true);
    getToolkit().adapt(scrolledFormText);
    GridDataFactory.fillDefaults().span(2, 1).hint(400, 500).grab(true, true).applyTo(scrolledFormText);
    GridLayoutFactory.fillDefaults().applyTo(scrolledFormText);

    documentationText = scrolledFormText.getFormText();
    documentationText.setFont("monospace", JFaceResources.getTextFont());
    documentationText.setFont("monospace_inline", JFaceResources.getTextFont());
    documentationText.setColor("header", getToolkit().getColors().getColor(IFormColors.TITLE));
    documentationText.setFont("header", JFaceResources.getBannerFont());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationText);
    documentationText.setWhitespaceNormalized(false);

    final HyperlinkAdapter hyperlinkListener = createHyperlinkListener();
    documentationText.addHyperlinkListener(hyperlinkListener);
    argumentsText.addHyperlinkListener(hyperlinkListener);
    addDisposeListener(new DisposeListener() {
        @Override//from  ww  w. j ava 2 s  . c o  m
        public void widgetDisposed(final DisposeEvent e) {
            documentationText.removeHyperlinkListener(hyperlinkListener);
            argumentsText.removeHyperlinkListener(hyperlinkListener);
        }
    });
    return actualComposite;
}

From source file:org.robotframework.ide.eclipse.main.plugin.navigator.actions.LibraryDocumentationComposite.java

License:Apache License

@Override
protected Composite createControl(final Composite parent) {
    setFormImage(RedImages.getBookImage());

    final Composite actualComposite = getToolkit().createComposite(parent);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(actualComposite);

    final Label version = getToolkit().createLabel(actualComposite, "Version");
    version.setFont(JFaceResources.getHeaderFont());
    version.setForeground(getToolkit().getColors().getColor(IFormColors.TITLE));
    versionLabel = getToolkit().createLabel(actualComposite, "");
    versionLabel.setFont(JFaceResources.getHeaderFont());
    versionLabel.setForeground(getToolkit().getColors().getColor(IFormColors.TITLE));
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(versionLabel);

    final Label scope = getToolkit().createLabel(actualComposite, "Scope");
    scope.setFont(JFaceResources.getBannerFont());
    scope.setForeground(getToolkit().getColors().getColor(IFormColors.TITLE));
    scopeLabel = getToolkit().createLabel(actualComposite, "");
    scopeLabel.setFont(JFaceResources.getBannerFont());
    scopeLabel.setForeground(getToolkit().getColors().getColor(IFormColors.TITLE));
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(scopeLabel);

    final Label separator = getToolkit().createSeparator(actualComposite, SWT.HORIZONTAL | SWT.SHADOW_OUT);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(separator);

    scrolledFormText = new ScrolledFormText(actualComposite, SWT.V_SCROLL | SWT.H_SCROLL, true);
    getToolkit().adapt(scrolledFormText);
    GridDataFactory.fillDefaults().span(2, 1).hint(400, 500).grab(true, true).applyTo(scrolledFormText);
    GridLayoutFactory.fillDefaults().applyTo(scrolledFormText);

    documentationText = scrolledFormText.getFormText();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationText);
    documentationText.setWhitespaceNormalized(false);

    documentationText.setFont("monospace", JFaceResources.getTextFont());
    documentationText.setFont("monospace_inline", JFaceResources.getTextFont());
    documentationText.setColor("header", getToolkit().getColors().getColor(IFormColors.TITLE));
    documentationText.setFont("header", JFaceResources.getBannerFont());

    final HyperlinkAdapter hyperlinkListener = createHyperlinkListener();
    documentationText.addHyperlinkListener(hyperlinkListener);
    addDisposeListener(new DisposeListener() {
        @Override//from  w  w w  .  ja  va 2 s.  co m
        public void widgetDisposed(final DisposeEvent e) {
            documentationText.removeHyperlinkListener(hyperlinkListener);
        }
    });
    return actualComposite;
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.LibrariesAutoDiscovererWindow.java

License:Apache License

private void createDetailsComposite(final Composite mainComposite) {
    final Composite detailsComposite = new Composite(mainComposite, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(detailsComposite);
    GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 100).grab(true, false).applyTo(detailsComposite);

    detailsText = new StyledText(detailsComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
    detailsText.setFont(JFaceResources.getTextFont());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(detailsText);
    GridLayoutFactory.fillDefaults().applyTo(detailsText);
    detailsText.setEditable(false);/*from ww  w  .  j  a  va  2 s .  c  o m*/
    detailsText.setAlwaysShowScrollBars(false);
}

From source file:org.robotframework.ide.eclipse.main.plugin.views.execution.ExecutionView.java

License:Apache License

private void createFailureMessageText(final Composite parent) {
    messageText = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    messageText.setFont(JFaceResources.getTextFont());
    GridDataFactory.fillDefaults().grab(true, false).indent(3, 0).hint(0, 50).applyTo(messageText);
    GridLayoutFactory.fillDefaults().applyTo(messageText);
    messageText.setEditable(false);//www.  j  a  v  a2s.  co  m
    messageText.setAlwaysShowScrollBars(false);
}

From source file:org.robotframework.ide.eclipse.main.plugin.views.message.MessageLogView.java

License:Apache License

@PostConstruct
public void postConstruct(final Composite parent) {
    final FillLayout layout = new FillLayout();
    layout.marginHeight = 2;/*from  www . j  a  v a2  s  .  co  m*/
    layout.marginWidth = 2;
    parent.setLayout(layout);

    styledText = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    styledText.setFont(JFaceResources.getTextFont());
    styledText.setEditable(false);

    setInput();
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.deployment.DeploymentPropertiesDialog.java

License:Open Source License

private void createYamlContentsGroup(Composite composite) {
    yamlGroup = new Group(composite, SWT.NONE);
    yamlGroup.setText("YAML Content");
    yamlGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    yamlGroup.setLayout(new GridLayout());

    fileYamlComposite = new Composite(yamlGroup, SWT.NONE);
    fileYamlComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    GridLayout layout = new GridLayout(3, false);
    layout.marginWidth = 0;//from  ww  w. j  av  a 2s.c  o  m
    fileYamlComposite.setLayout(layout);

    fileLabel = new Label(fileYamlComposite, SWT.WRAP);
    fileLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER)
            .span(3, SWT.DEFAULT).create());

    model.getFileLabel().addListener(new UIValueListener<String>() {
        @Override
        protected void uiGotValue(LiveExpression<String> exp, String value) {
            if (!fileLabel.isDisposed()) {
                fileLabel.setText(exp.getValue());
            }
        }
    });

    DefaultMarkerAnnotationAccess fileMarkerAnnotationAccess = new DefaultMarkerAnnotationAccess();
    OverviewRuler fileOverviewRuler = new OverviewRuler(fileMarkerAnnotationAccess, 10, colorsCache);
    String appName = model.getDeployedAppName();
    IVerticalRuler fileVerticalRuler = appName == null ? new CompositeRuler()
            : /*new VerticalRuler(16, fileMarkerAnnotationAccess)*/ null;
    fileYamlViewer = new SourceViewer(fileYamlComposite, fileVerticalRuler, fileOverviewRuler, true,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    ManifestYamlSourceViewerConfiguration fileYamlSourceViewerConfiguration = new ManifestYamlSourceViewerConfiguration(
            ShellProviders.from(composite)) {

        @Override
        protected IReconcilingStrategy createReconcilerStrategy(ISourceViewer viewer) {
            CompositeReconcilingStrategy strategy = new CompositeReconcilingStrategy();
            strategy.setReconcilingStrategies(
                    new IReconcilingStrategy[] { super.createReconcilerStrategy(viewer),
                            new AppNameReconcilingStrategy(viewer, getAstProvider(), appName) });
            return strategy;
        }

        @Override
        protected ForceableReconciler createReconciler(ISourceViewer sourceViewer) {
            IReconcilingStrategy strategy = createReconcilerStrategy(sourceViewer);
            if (strategy != null) {
                InstantForceableReconciler reconciler = new InstantForceableReconciler(strategy);
                reconciler.setDelay(500);
                return reconciler;
            }
            return null;
        }

    };
    fileYamlViewer.configure(fileYamlSourceViewerConfiguration);
    fileYamlViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());

    fileYamlDecorationSupport = new SourceViewerDecorationSupport(fileYamlViewer, fileOverviewRuler,
            fileMarkerAnnotationAccess, colorsCache);
    fileYamlAppNameAnnotationSupport = new AppNameAnnotationSupport(fileYamlViewer, fileMarkerAnnotationAccess,
            colorsCache);

    model.getFileDocument().addListener(new UIValueListener<IDocument>() {
        protected void uiGotValue(LiveExpression<IDocument> exp, IDocument value) {
            updateManifestFile();
        }
    });

    manualYamlComposite = new Composite(yamlGroup, SWT.NONE);
    manualYamlComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    layout = new GridLayout();
    layout.marginWidth = 0;
    manualYamlComposite.setLayout(layout);

    Label manualYamlDescriptionLabel = new Label(manualYamlComposite, SWT.WRAP);
    manualYamlDescriptionLabel.setText(model.isManualManifestReadOnly()
            ? "Preview of the contents of the auto-generated deployment manifest:"
            : "Edit deployment manifest contents:");
    manualYamlDescriptionLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    DefaultMarkerAnnotationAccess manualMarkerAnnotationAccess = new DefaultMarkerAnnotationAccess();
    OverviewRuler manualOverviewRuler = new OverviewRuler(manualMarkerAnnotationAccess, 10, colorsCache);
    IVerticalRuler manualVerticalRuler = appName == null ? new CompositeRuler()
            : /*new VerticalRuler(16, manualMarkerAnnotationAccess)*/ null;
    manualYamlViewer = new SourceViewer(manualYamlComposite, manualVerticalRuler, manualOverviewRuler, true,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    ManifestYamlSourceViewerConfiguration manualSourceViewerConfiguration = new ManifestYamlSourceViewerConfiguration(
            ShellProviders.from(composite)) {

        @Override
        protected IReconcilingStrategy createReconcilerStrategy(ISourceViewer viewer) {
            CompositeReconcilingStrategy strategy = new CompositeReconcilingStrategy();
            strategy.setReconcilingStrategies(
                    new IReconcilingStrategy[] { super.createReconcilerStrategy(viewer),
                            new AppNameReconcilingStrategy(viewer, getAstProvider(), appName) });
            return strategy;
        }

    };

    manualYamlViewer.configure(manualSourceViewerConfiguration);
    manualYamlViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());

    if (model.isManualManifestReadOnly()) {
        manualYamlViewer.setEditable(false);
        manualYamlViewer.getTextWidget().setCaret(null);
        manualYamlViewer.getTextWidget().setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
    }
    manualYamlDecorationSupport = new SourceViewerDecorationSupport(manualYamlViewer, manualOverviewRuler,
            manualMarkerAnnotationAccess, colorsCache);
    manualYamlAppNameAnnotationSupport = new AppNameAnnotationSupport(manualYamlViewer,
            manualMarkerAnnotationAccess, colorsCache);

    manualYamlViewer.setDocument(model.getManualDocument(), model.getManualAnnotationModel());

    /*
     * Set preferences for viewers decoration support
     */
    for (AnnotationPreference preference : (List<AnnotationPreference>) new MarkerAnnotationPreferences()
            .getAnnotationPreferences()) {
        manualYamlDecorationSupport.setAnnotationPreference(preference);
        fileYamlDecorationSupport.setAnnotationPreference(preference);
    }
    manualYamlDecorationSupport.install(EditorsUI.getPreferenceStore());
    fileYamlDecorationSupport.install(EditorsUI.getPreferenceStore());

    /*
     * Set the proper Font on the YAML viewers
     */
    fileYamlViewer.getTextWidget().setFont(JFaceResources.getTextFont());
    manualYamlViewer.getTextWidget().setFont(JFaceResources.getTextFont());

    /*
     * Set App Name annotation model on the dialog's model
     */
    model.setManualAppNameAnnotationModel(AppNameAnnotationSupport.getAppNameAnnotationModel(manualYamlViewer));

    /*
     * Set YAML validation annotation model (resource marker annotation model)
     */
    model.setManualResourceAnnotationModel(manualYamlViewer.getAnnotationModel());
}

From source file:org.springframework.ide.eclipse.roo.ui.internal.RooShellTab.java

License:Open Source License

public CTabItem addTab(CTabFolder parent) {
    final Composite tabComposite = new Composite(parent, SWT.NONE);
    tabComposite.setFont(parent.getFont());
    GridLayout layout = new GridLayout(1, false);
    if (Platform.getOS().equals(Platform.OS_MACOSX) && Platform.getWS().equals(Platform.WS_CARBON)) {
        layout.marginLeft = -9;/*from  www.  j a v  a  2s . c  o m*/
        layout.marginRight = -9;
        layout.marginTop = -9;
        layout.marginBottom = -9;
        layout.horizontalSpacing = -10;
        layout.verticalSpacing = -10;
    } else {
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 0;

    }
    tabComposite.setLayout(layout);
    tabComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    text = new StyledText(tabComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
    GridData data = new GridData(GridData.FILL_BOTH);
    text.setLayoutData(data);
    text.setFont(JFaceResources.getTextFont());
    text.setEditable(false);

    RooUiColors.applyShellBackground(text);
    RooUiColors.applyShellForeground(text);
    RooUiColors.applyShellFont(text);
    text.setText("Please stand by until the Roo Shell is completely loaded.\n\r");

    text.addListener(SWT.MouseUp, new Listener() {
        public void handleEvent(Event event) {
            handleMouseUp(event);
        }
    });

    new Label(tabComposite, SWT.NONE);

    Composite commandComposite = new Composite(tabComposite, SWT.NONE);
    layout = new GridLayout(2, false);
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    commandComposite.setLayout(layout);
    commandComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = new Label(commandComposite, SWT.NONE);
    label.setText("roo> ");

    command = new Text(commandComposite, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalIndent = 5;
    command.setLayoutData(data);
    addTypeFieldAssistToText(command);

    command.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            processKeyEvent(text, e, command.getText());
        }

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

    CTabItem item = new CTabItem(parent, SWT.CLOSE);
    item.setText(project.getName());
    item.setImage(new WorkbenchLabelProvider().getImage(project));

    item.setControl(tabComposite);
    item.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            shellView.removeTab(project);
            tabComposite.dispose();
            removeTab();
        }
    });

    parent.showItem(item);
    parent.setSelection(parent.indexOf(item));

    setEnabled(false);

    setupBootstrap();

    return item;
}