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:org.eclipse.edt.ide.ui.internal.record.NewRecordSummaryPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//*from  w w  w  .j a v  a 2 s  .com*/
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IUIHelpConstants.EGL_NEW_RECORD_SUMMARY_PAGE);

    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 1;

    Label label = new Label(container, SWT.HORIZONTAL);
    label.setText(NewRecordWizardMessages.NewRecordSummaryPage_previewLabel);

    TextTools tools = new TextTools(new PreferenceStore());

    fPreviewViewer = new SourceViewer(container, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    fPreviewViewer.configure(new EGLSourceViewerConfiguration(tools, null));
    Font font = JFaceResources.getFont(EGLPreferenceConstants.EDITOR_TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    fPreviewViewer.setEditable(false);
    fPreviewViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

    document = new Document("");

    IDocumentPartitioner partitioner = ((DocumentProvider) EGLUI.getDocumentProvider())
            .createDocumentPartitioner();
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);

    fPreviewViewer.setDocument(document);

    messageComposite = new HideableComposite(container, 0);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    messageComposite.setLayout(layout);
    messageComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    warningLabel = new Label(messageComposite, SWT.HORIZONTAL);
    warningLabel.setText(NewRecordWizardMessages.NewRecordSummaryPage_warningLabel);
    warningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    messageList = new Table(messageComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    messageList.setLinesVisible(false);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 80;
    messageList.setLayoutData(data);

    setControl(container);
}

From source file:org.eclipse.edt.ide.ui.internal.wizards.EGLCodePreviewPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *///from ww w  .  j  ava 2s . co  m
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IUIHelpConstants.EGL_NEW_RECORD_SUMMARY_PAGE);

    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 1;

    codeViewerSelectorContainer = new Composite(container, SWT.NULL);
    codeViewerSelectorContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    GridLayout codeViewerSelectorContainerLayout = new GridLayout(2, false);
    codeViewerSelectorContainerLayout.marginWidth = 0;
    codeViewerSelectorContainer.setLayout(codeViewerSelectorContainerLayout);

    TextTools tools = new TextTools(new PreferenceStore());

    fPreviewViewer = new SourceViewer(container, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    fPreviewViewer.configure(new EGLSourceViewerConfiguration(tools, null));
    Font font = JFaceResources.getFont(EGLPreferenceConstants.EDITOR_TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    fPreviewViewer.setEditable(false);
    fPreviewViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

    messageComposite = new HideableComposite(container, 0);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    messageComposite.setLayout(layout);
    messageComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    warningLabel = new Label(messageComposite, SWT.HORIZONTAL);
    warningLabel.setText(NewWizardMessages.NewEGLFilesPreviewPage_warningLabel);
    warningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    messageList = new Table(messageComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    messageList.setLinesVisible(false);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 80;
    messageList.setLayoutData(data);

    setControl(container);
}

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;//from  w w w .  ja  v a  2 s.co m
    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);//from  w  w w  .  j  a va 2  s .  c  om
    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);/*from w ww. j a  va 2s.  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);/*from  www . ja  va2 s  . c  o m*/
    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.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);// w  ww  .ja  va2 s . c  om
    _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
}

From source file:org.eclipse.jdt.internal.debug.ui.console.JavaStackTraceConsole.java

License:Open Source License

/**
 * Constructor/*  www. ja  v  a2 s.co  m*/
 */
public JavaStackTraceConsole() {
    super(ConsoleMessages.JavaStackTraceConsoleFactory_0, CONSOLE_TYPE, null, true);
    Font font = JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT);
    setFont(font);
    partitioner.connect(getDocument());
}

From source file:org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview.java

License:Open Source License

public JavaPreview(Map<String, String> workingValues, Composite parent) {
    JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
    fPreviewDocument = new Document();
    fWorkingValues = workingValues;//from   w w  w.  j  a v a  2  s.c o m
    tools.setupJavaDocumentPartitioner(fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING);

    PreferenceStore prioritizedSettings = new PreferenceStore();
    HashMap<String, String> complianceOptions = new HashMap<String, String>();
    JavaModelUtil.setComplianceOptions(complianceOptions, JavaModelUtil.VERSION_LATEST);
    for (Entry<String, String> complianceOption : complianceOptions.entrySet()) {
        prioritizedSettings.setValue(complianceOption.getKey(), complianceOption.getValue());
    }

    IPreferenceStore[] chain = { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() };
    fPreferenceStore = new ChainedPreferenceStore(chain);
    fSourceViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER,
            fPreferenceStore);
    fSourceViewer.setEditable(false);
    Cursor arrowCursor = fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
    fSourceViewer.getTextWidget().setCursor(arrowCursor);

    // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
    //      fSourceViewer.getTextWidget().setCaret(null);

    fViewerConfiguration = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore,
            null, IJavaPartitions.JAVA_PARTITIONING, true);
    fSourceViewer.configure(fViewerConfiguration);
    fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));

    fMarginPainter = new MarginPainter(fSourceViewer);
    final RGB rgb = PreferenceConverter.getColor(fPreferenceStore,
            AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
    fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
    fSourceViewer.addPainter(fMarginPainter);

    new JavaSourcePreviewerUpdater();
    fSourceViewer.setDocument(fPreviewDocument);
}

From source file:org.eclipse.jdt.internal.ui.refactoring.InputPageUtil.java

License:Open Source License

/**
 * Creates a signature preview viewer in a parent composite with a 1-column GridLayout.
 * /* ww  w . j ava2 s  . c om*/
 * @param parent the parent 
 * @return the preview viewer
 * @since 3.9
 */
public static JavaSourceViewer createSignaturePreview(Composite parent) {
    IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
    JavaSourceViewer signaturePreview = new JavaSourceViewer(parent, null, null, false,
            SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP, store);
    signaturePreview.configure(new JavaSourceViewerConfiguration(
            JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
    StyledText textWidget = signaturePreview.getTextWidget();
    textWidget.setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
    textWidget.setAlwaysShowScrollBars(false);
    signaturePreview.adaptBackgroundColor(parent);
    signaturePreview.setDocument(new Document());
    signaturePreview.setEditable(false);

    GridData gdata = new GridData(GridData.FILL_BOTH);
    gdata.widthHint = new PixelConverter(textWidget).convertWidthInCharsToPixels(50);
    gdata.heightHint = textWidget.getLineHeight() * 2;
    textWidget.setLayoutData(gdata);

    return signaturePreview;
}