Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Bug(s) in model persistence and setFocus?
Bug(s) in model persistence and setFocus? [message #753848] Sat, 29 October 2011 11:54 Go to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
I observe some strange things with model-persistence and don't know whether it is my fault or whether there are some bugs.

To explain what I mean: I have implemented the method AppHooks.processAdditions, which does nothing but print the model:
	@ProcessAdditions
	public void processAdditions(MApplication appModel) {
		System.out.println("AppHooks: processAdditions; appModel: " + appModel);
		List<MCommand> commands = appModel.getCommands();
		for (MCommand cmd : commands) {
			System.out.println("MCommand: " + cmd);
		}
		printMUIElement(appModel);
	}
	
	private int off = 0;
	
	private void printMUIElement(MUIElement element) {
		// print element
		for(int i = 0; i < off; i++) System.out.print("-");
		System.out.println("MUIElement: " + element);
		// print children
		if (element instanceof MElementContainer) {
			off++;
			List<? extends MUIElement> children = (List<? extends MUIElement>)((MElementContainer)element).getChildren();
			for( MUIElement child : children) {
				printMUIElement(child);
			}			
			off--;
		}
	}

When I start a clean application, I get, for instance:
MUIElement: org.eclipse.e4.ui.model.application.impl.ApplicationImpl@41e701b0 (elementId: de.gps.app.application, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (context: WorkbenchContext, variables: null)
-MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.TrimmedWindowImpl@569eebe5 (elementId: null, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: %windowTitle, iconURI: null, tooltip: null, context: null, variables: null, x: 30, y: 30, width: 300, height: 200)
--MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartSashContainerImpl@226eb6a4 (elementId: null, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: , accessibilityPhrase: null) (horizontal: true)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@3a5c470d (elementId: de.gps.app.partstacks.first, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 30, accessibilityPhrase: null)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@3cc46a (elementId: de.gps.app.partstacks.second, tags: [de.gps.app.editorArea], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 70, accessibilityPhrase: null)

The model has two MPartDescriptors, contributed through fragments, the first one can only provide one MPart (LogView), the other can provide multiple MParts (MtkEditor). The latter one is also dirtyable. So, when I open a clean application (see output above), create the LogView and one MtkEditor, close the application and start it again, I get:
MUIElement: org.eclipse.e4.ui.model.application.impl.ApplicationImpl@41e701b0 (elementId: de.gps.app.application, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (context: WorkbenchContext, variables: null)
-MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.TrimmedWindowImpl@569eebe5 (elementId: null, tags: [topLevel], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: %windowTitle, iconURI: null, tooltip: null, context: null, variables: null, x: 30, y: 30, width: 300, height: 200)
--MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartSashContainerImpl@1298daa5 (elementId: null, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: , accessibilityPhrase: null) (horizontal: true)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@3cc46a (elementId: de.gps.app.partstacks.first, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 30, accessibilityPhrase: null)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@15830b45 (elementId: de.gps.app.partstacks.second, tags: [de.gps.app.editorArea, active], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 70, accessibilityPhrase: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@2276517f (elementId: de.gps.log.db.ui.LogView, tags: null, contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.log.db.ui/de.gps.log.db.ui.views.LogView, object: null, context: null, variables: null, label: DBLogView, iconURI: null, tooltip: Tooltip, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@5e07a86 (elementId: de.gps.mtk.ui.mtkEditor, tags: [active], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 1, iconURI: null, tooltip: Tooltip1, dirty: false, closeable: true, description: null)

Things to note:

  • The are two MParts in the model, as expected
  • One MPart has the tag active

The Editor is active, which is correct.

First Problem: Aktive tags. With two parts (one LogView and one MtkEditor) I can switch the focus between these parts at will, close the application and start it again and only one part has the aktive tag. When I have three parts (one LogView and two MtkEditors), I can get all three parts to have the active tag after restarting the application:
MUIElement: org.eclipse.e4.ui.model.application.impl.ApplicationImpl@253b0fd8 (elementId: de.gps.app.application, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (context: WorkbenchContext, variables: null)
-MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.TrimmedWindowImpl@4ab69761 (elementId: null, tags: [topLevel], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: %windowTitle, iconURI: null, tooltip: null, context: null, variables: null, x: 515, y: 270, width: 868, height: 198)
--MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartSashContainerImpl@5943bd77 (elementId: null, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: , accessibilityPhrase: null) (horizontal: true)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@70fab733 (elementId: de.gps.app.partstacks.first, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 30, accessibilityPhrase: null)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@5c11af37 (elementId: de.gps.app.partstacks.second, tags: [de.gps.app.editorArea, active], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 70, accessibilityPhrase: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@cc1d919 (elementId: de.gps.log.db.ui.LogView, tags: [active], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.log.db.ui/de.gps.log.db.ui.views.LogView, object: null, context: null, variables: null, label: DBLogView, iconURI: null, tooltip: Tooltip, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@a93feda (elementId: de.gps.mtk.ui.mtkEditor, tags: [active], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 1, iconURI: null, tooltip: Tooltip1, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@7a409fa2 (elementId: de.gps.mtk.ui.mtkEditor, tags: [active], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 2, iconURI: null, tooltip: Tooltip2, dirty: false, closeable: true, description: null)

This is reproducible. I would conclude, that the active tag is not properly persisted.

Second Problem: Inconsistent model. I can open a clean application (the model has no part), add the LogView and (maybe) three MtkEditors. Then I delete the editor parts again and close the application. When I start it again, I get
MUIElement: org.eclipse.e4.ui.model.application.impl.ApplicationImpl@59a69d87 (elementId: de.gps.app.application, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (context: WorkbenchContext, variables: null)
-MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.TrimmedWindowImpl@74e6cbcd (elementId: null, tags: [topLevel], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: %windowTitle, iconURI: null, tooltip: null, context: null, variables: null, x: 30, y: 30, width: 1436, height: 198)
--MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartSashContainerImpl@66129da5 (elementId: null, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: , accessibilityPhrase: null) (horizontal: true)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@226eb6a4 (elementId: de.gps.app.partstacks.first, tags: null, contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 30, accessibilityPhrase: null)
---MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@1298daa5 (elementId: de.gps.app.partstacks.second, tags: [de.gps.app.editorArea, active], contributorURI: platform:/plugin/de.gps.app) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: 70, accessibilityPhrase: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@62f8f173 (elementId: de.gps.log.db.ui.LogView, tags: [active], contributorURI: null) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.log.db.ui/de.gps.log.db.ui.views.LogView, object: null, context: null, variables: null, label: DBLogView, iconURI: null, tooltip: Tooltip, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@45b3e7c8 (elementId: de.gps.mtk.ui.mtkEditor, tags: null, contributorURI: null) (widget: null, renderer: null, toBeRendered: false, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 1, iconURI: null, tooltip: Tooltip1, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@26361f38 (elementId: de.gps.mtk.ui.mtkEditor, tags: null, contributorURI: null) (widget: null, renderer: null, toBeRendered: false, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 2, iconURI: null, tooltip: Tooltip2, dirty: false, closeable: true, description: null)
----MUIElement: org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@2276517f (elementId: de.gps.mtk.ui.mtkEditor, tags: null, contributorURI: null) (widget: null, renderer: null, toBeRendered: false, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: platform:/plugin/de.gps.mtk.ui/de.gps.mtk.ui.views.MtkLogger, object: null, context: null, variables: null, label: Mtk Editor - 3, iconURI: null, tooltip: Tooltip3, dirty: false, closeable: true, description: null)

Strange, I have three editors in the model, but the UI only shows the LogView. These three model elements (editors) must have been persisted although I deleted them before I closed the application.

Third problem (may not be related, since I do not persist the model in between): The number of calls to the setFocus method of the parts:
I open a clean application and add the LogView. setFocus is called once. I add an editor, setFocus is called once. I select the LogView and setFocus is called twice. I again select the editor and setFocus is also called twice.




Re: Bug(s) in model persistence and setFocus? [message #753870 is a reply to message #753848] Sat, 29 October 2011 17:37 Go to previous messageGo to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
O.k., to make that long story short here is my current understanding:

StackRenderer does not seem to remove the MPart from the model, if the corresponding CTabItem is deleted from the CTabFolder. This might be all right if the MPart is created only once from an MPartDescriptor, i.e. one should use something like that in a Handler:
	@Execute
	public void execute(EPartService partService) {
		MPart part = partService.findPart(LogView.ID);
		if (part == null) {
			part = partService.createPart(LogView.ID);
		}
		if (part != null) {
			part.setLabel("DBLogView");
			part.setTooltip("Tooltip");
			partService.showPart(part, PartState.ACTIVATE);
		}
	}

After the MPart is created, it will be kept in the model forever, even if the corresponding CTabItem is closed.

I am not sure whether this makes sense if multiple MParts can be created for an MPartDescriptor. Suppose I open six MtkEditors in one session and close all of them before I quit the application. When it is restarted,
partService.findPart(MtkEditor.ID)

seems to return the "first" MPart for this editor. At this point I could reuse it, but I would have to tune it (set the label, tooltip etc). When I try to open the second editor, the "first" MPart is found again, which is already in use! (All MParts have the ID of the MPartDescriptor). So in order to recycle MParts, one would need to use EPartDescriptor.getParts() and look at all MParts in order to find one that could be recycled. Furthermore, after a wild edit session I might have a pool 50 MParts in the model and later on might only need to recycle at most three of them (or so). Hmmm... it might indeed be better to remove MParts from the model together with the corresponding CTabItems -- at least those created through an MPartDescriptor.

I have not looked at the IPartListener yet. Maybe one can remove the MParts employing this listener in the application code. Still, it might be better, if the framework would do it...

There is another point: If MParts are not removed, the model will continously grow for some time, until it contains MParts (one or more) for every MPartDescriptor.
Re: Bug(s) in model persistence and setFocus? [message #753881 is a reply to message #753848] Sat, 29 October 2011 21:42 Go to previous messageGo to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
The tag removeOnHide on the MPartDescriptor will do the job.
Re: Bug(s) in model persistence and setFocus? [message #753937 is a reply to message #753848] Sun, 30 October 2011 21:03 Go to previous messageGo to next message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
Karl Weber wrote on Sat, 29 October 2011 13:54

Third problem (may not be related, since I do not persist the model in between): The number of calls to the setFocus method of the parts:
I open a clean application and add the LogView. setFocus is called once. I add an editor, setFocus is called once. I select the LogView and setFocus is called twice. I again select the editor and setFocus is also called twice.


I shouldn't have put this in this thread since it is a different problem:

When I have two MParts in an MPartStack and the size of the MPartStack is large enough so that one can see both CTabItems displayed, then setFocus() of an MPart is called twice when I change the selection.

When the size of the MPartStack is so small that only one CTabItem is displayed together with the small button displaying ">>" and the number of "hidden" CTabItems as index, then when I change the selection through the ">>" button, setFocus is called only once.

When setFocus is called twice, this happens

  • Through StackRenderer.ActivateJob.run()
  • Through Composite.setFocus of the Composite created in ContributedPartRenderer.createWidget. It is called through the MouseListener added to the CTabFolder in hookControllerLogic.


Shall I file a bug report?

Edit: When setFocus is called only once, it happens through StackRenderer.ActivateJob.run().

[Updated on: Sun, 30 October 2011 22:45]

Report message to a moderator

Re: Bug(s) in model persistence and setFocus? [message #753950 is a reply to message #753937] Mon, 31 October 2011 06:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Yes
Am 30.10.11 22:03, schrieb Karl Weber:
> Karl Weber wrote on Sat, 29 October 2011 13:54
>> Third problem (may not be related, since I do not persist the model in
>> between): The number of calls to the setFocus method of the parts:
>> I open a clean application and add the LogView. setFocus is called
>> once. I add an editor, setFocus is called once. I select the LogView
>> and setFocus is called twice. I again select the editor and setFocus
>> is also called twice.
>
>
> I shouldn't have put this in this thread since it is a different problem:
>
> When I have two MParts in an MPartStack and the size of the MPartStack
> is large enough so that one can see both CTabItems displayed, then
> setFocus() of an MPart is called twice when I change the selection.
>
> When the size of the MPartStack is so small that only one CTabItem is
> displayed together with the small button displaying ">>" and the number
> of "hidden" CTabItems as index, then when I change the selection through
> the ">>" button, setFocus is called only once.
>
> When setFocus is called twice, this happens
>
> Through StackRenderer.ActivateJob.run()
> Through Composite.setFocus of the Composite created in
> ContributedPartRenderer.createWidget. It is called through the
> MouseListener added to the CTabFolder in hookControllerLogic.
>
>
> Shall I file a bug report?
>
>
Re: Bug(s) in model persistence and setFocus? [message #754211 is a reply to message #753848] Tue, 01 November 2011 12:42 Go to previous message
Karl Weber is currently offline Karl WeberFriend
Messages: 63
Registered: September 2010
Member
Bug report on setFocus
Previous Topic:WebDAV and SFS
Next Topic:minimize/maximize part
Goto Forum:
  


Current Time: Tue Apr 16 15:06:35 GMT 2024

Powered by FUDForum. Page generated in 0.05901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top