public class ElementFormPanel
extends java.lang.Object
IPanelProvider
implementation displaying a form for the selected model element.
Forms are build using an IFieldFactory
, and may be split into several pages. See FormFieldPage
.
AbstractFieldFactory
,
IFieldFactory.createFields(FormToolkit, Composite, ModelElement, FormFieldPage)
and IFieldFactory.createFieldPages(ModelElement)
ElementFormPanel(IModuleContext, IFieldFactory)
.
createPanel(Composite)
By default the model is updated immediately when a field is changed. Since Modelio Valkyrie 3.8 This behavior may be disabled with setAutoApply(boolean)
.
Panels listeners are always fired with the changed IField
as 'data' when a field value changes.
FormFieldPage
,
AbstractFieldFactory
Constructor and Description |
---|
ElementFormPanel(IModuleContext moduleContext,
IFieldFactory fieldFactory)
Build a new instance of
ElementFormPanel . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(IPanelListener l) |
void |
apply()
Save all fields to the model.
|
boolean |
canApply()
Tells whether
apply() may be called safely. |
protected void |
createFormFields(Composite parent,
ModelElement formInput)
Create a complete form for an element.
|
Composite |
createPanel(Composite parent) |
void |
dispose() |
protected void |
ensureFieldLayout(IField aField)
Ensure the
field has a GridData as layout data, creating one in the orher case. |
static <T> T |
getFirst(IStructuredSelection selection,
java.lang.Class<T> cls)
Deprecated.
Since 3.8 use
SelectionHelper#getFirst(org.eclipse.jface.viewers.ISelection, Class) |
java.lang.String |
getHelpTopic() |
java.lang.Object |
getInput() |
Composite |
getPanel() |
boolean |
isHeaderVisible() |
boolean |
isRelevantFor(java.lang.Object obj) |
protected void |
onModelChanged(IModelingSession session,
IModelChangeEvent event)
IModelChangeListener callback called on model change event. |
void |
removeListener(IPanelListener l) |
ElementFormPanel |
setAutoApply(boolean autoApply)
Set whether the field will apply their value when leaving it.
|
void |
setHeaderVisible(boolean headerVisible)
Display or hide the form header to display the edited element name or gain place.
|
void |
setInput(java.lang.Object input)
Set the panel input.
|
public ElementFormPanel(IModuleContext moduleContext, IFieldFactory fieldFactory)
ElementFormPanel
.
The fields will apply their value immediately on leaving.
moduleContext
- a module context to get modelio services and sessuin from.fieldFactory
- the factory to create form fields with.public void addListener(IPanelListener l)
public void apply()
To be used when setAutoApply(boolean)
was called with false.
May throw a runtime exception if one field has an invalid value.
public boolean canApply()
apply()
may be called safely.public final Composite createPanel(Composite parent)
public final void dispose()
@Deprecated public static <T> T getFirst(IStructuredSelection selection, java.lang.Class<T> cls)
SelectionHelper#getFirst(org.eclipse.jface.viewers.ISelection, Class)
T
- the required typeselection
- the selection objectcls
- the required type classpublic final java.lang.String getHelpTopic()
public final java.lang.Object getInput()
public final Composite getPanel()
public boolean isHeaderVisible()
public boolean isRelevantFor(java.lang.Object obj)
public void removeListener(IPanelListener l)
public ElementFormPanel setAutoApply(boolean autoApply)
If called with false apply()
must be called in order to apply the field values.
autoApply
- true to apply values immediately, false to manually apply them.public void setHeaderVisible(boolean headerVisible)
headerVisible
- whether the form header is displayed.public final void setInput(java.lang.Object input)
Supported inputs are:
ModelElement
Collection
containing one ModelElement
IStructuredSelection
containing one ModelElement
relevant
for the field provider the panel is emptied.
Since Modelio 3.8 passing any other input type will result in IllegalArgumentException
being thrown.
protected void createFormFields(Composite parent, ModelElement formInput)
parent
- a widget which will be the parent of the new field instance (cannot be null)formInput
- the element to build the form for.protected void ensureFieldLayout(IField aField)
field
has a GridData
as layout data, creating one in the orher case.aField
- a form fieldprotected void onModelChanged(IModelingSession session, IModelChangeEvent event)
IModelChangeListener
callback called on model change event.
Refresh and reset fields from the model. This method could be redefined by sub classes.
session
- the modeling sessionevent
- the event.