1 package com.proalpha.java.oea.plugins.oeaextension.fontsizer;
3 import org.eclipse.core.runtime.preferences.InstanceScope;
4 import org.eclipse.ui.preferences.ScopedPreferenceStore;
12 private ScopedPreferenceStore store;
15 public static FontSize getInstance() {
24 this.store =
new ScopedPreferenceStore(InstanceScope.INSTANCE,
"org.eclipse.ui.workbench");
27 public void increaseFont() {
28 changeFontSize(Size.INCEASE);
31 public void decreaseFont() {
32 changeFontSize(Size.DECREASE);
35 private void changeFontSize(Size size) {
37 if (this.store !=
null) {
39 String font = this.store.getString(
"org.eclipse.jface.textfont");
41 if (font !=
null && !
"".equals(font)) {
44 String[] split = font.split(
"\\|");
46 float fontSize = 1.0F;
48 if (size == Size.INCEASE)
49 fontSize = Float.parseFloat(split[2]) + 1.0F;
51 fontSize = Float.parseFloat(split[2]) - 1.0F;
54 if (fontSize <= 0.0F) {
58 split[2] = Float.toString(fontSize);
59 StringBuilder builder =
new StringBuilder(split[0]);
60 for (
int i = 1; i < split.length; i++) {
61 builder.append(
'|').append(split[i]);
63 this.store.setValue(
"org.eclipse.jface.textfont", builder.toString());
65 }
catch (Exception e) {