]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views.swt/src/org/simantics/views/swt/SWTViewLoaderProcess.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.views.swt / src / org / simantics / views / swt / SWTViewLoaderProcess.java
index f5c4d83bac5e39cb005ad41b564f7e89a3182152..a18638ed11b8249e5a29d871bf791f1f4f81015b 100644 (file)
-package org.simantics.views.swt;\r
-\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.common.ErrorLogger;\r
-import org.simantics.browsing.ui.graph.impl.GraphInputSources;\r
-import org.simantics.browsing.ui.graph.impl.InputSourceListener;\r
-import org.simantics.browsing.ui.graph.impl.ObservableInputSource;\r
-import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;\r
-import org.simantics.browsing.ui.graph.impl.WorkbenchSessionContextInputSource;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.RequestProcessor;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UniqueRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.VariableRepository;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.scenegraph.INode;\r
-import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;\r
-import org.simantics.views.ontology.ViewsResources;\r
-import org.simantics.views.swt.client.base.SWTRoot;\r
-\r
-public class SWTViewLoaderProcess extends ScenegraphLoaderProcess {\r
-\r
-       final private ModelledView view;\r
-       final private IWorkbenchSite site;\r
-       \r
-       public static class ISL implements InputSourceListener {\r
-               \r
-               private SWTViewLoaderProcess process;\r
-               \r
-               ISL(SWTViewLoaderProcess process) {\r
-                       this.process = process;\r
-               }\r
-               \r
-               void dispose() {\r
-                       process = null;\r
-               }\r
-               \r
-        @Override\r
-        public void inputChanged(SessionContextInputSource source) {\r
-               if(process == null) return;\r
-            Object input = source.get( Simantics.getSessionContext() );\r
-            if (input != null)\r
-                process.view.inputChanged(source.getProvider(), input);\r
-            else\r
-                ErrorLogger.defaultLogWarning("input source " + source + " invalidly returned null", new Exception("for stack trace only"));\r
-        }\r
-       };\r
-       \r
-    ISL inputSourceListener = new ISL(this);\r
-       \r
-       public SWTViewLoaderProcess(ModelledView view, IWorkbenchSite site, String name) {\r
-               super(name);\r
-               this.view = view;\r
-               this.site = site;\r
-               this.root = new SWTRoot(site);\r
-       }\r
-\r
-       public SWTViewLoaderProcess(ModelledView view, IWorkbenchSite site) {\r
-               this(view, site, "<unnamed SWTViewLoaderProcess>");\r
-       }\r
-\r
-       @Override\r
-       public INode getRoot() {\r
-               return root;\r
-       }\r
-       \r
-       @Override\r
-       protected void initialize(RequestProcessor processor, final Variable configuration) throws DatabaseException {\r
-               \r
-               SessionContextInputSource inputSource = processor.sync(new UniqueRead<SessionContextInputSource>() {\r
-                       @Override\r
-                       public SessionContextInputSource perform(ReadGraph graph) throws DatabaseException {\r
-                               ViewsResources VIEW = ViewsResources.getInstance(graph);\r
-                               Resource represents = configuration.getRepresents(graph);\r
-                               Resource inputSource = graph.getPossibleObject(represents, VIEW.HasInputSource);\r
-                               if (inputSource == null)\r
-                                       return GraphInputSources.projectSource();\r
-                               return graph.adapt(inputSource, SessionContextInputSource.class);\r
-                       }\r
-               });\r
-\r
-        if(view != null)\r
-            view.setInputSource(inputSource);\r
-\r
-        if (inputSource instanceof ObservableInputSource)\r
-            ((ObservableInputSource) inputSource).setListener(inputSourceListener);\r
-\r
-        if (inputSource instanceof WorkbenchSessionContextInputSource)\r
-                       ((WorkbenchSessionContextInputSource) inputSource).init(site, view);\r
-\r
-       }\r
-       \r
-       @Override\r
-       public void dispose() {\r
-               \r
-               if (isDisposed())\r
-                       return;\r
-               \r
-               inputSourceListener.dispose();\r
-               for(String uri : registeredURIs) VariableRepository.unregister(uri);\r
-               SWTRoot r = (SWTRoot)root;\r
-               r.dispose();\r
-               \r
-               super.dispose();\r
-               \r
-       }\r
-\r
-}\r
+package org.simantics.views.swt;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.common.ErrorLogger;
+import org.simantics.browsing.ui.graph.impl.GraphInputSources;
+import org.simantics.browsing.ui.graph.impl.InputSourceListener;
+import org.simantics.browsing.ui.graph.impl.ObservableInputSource;
+import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;
+import org.simantics.browsing.ui.graph.impl.WorkbenchSessionContextInputSource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.VariableRepository;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;
+import org.simantics.views.ontology.ViewsResources;
+import org.simantics.views.swt.client.base.SWTRoot;
+
+public class SWTViewLoaderProcess extends ScenegraphLoaderProcess {
+
+       final private ModelledView view;
+       final private IWorkbenchSite site;
+       
+       public static class ISL implements InputSourceListener {
+               
+               private SWTViewLoaderProcess process;
+               
+               ISL(SWTViewLoaderProcess process) {
+                       this.process = process;
+               }
+               
+               void dispose() {
+                       process = null;
+               }
+               
+        @Override
+        public void inputChanged(SessionContextInputSource source) {
+               if(process == null) return;
+            Object input = source.get( Simantics.getSessionContext() );
+            if (input != null)
+                process.view.inputChanged(source.getProvider(), input);
+            else
+                ErrorLogger.defaultLogWarning("input source " + source + " invalidly returned null", new Exception("for stack trace only"));
+        }
+       };
+       
+    ISL inputSourceListener = new ISL(this);
+       
+       public SWTViewLoaderProcess(ModelledView view, IWorkbenchSite site, String name) {
+               super(name);
+               this.view = view;
+               this.site = site;
+               this.root = new SWTRoot(site);
+       }
+
+       public SWTViewLoaderProcess(ModelledView view, IWorkbenchSite site) {
+               this(view, site, "<unnamed SWTViewLoaderProcess>");
+       }
+
+       @Override
+       public INode getRoot() {
+               return root;
+       }
+       
+       @Override
+       protected void initialize(RequestProcessor processor, final Variable configuration) throws DatabaseException {
+               
+               SessionContextInputSource inputSource = processor.sync(new UniqueRead<SessionContextInputSource>() {
+                       @Override
+                       public SessionContextInputSource perform(ReadGraph graph) throws DatabaseException {
+                               ViewsResources VIEW = ViewsResources.getInstance(graph);
+                               Resource represents = configuration.getRepresents(graph);
+                               Resource inputSource = graph.getPossibleObject(represents, VIEW.HasInputSource);
+                               if (inputSource == null)
+                                       return GraphInputSources.projectSource();
+                               return graph.adapt(inputSource, SessionContextInputSource.class);
+                       }
+               });
+
+        if(view != null)
+            view.setInputSource(inputSource);
+
+        if (inputSource instanceof ObservableInputSource)
+            ((ObservableInputSource) inputSource).setListener(inputSourceListener);
+
+        if (inputSource instanceof WorkbenchSessionContextInputSource)
+                       ((WorkbenchSessionContextInputSource) inputSource).init(site, view);
+
+       }
+       
+       @Override
+       public void dispose() {
+               
+               if (isDisposed())
+                       return;
+               
+               inputSourceListener.dispose();
+               for(String uri : registeredURIs) VariableRepository.unregister(uri);
+               SWTRoot r = (SWTRoot)root;
+               r.dispose();
+               
+               super.dispose();
+               
+       }
+
+}