| Summary: | Update ApplyStereotypeAction to select a resource location | ||
|---|---|---|---|
| Product: | [Modeling] MDT.UML2 | Reporter: | James Bruck <bruck.james> |
| Component: | Core | Assignee: | Christian Damus <give.a.damus> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | Kenn.Hussey |
| Version: | 3.0.0 | Keywords: | plan |
| Target Milestone: | M3 | Flags: | give.a.damus:
luna+
Kenn.Hussey: review+ |
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | Community Support | ||
Unfortunately this did not get into M6 I have pushed a new branch bugs/268444 with an enhancement to the Apply Stereotype(s) dialog in commit 2ba746f. The ChoicesDialog introduced by bug 326915 is updated to call out to its delegate to (optionally) create additional controls in the dialog. The ApplyStereotyeAction implements this new delegate API to add a drop-down list from which the user may select a resource (from amongst the currently loaded non-read-only resources in the editor's resource set) in which to create the new stereotype application(s). The default resource selection is the one in which all of the element's current stereotype applications reside or, if none or if multiple resources store the element's stereotype applications, the default is the resource containing the element. The user may also load a previously unloaded resource into the editor from this enhanced dialog; in this case, existing stereotype applications may be discovered, so the dialog updates to reflect that if necessary. The editor now also refreshes the presentation of elements' stereotype applications whenever a resource is loaded or unloaded in the resource set, on the expectation that such resource may bring in or unload stereotype applications extending elements in the primary model resource. The following functions are not in scope of this enhancement and would require new enhancements if desired: * move existing stereotype applications to another resource * resolve conflicting stereotype applications when a resource loads applications of stereotypes that are already applied to some element (only a single instance of each extension is permitted by the UML) Thanks, Christian. I think the dialog that we use to specify a different resource in which to put the stereotype applications needs to allow creation of a new file in addition to selecting an existing one - in a way similar to the dialog that the "Control..." action uses. Also, alignment of the combo looks odd; should/could we make it grab the available horizontal space? I have merged master into the branch and pushed a new commit a5da73c to address code review comments. We now have two actions in the resource selection list: "Load existing resource..." and "Create new resource...". Both actions do a bunch of validation when the user presses OK in the dialog to provide user-friendly diagnosis of invalid URI selections. The pick-list now fills the entire width of the dialog which, as for the FeatureEditorDialog, is quite a lot. I'm not sure that it looks good, but it's probably more correct. Thanks, Christian. I committed and pushed a few minor commenting and formatting tweaks. Things certainly look better, but when I tried creating a new resource for the stereotypes to be created in, I got the following error in my editor: Problems encountered in file "platform:/resource/test/My.stereotypes.uml" Resource '/test/My.stereotypes.uml' does not exist. I also noticed several exceptions like this in my log which, presumably, happened when I closed my runtime workspace: !ENTRY org.eclipse.ui.workbench 4 0 2013-10-10 10:07:07.622 !MESSAGE Widget is disposed !STACK 0 org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.SWT.error(SWT.java:4168) at org.eclipse.swt.widgets.Widget.error(Widget.java:774) at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:894) at org.eclipse.uml2.uml.editor.presentation.UMLEditor$9.refreshViewer(UMLEditor.java:1123) at org.eclipse.uml2.uml.editor.presentation.UMLEditor$9.notifyChanged(UMLEditor.java:1073) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.unload(ResourceImpl.java:1670) at org.eclipse.uml2.uml.editor.presentation.UMLEditor.dispose(UMLEditor.java:1945) at org.eclipse.ui.internal.WorkbenchPartReference.doDisposePart(WorkbenchPartReference.java:737) at org.eclipse.ui.internal.EditorReference.doDisposePart(EditorReference.java:327) at org.eclipse.ui.internal.WorkbenchPartReference.dispose(WorkbenchPartReference.java:684) at org.eclipse.ui.internal.WorkbenchPage.disposePart(WorkbenchPage.java:1797) at org.eclipse.ui.internal.WorkbenchPage.handleDeferredEvents(WorkbenchPage.java:1501) at org.eclipse.ui.internal.WorkbenchPage.deferUpdates(WorkbenchPage.java:1485) at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1459) at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1514) at org.eclipse.ui.internal.EditorPane.doHide(EditorPane.java:61) at org.eclipse.ui.internal.PartStack.close(PartStack.java:537) at org.eclipse.ui.internal.EditorStack.close(EditorStack.java:206) at org.eclipse.ui.internal.PartStack$1.close(PartStack.java:120) at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:83) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:269) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:278) at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1) at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$1.closeButtonPressed(DefaultTabFolder.java:71) at org.eclipse.ui.internal.presentations.PaneFolder.notifyCloseListeners(PaneFolder.java:631) at org.eclipse.ui.internal.presentations.PaneFolder$3.close(PaneFolder.java:206) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1598) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:261) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3974) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3613) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Thanks, Kenn. I have pushed a new commit 5e28ce8 to the branch to fix these exceptions:
* the "Create new resource..." option in the Apply Stereotypes dialog now ensures that
the dialog won't try to load it from the storage that doesn't exist
* the UML Editor now remembers the adapter that refreshes on resource load/unload
to remove it when closing the editor. Also, the adapter has a guard to check that
the viewer is not disposed
Re: the updates to copyright comments: I thought it wasn't conventional for the "initial API and implementation" copyright holder to log their own changes to a file. If that's UML2 policy, I'll try to remember to do it from henceforth.
(In reply to comment #7) > Re: the updates to copyright comments: I thought it wasn't conventional for the > "initial API and implementation" copyright holder to log their own changes to a > file. If that's UML2 policy, I'll try to remember to do it from henceforth. Oh, maybe it's not conventional. But I've been in the habit of logging all changes to a file so that, even in the absence of git history, it's possible to figure out how/why the file has evolved over time. The changes have been merged and pushed to the 'master' branch in git. The changes are available in an integration build for 4.2.0. |
Since the default location of stereotype applications can be changed, we should update the examples to make use of that functionality. This would involve enhancing the dialog to allow users to pick a resource location. In addition, we would need to create a class that extends StereotypeApplicationHelper, perhaps something like: public class MyStereotypeHelper extends StereotypeApplicationHelper { @Override protected EList<EObject> getContainmentList(Element element, EClass definition) { URI uri = URI.createFileURI("c:\\jam.uml"); Resource resource = element.eResource().getResourceSet().getResource( uri, true); if (resource != null) { return resource.getContents(); } return super.getContainmentList(element, definition); } } When opening up the resource containing the stereotype applications, we would need to refresh the original model in order to see the stereotypes <<>>.