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.jboss.tools.aesh.ui.view.AbstractTextViewer.java

License:Open Source License

private void initializeTextWidget() {
    textWidget.setConsole(console);/* w  w w  . j  a  va  2s  . c om*/
    textWidget.setFont(JFaceResources.getFont(FontManager.AESH_CONSOLE_FONT));
    textWidget.addVerifyKeyListener(new VerifyKeyListenerImpl(console));
}

From source file:org.jboss.tools.forge.ui.internal.viewer.F1TextViewer.java

License:Open Source License

private void initViewer() {
    getTextWidget().setStyleRanges(forgeDocument.getStyleRanges());
    getTextWidget().setFont(JFaceResources.getFont(FORGE_CONSOLE_FONT));
    getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {
        @Override//ww  w.  ja  va  2  s  . c o m
        public void verifyKey(VerifyEvent event) {
            if ((event.stateMask & SWT.CTRL) == SWT.CTRL) {
                if (event.keyCode == 'd') {
                    getRuntime().sendInput(CTRL_D);
                } else if (event.keyCode == 'c') {
                    getRuntime().sendInput(CTRL_C);
                }
            }
        }
    });
}

From source file:org.jboss.tools.jst.css.dialog.tabs.TabPreviewControl.java

License:Open Source License

/**
 * Method update preview tab with information from the CSS file passed by
 * parameter./*from  w w w .  j ava  2 s  .  c o m*/
 * 
 * @param cssFile
 *            CSS file to be displayed in preview area
 */
public void initPreview(ICSSDialogModel cssModel) {
    this.cssModel = cssModel;
    if (cssModel != null) {

        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationCSS();

        viewer = new StructuredTextViewer(this, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
        ((StructuredTextViewer) viewer).getTextWidget()
                .setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$

        viewer.configure(baseConfiguration);
        viewer.setDocument(cssModel.getDocument());
        viewer.setEditable(false);

        layout();
    }
}

From source file:org.jboss.tools.jst.web.ui.wizards.newfile.NewXHTMLTemplatesWizardPage.java

License:Open Source License

/**
 * Creates, configures and returns a source viewer to present the template
 * pattern on the preference page. Clients may override to provide a
 * custom source viewer featuring e.g. syntax coloring.
 * //from  w  ww.ja  v  a 2 s  . com
 * @param parent
 *            the parent control
 * @return a configured source viewer
 */
private SourceViewer createViewer(Composite parent) {
    SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML();

        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
            return baseConfiguration.getConfiguredContentTypes(sourceViewer);
        }

        public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
            return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
        }
    };
    SourceViewer viewer = new StructuredTextViewer(parent, null, null, false,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    ((StructuredTextViewer) viewer).getTextWidget()
            .setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$
    IStructuredModel scratchModel = StructuredModelManager.getModelManager()
            .createUnManagedStructuredModelFor("org.eclipse.wst.html.core.htmlsource");
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(sourceViewerConfiguration);
    viewer.setDocument(document);
    return viewer;
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.plaintext.PlainTextPresentation.java

License:Open Source License

@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);

    UIUtils.createHorizontalLine(parent);
    text = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setBlockSelection(true);//from  ww  w. j  av a2 s .  c o  m
    text.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_IBEAM));
    text.setMargins(4, 4, 4, 4);
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    text.setLayoutData(new GridData(GridData.FILL_BOTH));
    text.addCaretListener(new CaretListener() {
        @Override
        public void caretMoved(CaretEvent event) {
            onCursorChange(event.caretOffset);
        }
    });

    final ScrollBar verticalBar = text.getVerticalBar();
    verticalBar.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (verticalBar.getSelection() + verticalBar.getPageIncrement() >= verticalBar.getMaximum()) {
                if (controller.getPreferenceStore()
                        .getBoolean(DBeaverPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT)
                        && !controller.isRecordMode() && controller.isHasMoreData()) {
                    controller.readNextSegment();
                }
            }
        }
    });
    findReplaceTarget = new StyledTextFindReplaceTarget(text);
    UIUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), text);
    applyThemeSettings();

    registerContextMenu();
    trackPresentationControl();
}

From source file:org.jkiss.dbeaver.ui.data.editors.ContentInlineEditor.java

License:Open Source License

@Override
protected Text createControl(Composite editPlaceholder) {
    final Text editor = new Text(editPlaceholder, SWT.BORDER);
    editor.setEditable(!valueController.isReadOnly());
    editor.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    long maxLength = valueController.getValueType().getMaxLength();
    if (maxLength <= 0) {
        maxLength = MAX_STRING_LENGTH;// w w w. j a  va  2s.  co m
    } else {
        maxLength = Math.min(maxLength, MAX_STRING_LENGTH);
    }
    editor.setTextLimit((int) maxLength);
    return editor;
}

From source file:org.jkiss.dbeaver.ui.data.editors.ContentPanelEditor.java

License:Open Source License

@Override
protected Control createControl(Composite editPlaceholder) {
    DBDContent content = (DBDContent) valueController.getValue();
    if (ContentUtils.isTextContent(content)) {
        Text text = new Text(editPlaceholder, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
        text.setEditable(!valueController.isReadOnly());
        text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
        return text;
    } else {//from www.java2  s.  c o m
        ImageDetector imageDetector = new ImageDetector(content);
        if (!DBUtils.isNullValue(content)) {
            DBeaverUI.runInUI(valueController.getValueSite().getWorkbenchWindow(), imageDetector);
        }

        IContributionManager editBar = valueController.getEditBar();
        if (imageDetector.isImage()) {
            ImageViewer imageViewer = new ImageViewer(editPlaceholder, SWT.BORDER);
            if (editBar != null) {
                imageViewer.fillToolBar(editBar);
            }
            return imageViewer;
        } else {
            final HexEditControl hexEditor = new HexEditControl(editPlaceholder, SWT.BORDER);
            if (editBar != null) {
                editBar.add(new Action("Switch Insert/Overwrite mode",
                        DBeaverIcons.getImageDescriptor(UIIcon.CURSOR)) {
                    @Override
                    public void run() {
                        hexEditor.redrawCaret(true);
                    }
                });
            }
            return hexEditor;
        }
    }
}

From source file:org.jkiss.dbeaver.ui.data.managers.stream.TextPanelEditor.java

License:Apache License

@Override
public StyledText createControl(IValueController valueController) {
    StyledText text = new StyledText(valueController.getEditPlaceholder(), SWT.MULTI | SWT.V_SCROLL);
    text.setEditable(!valueController.isReadOnly());
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    ContentPanelEditor.setEditorSettings(text);
    return text;/*from w  w w. j a v a2 s .  c  om*/
}

From source file:org.kalypso.ogc.gml.map.themes.KalypsoTextTheme.java

License:Open Source License

/**
 * This function creates an SWT image.//w ww  . ja v  a2s . co m
 * 
 * @return The SWT image.
 */
protected org.eclipse.swt.graphics.Image createSwtImage() {
    /* Is a text available? */
    if (m_text == null || m_text.length() == 0)
        return null;

    /* Get the font. */
    final Font smallFont = JFaceResources.getFont(JFaceResources.DIALOG_FONT);
    final Font bigFont = FontUtilities.changeHeightAndStyle(smallFont.getDevice(), smallFont, m_fontSize,
            SWT.BOLD);

    /* Create a helper image. */
    final org.eclipse.swt.graphics.Image helperImage = new org.eclipse.swt.graphics.Image(bigFont.getDevice(),
            100, 100);
    final GC helperGC = new GC(helperImage);
    helperGC.setFont(bigFont);

    /* Get the text extent. */
    final Point textExtent = helperGC.textExtent(m_text);
    final int width = textExtent.x;
    final int height = textExtent.y;

    /* Dispose the helper image. */
    helperImage.dispose();
    helperGC.dispose();

    /* Create the palette. */
    final Color white = bigFont.getDevice().getSystemColor(SWT.COLOR_WHITE);
    final Color black = bigFont.getDevice().getSystemColor(SWT.COLOR_BLACK);
    PaletteData palette = new PaletteData(new RGB[] { m_background, black.getRGB() });
    if (m_transparency)
        palette = new PaletteData(new RGB[] { white.getRGB(), black.getRGB() });

    /* Create a new image data. */
    final ImageData newImageData = new ImageData(width, height, 2, palette);
    if (m_transparency)
        newImageData.transparentPixel = 0;

    /* Create a new image. */
    final org.eclipse.swt.graphics.Image newImage = new org.eclipse.swt.graphics.Image(bigFont.getDevice(),
            newImageData);
    final GC newGC = new GC(newImage);
    newGC.setFont(bigFont);

    /* Draw the text. */
    final Color backgroundColor = new Color(newGC.getDevice(), m_background);
    if (!m_transparency)
        newGC.setBackground(backgroundColor);

    newGC.setForeground(black);
    newGC.drawText(m_text, 0, 0);

    /* Dispose the new image. */
    newGC.dispose();
    backgroundColor.dispose();

    return newImage;
}

From source file:org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 *//*from ww  w.j a v  a 2s  . c  o m*/
@Override
protected Control createDialogArea(final Composite parent) {
    setTitle(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.2")); //$NON-NLS-1$
    setMessage(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.3")); //$NON-NLS-1$

    final Group composite = new Group(parent, SWT.NONE);
    composite.setLayout(new GridLayout(3, false));
    // composite.setText( "Eigenschaften" );
    // Also set layoutData as it is not set by parent. Maybe fixed in 3.3?
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // Name
    final Label nameLabel = new Label(composite, SWT.NONE);
    nameLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.4")); //$NON-NLS-1$

    final Text nameText = new Text(composite, SWT.BORDER);
    final GridData nameData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    nameData.horizontalSpan = 2;
    nameText.setLayoutData(nameData);

    // Color
    final Label colorLabel = new Label(composite, SWT.NONE);
    colorLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.5")); //$NON-NLS-1$

    final Button colorButton = new Button(composite, SWT.PUSH);
    final GridData colorData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    colorButton.setLayoutData(colorData);

    final Scale alphaSlider = new Scale(composite, SWT.HORIZONTAL);
    final GridData alphaData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    alphaData.widthHint = 150;
    alphaSlider.setLayoutData(alphaData);
    alphaSlider.setIncrement(1);
    alphaSlider.setMinimum(0);
    alphaSlider.setMaximum(255);
    alphaSlider.setPageIncrement(20);

    // Stroke
    final Label sizeLabel = new Label(composite, SWT.NONE);
    sizeLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.6")); //$NON-NLS-1$

    final ComboViewer dashCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    dashCombo.getControl().setFont(composite.getDisplay().getSystemFont());
    final GridData dashData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    dashCombo.getCombo().setLayoutData(dashData);
    // Better would be some fixed-sized font, but what is the best way to find it?
    final Font comboFont = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    dashCombo.getCombo().setFont(comboFont);
    dashCombo.setLabelProvider(new DashTypeLabelProvider());
    dashCombo.setContentProvider(new ArrayContentProvider());
    dashCombo.setInput(DashType.KNOWN_DASHS);

    final Scale sizeSlider = new Scale(composite, SWT.HORIZONTAL);
    final GridData sizeData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    sizeData.widthHint = 150;
    sizeSlider.setLayoutData(sizeData);
    sizeSlider.setIncrement(1);
    sizeSlider.setMinimum(1);
    sizeSlider.setMaximum(10);
    sizeSlider.setPageIncrement(5);

    // hook-listeners
    nameText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            handleNameTextModified(nameText);
            updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);
        }
    });

    colorButton.addSelectionListener(new SelectionAdapter() {
        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            handleColorButtonSelected();
            updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);
        }
    });

    colorButton.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent e) {
            if (colorButton.getImage() != null)
                colorButton.getImage().dispose();
        }
    });

    alphaSlider.addSelectionListener(new SelectionAdapter() {
        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            handleAlphaSliderSelected(alphaSlider);
            updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);
        }
    });

    sizeSlider.addSelectionListener(new SelectionAdapter() {
        /**
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            handleSizeSliderSelected(sizeSlider);
            updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);

        }
    });

    dashCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            handleTypeSelectionChanged((IStructuredSelection) event.getSelection());
            updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);
        }
    });

    // Initalize controls
    if (m_name == NAME_UNDEF)
        nameText.setEditable(false);
    else
        nameText.setText(m_name);

    if (m_color == LineProperties.COLOR_UNDEF) {
    } else
        alphaSlider.setSelection(m_alpha);

    if (m_size != LineProperties.SIZE_UNDEF)
        sizeSlider.setSelection(m_size.intValue());

    dashCombo.setSelection(new StructuredSelection(m_dash));

    updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider);

    return super.createDialogArea(parent);
}