Bug 549943 - Problem using new transient ui element feature
Summary: Problem using new transient ui element feature
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.11   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-09 12:42 EDT by Rolf Theunissen CLA
Modified: 2019-10-25 09:32 EDT (History)
3 users (show)

See Also:


Attachments
Example project (70.22 KB, application/x-zip-compressed)
2019-08-09 12:42 EDT, Rolf Theunissen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Theunissen CLA 2019-08-09 12:42:04 EDT
Created attachment 279536 [details]
Example project

From the forum: https://www.eclipse.org/forums/index.php/t/1099667/

In eclipse 4.11, there is a new feature where a ui element can be marked to not be persisted (https://www.eclipse.org/eclipse/news/4.11/platform_isv.php)

part.getPersistedState().put(IWorkbench.PERSIST_STATE, "false");

When I use this feature, the view will not be persisted to the workbench.xmi file, but eclipse still persists that this view was selected in the partstack when I closed the application and when I restart, the application throws an exception and resets the perspective together with all other views which should be persisted.

Here is the tag that cannot be parsed by eclipse
<children xsi:type="basic:PartStack" xmi:id="_PYv99KL2EemRTJKPOqiKJQ" elementId="persist.partstack.sample" contributorURI="platform:/plugin/persist" containerData="5000" selectedElement="_PYv99qL2EemRTJKPOqiKJQ">

The exception mentions the ID in selectedElement

Is this a glitch in the new feature or am I missing something?

Here is the exception
Caused by: org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference '_PYv99qL2EemRTJKPOqiKJQ'. (file:/C:/Users/stefan.folkesson/runtime-persist.product/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi, 8, 219)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardReferences(XMLHandler.java:1197)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHandler.java:1282)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1342)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 20 more


I have attached an example project with two views. One is always open and should be persisted. The other is opened through the open command and is marked not to be persisted, see OpenHandler.java.

To reproduce the error, open the second view (leave the new view selected in the partstack), close the application, and open the application again. This gives the exception and the perspective is reset.
Comment 1 Lars Vogel CLA 2019-08-09 12:51:43 EDT
How should this be handled? Cleanout selected elements which will not be persisted during persistence?
Comment 2 Rolf Theunissen CLA 2019-08-09 13:16:51 EDT
(In reply to Lars Vogel from comment #1)
> How should this be handled? Cleanout selected elements which will not be
> persisted during persistence?

References to elements that are not persisted should not be persisted as well. If the resulting model is still valid, depends on if the reference is mandatory or not.

Filter should be done in E4XMISave, probably by custom implementation of getElementIDRefSingleSimple and friends.
Comment 3 Rolf Theunissen CLA 2019-10-25 09:32:24 EDT
Again I have seen the same error, but now I was not able to recover the original workbench.xmi.
At least the error message should give some more context otherwise we cannot analyze this one at all.