From: lempinen Date: Tue, 30 Mar 2010 11:13:55 +0000 (+0000) Subject: Deleting an item from model browser closes its editor and empties configuration view X-Git-Tag: apros-i4-rc2~6 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=aa9e3cfa959795c720aecbbb24fdab97115a67fb;p=simantics%2Fsysdyn.git Deleting an item from model browser closes its editor and empties configuration view git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15269 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/configuration/ConfigurationView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/configuration/ConfigurationView.java index 7f1bea27..36cd83ce 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/configuration/ConfigurationView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/configuration/ConfigurationView.java @@ -130,6 +130,11 @@ public class ConfigurationView extends ViewPart { @Override public void partClosed(IWorkbenchPartReference partRef) { + if(partRef.getPart(false) instanceof SysdynDiagramEditor) { + if(((SysdynDiagramEditor)partRef.getPart(false)).equals(editor)) { + initializeFields(null); + } + } } @Override @@ -202,8 +207,10 @@ public class ConfigurationView extends ViewPart { this.editor = editor; } else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().getActiveEditor() instanceof SysdynDiagramEditor) { - editor = (SysdynDiagramEditor)PlatformUI.getWorkbench() + this.editor = (SysdynDiagramEditor)PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + } else { + this.editor = null; } } @@ -212,17 +219,30 @@ public class ConfigurationView extends ViewPart { updateMapping(); if(mapping != null) setFields((Configuration)mapping.get(editor.getResourceInput().getResource())); + else + emptyFields(); } + private void emptyFields() { + name.setText(""); + name.setEnabled(false); + startTime.setText(""); + startTime.setEnabled(false); + stopTime.setText(""); + stopTime.setEnabled(false); + } private void setFields(Configuration conf) { if(editor != null && mapping != null) { originalName = conf.name; name.setText(originalName); + name.setEnabled(true); originalStart = conf.startTime.toString(); startTime.setText(originalStart); + startTime.setEnabled(true); originalStop = conf.stopTime.toString(); stopTime.setText(originalStop); + stopTime.setEnabled(true); setPartName(conf.name); } @@ -341,6 +361,8 @@ public class ConfigurationView extends ViewPart { }; mapping.addMappingListener(mappingListener); + } else { + mapping = null; } } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler.java index 9c65ec2e..307f1f20 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler.java @@ -17,6 +17,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.db.Builtins; import org.simantics.db.Resource; @@ -24,6 +26,7 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.CancelTransactionException; import org.simantics.db.exception.DatabaseException; +import org.simantics.sysdyn.ui.editor.SysdynDiagramEditor; import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; import org.simantics.utils.ui.ExceptionUtils; @@ -63,6 +66,19 @@ public class UnlinkNodeHandler extends AbstractHandler { } catch (DatabaseException e) { ExceptionUtils.logAndShowError(e); } + + for (Resource r : resources) { + IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); + for(IEditorReference er : editorReferences) { + if(er.getEditor(false) instanceof SysdynDiagramEditor) { + SysdynDiagramEditor editor = (SysdynDiagramEditor)er.getEditor(false); + if(editor.getResourceInput().getResource().equals(r)) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false); + } + } + } + } + } } \ No newline at end of file