Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Problem with e4 save parts dialog
Problem with e4 save parts dialog [message #903562] Fri, 24 August 2012 06:57 Go to next message
Eclipse UserFriend
Another problem I am having with the e4 "Select the parts to save"-dialog is this:

* mark a part as dirty
* close the part
* dialog appears (Select the parts to save)
* uncheck the item (thereby NOT saving the part)
* part disappears as expected

But then when I attempt to close the Window the same dialog appears again, asking me again if I want to save the (long gone) part. Apparently it is still lurking around somewhere, probably also causing a memory leak.

What's the right way to handle this properly?
Re: Problem with e4 save parts dialog [message #903565 is a reply to message #903562] Fri, 24 August 2012 07:07 Go to previous messageGo to next message
Eclipse UserFriend
If you want parts to get removed when closed you need to tell the system
to do so by adding a tag with the value of
EPartService.REMOVE_ON_HIDE_TAG else all the system does is to set the
toBeRenderer flag to false.

Tom

Am 24.08.12 12:57, schrieb Markus Wiederkehr:
> Another problem I am having with the e4 "Select the parts to
> save"-dialog is this:
>
> * mark a part as dirty
> * close the part
> * dialog appears (Select the parts to save)
> * uncheck the item (thereby NOT saving the part)
> * part disappears as expected
>
> But then when I attempt to close the Window the same dialog appears
> again, asking me again if I want to save the (long gone) part.
> Apparently it is still lurking around somewhere, probably also causing a
> memory leak.
>
> What's the right way to handle this properly?
Re: Problem with e4 save parts dialog [message #903582 is a reply to message #903565] Fri, 24 August 2012 08:19 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Tom, but what's interesting is that apparently the toBeRendered flag does get set to false without that tag.

I have this listener and it gets notified whenever I close one of my editor parts:

private final EventHandler closePartEventHandler = new EventHandler() {
	@Override
	public void handleEvent(Event event) {
		Object part = event.getProperty(UIEvents.EventTags.ELEMENT);
		boolean toBeRendered = (Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
		if (!toBeRendered && part instanceof MPart && profileEditors.containsValue(part)) {
			profileEditors.values().remove(part);
		}
	}
};

@PostConstruct
private void subscribe(IEventBroker eventBroker) {
	eventBroker.subscribe(UIElement.TOPIC_TOBERENDERED, closePartEventHandler);
}

@PreDestroy
private void unsubscribe(IEventBroker eventBroker) {
	eventBroker.unsubscribe(closePartEventHandler);
}
Re: Problem with e4 save parts dialog [message #903591 is a reply to message #903582] Fri, 24 August 2012 08:50 Go to previous messageGo to next message
Eclipse UserFriend
Well that's what I said though I probably left an important part.

The only thing that happens if you are not setting this flag is that the
MPart's toBeRendered is set to false but the MPart IS NOT removed from
the MPartStack/MPartSash!

So when I said "removed" I meant removed from the MElementContainer and
not the UI which are 2 different things. The reason for this is mainly
because Views should be shown at the same position they've been hidden.

Tom

Am 24.08.12 14:19, schrieb Markus Wiederkehr:
> Thanks Tom, but what's interesting is that apparently the toBeRendered
> flag does get set to false without that tag.
>
> I have this listener and it gets notified whenever I close one of my
> editor parts:
>
>
> private final EventHandler closePartEventHandler = new EventHandler() {
> @Override
> public void handleEvent(Event event) {
> Object part = event.getProperty(UIEvents.EventTags.ELEMENT);
> boolean toBeRendered = (Boolean)
> event.getProperty(UIEvents.EventTags.NEW_VALUE);
> if (!toBeRendered && part instanceof MPart &&
> profileEditors.containsValue(part)) {
> profileEditors.values().remove(part);
> }
> }
> };
>
> @PostConstruct
> private void subscribe(IEventBroker eventBroker) {
> eventBroker.subscribe(UIElement.TOPIC_TOBERENDERED,
> closePartEventHandler);
> }
>
> @PreDestroy
> private void unsubscribe(IEventBroker eventBroker) {
> eventBroker.unsubscribe(closePartEventHandler);
> }
>
Re: Problem with e4 save parts dialog [message #903603 is a reply to message #903591] Fri, 24 August 2012 09:39 Go to previous message
Eclipse UserFriend
I think I may have read over the "else" in your first response. Everything is clear now, thanks a lot!
Previous Topic:Modal and closeable MWindow
Next Topic:ui-independent TextEditor
Goto Forum:
  


Current Time: Sat Jul 05 07:03:46 EDT 2025

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

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

Back to the top