Search in sources :

Example 6 with FontData

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

the class SystemPreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setDefault(IPreferenceConstants.SYSTEM_AUTO_UPDATE, IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_WEEKLY);
    store.setDefault(IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_WEEKLY_DATE, 2);
    store.setDefault(IPreferenceConstants.SYSTEM_LANGUAGE, IPreferenceConstants.SYSTEM_LANGUAGE_WITH_EN);
    // 默认语言从产品的 ini 文件中取值
    Location configArea = Platform.getInstallLocation();
    String locale = "en";
    URL location = null;
    try {
        location = new URL(configArea.getURL().toExternalForm() + "configuration" + File.separator + "config.ini");
    } catch (MalformedURLException e) {
        // This should never happen
        LOGGER.error(Messages.getString("preferencepage.SystemPreferenceInitializer.logger1"), e);
    }
    try {
        String fileName = location.getFile();
        BufferedReader in = new BufferedReader(new FileReader(fileName));
        boolean isNl = false;
        String line = in.readLine();
        while (line != null) {
            if (line.startsWith("osgi.nl=")) {
                isNl = true;
                locale = line.substring("osgi.nl=".length()).trim();
                break;
            }
            line = in.readLine();
        }
        in.close();
        if (!isNl) {
            locale = "en";
        }
    } catch (FileNotFoundException e) {
        LOGGER.error(Messages.getString("preferencepage.SystemPreferenceInitializer.logger1"), e);
    } catch (IOException e) {
        LOGGER.error("", e);
    }
    if (locale != null) {
        if (locale.startsWith("en")) {
            CommonFunction.setSystemLanguage("en");
            store.setValue(IPreferenceConstants.SYSTEM_LANGUAGE, IPreferenceConstants.SYSTEM_LANGUAGE_WITH_EN);
        } else if (locale.startsWith("zh")) {
            CommonFunction.setSystemLanguage("zh");
            store.setValue(IPreferenceConstants.SYSTEM_LANGUAGE, IPreferenceConstants.SYSTEM_LANGUAGE_WITH_ZH_CN);
        }
    }
    store.setDefault(IPreferenceConstants.SYSTEM_USER, System.getProperty("user.name"));
    //将用户保存到平台首选项中
    PlatformUI.getPreferenceStore().setDefault(IPreferenceConstants.SYSTEM_USER, store.getDefaultString(IPreferenceConstants.SYSTEM_USER));
    FontData fd = JFaceResources.getDefaultFont().getFontData()[0];
    store.setDefault(IPreferenceConstants.XLIFF_EDITOR_FONT_NAME, fd.getName());
    int fontSize = fd.getHeight();
    store.setDefault(IPreferenceConstants.XLIFF_EDITOR_FONT_SIZE, fontSize < 13 ? 13 : fontSize);
    store.setDefault(IPreferenceConstants.MATCH_VIEW_FONT_NAME, fd.getName());
    store.setDefault(IPreferenceConstants.MATCH_VIEW_FONT_SIZE, fontSize < 13 ? 13 : fontSize);
    store.setDefault(IPreferenceConstants.XLIFF_EDITOR_SHOWHIDEN_NONPRINTCHARACTER, false);
}
Also used : MalformedURLException(java.net.MalformedURLException) FontData(org.eclipse.swt.graphics.FontData) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) URL(java.net.URL) Location(org.eclipse.osgi.service.datalocation.Location)

Example 7 with FontData

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

the class Activator method start.

/**
	 * 启动插件应用,创建共享的插件实例。
	 * @param context
	 *            the context
	 * @throws Exception
	 *             the exception
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    Activator.context = context;
    // Load the font for preference store
    String fontName = getPreferenceStore().getString(IPreferenceConstants.XLIFF_EDITOR_FONT_NAME);
    int size = getPreferenceStore().getInt(IPreferenceConstants.XLIFF_EDITOR_FONT_SIZE);
    FontData fontData = new FontData();
    fontData.setHeight(size);
    fontData.setName(fontName);
    JFaceResources.getFontRegistry().put(Constants.XLIFF_EDITOR_TEXT_FONT, new FontData[] { fontData });
    fontName = getPreferenceStore().getString(IPreferenceConstants.MATCH_VIEW_FONT_NAME);
    size = getPreferenceStore().getInt(IPreferenceConstants.MATCH_VIEW_FONT_SIZE);
    fontData = new FontData();
    fontData.setHeight(size);
    fontData.setName(fontName);
    JFaceResources.getFontRegistry().put(Constants.MATCH_VIEWER_TEXT_FONT, new FontData[] { fontData });
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 8 with FontData

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

the class FontPicker method createDisplayFont.

private Font createDisplayFont(FontData data) {
    FontData resizedData = new FontData(data.getName(), 8, data.getStyle());
    displayFont = GUIHelper.getFont(resizedData);
    return displayFont;
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 9 with FontData

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

the class SeparatorPanel method initComponents.

public void initComponents(String label) {
    GridLayout gridLayout = new GridLayout(2, false);
    setLayout(gridLayout);
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    setLayoutData(layoutData);
    // Text label
    StyledText gridLinesLabel = new StyledText(this, SWT.NONE);
    gridLinesLabel.setEditable(false);
    Display display = Display.getDefault();
    FontData data = display.getSystemFont().getFontData()[0];
    Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
    gridLinesLabel.setFont(font);
    gridLinesLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gridLinesLabel.setText(label);
    // Separator line
    Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData separatorData = new GridData();
    separatorData.grabExcessHorizontalSpace = true;
    separatorData.horizontalAlignment = GridData.FILL;
    separatorData.horizontalIndent = 5;
    separator.setLayoutData(separatorData);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) Display(org.eclipse.swt.widgets.Display)

Example 10 with FontData

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

the class WaitDialog method createContents.

@Override
protected Control createContents(Composite parent) {
    centerDialogOnScreen(getShell());
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(CENTER, CENTER, true, true));
    composite.setRedraw(true);
    Label imgLabel = new Label(composite, SWT.NONE);
    imgLabel.setImage(iconImage);
    textLabel = new Label(composite, SWT.NONE);
    textLabel.setLayoutData(new GridData(CENTER, CENTER, true, true));
    textLabel.setFont(GUIHelper.getFont(new FontData("Arial", 9, SWT.BOLD)));
    textLabel.setRedraw(true);
    textLabel.setText(msg);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Aggregations

FontData (org.eclipse.swt.graphics.FontData)147 Font (org.eclipse.swt.graphics.Font)89 GridData (org.eclipse.swt.layout.GridData)30 Label (org.eclipse.swt.widgets.Label)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Composite (org.eclipse.swt.widgets.Composite)25 Point (org.eclipse.swt.graphics.Point)23 Test (org.junit.Test)21 Color (org.eclipse.swt.graphics.Color)15 FontStyle (org.eclipse.gmf.runtime.notation.FontStyle)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 Button (org.eclipse.swt.widgets.Button)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 Display (org.eclipse.swt.widgets.Display)9 Text (org.eclipse.swt.widgets.Text)9 GC (org.eclipse.swt.graphics.GC)8 StyleRange (org.eclipse.swt.custom.StyleRange)7 Image (org.eclipse.swt.graphics.Image)7 IOException (java.io.IOException)6