]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Added Chart Preferences action to time series chart editor context menu 54/4054/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 19 Mar 2020 23:46:45 +0000 (01:46 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 20 Mar 2020 06:19:09 +0000 (06:19 +0000)
gitlab #502

Change-Id: I901c2c4b92fb75b255aee3a123b0f5802f5c2fb3
(cherry picked from commit fa107b33201040a66ef237f3705395d74b22bb97)

bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartPreferencesAction.java [new file with mode: 0644]
bundles/org.simantics.charts/src/org/simantics/charts/editor/Messages.java [new file with mode: 0644]
bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java
bundles/org.simantics.charts/src/org/simantics/charts/editor/messages.properties [new file with mode: 0644]

diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartPreferencesAction.java b/bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartPreferencesAction.java
new file mode 100644 (file)
index 0000000..0cc5820
--- /dev/null
@@ -0,0 +1,38 @@
+package org.simantics.charts.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ChartPreferencesAction extends Action {
+
+       private static final String CHART_DEFAULTS_PREF_PAGE_ID = "org.simantics.charts.defaults"; //$NON-NLS-1$
+       private static final String CHART_PREF_PAGE_ID = "org.simantics.charts.pref"; //$NON-NLS-1$
+       private static final String CSV_PREF_PAGE_ID = "org.simantics.modeling.csv.preferences"; //$NON-NLS-1$ 
+
+       private IShellProvider shell;
+
+       public ChartPreferencesAction(IShellProvider shell) {
+               super(Messages.ChartPreferencesAction_ChartPreferences);
+               this.shell = shell;
+       }
+
+       @Override
+       public void run() {
+               PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+                               shell.getShell(),
+                               CHART_PREF_PAGE_ID,
+                               new String[] {
+                                               CHART_PREF_PAGE_ID,
+                                               CHART_DEFAULTS_PREF_PAGE_ID,
+                                               CSV_PREF_PAGE_ID
+                               },
+                               null);
+               dialog.open();
+       }
+
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/editor/Messages.java b/bundles/org.simantics.charts/src/org/simantics/charts/editor/Messages.java
new file mode 100644 (file)
index 0000000..5771b14
--- /dev/null
@@ -0,0 +1,15 @@
+package org.simantics.charts.editor;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.simantics.charts.editor.messages"; //$NON-NLS-1$
+       public static String ChartPreferencesAction_ChartPreferences;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
index bffd4c8a24952fb60bfae8cd517be91a9d24e36d..ad718e49ec353c11c5de660ea77fd767af3bc23b 100644 (file)
@@ -635,6 +635,8 @@ public class TimeSeriesEditor extends ResourceEditorPart {
                             if (chartItem != null) {
                                 manager.add(new HideItemsAction("Hide Item", true, Collections.singletonList(chartItem)));
                                 manager.add(new Separator());
+                                manager.add(new ChartPreferencesAction(getSite()));
+                                manager.add(new Separator());
                                 manager.add(new PropertiesAction("Item Properties", canvas, chartItem));
                                 manager.add(new PropertiesAction("Chart Properties", canvas, chart));
                             }
@@ -674,6 +676,8 @@ public class TimeSeriesEditor extends ResourceEditorPart {
                     manager.add(new SendCommandAction("Zoom to Fit Vertically", IMG_ZOOM_TO_FIT_VERT, cvsCtx, Commands.ZOOM_TO_FIT_VERT));
                     manager.add(new SendCommandAction("Autoscale Chart", IMG_AUTOSCALE, cvsCtx, Commands.AUTOSCALE));
                     manager.add(new Separator());
+                    manager.add(new ChartPreferencesAction(getSite()));
+                    manager.add(new Separator());
                     manager.add(new PropertiesAction("Chart Properties", canvas, chart));
                 }
             }
diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/editor/messages.properties b/bundles/org.simantics.charts/src/org/simantics/charts/editor/messages.properties
new file mode 100644 (file)
index 0000000..37bbe90
--- /dev/null
@@ -0,0 +1 @@
+ChartPreferencesAction_ChartPreferences=Chart Preferences