summaryrefslogtreecommitdiffstats
path: root/rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java
diff options
context:
space:
mode:
authorKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-03 18:42:39 +0900
committerKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-06 19:32:38 +0900
commitbe4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch)
tree1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java
parent71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff)
Initial commit
Bug-AGL: SPEC-4033 Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java')
-rw-r--r--rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java b/rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java
new file mode 100644
index 0000000..21ff588
--- /dev/null
+++ b/rba.tool.editor.ui/src/rba/tool/editor/ui/recordandplay/RBASimulationRecordSettingManager.java
@@ -0,0 +1,71 @@
+package rba.tool.editor.ui.recordandplay;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.Preferences;
+
+
+public class RBASimulationRecordSettingManager {
+
+ public static final RBASimulationRecordSettingManager INSTANCE = new RBASimulationRecordSettingManager();
+
+ public static final String ID_PREFERENCE_NODE = "rba.model.tool"; //$NON-NLS-1$
+
+ private static final String ID_PREFERENCES = "rba.model.tool.recordAndPlay"; //$NON-NLS-1$
+
+ private static final String ID_RECORD_PATH = "RecordFilePath"; //$NON-NLS-1$
+
+ /**
+ * Save record file path
+ * @param path
+ */
+ public void saveRecordFilePath(final String path) {
+ final String oldPath = RBASimulationRecordSettingManager.INSTANCE.getRecordFilePath();
+ if (!equals(oldPath, path)) {
+ IEclipsePreferences preferences = getPreferences();
+ Preferences sub = preferences.node(ID_PREFERENCES);
+ sub.put(ID_RECORD_PATH, path);
+ }
+ }
+
+ /**
+ * Get record file path
+ * @return path
+ */
+ public String getRecordFilePath() {
+ IEclipsePreferences preferences = getPreferences();
+ Preferences sub = preferences.node(ID_PREFERENCES);
+ return sub.get(ID_RECORD_PATH, "");
+ }
+
+ private IEclipsePreferences getPreferences() {
+ return InstanceScope.INSTANCE.getNode(ID_PREFERENCE_NODE);
+ }
+
+ /**
+ * String equality check
+ * @param cs1
+ * @param cs2
+ * @return
+ */
+ private boolean equals(String cs1, String cs2) {
+
+ boolean result = false;
+
+ if (cs1 == cs2) {
+ result = true;
+ }
+ if (cs1 == null || cs2 == null) {
+ result = false;
+ }
+ if (cs1.length() != cs2.length()) {
+ result = false;
+ }
+ if (cs1 instanceof String && cs2 instanceof String) {
+ result = cs1.equals(cs2);
+ }
+
+ return result;
+ }
+
+}