Bug 547503 - Incorrect persisted state for shared elements in fragments
Summary: Incorrect persisted state for shared elements in fragments
Status: CLOSED DUPLICATE of bug 440030
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-21 05:32 EDT by Simon Scholz CLA
Modified: 2019-06-01 17:01 EDT (History)
2 users (show)

See Also:


Attachments
Sample e4 application to reproduce the error (39.28 KB, application/zip)
2019-05-21 05:32 EDT, Simon Scholz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Scholz CLA 2019-05-21 05:32:25 EDT
Created attachment 278676 [details]
Sample e4 application to reproduce the error

Besides this error from yesterday (https://bugs.eclipse.org/bugs/show_bug.cgi?id=547485) I have another finding concerning the persisted state of a shared element, which is defined in a fragment.e4xmi file.

This is the implementation of a SampleView part, which is referenced as shared element.

public class SampleView {

	private static final String PERSISTED_TEXT = "text";
	private Text text;

	@PostConstruct
	public void createPartControl(Composite parent, MPart part) {
		text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		text.setMessage("Type text to be persited here");
		text.setText(part.getPersistedState().getOrDefault(PERSISTED_TEXT, ""));
	}

	@PersistState
	public void persist(MPart part) {
		part.getPersistedState().put(PERSISTED_TEXT, text.getText());
	}
}

When I type "Test" into the Text control and close the application, the persisted state is correctly persisted:

 <sharedElements xsi:type="basic:Part" xmi:id="_-5fZQHsAEemM37NvJ3qSlQ" elementId="brokenmodel.part.sharedpart" contributorURI="platform:/plugin/brokenmodelfragment" contributionURI="bundleclass://brokenmodelfragment/brokenmodel.parts.SampleView" label="Shared Part">
      <persistedState key="text" value="Test"/>
      <tags>active</tags>
</sharedElements>

But when I restart the application (of course WITHOUT -clearPersistedState flag or anything else, which clears the workspace) the persisted state cannot be restored, which means that the Text control remains empty even though "text.setText(part.getPersistedState().getOrDefault(PERSISTED_TEXT, ""));" is used.

I also tried each and every combination for applying different fragment behavior:

   <extension
         id="brokenmodel.fragment"
         point="org.eclipse.e4.workbench.model">
      <fragment
            apply="{Tried each kind of apply method}"
            uri="fragment.e4xmi">
      </fragment>
   </extension>

It seems that having placeholders and shared elements in a fragment is severely broken.

I also attached a sample application, steps to reproduce are:

1) Start the application by using the product
2) Click on the "Shared Part" part and type some text into the textfield
3) Close the application (causes save of persisted state in workbench.xmi file)
4) Restart the application (without -clearPersistedState flag -> loads workbench.xmi)
5) Click on "Shared Part" tab and still have an empty Text control without the previously typed text, even though it is visible in the workbench.xmi file
Comment 1 Andrey Loskutov CLA 2019-05-22 16:04:08 EDT
I also assume this is not a regression in 4.12?
Comment 2 Rolf Theunissen CLA 2019-06-01 16:40:59 EDT

*** This bug has been marked as a duplicate of bug 487748 ***
Comment 3 Rolf Theunissen CLA 2019-06-01 17:01:05 EDT

*** This bug has been marked as a duplicate of bug 440030 ***