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

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

Introduction

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

Prototype

String TEXT_FONT

To view the source code for org.eclipse.jface.resource JFaceResources TEXT_FONT.

Click Source Link

Document

The symbolic font name for the text font (value "org.eclipse.jface.textfont").

Usage

From source file:org.eclipse.datatools.sqltools.sqlbuilder.views.source.SQLSourceViewer.java

License:Open Source License

private void initTextWidget() {

    setEditable(true);/* w w  w  .ja  va2 s.co  m*/
    StyledText styledText = sourceViewer.getTextWidget();
    styledText.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    JFaceResources.getFontRegistry().addListener(this);
    sourceViewer.getControl().addDisposeListener(this);

    styledText.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            // can only edit if root statement...
            if (isRootStatement()) {
                if (e.stateMask == SWT.CTRL && e.character == ' ' && contentAssistAction != null) {
                    contentAssistAction.run();
                }
                if (e.stateMask == (SWT.SHIFT | SWT.CTRL) && e.character == ' ' && contentTipAction != null) {
                    contentTipAction.run();
                }
            }
            setParseRequired(true);
        }

    });

    styledText.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent e) {
            //if contentassist is running, the ignore the focusLost event
            if (contentAssistAction.isActive()) {
                return;
            }

            // [wsdbu00055322] bgp 03May2006, [RATLC01118321] bgp 18Aug2006
            // Ignore the focus lost event if the content assist is active.
            if (configuration.getIsContentAssistActive() == true) {
                return;
            }

            if (isTextChanged() == true)
                reparse();

            // A call to validateEdit will cause a loss of focus, in that case, we
            // don't want to reparse

            // is context menu showing? if so - leave menu options active & do not reparse
            // on Linux extra focusLost gets called on right click
            boolean menuShowing = getControl().getMenu().isVisible();
            boolean sqlBuilderNotInValidate = (sqlbuilder != null)
                    && (sqlbuilder.inValidateEditCall() == false);

            if (!menuShowing && (sqlbuilder == null || sqlBuilderNotInValidate)) {
                reparse();
                Iterator aIterator = actions.values().iterator();
                while (aIterator.hasNext()) {
                    Object object = aIterator.next();
                    ((Action) object).setEnabled(false);
                }
            }
        }

        public void focusGained(FocusEvent e) {
            Iterator aIterator = actions.values().iterator();

            while (aIterator.hasNext()) {
                Object object = aIterator.next();
                if (object instanceof TextViewerOperationAction) {
                    TextViewerOperationAction textAction = (TextViewerOperationAction) object;
                    textAction.update();
                } else if (object instanceof SourceViewerAction) {
                    SourceViewerAction sourceAction = (SourceViewerAction) object;
                    sourceAction.setEnabled(true);
                }
            }
            contentAssistAction.setAsActive(false);
        }
    });

}

From source file:org.eclipse.datatools.sqltools.sqlbuilder.views.source.SQLSourceViewer.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {
    if (event.getProperty() == JFaceResources.TEXT_FONT && sourceViewer != null) {
        sourceViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    }/* w ww.java 2s  . c  o  m*/
}

From source file:org.eclipse.edt.ide.ui.internal.editor.SourceViewerInformationControl.java

License:Open Source License

private SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, SWT.NONE);

    SourceViewerConfiguration configuration = new EGLSourceViewerConfiguration();
    viewer.configure(configuration);//from   w  w  w . j  a v  a2s  . c om
    viewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    viewer.getTextWidget().setFont(font);

    return viewer;
}

From source file:org.eclipse.egit.ui.internal.commit.DiffViewer.java

License:Open Source License

private void styleViewer() {
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    Color foreground = null;//w ww . j a v  a  2s. c  om
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT))
        foreground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);

    Color background = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT))
        background = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);

    Color selectionForeground = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT))
        selectionForeground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);

    Color selectionBackground = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT))
        selectionBackground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);

    StyledText text = getTextWidget();
    text.setForeground(foreground);
    text.setBackground(background);
    text.setSelectionForeground(selectionForeground);
    text.setSelectionBackground(selectionBackground);
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    if (lineNumberRuler != null) {
        lineNumberRuler.setFont(text.getFont());
        lineNumberRuler.setForeground(foreground);
        lineNumberRuler.setBackground(background);
    }
}

From source file:org.eclipse.egit.ui.internal.commit.NoteDetailsPage.java

License:Open Source License

public void createContents(Composite parent) {
    GridLayoutFactory.swtDefaults().applyTo(parent);
    Section notesSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
    notesSection.setText(UIText.NoteDetailsPage_ContentSection);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(notesSection);

    Composite notesArea = toolkit.createComposite(notesSection);
    toolkit.paintBordersFor(notesArea);/* ww w . ja v a 2s . c  o m*/
    notesSection.setClient(notesArea);
    GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(notesArea);

    notesText = new SpellcheckableMessageArea(notesArea, "", SWT.NONE) { //$NON-NLS-1$

        protected void createMarginPainter() {
            // Disabled intentionally
        }

    };
    notesText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    StyledText text = notesText.getTextWidget();
    text.setEditable(false);
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    text.setForeground(text.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(notesText);
}

From source file:org.eclipse.emf.ocl.examples.interpreter.console.OCLConsolePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    // force left-to-right text direction in the console, because it
    //    works with OCL text and the OCL language is based on English
    page = new SashForm(parent, SWT.VERTICAL | SWT.LEFT_TO_RIGHT);

    output = new TextViewer(page, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH));
    output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    output.setEditable(false);/*  ww  w .ja v a2  s  .c  o  m*/
    output.setDocument(new Document());

    colorManager = new ColorManager();
    document = new OCLDocument();
    document.setOCLFactory(oclFactory);
    document.setModelingLevel(modelingLevel);

    input = new OCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI);
    input.setDocument(document);
    input.getTextWidget().addKeyListener(new InputKeyListener());

    selectionListener = new ISelectionListener() {
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            OCLConsolePage.this.selectionChanged(selection);
        }
    };
    selectionService = getSite().getWorkbenchWindow().getSelectionService();
    selectionService.addPostSelectionListener(selectionListener);

    // get current selection
    selectionChanged(selectionService.getSelection());

    ((SashForm) page).setWeights(new int[] { 2, 1 });

    ClearOutputAction clear = new ClearOutputAction(output);
    CloseAction close = new CloseAction();
    SaveAction save = new SaveAction();
    LoadAction load = new LoadAction();

    IMenuManager menu = getSite().getActionBars().getMenuManager();
    menu.add(load);
    menu.add(save);
    menu.add(clear);
    menu.add(close);

    IMenuManager metamodelMenu = new MenuManager(OCLInterpreterMessages.console_metamodelMenu,
            "org.eclipse.emf.ocl.examples.interpreter.metamodel"); //$NON-NLS-1$
    menu.add(metamodelMenu);
    DropDownAction metamodelAction = new DropDownAction();
    metamodelAction.setToolTipText(OCLInterpreterMessages.console_metamodelTip);
    addMetamodelActions(metamodelMenu, metamodelAction);

    IMenuManager levelMenu = new MenuManager(OCLInterpreterMessages.console_modelingLevel);
    menu.add(levelMenu);
    DropDownAction levelAction = new DropDownAction();
    levelAction.setToolTipText(OCLInterpreterMessages.console_modelingLevelTip);
    IAction m2 = new ModelingLevelAction(ModelingLevel.M2);
    m2.setChecked(true);
    levelMenu.add(m2);
    levelAction.addAction(m2);
    IAction m1 = new ModelingLevelAction(ModelingLevel.M1);
    levelMenu.add(m1);
    levelAction.addAction(m1);

    ActionContributionItem metamodelItem = new ActionContributionItem(metamodelAction);
    metamodelItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);

    IToolBarManager toolbar = getSite().getActionBars().getToolBarManager();
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, metamodelItem);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, levelAction);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, load);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, save);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, clear);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, close);
}

From source file:org.eclipse.epp.internal.logging.aeri.ui.ReportDialog.java

License:Open Source License

private void createMessageComposite(Composite container) {
    Composite messageComposite = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(messageComposite);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(messageComposite);
    messageText = new StyledText(messageComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    messageText.setEditable(false);/* w ww.  ja  v a2  s . c om*/
    messageText.setMargins(5, messageText.getTopMargin(), messageText.getRightMargin(),
            messageText.getBottomMargin());
    messageText.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    messageText.setForeground(new Color(container.getDisplay(), 80, 80, 80));
    GridDataFactory.fillDefaults().minSize(100, 1).hint(100, 300).grab(true, true).applyTo(messageText);
}

From source file:org.eclipse.etrice.core.ui.labeling.RoomLabelProvider.java

License:Open Source License

private Styler getKeywordStyler() {
    if (keywordStyler == null) {
        FontDescriptor font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT);
        FontDescriptor boldFont = font.setStyle(SWT.BOLD);
        keywordStyler = stylerFactory.createStyler(boldFont, KEYWORD_COLOR, null);
    }/*www  .  j a  v a 2 s .  c  o  m*/
    return keywordStyler;
}

From source file:org.eclipse.etrice.core.ui.labeling.RoomLabelProvider.java

License:Open Source License

private Styler getTypeStyler() {
    if (typeStyler == null) {
        FontDescriptor font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT);
        FontDescriptor italicFont = font.setStyle(SWT.ITALIC);
        typeStyler = stylerFactory.createStyler(italicFont, null, null);
    }//from   w  ww.j av a  2s .c  o  m
    return typeStyler;
}

From source file:org.eclipse.gemoc.execution.concurrent.ccsljavaengine.ui.views.step.LogicalStepsView.java

License:Open Source License

private void createTreeViewer(Composite parent) {
    _viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    _viewer.setUseHashlookup(true);/*from  w  w  w. jav  a  2s .com*/
    _contentProvider = new LogicalStepsViewContentProvider();
    _viewer.setContentProvider(_contentProvider);
    Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    _viewer.getTree().setFont(mono);
    createColumns();
    // The table will take all the horizontal and vertical excess space
    GridData grid = new GridData(SWT.FILL, SWT.FILL, true, true);
    _viewer.getControl().setLayoutData(grid);
    _viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // invoke the columns pack, in order to let a column fit to its contents width
    Tree tree = (Tree) _viewer.getControl();
    tree.setHeaderVisible(true);
    Listener listener = new Listener() {
        @Override
        public void handleEvent(Event event) {
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    TreeViewerHelper.resizeColumns(_viewer);
                }
            });
        }
    };

    tree.addListener(SWT.Expand, listener);
    // adjust the table when expanding
}