]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/NatTableGraphExplorer.java
UI locking fixes for GraphExplorer implementations
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / NatTableGraphExplorer.java
index aa384ad1d75e5abe61fbe3b0ede5a66218e67d47..37eafd4eb5e965e1e1811fc418576e8a37535b21 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.resource.ColorDescriptor;
@@ -141,6 +140,7 @@ import org.simantics.browsing.ui.PrimitiveQueryUpdater;
 import org.simantics.browsing.ui.SelectionDataResolver;
 import org.simantics.browsing.ui.SelectionFilter;
 import org.simantics.browsing.ui.StatePersistor;
+import org.simantics.browsing.ui.common.AdaptableHintContext;
 import org.simantics.browsing.ui.common.ColumnKeys;
 import org.simantics.browsing.ui.common.ErrorLogger;
 import org.simantics.browsing.ui.common.NodeContextBuilder;
@@ -171,6 +171,7 @@ import org.simantics.browsing.ui.common.processors.DefaultViewpointProcessor;
 import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
 import org.simantics.browsing.ui.common.processors.NoSelectionRequestProcessor;
 import org.simantics.browsing.ui.common.processors.ProcessorLifecycle;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
 import org.simantics.browsing.ui.content.Labeler;
 import org.simantics.browsing.ui.content.Labeler.CustomModifier;
 import org.simantics.browsing.ui.content.Labeler.DialogModifier;
@@ -178,7 +179,6 @@ import org.simantics.browsing.ui.content.Labeler.EnumerationModifier;
 import org.simantics.browsing.ui.content.Labeler.Modifier;
 import org.simantics.browsing.ui.nattable.override.DefaultTreeLayerConfiguration2;
 import org.simantics.browsing.ui.swt.Activator;
-import org.simantics.browsing.ui.swt.AdaptableHintContext;
 import org.simantics.browsing.ui.swt.DefaultImageDecoratorsProcessor;
 import org.simantics.browsing.ui.swt.DefaultIsExpandedProcessor;
 import org.simantics.browsing.ui.swt.DefaultLabelDecoratorsProcessor;
@@ -198,6 +198,7 @@ import org.simantics.utils.threads.SWTThread;
 import org.simantics.utils.threads.ThreadUtils;
 import org.simantics.utils.ui.AdaptionUtils;
 import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
 import org.simantics.utils.ui.jface.BasePostSelectionProvider;
 
 import gnu.trove.map.hash.THashMap;
@@ -580,17 +581,16 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     private void initializeState() {
         if (persistor == null)
             return;
+        ExplorerStates.scheduleRead(getRoot(), persistor)
+        .thenAccept(state -> SWTUtils.asyncExec(natTable, () -> restoreState(state)));
+    }
 
-        ExplorerState state = persistor.deserialize(
-                Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
-                getRoot());
-
-
+    private void restoreState(ExplorerState state) {
         Object processor = getPrimitiveProcessor(BuiltinKeys.IS_EXPANDED);
         if (processor instanceof DefaultIsExpandedProcessor) {
             DefaultIsExpandedProcessor isExpandedProcessor = (DefaultIsExpandedProcessor)processor;
             for(NodeContext expanded : state.expandedNodes) {
-                isExpandedProcessor.setExpanded(expanded, true);
+                isExpandedProcessor.replaceExpanded(expanded, true);
             }
         }
     }
@@ -1313,6 +1313,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
 //                             } else {
 //                                     viewer.refresh(element,true);
 //                             }
+                               element.initData();
                                natTable.redraw();
                        }
                        
@@ -1505,7 +1506,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     final ExecutorService                        queryUpdateScheduler = Threads.getExecutor();
     
     
-       private double getDisplayScale() {
+    public static double getDisplayScale() {
                Point dpi = Display.getCurrent().getDPI();
                return (double)dpi.x/96.0;
        }