+ new TitleUpdater(site.getShell().getDisplay(), this::safeSetTitleToolTip, disposedCallback));
+ }
+ }
+
+ /**
+ * Safely sets part name for parts whose IEditorInput is not yet disposed (e.g.
+ * removed from database)
+ *
+ * @param partName
+ */
+ protected void safeSetPartName(String partName) {
+ 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)
+ *
+ * @param toolTip
+ */
+ protected void safeSetTitleToolTip(String toolTip) {
+ if (!disposed) {
+ setTitleToolTip(toolTip);