|
Re: Sapphire for a "viewer" application: two questions [message #1041457 is a reply to message #1041239] |
Mon, 15 April 2013 06:01 |
Greg Amerson Messages: 119 Registered: March 2010 |
Senior Member |
|
|
With regards to 1), you can do this by using property inheritance. Simply create another modelElement that inherits from existing one. For the particular property you want to treat as read only, redefine the property but instead of putting a String for the propertyname, put a reference to the super-class'es property field. Then on this sub-class property mark it with @ReadOnly annotation.
Then in this new viewer, create a "snapshot" model using this new subclass model element that has the new @ReadOnly property instead of the normal element where this property is editable. The sapphire UI in this new viewer will show the field as readonly.
Example superclass element:
@GenerateImpl
public interface Node extends IModelElement
{
ModelElementType TYPE = new ModelElementType( Node.class );
// *** Name ***
@XmlBinding( path = "name" )
@Label( standard = "&name" )
@Required
ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" );
Value<String> getName();
void setName( String value );
}
Subclass element where you want to "override" the property editor behavior:
@GenerateImpl
public interface ReadOnlyNode extends Node
{
ModelElementType TYPE = new ModelElementType( ReadOnlyNode.class );
@ReadOnly
ValueProperty PROP_NAME = new ValueProperty( TYPE, Node.PROP_NAME );
}
[Updated on: Mon, 15 April 2013 06:03] Report message to a moderator
|
|
|
Re: Sapphire for a "viewer" application: two questions [message #1041843 is a reply to message #1041457] |
Mon, 15 April 2013 16:54 |
Konstantin Komissarchik Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
Quote:1) The output XML contains a "snapshot" of the input XML configuration file (for which I have a separate Sapphire model and editor). I want this original data to be viewable but not updateable. Can this be accomplished at the UI level, or is @ReadOnly the only way to set an element as, well, read-only?
In addition to the override pattern that Greg has described, you can also make a writable property read-only in UI by using "read.only" hint in sdef for the property editor. I haven't tried this exact scenario, but you should be able to make the value of the "read.only" hint a template variable in sdef that you can set in sdef's part include constructs.
Quote:2) I'd like to include a custom SWT component that is hover-sensitive and will control displays within another linked viewer. To include this component on a FormEditorPage, should it extend SapphirePart (such that it can be used in a <custom/> element)? I'm having difficulty finding examples of this.
To use <custom/> element in sdef, you would indeed need to implement SapphirePart. There isn't an example of this in samples, but existing implementation in sapphire.ui should be informative. Maybe start with a simple one like LabelPart.
PS: For ease of reading and responding, it is best to restrict one thread to one topic.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03686 seconds