X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2FStatePersistor.java;fp=bundles%2Forg.simantics.browsing.ui%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2FStatePersistor.java;h=49213b766a7e44eb360ed83fd9b9e2c4f1f8e743;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08
diff --git a/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/StatePersistor.java b/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/StatePersistor.java
new file mode 100644
index 000000000..49213b766
--- /dev/null
+++ b/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/StatePersistor.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui;
+
+import java.io.File;
+
+/**
+ * @author Antti Villberg
+ * @see GraphExplorer#setPersistor(StatePersistor)
+ */
+public interface StatePersistor {
+
+ /**
+ * Deserializes a possibly stored state for the specified input from the
+ * specified location. The locality of the restored state is up to the
+ * implementation to decide (i.e. input-specific or more global).
+ *
+ * @param stateLocation
+ * the base location to deserialize the possible state from
+ * @param root
+ * the current input to deserialize the state for or
+ * null
if no input is defined
+ * @return the deserialized state, may not be null
.
+ * Implementations may return {@link ExplorerState#EMPTY} if there's
+ * no state to restore.
+ * @see ExplorerState#EMPTY
+ */
+ ExplorerState deserialize(File stateLocation, NodeContext root);
+
+ /**
+ * Serializes the specified explorer state for the specified input to the
+ * specified location. The locality of the stored state is up to the
+ * implementation to decide (i.e. input-specific or more global).
+ *
+ * @param stateLocation
+ * the base location to serialize the state to
+ * @param root
+ * the current input to serialize the state for or
+ * null
if no input is defined
+ * @param state
+ * the state to serialize
+ */
+ void serialize(File stateLocation, NodeContext root, ExplorerState state);
+
+}