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);
}
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 });
}
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;
}
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);
}
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;
}
Aggregations