Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Disable Sapphire.Restore.Defaults on section
Disable Sapphire.Restore.Defaults on section [message #1239330] Tue, 04 February 2014 00:22 Go to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Is there a way to disable the Sapphire.Restore.Defaults action. Would it also remove the Clear action next to a property editor? In our use case, we got a list property, that should not be cleared.

I guess this is possible using a SapphireActionHandlerFilter, but they are only available on property editors, and not on the Section part e.g..

Defining the context explicitly is also not working, but shouldn't it?

<action-handler-filter>
	<impl>RestoreDefaultsActionFilter</impl>
	<context>Sapphire.Section</context>
	<context>Sapphire.ListPropertyEditor</context>
</action-handler-filter>


Filter Looks like this:
public boolean check(SapphireActionHandler handler) {
	return !(handler.getAction().getId().equals("Sapphire.Restore.Defaults"));
}


Thanks once more.
Re: Disable Sapphire.Restore.Defaults on section [message #1239356 is a reply to message #1239330] Tue, 04 February 2014 02:11 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
Is there a way to disable the Sapphire.Restore.Defaults action. [snip] I guess this is possible using a SapphireActionHandlerFilter, but they are only available on property editors, and not on the Section part e.g.


You can use action handler filters on section. I have fixed the missing action settings for sections issue in the sdef editor.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=427336

Quote:
Would it also remove the Clear action next to a property editor?


No, there is no means to remove content from the property editor assist popup. Rather than trying to suppress these actions, you can instead no-op when deleting the list entries that aren't supposed to be deleted within your custom list property binding.
Re: Disable Sapphire.Restore.Defaults on section [message #1239439 is a reply to message #1239356] Tue, 04 February 2014 07:59 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Noop done and working. Thanks.

For the community: First add
@CustomXmlListBinding(impl = CustomListBinding.class)
to your List property and then override:
org.eclipse.sapphire.modeling.xml.StandardXmlListBindingImpl.remove(Resource)
Re: Disable Sapphire.Restore.Defaults on section [message #1239484 is a reply to message #1239356] Tue, 04 February 2014 09:48 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
I have fixed the missing action settings for sections issue in the sdef editor.


There is one problem with ActionHandlers added on a section, see my comment here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=427336#c2
Re: Disable Sapphire.Restore.Defaults on section [message #1239491 is a reply to message #1239484] Tue, 04 February 2014 09:58 Go to previous message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Got the root element from the part.

The shell can be obtained using the org.eclipse.sapphire.ui.forms.swt.FormComponentPresentation.

So dunno if SectionPresentation is still required for other purposes.

protected Object run(final Presentation context) {
	final Element rootElement = context.part().getModelElement();

	final SapphireDialog dialog = new SapphireDialog(
			((org.eclipse.sapphire.ui.forms.swt.FormComponentPresentation) context).shell(), editElement,
			DefinitionLoader.context(RootModel.class).sdef("Model")
					.dialog("MyDialog"));
	dialog.open();

	switch (dialog.getReturnCode()) {
	case 0:
		// ok
		break;
	case 1:
		// cancel
		break;
	}

	return null;
}
Previous Topic:Apply read.only to cells at runtime
Next Topic:Button for Sapphire.Jump.Java.Type action handler
Goto Forum:
  


Current Time: Wed Apr 24 19:41:06 GMT 2024

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

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

Back to the top