Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » What class/interface do I need to extend/implement to create a custom Sapphire property editor?
What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1480617] Thu, 20 November 2014 10:23 Go to next message
Dmitri Pisarenko is currently offline Dmitri PisarenkoFriend
Messages: 24
Registered: September 2014
Junior Member
Hello!

I want to create a custom property editor for an integer field (text box plus slider).

What class do I need to extend (what interface should I implement) in order to do that (allow the user to enter property values both via the text field and using the slider) ?

Thanks in advance

Dmitri
Re: What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1481178 is a reply to message #1480617] Thu, 20 November 2014 20:43 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
To create a custom property editor for an integer property, you'd extend from ValuePropertyEditorPresentation. Note that the existing, ScalePropertyEditorPresentation may suit your requirements.

<property-editor>
  <property>MyInteger</property>
  <hint>
    <name>factory</name>
    <value>org.eclipse.sapphire.ui.forms.swt.internal.ScalePropertyEditorPresentation$Factory</value>
  </hint>
</property-editor>
Re: What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1481832 is a reply to message #1481178] Fri, 21 November 2014 09:00 Go to previous messageGo to next message
Dmitri Pisarenko is currently offline Dmitri PisarenkoFriend
Messages: 24
Registered: September 2014
Junior Member
Hello Konstantin!

Thanks for your answer.

I tried

    <property-editor>
        <scale-vertically>false</scale-vertically>
        <property>PropertyName</property>
        <show-label>true</show-label>
        <hint>
			<name>factory</name>
			<value>org.eclipse.sapphire.ui.forms.swt.internal.ScalePropertyEditorPresentation.Factory</value>
		</hint>
    </property-editor>


and

    <property-editor>
        <scale-vertically>false</scale-vertically>
        <property>PropertyName</property>
        <show-label>true</show-label>
        <hint>
			<name>factory</name>
			<value>org.eclipse.sapphire.ui.forms.swt.internal.ScalePropertyEditorPresentation$Factory</value>
		</hint>
    </property-editor>

but it doesn't work (I don't see the slider).

How can I fix it?

Thanks

Dmitri
Re: What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1486031 is a reply to message #1481832] Mon, 24 November 2014 19:19 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
It looks like recent refactoring has rendered this presentation inaccessible. I will open a bug to track fixing this. In the meantime, you can work-around this by copying the ScalePropertyEditorPresentation class.

Also, I forgot that the factory hint requires the use of the import package directive, so the usage would be something like this:

  <import>
    <package>some.package</package>
  </import>

    <property-editor>
        <scale-vertically>false</scale-vertically>
        <property>PropertyName</property>
        <show-label>true</show-label>
        <hint>
            <name>factory</name>
            <value>ScalePropertyEditorPresentation$Factory</value>
        </hint>
    </property-editor>
Re: What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1486187 is a reply to message #1486031] Mon, 24 November 2014 22:19 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
The following bug tracks the inability to access the scale presentation.

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

This is issue is now fixed. The fix will ship in the upcoming 8.1.1 release. Could you try a pre-release build to verify that you are able to access the scale presentation? Please use build 22 or newer and make a note in the bug with your findings.

https://hudson.eclipse.org/sapphire/job/8.1.x/22/

To use the scale presentation, please remove the factory hint and set Sapphire.PropertyEditor.Scale style.

<property-editor>
    <property>PropertyName</property>
    <style>Sapphire.PropertyEditor.Scale</style>
</property-editor>


The scale presentation will activate automatically if this style is specified for the property editor and the property is an integer property with a @NumericRange constraint, where min and max are both specified.
Re: What class/interface do I need to extend/implement to create a custom Sapphire property editor? [message #1487161 is a reply to message #1486187] Tue, 25 November 2014 16:15 Go to previous message
Dmitri Pisarenko is currently offline Dmitri PisarenkoFriend
Messages: 24
Registered: September 2014
Junior Member
Hello Konstantin!

Thanks for your efforts.

I've tried the new Sapphire, but got an error (see the bug report for details).

Best regards

Dmitri
Previous Topic:Can Sapphire be used with EMF models?
Next Topic:How to programmatically add elements to a Sapphire list?
Goto Forum:
  


Current Time: Wed Sep 19 18:16:20 GMT 2018

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

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

Back to the top