Community
Participate
Working Groups
Build ID: I20061214-1445 Steps To Reproduce: 1. Create simple Taipan Diagram 2. Invoke "Save as..." action. 3. There are two scenarios: - let the original name of the file. Then confirmation diagram "The file xxx already exists. Do you want to replace existing one". After pressing "yes" error message appears: "Save could not be completed. Target file is already open in another editor." Save was not performed. - enter a new file name. Then another error message appears: "Cannot open input element: Reason : Resource xxx does not exist". More information: The problem is also relevant for all UML2Tools diagrams.
We fixed this in the STP BPMN modeler. See here: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.stp.bpmn/org.eclipse.stp.bpmn.diagram/src/org/eclipse/stp/bpmn/diagram/part/BpmnDocumentProvider.java?root=STP_Project&view=markup However there are issues when renaming the diagram or any of its containers (project and folders). Hope this helps.
Increasing priority, adding PMC approval.
-
I am very interested in this bug. Could you please give a sample of the code that will be now generated for the save as ? As an alternative, could you point me to the commit revision log corresponding to the fix ? I would like to integrate those changes in STP, and make sure there are no renaming issues. Thanks !
This fix was commited as a 1.16 revision of DocumentProvider.xpt Do not hesitate to report any additional problems with current implementation. In few words, following else {} statement was added (quotation from EcoreDocumentProvider): protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); if (info != null) { // Not changed } else { // added: URI newResoruceURI; List affectedFiles = null; if (element instanceof FileEditorInput) { IFile newFile = ((FileEditorInput) element).getFile(); affectedFiles = Collections.singletonList(newFile); newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true); } else if (element instanceof URIEditorInput) { newResoruceURI = ((URIEditorInput) element).getURI(); } else { fireElementStateChangeFailed(element); throw new CoreException(new Status(IStatus.ERROR, EcoreDiagramEditorPlugin.ID, 0, NLS.bind(Messages.EcoreDocumentProvider_IncorrectInputError, new Object[] { element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ null)); } if (false == document instanceof IDiagramDocument) { fireElementStateChangeFailed(element); throw new CoreException(new Status(IStatus.ERROR, EcoreDiagramEditorPlugin.ID, 0, "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$ } IDiagramDocument diagramDocument = (IDiagramDocument) document; final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI); final Diagram diagramCopy = (Diagram) EcoreUtil.copy(diagramDocument.getDiagram()); try { new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind(Messages.EcoreDocumentProvider_SaveAs, diagramCopy.getName()), affectedFiles) { protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { newResource.getContents().add(diagramCopy); return CommandResult.newOKCommandResult(); } }.execute(monitor, null); newResource.save(EcoreDiagramEditorUtil.getSaveOptions()); } catch (ExecutionException e) { fireElementStateChangeFailed(element); throw new CoreException(new Status(IStatus.ERROR, EcoreDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); } catch (IOException e) { fireElementStateChangeFailed(element); throw new CoreException(new Status(IStatus.ERROR, EcoreDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); } newResource.unload(); } }
Thank you Alexander, this is much appreciated. I will try this out.
Sorry Alexander, we cannot test it now as apparently we are one step behind for the BPMN modeler. We still use a FileEditorInput, your document provider requires a URIEditorInput. We will test this feature when we regenerate our classes with GMF 2.0.
[GMF Restructure] Bug 319140 : product GMF and component Generation was the original product and component for this bug