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.google.dart.tools.ui.internal.text.functions.ChangeHoverInformationControl.java

License:Open Source License

/**
 * Sets the font for this viewer sustaining selection and scroll position.
 *//*from  w  ww.j  ava2  s.c  o  m*/
private void setViewerFont() {
    Font font = JFaceResources.getFont(SYMBOLIC_FONT_NAME);

    if (getViewer().getDocument() != null) {

        Point selection = getViewer().getSelectedRange();
        int topIndex = getViewer().getTopIndex();

        StyledText styledText = getViewer().getTextWidget();
        Control parent = styledText;
        if (getViewer() instanceof ITextViewerExtension) {
            ITextViewerExtension extension = (ITextViewerExtension) getViewer();
            parent = extension.getControl();
        }

        parent.setRedraw(false);

        styledText.setFont(font);

        getViewer().setSelectedRange(selection.x, selection.y);
        getViewer().setTopIndex(topIndex);

        if (parent instanceof Composite) {
            Composite composite = (Composite) parent;
            composite.layout(true);
        }

        parent.setRedraw(true);

    } else {
        StyledText styledText = getViewer().getTextWidget();
        styledText.setFont(font);
    }
}

From source file:com.google.dart.tools.ui.internal.text.functions.DartOutlineInformationControl.java

License:Open Source License

/**
 * {@inheritDoc}//  w  w w.  j  ava 2s. co m
 */
@Override
protected TreeViewer createTreeViewer(Composite parent, int style) {
    Tree tree = new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = tree.getItemHeight() * 12;
    tree.setLayoutData(gd);

    final TreeViewer treeViewer = new OutlineTreeViewer(tree);
    ColoredViewersManager.install(treeViewer);

    // Hard-coded filters
    treeViewer.addFilter(new NamePatternFilter());
    treeViewer.addFilter(new MemberFilter());

    fInnerLabelProvider = new OutlineLabelProvider();
    fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
    IDecoratorManager decoratorMgr = PlatformUI.getWorkbench().getDecoratorManager();
    if (decoratorMgr.getEnabled("com.google.dart.tools.ui.override.decorator")) {
        fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null));
    }

    treeViewer.setLabelProvider(fInnerLabelProvider);

    fLexicalSortingAction = new LexicalSortingAction(treeViewer);
    fSortByDefiningTypeAction = new SortByDefiningTypeAction(treeViewer);
    //    fShowOnlyMainTypeAction = new ShowOnlyMainTypeAction(treeViewer);
    DartX.todo();
    // fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer,
    // getId(), getInputForCategories());

    fOutlineContentProvider = new OutlineContentProvider(false);
    treeViewer.setContentProvider(fOutlineContentProvider);
    fOutlineSorter = new OutlineSorter();
    treeViewer.setComparator(fOutlineSorter);
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

    treeViewer.getTree().addKeyListener(getKeyAdapter());

    Font newFont = JFaceResources.getFont(FontPreferencePage.BASE_FONT_KEY);
    Font oldFont = treeViewer.getTree().getFont();
    Font font = SWTUtil.changeFontSize(oldFont, newFont);
    treeViewer.getTree().setFont(font);

    return treeViewer;
}

From source file:com.google.dart.tools.ui.web.yaml.PubspecYamlEditor.java

License:Open Source License

private void initializeViewerFont(ISourceViewer viewer) {
    Font font = null;//from  w  w w  .  j  ava 2s .  c  om

    String symbolicFontName = PreferenceConstants.EDITOR_TEXT_FONT;
    font = JFaceResources.getFont(symbolicFontName);
    if (font == null) {
        font = JFaceResources.getTextFont();
    }
    if (!font.equals(getSourceViewer().getTextWidget().getFont())) {
        setFont(viewer, font);
    } else {
        font.dispose();
    }
}

From source file:com.google.gapid.views.LogView.java

License:Apache License

public LogView(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(new FillLayout(SWT.VERTICAL));

    text = new TextViewer(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setEditable(false);//from  w  w  w .  j a va  2 s .  c  o  m
    text.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    text.setDocument(new Document());
    updateText();
    Logging.setListener(() -> {
        if (!dirty.getAndSet(true)) {
            Widgets.scheduleIfNotDisposed(this, this::updateText);
        }
    });
    addListener(SWT.Dispose, e -> Logging.setListener(null));
}

From source file:com.hangum.tadpole.engine.manager.TadpoleApplicationContextManager.java

License:Open Source License

/**
 * get erd title font//w  ww.  ja  v a2s.c  o  m
 * @return
 */
public static Font getERDTitleFont() {
    ApplicationContext context = RWT.getApplicationContext();
    Object obj = context.getAttribute("getERDTitleFont");
    if (obj == null) {
        Font defaultFont = JFaceResources.getFont(JFaceResources.DEFAULT_FONT);
        FontData[] fd = defaultFont.getFontData();
        int fontSize = fd[0].getHeight() + 1;
        fd[0].setHeight(fontSize);

        Font titleFont = new Font(Display.getCurrent(), fd[0]);
        context.setAttribute("getERDTitleFont", titleFont);
        return titleFont;
    }

    return (Font) obj;
}

From source file:com.hangum.tadpole.engine.manager.TadpoleApplicationContextManager.java

License:Open Source License

/**
 * gulim font//from  w  ww.  ja v  a 2 s. co m
 * @return
 */
public static Font getGulimFont() {
    ApplicationContext context = RWT.getApplicationContext();
    Object obj = context.getAttribute("getGulimFont");
    if (obj == null) {
        Font defaultFont = JFaceResources.getFont(JFaceResources.DEFAULT_FONT);
        int intDefaultHeight = defaultFont.getFontData()[0].getHeight() + 1;
        Font font = new Font(Display.getCurrent(),
                new FontData(Messages.get().Gullim, intDefaultHeight, SWT.NONE));
        context.setAttribute("getGulimFont", font);
        return font;
    }

    return (Font) obj;
}

From source file:com.imperial.fiksen.codesimilarity.compare.ParseTreeMergeViewer.java

License:Open Source License

private void updateFont() {
    Font f = JFaceResources.getFont(fSymbolicFontName);
    if (f != null) {
        if (fAncestor != null)
            fAncestor.setFont(f);/*from w  w  w.j  a va2  s.c o  m*/
        if (fLeft != null)
            fLeft.setFont(f);
        if (fRight != null)
            fRight.setFont(f);
    }
}

From source file:com.iw.plugins.spindle.ui.preferences.SpindleFormatterPreferencePage.java

License:Mozilla Public License

private Control createPreviewer(Composite parent) {
    fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    fSpecConfiguration = new BasicSpecConfiguration(UIPlugin.getDefault().getXMLTextTools(), null,
            getOverlayStore()) {//  w  w  w.j  a v  a  2  s . co m

        public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
            return null;
        }

        public IReconciler getReconciler(ISourceViewer sourceViewer) {
            return null;
        }

        public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
            return null;
        }

        public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
            return null;
        }

        public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
            return null;
        }

        public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
            return new String[] { "\t", "    ", "" };
        }

        public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
            return null;
        }

        public IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer) {
            return null;
        }

        public int getHyperlinkStateMask(ISourceViewer sourceViewer) {
            return -1;
        }

    };

    fPreviewViewer.configure(fSpecConfiguration);
    fPreviewViewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    fMarginPainter = installMarginPainter(fPreviewViewer);

    fPreviewerUpdater = new PreviewerUpdater(fPreviewViewer, getOverlayStore());

    fContent = loadPreviewContentFromFile("FormatPreview.txt");

    fDocument = new Document(fContent);
    XMLReconciler model = new SpecDocumentSetupParticipant().setup(fDocument);
    BaseDocumentSetupParticipant.removeModel(fDocument);
    fPreviewViewer.setDocument(fDocument);
    format(getOverlayStore());
    return fPreviewViewer.getControl();
}

From source file:com.mentor.nucleus.bp.compare.contentmergeviewer.ModelContentViewer.java

License:Open Source License

ModelContentViewer(Composite parent) {
    fSourceViewer = new SourceViewer(parent, null, SWT.H_SCROLL + SWT.V_SCROLL);
    Control control = fSourceViewer.getTextWidget();
    Font font = JFaceResources.getFont(TextMergeViewer.class.getName());
    control.setFont(font);//from w  w  w.j  a  v a 2  s  .  c o m
    control.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            handleDispose();
        }
    });
    fSourceViewer.setEditable(false);
}

From source file:com.mentor.nucleus.bp.ui.text.editor.oal.preference.OALEditorSyntaxPreferencePage.java

License:Open Source License

protected Control createPreviewer(Composite parent) {
    final SyntaxHighlightingPreferences clonedPreferences = (SyntaxHighlightingPreferences) clonedModel;

    final SourceViewer viewer = new SourceViewer(parent, null, null, false,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    OALEditorConfiguration viewerConfiguration = new OALEditorConfiguration(clonedPreferences);
    viewer.configure(viewerConfiguration);
    Font font = JFaceResources.getFont("org.eclipse.jdt.ui.editors.textfont");
    viewer.getTextWidget().setFont(font);
    viewer.getTextWidget().setBackground(clonedPreferences.getBackgroundColor());
    viewer.setEditable(false);/*  w w w .  java2 s. c  o m*/

    String content = loadPreviewContentFromFile("OALPreviewCode.txt");
    IDocument document = new Document(content);
    OALDocumentProvider.setDocumentPartitioner(document);
    viewer.setDocument(document);

    clonedPreferences.addModelChangeListener(new IChangeListener() {
        public void modelChanged(IPreferenceModel model, int changeHints) {
            switch (changeHints) {
            case SyntaxHighlightingPreferences.MODEL_BACKGROUND_CHANGED:
                viewer.getTextWidget().setBackground(clonedPreferences.getBackgroundColor());
                break;
            case SyntaxHighlightingPreferences.MODEL_TOKEN_ATTRIBUTE_CHANGED:
                viewer.invalidateTextPresentation();
                break;
            }
        }
    });

    return viewer.getControl();
}