|
|
|
|
Re: How to create multiline messages in GMF? [message #633110 is a reply to message #632742] |
Fri, 15 October 2010 12:02 |
Elhamlaoui Mahmoud Messages: 268 Registered: March 2010 |
Senior Member |
|
|
Hi Milind,
you should try the solution bellow, its worked for me.
1-you have to go to your *.gmfgen model and navigate to the Property Sheet element. Create a new Custom Property Tab element and populate it this way:
Human Readable Label : Validation
Identifier: validation
Implementation Class : ModelDescriptionPropertySection
then you create a child Typed selection filter :
Generated types : abstractNavigatorItem
Typed in selection : .... *.Application
....digaram.edit.parts.ApplicationEditPart
the regenearte your diagram.
you should have in your diagram something like this :
Quote: |
<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" id="proptabs">
.........................
<propertyTab
category="visual"
id="property.tab.DiagramPropertySection"
label="%tab.diagram"/>
<propertyTab
category="domain"
id="property.tab.domain"
label="%tab.domain"/>
<propertyTab
category="extra"
id="property.tab.description"
label="%tab.description"/>
</propertyTabs>
</extension>
|
2- you edit the generated class ModelDescriptionPropertySection to be like this :
Quote: |
public class ModelDescriptionPropertySection extends AbstractBasicTextPropertySection
{
@Override
protected String getPropertyChangeCommandName() {
return "ApplicationDescriptionChangeCommand";
}
@Override
protected String getPropertyNameLabel() {
return "";
}
@Override
protected String getPropertyValueString() {
String description = ((Application) getEObject()).getName();
return description == null ? "" : description;
}
@Override
protected void setPropertyValue(EObject object, Object value) {
((Application) getEObject()).setName((String) value);
}
protected Text createTextWidget(Composite parent) {
Text text = getWidgetFactory().createText(parent, StringStatics.BLANK,
SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
data.height = 100;
data.width = 100;
text.setLayoutData(data);
if (isReadOnly()) {
text.setEditable(false);
}
return text;
}
@Override
protected EObject unwrap(Object object) {
if (object instanceof Application) {
return (EObject) object;
}
if (object instanceof EditPart) {
Object model = ((EditPart) object).getModel();
return model instanceof View ? ((View) model).getElement() : null;
}
if (object instanceof View) {
return ((View) object).getElement();
}
if (object instanceof IAdaptable) {
View view = (View) ((IAdaptable) object).getAdapter(View.class);
if (view != null) {
return view.getElement();
}
}
return null;
}
}
|
thats all, you should see than your multiline message of validation.
Good luck
Mahmoud
|
|
|
Powered by
FUDForum. Page generated in 0.03819 seconds