Browse Source

disable option on other OS than windows

andreas muelder 7 years ago
parent
commit
f82aa183e1

+ 8 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/figures/PriorityFigure.java

@@ -32,8 +32,11 @@ public class PriorityFigure extends Ellipse {
 	private static final FontData SMALL_FONT = new FontData("Arial", 7, SWT.NORMAL);
 	private static final FontData NORMAL_FONT = new FontData("Arial", 8, SWT.NORMAL);
 	protected IMapMode mapMode;
+	private int priority;
+	private Label label;
 
 	public PriorityFigure(IMapMode mapMode, int priority) {
+		this.priority = priority;
 		this.setLayoutManager(new StackLayout());
 		setForegroundColor(ColorConstants.black);
 		setBackgroundColor(ColorConstants.white);
@@ -41,7 +44,7 @@ public class PriorityFigure extends Ellipse {
 		setOpaque(false);
 		setFill(true);
 		this.setLineWidth(-1);
-		Label label = new Label(String.valueOf(priority));
+		label = new Label(String.valueOf(priority));
 		label.setFont(createFont(priority));
 		add(label);
 	}
@@ -51,4 +54,8 @@ public class PriorityFigure extends Ellipse {
 				FontDescriptor.createFrom(FontScalingUtil.scaleFont(priority > 9 ? SMALL_FONT : NORMAL_FONT)));
 	}
 
+	public void refreshFont() {
+		label.setFont(createFont(priority));
+	}
+
 }

+ 1 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/preferences/PreferenceInitializer.java

@@ -69,7 +69,7 @@ public class PreferenceInitializer extends DiagramPreferenceInitializer implemen
 		// Syntax coloring
 		getPreferenceStore().setDefault(StatechartPreferenceConstants.PREF_SYNTAX_COLORING, false);
 		//Font scaling
-		getPreferenceStore().setDefault(StatechartPreferenceConstants.PREF_FONT_SCALING, true);
+		getPreferenceStore().setDefault(StatechartPreferenceConstants.PREF_FONT_SCALING, false);
 
 	}
 

+ 6 - 3
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/preferences/StatechartAppearancePreferencePage.java

@@ -82,10 +82,13 @@ public class StatechartAppearancePreferencePage extends FieldEditorPreferencePag
 		Composite composite = createGroupComposite(main, "Miscellaneous");
 
 		// Syntax coloring:
-		BooleanFieldEditor fontScalingEditor = new BooleanFieldEditor(
-					StatechartPreferenceConstants.PREF_FONT_SCALING, "Enable font scaling", composite);
+		BooleanFieldEditor fontScalingEditor = new BooleanFieldEditor(StatechartPreferenceConstants.PREF_FONT_SCALING,
+				"Enable font scaling (Windows)", composite);
 		addField(fontScalingEditor);
-		
+		if (System.getProperty("os.name").toLowerCase().indexOf("win") == -1) {
+			fontScalingEditor.setEnabled(false, composite);
+		}
+
 		// Syntax coloring:
 		BooleanFieldEditor syntaxColoringEditor = new BooleanFieldEditor(
 				StatechartPreferenceConstants.PREF_SYNTAX_COLORING, "Enable syntax coloring", composite);

+ 2 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/AbstractPriorityDecorationProvider.java

@@ -58,7 +58,8 @@ public abstract class AbstractPriorityDecorationProvider extends AbstractDecorat
 
 	@Override
 	public void propertyChange(PropertyChangeEvent event) {
-		if (StatechartPreferenceConstants.PREF_PRIORITY_LABELS.equals(event.getProperty())) {
+		if (StatechartPreferenceConstants.PREF_PRIORITY_LABELS.equals(event.getProperty())
+				|| StatechartPreferenceConstants.PREF_FONT_SCALING.equals(event.getProperty())) {
 			for (IDecorator decorator : decorators) {
 				decorator.refresh();
 			}

+ 2 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/utils/FontScalingUtil.java

@@ -13,13 +13,14 @@ import org.yakindu.sct.ui.editor.preferences.StatechartPreferenceConstants;
 public class FontScalingUtil {
 
 	private static final int WINDOWS_DEFAULT_DPI = 96;
+	private static final String OPERATING_SYSTEM = System.getProperty("os.name").toLowerCase();
 
 	public static FontData scaleFont(FontData fontData) {
 		return scaleFont(fontData, 0);
 	}
 
 	public static FontData scaleFont(FontData fontData, int style) {
-		if (DiagramActivator.getDefault().getPreferenceStore()
+		if (OPERATING_SYSTEM.indexOf("win") == -1 || DiagramActivator.getDefault().getPreferenceStore()
 				.getBoolean(StatechartPreferenceConstants.PREF_FONT_SCALING)) {
 			return fontData;
 		}