Search in sources :

Example 1 with FontData

use of org.eclipse.swt.graphics.FontData in project OpenGrok by OpenGrok.

the class TextUtils method makeEditable.

public static void makeEditable(Text text) {
    Object isdefault = text.getData("default");
    if (isdefault != null && (Boolean) isdefault == true) {
        text.setForeground(new Color(null, 0x00, 0x00, 0x00));
        text.setText("");
        FontData fontData = text.getFont().getFontData()[0];
        Font font = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.NORMAL));
        text.setFont(font);
        text.setData("default", false);
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Example 2 with FontData

use of org.eclipse.swt.graphics.FontData in project dbeaver by serge-rider.

the class EmptyPresentation method createPresentation.

@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    UIUtils.createHorizontalLine(parent);
    placeholder = new Canvas(parent, SWT.NONE);
    placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
    placeholder.setBackground(controller.getDefaultBackground());
    final Font normalFont = parent.getFont();
    FontData[] fontData = normalFont.getFontData();
    fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
    fontData[0].setHeight(18);
    final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
    placeholder.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            UIUtils.dispose(largeFont);
        }
    });
    placeholder.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (controller.isRefreshInProgress()) {
                return;
            }
            e.gc.setFont(largeFont);
            UIUtils.drawMessageOverControl(placeholder, e, "No Data", -10);
            e.gc.setFont(normalFont);
            if (controller.getDataContainer() instanceof SQLEditor.QueryResultsContainer) {
                String execQuery = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_STATEMENT, controller.getSite(), true);
                String execScript = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_SCRIPT, controller.getSite(), true);
                UIUtils.drawMessageOverControl(placeholder, e, "Execute query (" + execQuery + ") or script (" + execScript + ") to see results", 20);
            }
        }
    });
    trackPresentationControl();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) FontData(org.eclipse.swt.graphics.FontData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData)

Example 3 with FontData

use of org.eclipse.swt.graphics.FontData in project dbeaver by serge-rider.

the class HexPreferencesPage method createContents.

/**
     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createContents(Composite parent) {
    FontData fontData = getPrefFontData();
    preferences = new HexPreferencesManager(fontData);
    return preferences.createPreferencesPart(parent);
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 4 with FontData

use of org.eclipse.swt.graphics.FontData in project dbeaver by serge-rider.

the class HexPreferencesPage method performOk.

/**
     * @see HexPreferencesPage#performOk()
     */
@Override
public boolean performOk() {
    DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
    FontData fontData = preferences.getFontData();
    store.setValue(DBeaverPreferences.HEX_FONT_NAME, fontData.getName());
    store.setValue(DBeaverPreferences.HEX_FONT_STYLE, fontData.getStyle());
    store.setValue(DBeaverPreferences.HEX_FONT_SIZE, fontData.getHeight());
    store.firePropertyChangeEvent(PROP_FONT_DATA, null, fontData);
    PrefUtils.savePreferenceStore(store);
    return true;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 5 with FontData

use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.

the class DefaultCellStyle method setFont.

/**
     * @param font The font to set.
     */
public void setFont(FontData font) {
    if (isRealModification(_font, font)) {
        FontData oldVal = _font;
        _font = font;
        firePropertyChange(FONT, oldVal, font);
    }
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Aggregations

FontData (org.eclipse.swt.graphics.FontData)70 Font (org.eclipse.swt.graphics.Font)38 FontStyle (org.eclipse.gmf.runtime.notation.FontStyle)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 Point (org.eclipse.swt.graphics.Point)8 Label (org.eclipse.swt.widgets.Label)8 Text (org.eclipse.swt.widgets.Text)5 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Color (org.eclipse.swt.graphics.Color)4 GC (org.eclipse.swt.graphics.GC)4 IFigure (org.eclipse.draw2d.IFigure)3 Dimension (org.eclipse.draw2d.geometry.Dimension)3 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3