From: Tuukka Lehtonen Date: Thu, 19 Mar 2020 23:46:45 +0000 (+0200) Subject: Added Chart Preferences action to time series chart editor context menu X-Git-Tag: v1.43.0~52 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=fa107b33201040a66ef237f3705395d74b22bb97;p=simantics%2Fplatform.git Added Chart Preferences action to time series chart editor context menu gitlab #502 Change-Id: I901c2c4b92fb75b255aee3a123b0f5802f5c2fb3 --- 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 index 000000000..0cc582024 --- /dev/null +++ b/bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartPreferencesAction.java @@ -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 index 000000000..5771b1421 --- /dev/null +++ b/bundles/org.simantics.charts/src/org/simantics/charts/editor/Messages.java @@ -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() { + } +} diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java b/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java index bffd4c8a2..ad718e49e 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java @@ -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 index 000000000..37bbe90f6 --- /dev/null +++ b/bundles/org.simantics.charts/src/org/simantics/charts/editor/messages.properties @@ -0,0 +1 @@ +ChartPreferencesAction_ChartPreferences=Chart Preferences