]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceEditorSupport.java
Remove usage of deprecated SimanticsUI-methods
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / ResourceEditorSupport.java
index 4075e1e11efaec0a6b3161db1bf9cf2b3f67bdba..3597804d8f83164637e8f0b5e60e44c9879d25c2 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
+import org.simantics.Simantics;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Session;
 import org.simantics.db.common.procedure.adapter.ListenerAdapter;
@@ -28,7 +29,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.management.ISessionContextProvider;
 import org.simantics.db.service.GraphChangeListenerSupport;
-import org.simantics.ui.SimanticsUI;
 import org.simantics.utils.datastructures.map.Tuple;
 import org.simantics.utils.ui.ExceptionUtils;
 import org.simantics.utils.ui.SWTUtils;
@@ -91,7 +91,7 @@ public class ResourceEditorSupport implements IAdaptable, ChangeListener {
 
     private ISessionContext initSession() throws PartInitException {
         if (sessionContext == null) {
-            ISessionContextProvider provider = SimanticsUI.getSessionContextProvider();
+            ISessionContextProvider provider = Simantics.getSessionContextProvider();
             ISessionContext sc = provider.getSessionContext();
             if (sc == null)
                 throw new PartInitException("active database session context is null");
@@ -311,7 +311,9 @@ public class ResourceEditorSupport implements IAdaptable, ChangeListener {
     }
 
     private static void scheduleEditorClose(IEditorPart editorPart) {
-        SWTUtils.asyncExec(editorPart.getSite().getShell(), () -> {
+        if (editorPart == null)
+            return;
+        SWTUtils.asyncExec(editorPart.getSite().getWorkbenchWindow().getShell(), () -> {
             // Don't have to check isDisposed since closeEditor
             // will ignore already closed editor parts.
             WorkbenchUtils.closeEditor(editorPart, false);