Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [GEF5] AbstractVisualPart activate while addChild
[GEF5] AbstractVisualPart activate while addChild [message #1775104] Tue, 24 October 2017 15:05 Go to next message
Maxim Martynov is currently offline Maxim MartynovFriend
Messages: 22
Registered: February 2017
Junior Member
Hi.
Why activate child part invoke after child refreshVisual?
Now i'm add code to init field which depends on getContent().
i'm using this field in refreshVisual, but it's null because doActivate() not invoke.

	@Override
	public void addChild(IVisualPart<? extends Node> child, int index) {
		if (children.contains(child)) {
			throw new IllegalArgumentException("Cannot add " + child
					+ " as child of " + this + " because its already a child.");
		}

		// System.out.println(
		// "Add child " + child + " to " + this + " with index " + index);

		children.add(index, child);
		child.setParent(this);

		refreshVisual();
		doAddChildVisual(child, index);
		child.refreshVisual();

		if (isActive()) {
			child.activate();
		}
	}


Is it bug or special?
If it not a bug, where i can init my field which depends on getContent()? Thanks.
Re: [GEF5] AbstractVisualPart activate while addChild [message #1775359 is a reply to message #1775104] Sat, 28 October 2017 11:08 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
I am not exactly sure what you are referring to here. Let me try to clarify things a bit. Only when being active, VisualParts may register listeners (ContentParts most likely listen for changes of their model) and react to changes that have been notified. As such, the activation and deactivation hooks are the places to register/unregister any listeners that trigger active reactions within your VisualPart. Within ContentParts, the refreshVisual() method is the correct place to update the visuals from the content (or more accurately the doRefreshVisuals() hook method that is called from it). The child should already have a content when being added to its parent (this is done by the ContentBehavior, so its valid to all refreshVisuals() before activating the child. Having said so, activate() is not the place to perform a one-time initialization. You might do such kind of things within the context of setContent() or lazily within refreshVisuals() instead.

[Updated on: Sat, 28 October 2017 11:09]

Report message to a moderator

Re: [GEF5] AbstractVisualPart activate while addChild [message #1775522 is a reply to message #1775359] Tue, 31 October 2017 11:19 Go to previous messageGo to next message
Maxim Martynov is currently offline Maxim MartynovFriend
Messages: 22
Registered: February 2017
Junior Member
Ok, thanks for your reply.

[Updated on: Tue, 31 October 2017 11:22]

Report message to a moderator

Re: [GEF5] AbstractVisualPart activate while addChild [message #1775523 is a reply to message #1775359] Tue, 31 October 2017 11:19 Go to previous message
Maxim Martynov is currently offline Maxim MartynovFriend
Messages: 22
Registered: February 2017
Junior Member
No Message Body
Previous Topic:doAddContentChild IllegalStateException
Next Topic:Apply changes to all the figures
Goto Forum:
  


Current Time: Sat Apr 20 03:46:59 GMT 2024

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

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

Back to the top