import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.internal.PartSite;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor;
import org.eclipse.ui.part.EditorPart;
import org.simantics.db.Resource;
import org.simantics.db.Session;
* @param partName
*/
protected void safeSetPartName(String partName) {
- if (!disposed) {
+ if (!disposed && checkCompatibilityPartNotBeingDisposed()) { // this is to fix bug https://gitlab.simantics.org/simantics/platform/issues/117
setPartName(partName);
}
}
+ @SuppressWarnings("restriction")
+ private boolean checkCompatibilityPartNotBeingDisposed() {
+ IWorkbenchPartSite site = getSite();
+ if (site instanceof PartSite) {
+ PartSite partSite = (PartSite) getSite();
+ Object object = partSite.getModel().getObject();
+ if (object instanceof CompatibilityEditor) {
+ CompatibilityEditor editor = (CompatibilityEditor) object;
+ return !editor.isBeingDisposed();
+ }
+ }
+ return true;
+ }
+
/**
* Safely sets title tooltip for parts whose IEditorInput is not yet disposed (e.g.
* removed from database)