Commit e9282bbd authored by Adrien's avatar Adrien Committed by Romain Bioteau

feat(bdm) add description fields (#2068)

* attributes
* constraints
* query / query param
* indexes

[STUDIO-3360](https://bonitasoft.atlassian.net/browse/STUDIO-3360)
parent 7edce2d9
......@@ -307,4 +307,5 @@ addIndexTooltip=Add a new index
deleteIndexTooltip=Remove the selected index
searchIndex=Search index
dndIndexTooltip=Attributes can be indexed / deindexed using Drag and Drop.\nIndexed attributes can also be sorted using Drag and Drop.
pakage=Package
\ No newline at end of file
pakage=Package
fieldDescriptionPlaceholder=Attribute description
\ No newline at end of file
......@@ -28,6 +28,7 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Field" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="nullable" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
defaultValueLiteral="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="collection" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
......@@ -35,16 +36,19 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="UniqueConstraint">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="fieldNames" unique="false"
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Index">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="fieldNames" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Query">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="content" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="returnType" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="queryParameters" upperBound="-1"
......@@ -52,6 +56,7 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="QueryParameter">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="className" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SimpleField" eSuperTypes="#//Field">
......
......@@ -53,25 +53,30 @@
</genClasses>
<genClasses image="false" ecoreClass="BusinessDataModel.ecore#//Field">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Field/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Field/description"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Field/nullable"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Field/collection"/>
</genClasses>
<genClasses ecoreClass="BusinessDataModel.ecore#//UniqueConstraint">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//UniqueConstraint/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//UniqueConstraint/description"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//UniqueConstraint/fieldNames"/>
</genClasses>
<genClasses ecoreClass="BusinessDataModel.ecore#//Index">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Index/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Index/description"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Index/fieldNames"/>
</genClasses>
<genClasses ecoreClass="BusinessDataModel.ecore#//Query">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Query/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Query/description"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Query/content"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//Query/returnType"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference BusinessDataModel.ecore#//Query/queryParameters"/>
</genClasses>
<genClasses ecoreClass="BusinessDataModel.ecore#//QueryParameter">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//QueryParameter/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//QueryParameter/description"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute BusinessDataModel.ecore#//QueryParameter/className"/>
</genClasses>
<genClasses ecoreClass="BusinessDataModel.ecore#//SimpleField">
......
......@@ -69,6 +69,7 @@ public class DocumentationBusinessDataModelConverter {
return uniqueConstraints.stream()
.map(c -> UniqueConstraint.builder()
.name(c.getName())
.description(c.getDescription())
.attributes(c.getFieldNames().toArray(new String[] {}))
.build())
.toArray(UniqueConstraint[]::new);
......@@ -79,6 +80,7 @@ public class DocumentationBusinessDataModelConverter {
return indexes.stream()
.map(index -> Index.builder()
.name(index.getName())
.description(index.getDescription())
.attributes(index.getFieldNames().toArray(new String[] {}))
.build())
.toArray(Index[]::new);
......@@ -87,6 +89,7 @@ public class DocumentationBusinessDataModelConverter {
private Query[] convertQueries(List<org.bonitasoft.engine.bdm.model.Query> queries, BusinessObject object) {
return queries.stream()
.map(q -> Query.builder().name(q.getName())
.description(q.getDescription())
.returnType(convertToSimpleType(q.getReturnType(), object))
.sourceCode(q.getContent())
.parameters(convertQueryParameters(q, object))
......@@ -121,6 +124,7 @@ public class DocumentationBusinessDataModelConverter {
.map(SimpleField.class::cast)
.map(f -> Attribute.builder()
.name(f.getName())
.description(f.getDescription())
.type(f.getType().getClazz().getSimpleName())
.multiple(f.isCollection())
.mandatory(!f.isNullable())
......@@ -140,6 +144,7 @@ public class DocumentationBusinessDataModelConverter {
.map(RelationField.class::cast)
.map(f -> Relation.builder()
.name(f.getName())
.description(f.getDescription())
.type(f.getReference().getSimpleName())
.relationType(f.getType().toString())
.mandatory(!f.isNullable())
......
......@@ -207,6 +207,7 @@ public class BusinessDataModelConverter {
private RelationField convertRelationField(org.bonitasoft.engine.bdm.model.field.RelationField field) {
RelationField relationField = new RelationFieldBuilder()
.withName(field.getName())
.withDescription(field.getDescription())
.withNullable(field.isNullable())
.withCollection(field.isCollection())
.withReference(new BusinessObjectBuilder() // replaced with the real reference when all the business objects are created
......@@ -221,6 +222,7 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.field.RelationField convertRelationField(RelationField field) {
org.bonitasoft.engine.bdm.model.field.RelationField relationField = new org.bonitasoft.engine.bdm.model.field.RelationField();
relationField.setName(field.getName());
relationField.setDescription(field.getDescription());
relationField.setNullable(field.isNullable());
relationField.setCollection(field.isCollection());
org.bonitasoft.engine.bdm.model.BusinessObject tmpReference = new org.bonitasoft.engine.bdm.model.BusinessObject(
......@@ -259,6 +261,7 @@ public class BusinessDataModelConverter {
private SimpleField convertSimpleField(org.bonitasoft.engine.bdm.model.field.SimpleField field) {
SimpleField simpleField = new SimpleFieldBuilder()
.withName(field.getName())
.withDescription(field.getDescription())
.withLength(field.getLength())
.withCollection(field.isCollection())
.withNullable(field.isNullable())
......@@ -270,6 +273,7 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.field.SimpleField convertSimpleField(SimpleField field) {
org.bonitasoft.engine.bdm.model.field.SimpleField simpleField = new org.bonitasoft.engine.bdm.model.field.SimpleField();
simpleField.setName(field.getName());
simpleField.setDescription(field.getDescription());
simpleField.setLength(field.getLength());
simpleField.setCollection(field.isCollection());
simpleField.setNullable(field.isNullable());
......@@ -348,6 +352,7 @@ public class BusinessDataModelConverter {
private Index convertIndex(org.bonitasoft.engine.bdm.model.Index index) {
Index indx = new IndexBuilder()
.withName(index.getName())
.withDescription(index.getDescription())
.withFieldNames(index.getFieldNames().toArray(new String[0]))
.create();
return indx;
......@@ -356,6 +361,7 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.Index convertIndex(Index index) {
org.bonitasoft.engine.bdm.model.Index indx = new org.bonitasoft.engine.bdm.model.Index();
indx.setName(index.getName());
indx.setDescription(index.getDescription());
indx.setFieldNames(index.getFieldNames());
return indx;
}
......@@ -363,6 +369,7 @@ public class BusinessDataModelConverter {
private Query convertQuery(org.bonitasoft.engine.bdm.model.Query query) {
Query qury = new QueryBuilder()
.withName(query.getName())
.withDescription(query.getDescription())
.withContent(query.getContent())
.withReturnType(query.getReturnType())
.create();
......@@ -373,6 +380,7 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.Query convertQuery(Query query) {
org.bonitasoft.engine.bdm.model.Query qury = new org.bonitasoft.engine.bdm.model.Query(query.getName(),
query.getContent(), query.getReturnType());
qury.setDescription(query.getDescription());
query.getQueryParameters().stream().map(this::convertQueryParameter).forEach(qury.getQueryParameters()::add);
return qury;
}
......@@ -380,6 +388,7 @@ public class BusinessDataModelConverter {
private QueryParameter convertQueryParameter(org.bonitasoft.engine.bdm.model.QueryParameter queryParameter) {
QueryParameter quryParameter = new QueryParameterBuilder()
.withName(queryParameter.getName())
.withDescription(queryParameter.getDescription())
.withClassName(queryParameter.getClassName())
.create();
return quryParameter;
......@@ -388,12 +397,14 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.QueryParameter convertQueryParameter(QueryParameter queryParameter) {
org.bonitasoft.engine.bdm.model.QueryParameter quryParameter = new org.bonitasoft.engine.bdm.model.QueryParameter(
queryParameter.getName(), queryParameter.getClassName());
quryParameter.setDescription(queryParameter.getDescription());
return quryParameter;
}
private UniqueConstraint convertUniqueConstraint(org.bonitasoft.engine.bdm.model.UniqueConstraint uniqueConstraint) {
UniqueConstraint constraint = new UniqueConstraintBuilder()
.withName(uniqueConstraint.getName())
.withDescription(uniqueConstraint.getDescription())
.withFieldNames(uniqueConstraint.getFieldNames().toArray(new String[0]))
.create();
return constraint;
......@@ -402,6 +413,7 @@ public class BusinessDataModelConverter {
private org.bonitasoft.engine.bdm.model.UniqueConstraint convertUniqueConstraint(UniqueConstraint uniqueConstraint) {
org.bonitasoft.engine.bdm.model.UniqueConstraint constraint = new org.bonitasoft.engine.bdm.model.UniqueConstraint();
constraint.setName(uniqueConstraint.getName());
constraint.setDescription(uniqueConstraint.getDescription());
constraint.setFieldNames(uniqueConstraint.getFieldNames());
return constraint;
}
......
......@@ -14,6 +14,8 @@
*/
package org.bonitasoft.studio.businessobject.editor.editor.ui.control.attribute;
import java.util.Optional;
import org.bonitasoft.studio.businessobject.editor.editor.ui.formpage.model.BusinessDataModelFormPage;
import org.bonitasoft.studio.businessobject.editor.model.BusinessDataModelPackage;
import org.bonitasoft.studio.businessobject.editor.model.Field;
......@@ -25,6 +27,7 @@ import org.bonitasoft.studio.businessobject.ui.DateTypeLabels;
import org.bonitasoft.studio.common.widgets.CustomStackLayout;
import org.bonitasoft.studio.ui.databinding.UpdateStrategyFactory;
import org.bonitasoft.studio.ui.widget.ComboWidget;
import org.bonitasoft.studio.ui.widget.TextAreaWidget;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.conversion.NumberToStringConverter;
import org.eclipse.core.databinding.conversion.StringToNumberConverter;
......@@ -40,7 +43,9 @@ import org.eclipse.swt.widgets.Label;
public class FieldDetailsControl extends Composite {
private BusinessDataModelFormPage formPage;
private DataBindingContext ctx;
private IObservableValue<Field> selectedFieldObservable;
private IObservableValue<String> descriptionObservable;
private CustomStackLayout stackLayout;
private Composite stringFieldDetailsComposite;
private Composite dateDeprecatedComposite;
......@@ -55,7 +60,10 @@ public class FieldDetailsControl extends Composite {
IObservableValue<Field> selectedFieldObservable, DataBindingContext ctx) {
super(parent, SWT.None);
this.formPage = formPage;
this.ctx = ctx;
this.selectedFieldObservable = selectedFieldObservable;
this.descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedFieldObservable, BusinessDataModelPackage.Literals.FIELD__DESCRIPTION);
formPage.getToolkit().adapt(this);
stackLayout = new CustomStackLayout(this);
......@@ -108,45 +116,49 @@ public class FieldDetailsControl extends Composite {
}
private void createNoDetailsComposite() {
noDetailsComposite = createDescriptionComposite(Messages.noDetailsAvailable);
noDetailsComposite = createDescriptionComposite(Optional.empty());
}
private void createRelationFieldComposite(DataBindingContext ctx) {
relationFieldComposite = new RelationFieldDetailsControl(this, formPage, selectedFieldObservable, ctx);
relationFieldComposite = new RelationFieldDetailsControl(this, formPage, selectedFieldObservable,
descriptionObservable, ctx);
}
private void createTextFieldComposite() {
textFieldComposite = createDescriptionComposite(Messages.textDetails);
textFieldComposite = createDescriptionComposite(Optional.of(Messages.textDetails));
}
private void createDateTimeComposite() {
dateTimeComposite = createDescriptionComposite(String.format(Messages.dateTimeDetails,
DateTypeLabels.DATE_AND_TIME, DateTypeLabels.DATE_TIME_WITH_TIMEZONE));
dateTimeComposite = createDescriptionComposite(Optional.of(String.format(Messages.dateTimeDetails,
DateTypeLabels.DATE_AND_TIME, DateTypeLabels.DATE_TIME_WITH_TIMEZONE)));
}
private void createDateTimeInTimeZoneComposite() {
dateTimeInTimezoneComposite = createDescriptionComposite(
String.format(Messages.dateTimeInTimezoneDetails, DateTypeLabels.DATE_TIME_WITH_TIMEZONE));
Optional.of(String.format(Messages.dateTimeInTimezoneDetails, DateTypeLabels.DATE_TIME_WITH_TIMEZONE)));
}
private void createDateOnlyDetailsComposite() {
dateOnlyComposite = createDescriptionComposite(String.format(Messages.dateOnlyDetails, DateTypeLabels.DATE_ONLY));
dateOnlyComposite = createDescriptionComposite(
Optional.of(String.format(Messages.dateOnlyDetails, DateTypeLabels.DATE_ONLY)));
}
private void createStringFieldDetailsComposite(DataBindingContext ctx) {
stringFieldDetailsComposite = formPage.getToolkit().createComposite(this);
stringFieldDetailsComposite.setLayout(GridLayoutFactory.fillDefaults().margins(5, 0).create());
stringFieldDetailsComposite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
stringFieldDetailsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
IObservableValue<Integer> fieldLengthObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedFieldObservable, BusinessDataModelPackage.Literals.SIMPLE_FIELD__LENGTH);
createDescriptionTextArea(stringFieldDetailsComposite);
new ComboWidget.Builder()
.withLabel(Messages.length)
.withCompositeMessageDecorator()
.withItems(new String[] { "64", "128", "255", "512" })
.labelAbove()
.widthHint(400)
.widthHint(500)
.bindTo(fieldLengthObservable)
.withTargetToModelStrategy(UpdateStrategyFactory.updateValueStrategy()
.withConverter(StringToNumberConverter.toInteger(false))
......@@ -165,9 +177,11 @@ public class FieldDetailsControl extends Composite {
private void createDateDeprecatedDetailsComposite() {
dateDeprecatedComposite = formPage.getToolkit().createComposite(this);
dateDeprecatedComposite.setLayout(GridLayoutFactory.fillDefaults().margins(5, 0).create());
dateDeprecatedComposite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
dateDeprecatedComposite.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create());
createDescriptionTextArea(dateDeprecatedComposite);
Label descriptionLabel = formPage.getToolkit().createLabel(dateDeprecatedComposite, Messages.dateDetails);
descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().create());
......@@ -176,15 +190,31 @@ public class FieldDetailsControl extends Composite {
deprecatedDetailsLabel.setLayoutData(GridDataFactory.fillDefaults().create());
}
private Composite createDescriptionComposite(String description) {
private Composite createDescriptionComposite(Optional<String> description) {
Composite composite = formPage.getToolkit().createComposite(this);
composite.setLayout(GridLayoutFactory.fillDefaults().margins(5, 0).create());
composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
composite.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create());
Label descriptionLabel = formPage.getToolkit().createLabel(composite, description);
descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().create());
createDescriptionTextArea(composite);
description.ifPresent(desc -> {
Label descriptionLabel = formPage.getToolkit().createLabel(composite, desc);
descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().create());
});
return composite;
}
private void createDescriptionTextArea(Composite parent) {
new TextAreaWidget.Builder()
.withLabel(Messages.fieldDescriptionPlaceholder)
.labelAbove()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(parent);
}
}
......@@ -25,6 +25,7 @@ import org.bonitasoft.studio.businessobject.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.bonitasoft.studio.ui.viewer.LabelProviderBuilder;
import org.bonitasoft.studio.ui.widget.TextAreaWidget;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
......@@ -47,23 +48,39 @@ public class RelationFieldDetailsControl extends Composite {
private BusinessDataModelFormPage formPage;
private IObservableValue<Field> selectedFieldObservable;
private DataBindingContext ctx;
private IObservableValue<String> descriptionObservable;
public RelationFieldDetailsControl(Composite parent, BusinessDataModelFormPage formPage,
IObservableValue<Field> selectedFieldObservable, DataBindingContext ctx) {
IObservableValue<Field> selectedFieldObservable, IObservableValue<String> descriptionObservable,
DataBindingContext ctx) {
super(parent, SWT.None);
this.descriptionObservable = descriptionObservable;
setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
setLayout(GridLayoutFactory.fillDefaults().margins(5, 0).create());
setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
formPage.getToolkit().adapt(this);
this.formPage = formPage;
this.selectedFieldObservable = selectedFieldObservable;
this.ctx = ctx;
createDescriptionTextArea();
createRelationKindLabel();
createRelationKindCombo();
createLoadingModeRadioButtons();
}
private void createDescriptionTextArea() {
new TextAreaWidget.Builder()
.withLabel(Messages.fieldDescriptionPlaceholder)
.labelAbove()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(this);
}
private void createLoadingModeRadioButtons() {
Composite buttonsComposite = formPage.getToolkit().createComposite(this);
buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).spacing(20, 5).create());
......
......@@ -70,7 +70,6 @@ public class BusinessObjectEditionControl {
editionSection.setClient(client);
}
@SuppressWarnings("unchecked")
private void buildDescriptionSection(Composite parent, BusinessDataModelFormPage formPage, DataBindingContext ctx) {
IObservableValue<String> descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
boSelectedObservable, BusinessDataModelPackage.Literals.BUSINESS_OBJECT__DESCRIPTION);
......
......@@ -36,6 +36,7 @@ import org.bonitasoft.studio.ui.util.StringIncrementer;
import org.bonitasoft.studio.ui.viewer.EditingSupportBuilder;
import org.bonitasoft.studio.ui.viewer.LabelProviderBuilder;
import org.bonitasoft.studio.ui.widget.SearchWidget;
import org.bonitasoft.studio.ui.widget.TextAreaWidget;
import org.bonitasoft.studio.ui.widget.TextWidget;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.PojoProperties;
......@@ -104,7 +105,7 @@ public class ConstraintEditionControl {
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
createConstraintDefinitionSection();
createCronstraintEditionSection(ctx);
createConstraintEditionComposite(ctx);
enableButtons(ctx);
ctx.bindSet(ViewersObservables.observeCheckedElements(constraintEditionViewer, Field.class),
......@@ -153,8 +154,49 @@ public class ConstraintEditionControl {
() -> new RuntimeException(String.format("Unable to find a field with the name %s", fieldName)));
}
private void createCronstraintEditionSection(DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(mainComposite, Section.EXPANDED);
private void createConstraintEditionComposite(DataBindingContext ctx) {
Composite composite = formPage.getToolkit().createComposite(mainComposite);
composite.setLayout(GridLayoutFactory.fillDefaults().create());
composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
createConstraintDescriptionSection(composite, ctx);
createConstraintEditionSection(composite);
ctx.bindValue(WidgetProperties.visible().observe(composite), new ComputedValue<Boolean>() {
@Override
protected Boolean calculate() {
return selectedConstraintObservable.getValue() != null;
}
});
}
private void createConstraintDescriptionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.description);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
IObservableValue descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedConstraintObservable, BusinessDataModelPackage.Literals.UNIQUE_CONSTRAINT__DESCRIPTION);
new TextAreaWidget.Builder()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
section.setClient(client);
}
private void createConstraintEditionSection(Composite parent) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.attributes);
......@@ -173,13 +215,6 @@ public class ConstraintEditionControl {
createConstraintEditionViewer(client);
section.setClient(client);
ctx.bindValue(WidgetProperties.visible().observe(section), new ComputedValue<Boolean>() {
@Override
protected Boolean calculate() {
return selectedConstraintObservable.getValue() != null;
}
});
}
private void createConstraintEditionViewer(Composite parent) {
......
......@@ -38,6 +38,7 @@ import org.bonitasoft.studio.ui.util.StringIncrementer;
import org.bonitasoft.studio.ui.viewer.EditingSupportBuilder;
import org.bonitasoft.studio.ui.viewer.LabelProviderBuilder;
import org.bonitasoft.studio.ui.widget.SearchWidget;
import org.bonitasoft.studio.ui.widget.TextAreaWidget;
import org.bonitasoft.studio.ui.widget.TextWidget;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.PojoProperties;
......@@ -104,7 +105,7 @@ public class IndexControl {
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
createIndexDefinitionSection(ctx);
createIndexEditionSection(ctx);
createIndexEditionComposite(ctx);
enableButtons(ctx);
EMFObservables.observeDetailList(Realm.getDefault(), selectedIndexObservable,
......@@ -190,17 +191,15 @@ public class IndexControl {
deleteIndexItem.addListener(SWT.Selection, e -> removeIndex());
}
private void createIndexEditionSection(DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(mainComposite, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.attributes);
private void createIndexEditionComposite(DataBindingContext ctx) {
Composite composite = formPage.getToolkit().createComposite(mainComposite);
composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
composite.setLayout(GridLayoutFactory.fillDefaults().create());
indexEditionControl = new IndexEditionControl(section, formPage, ctx, selectedIndexObservable,
actualsFieldsObservable);
createIndexDescriptionSection(composite, ctx);
createIndexEditionSection(composite, ctx);
section.setClient(indexEditionControl);
ctx.bindValue(WidgetProperties.visible().observe(section), new ComputedValue<Boolean>() {
ctx.bindValue(WidgetProperties.visible().observe(composite), new ComputedValue<Boolean>() {
@Override
protected Boolean calculate() {
......@@ -209,6 +208,42 @@ public class IndexControl {
});
}
private void createIndexDescriptionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.description);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
IObservableValue descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedIndexObservable, BusinessDataModelPackage.Literals.INDEX__DESCRIPTION);
new TextAreaWidget.Builder()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
section.setClient(client);
}
private void createIndexEditionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.attributes);
indexEditionControl = new IndexEditionControl(section, formPage, ctx, selectedIndexObservable,
actualsFieldsObservable);
section.setClient(indexEditionControl);
}
private void createIndexViewer(Composite parent) {
indexViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
indexViewer.getTable()
......
......@@ -95,7 +95,13 @@ public class QueryEditionControl {
this.ctx = ctx;
this.queryContentCreator = new QueryContentCreator();
createSection(parent);
Composite queryEditionComposite = formPage.getToolkit().createComposite(parent);