Commit 8ab1194b authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

fix(bdm) fix ui glitch in bdm wizard (#249)

use asynchrnous refresh

closes [BS-16076](https://bonitasoft.atlassian.net/browse/BS-16076)
parent 89a069fd
......@@ -113,7 +113,8 @@ public class BusinessDataModelWizardPage extends WizardPage {
final DataBindingContext ctx = new DataBindingContext();
final Composite mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(10, 10, 10, 0).spacing(1, 5).create());
mainComposite.setLayout(
GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(10, 10, 10, 0).spacing(1, 5).create());
final IViewerObservableValue viewerObservableValue = createListOfBusinessObjects(mainComposite, ctx);
createSeparator(mainComposite);
......@@ -130,12 +131,14 @@ public class BusinessDataModelWizardPage extends WizardPage {
protected void createHelpControl(final Composite mainComposite) {
helpLabel = new Label(mainComposite, SWT.WRAP);
helpLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(400, SWT.DEFAULT).span(3, 1).indent(0, 10).create());
helpLabel.setLayoutData(
GridDataFactory.fillDefaults().grab(true, false).hint(400, SWT.DEFAULT).span(3, 1).indent(0, 10).create());
helpLabel.setVisible(false);
helpLabel.setText(Messages.howToUseBusinessObjectsContent);
}
protected void createBusinessObjectDescription(final Composite mainComposite, final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue) {
protected void createBusinessObjectDescription(final Composite mainComposite, final DataBindingContext ctx,
final IViewerObservableValue viewerObservableValue) {
businessObjectDescriptionGroup = new Group(mainComposite, SWT.NONE);
businessObjectDescriptionGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(1, 2).create());
businessObjectDescriptionGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create());
......@@ -146,7 +149,8 @@ public class BusinessDataModelWizardPage extends WizardPage {
public void handleValueChange(final ValueChangeEvent event) {
final Object newValue = event.diff.getNewValue();
if (newValue != null) {
businessObjectDescriptionGroup.setText(NamingUtils.getSimpleName(((BusinessObject) newValue).getQualifiedName()));
businessObjectDescriptionGroup
.setText(NamingUtils.getSimpleName(((BusinessObject) newValue).getQualifiedName()));
} else {
businessObjectDescriptionGroup.setText(Messages.selectABusinessObjectToEdit);
}
......@@ -164,48 +168,59 @@ public class BusinessDataModelWizardPage extends WizardPage {
createIndexesTabItem(ctx, viewerObservableValue, tabFolder);
}
protected void createQueriesTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final TabFolder tabFolder) {
protected void createQueriesTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final TabFolder tabFolder) {
final TabItem queriesItem = new TabItem(tabFolder, SWT.BORDER);
queriesItem.setText(Messages.queries);
queriesItem.setControl(new QueriesTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList));
}
protected void createAttributeTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final TabFolder tabFolder) {
protected void createAttributeTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final TabFolder tabFolder) {
final TabItem attributeItem = new TabItem(tabFolder, SWT.BORDER);
attributeItem.setText(Messages.attributes);
attributeItem.setControl(new AttributesTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
attributeItem.setControl(
new AttributesTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
}
protected void createConstraintsTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final TabFolder tabFolder) {
protected void createConstraintsTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final TabFolder tabFolder) {
final TabItem constraintsTabItem = new TabItem(tabFolder, SWT.BORDER);
constraintsTabItem.setText(Messages.constraints);
constraintsTabItem.setControl(new UniqueConstraintTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
constraintsTabItem.setControl(
new UniqueConstraintTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
}
protected void createIndexesTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final TabFolder tabFolder) {
protected void createIndexesTabItem(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final TabFolder tabFolder) {
final TabItem indexTabItem = new TabItem(tabFolder, SWT.BORDER);
indexTabItem.setText(Messages.indexes);
indexTabItem.setControl(new IndexesTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
indexTabItem.setControl(
new IndexesTabItemControl(tabFolder, ctx, viewerObservableValue, fieldsList, businessObjectModel));
}
protected Button createDeleteButton(final Composite buttonsComposite) {
final Button deleteButton = new Button(buttonsComposite, SWT.FLAT);
deleteButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
deleteButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
.minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
deleteButton.setText(Messages.delete);
deleteButton.setEnabled(false);
return deleteButton;
}
protected Button createAddButton(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final Composite buttonsComposite) {
protected Button createAddButton(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final Composite buttonsComposite) {
final Button addButton = new Button(buttonsComposite, SWT.FLAT);
addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
.minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
addButton.setText(Messages.add);
addButton.setEnabled(false);
return addButton;
}
protected void createDescription(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue, final Group descriptionGroup) {
protected void createDescription(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
final Group descriptionGroup) {
final Label descriptionLabel = new Label(descriptionGroup, SWT.NONE);
descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).create());
descriptionLabel.setText(Messages.description);
......@@ -214,7 +229,8 @@ public class BusinessDataModelWizardPage extends WizardPage {
descriptionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 50).create());
descriptionText.setEnabled(viewerObservableValue.getValue() != null);
final IObservableValue observeDetailValue = PojoObservables.observeDetailValue(viewerObservableValue, "description", String.class);
final IObservableValue observeDetailValue = PojoObservables.observeDetailValue(viewerObservableValue, "description",
String.class);
ctx.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify), observeDetailValue);
final UpdateValueStrategy enableStrategy = new UpdateValueStrategy();
......@@ -231,10 +247,12 @@ public class BusinessDataModelWizardPage extends WizardPage {
protected void createSeparator(final Composite mainComposite) {
final Label separator = new Label(mainComposite, SWT.NONE);
separator.setImage(Pics.getImage("arrow.png", BusinessObjectPlugin.getDefault()));
separator.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).span(1, 2).create());
separator.setLayoutData(
GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).span(1, 2).create());
}
protected IViewerObservableValue createListOfBusinessObjects(final Composite mainComposite, final DataBindingContext ctx) {
protected IViewerObservableValue createListOfBusinessObjects(final Composite mainComposite,
final DataBindingContext ctx) {
final Group group = new Group(mainComposite, SWT.NONE);
group.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).spacing(5, 0).create());
......@@ -245,16 +263,19 @@ public class BusinessDataModelWizardPage extends WizardPage {
buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create());
final Button addButton = new Button(buttonsComposite, SWT.FLAT);
addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
.minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
addButton.setText(Messages.add);
final Button deleteButton = new Button(buttonsComposite, SWT.FLAT);
deleteButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
deleteButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
.minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
deleteButton.setText(Messages.delete);
deleteButton.setEnabled(false);
final TableViewer boTableViewer = new TableViewer(group, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
boTableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, SWT.DEFAULT).create());
boTableViewer.getControl()
.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, SWT.DEFAULT).create());
boTableViewer.getTable().setLinesVisible(true);
boTableViewer.getTable().setHeaderVisible(true);
final TableLayout tableLayout = new TableLayout();
......@@ -279,8 +300,9 @@ public class BusinessDataModelWizardPage extends WizardPage {
public void afterEditorDeactivated(final ColumnViewerEditorDeactivationEvent event) {
final ISelection selection = boTableViewer.getSelection();
if (selection != null && ((IStructuredSelection) selection).getFirstElement() != null) {
businessObjectDescriptionGroup.setText(NamingUtils.getSimpleName(((BusinessObject) ((IStructuredSelection) selection).getFirstElement())
.getQualifiedName()));
businessObjectDescriptionGroup.setText(
NamingUtils.getSimpleName(((BusinessObject) ((IStructuredSelection) selection).getFirstElement())
.getQualifiedName()));
boTableViewer.refresh();
} else {
businessObjectDescriptionGroup.setText(Messages.selectABusinessObjectToEdit);
......@@ -305,10 +327,12 @@ public class BusinessDataModelWizardPage extends WizardPage {
}
});
ctx.bindValue(SWTObservables.observeEnabled(deleteButton), observeSingleSelection, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
ctx.bindValue(SWTObservables.observeEnabled(deleteButton), observeSingleSelection,
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
enableStrategy);
final IObservableList businessObjectObserveList = PojoObservables.observeList(businessObjectModel, "businessObjects");
final IObservableList businessObjectObserveList = PojoObservables.observeList(businessObjectModel,
"businessObjects");
boTableViewer.setInput(businessObjectObserveList);
addButton.addSelectionListener(new SelectionAdapter() {
......@@ -388,7 +412,8 @@ public class BusinessDataModelWizardPage extends WizardPage {
if (businessObjectModel.getBusinessObjects().isEmpty()) {
packageNameObserveText.setValue(DEFAULT_PACKAGE_NAME);
} else {
packageNameObserveText.setValue(NamingUtils.getPackageName(businessObjectModel.getBusinessObjects().get(0).getQualifiedName()));
packageNameObserveText.setValue(
NamingUtils.getPackageName(businessObjectModel.getBusinessObjects().get(0).getQualifiedName()));
}
}
......@@ -396,7 +421,14 @@ public class BusinessDataModelWizardPage extends WizardPage {
final BusinessObject businessObject = new BusinessObject();
businessObject.setQualifiedName(generateObjectName());
businessObjectsObserveList.add(businessObject);
boTableViewer.editElement(businessObject, 0);
boTableViewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
boTableViewer.editElement(businessObject, 0);
}
});
}
protected IStatus validatePackageName(final Object value) {
......@@ -434,7 +466,8 @@ public class BusinessDataModelWizardPage extends WizardPage {
}
}
protected void createBusinessObjectNameColumn(final DataBindingContext ctx, final IViewerObservableValue businessObjectSingleSelection,
protected void createBusinessObjectNameColumn(final DataBindingContext ctx,
final IViewerObservableValue businessObjectSingleSelection,
final TableViewer boTableViewer) {
final TableViewerColumn columnViewer = new TableViewerColumn(boTableViewer, SWT.FILL);
final TableColumn column = columnViewer.getColumn();
......@@ -453,8 +486,10 @@ public class BusinessDataModelWizardPage extends WizardPage {
return super.getText(element);
}
});
columnViewer.setEditingSupport(new BusinessObjectNameEditingSupport(businessObjectModel, businessObjectSingleSelection, PojoObservables.observeValue(
this, "packageName"), columnViewer.getViewer(), ctx));
columnViewer.setEditingSupport(new BusinessObjectNameEditingSupport(businessObjectModel,
businessObjectSingleSelection, PojoObservables.observeValue(
this, "packageName"),
columnViewer.getViewer(), ctx));
final TableColumnSorter sorter = new TableColumnSorter(boTableViewer);
sorter.setColumn(column);
......
......@@ -95,7 +95,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
private final BusinessObjectModel businessObjectModel;
public AttributesTabItemControl(final TabFolder parent, final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue,
public AttributesTabItemControl(final TabFolder parent, final DataBindingContext ctx,
final IViewerObservableValue viewerObservableValue,
final IObservableList fieldsList,
final BusinessObjectModel businessObjectModel) {
super(parent, SWT.NONE);
......@@ -112,15 +113,18 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
createAttributeDetailControl(ctx, attributeSelectionObservable, viewerObservableValue);
}
private void createAttributeDetailControl(final DataBindingContext ctx, final IViewerObservableValue attributeSelectionObservable,
private void createAttributeDetailControl(final DataBindingContext ctx,
final IViewerObservableValue attributeSelectionObservable,
final IViewerObservableValue viewerObservableValue) {
final Group detailGroup = new Group(this, SWT.NONE);
detailGroup.setText(Messages.details);
detailGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 80).indent(0, 10).span(2, 1).create());
detailGroup.setLayoutData(
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 80).indent(0, 10).span(2, 1).create());
final StackLayout stackLayout = new StackLayout();
detailGroup.setLayout(stackLayout);
final Composite relationFieldContent = createRelationFieldDetailContent(detailGroup, ctx, attributeSelectionObservable, viewerObservableValue);
final Composite relationFieldContent = createRelationFieldDetailContent(detailGroup, ctx,
attributeSelectionObservable, viewerObservableValue);
final Composite stringFieldContent = createStringFieldDetailContent(detailGroup, ctx, attributeSelectionObservable);
final Composite emptyContent = createNoDetailsContent(detailGroup);
stackLayout.topControl = emptyContent;
......@@ -188,7 +192,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
public IStatus validate(final Object value) {
if (value == null || value.toString().isEmpty()) {
final Object selectedField = attributeSelectionObservable.getValue();
if (selectedField instanceof SimpleField && ((SimpleField) selectedField).getType() == FieldType.STRING) {
if (selectedField instanceof SimpleField
&& ((SimpleField) selectedField).getType() == FieldType.STRING) {
return ValidationStatus.error(Messages.lengthCannotBeEmpty);
}
}
......@@ -272,7 +277,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
public void handleValueChange(final ValueChangeEvent event) {
final BusinessObject bo = (BusinessObject) event.diff.getNewValue();
if (bo != null) {
eagerDecorator.setDescriptionText(Messages.bind(Messages.alwaysLoadHint, NamingUtils.getSimpleName(bo.getQualifiedName())));
eagerDecorator.setDescriptionText(
Messages.bind(Messages.alwaysLoadHint, NamingUtils.getSimpleName(bo.getQualifiedName())));
}
}
});
......@@ -286,7 +292,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
return composite;
}
private IViewerObservableValue createAttributeTableControl(final DataBindingContext ctx, final IViewerObservableValue viewerObservableValue) {
private IViewerObservableValue createAttributeTableControl(final DataBindingContext ctx,
final IViewerObservableValue viewerObservableValue) {
final Composite buttonsComposite = new Composite(this, SWT.NONE);
buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).indent(0, 20).create());
buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create());
......@@ -307,16 +314,20 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
final Button downButton = createDownButton(viewerObservableValue, buttonsComposite);
final Button deleteButton = createDeleteButton(buttonsComposite);
final TableViewer featuresTableViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
featuresTableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, 200).create());
final TableViewer featuresTableViewer = new TableViewer(this,
SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
featuresTableViewer.getControl()
.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, 200).create());
featuresTableViewer.getTable().setEnabled(viewerObservableValue.getValue() != null);
featuresTableViewer.getTable().setLinesVisible(true);
featuresTableViewer.getTable().setHeaderVisible(true);
featuresTableViewer.setContentProvider(new ObservableListContentProvider());
ColumnViewerToolTipSupport.enableFor(featuresTableViewer);
ctx.bindValue(SWTObservables.observeEnabled(featuresTableViewer.getTable()), viewerObservableValue, null, enableStrategy);
final IViewerObservableValue observeAttributeSelection = ViewersObservables.observeSingleSelection(featuresTableViewer);
ctx.bindValue(SWTObservables.observeEnabled(featuresTableViewer.getTable()), viewerObservableValue, null,
enableStrategy);
final IViewerObservableValue observeAttributeSelection = ViewersObservables
.observeSingleSelection(featuresTableViewer);
final TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(4));
......@@ -457,7 +468,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
return observeAttributeSelection;
}
protected void createFieldNameColumn(final DataBindingContext ctx, final TableViewer featuresTableViewer, final IViewerObservableValue viewerObservableValue) {
protected void createFieldNameColumn(final DataBindingContext ctx, final TableViewer featuresTableViewer,
final IViewerObservableValue viewerObservableValue) {
final TableViewerColumn nameColumnViewer = new TableViewerColumn(featuresTableViewer, SWT.FILL);
final TableColumn column = nameColumnViewer.getColumn();
column.setText(Messages.name);
......@@ -475,7 +487,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
return super.getText(element);
}
});
nameColumnViewer.setEditingSupport(new FieldNameEditingSupport(viewerObservableValue, nameColumnViewer.getViewer(), ctx));
nameColumnViewer
.setEditingSupport(new FieldNameEditingSupport(viewerObservableValue, nameColumnViewer.getViewer(), ctx));
}
protected void createFieldTypeColumn(final DataBindingContext ctx, final TableViewer featuresTableViewer,
......@@ -484,8 +497,9 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
final TableColumn column = typeColumnViewer.getColumn();
column.setText(Messages.type);
typeColumnViewer.setLabelProvider(new FieldTypeLabelProvider());
typeColumnViewer.setEditingSupport(new FieldTypeEditingSupport(typeColumnViewer.getViewer(), businessObjectModel, fieldsList,
fieldSingSelectionObervableValue));
typeColumnViewer
.setEditingSupport(new FieldTypeEditingSupport(typeColumnViewer.getViewer(), businessObjectModel, fieldsList,
fieldSingSelectionObervableValue));
}
protected void createMandatoryColumn(final TableViewer featuresTableViewer) {
......@@ -515,7 +529,14 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
fieldsList.add(field);
observeAttributeSelection.setValue(field);
featuresTableViewer.editElement(field, 0);
featuresTableViewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
featuresTableViewer.editElement(field, 0);
}
});
}
protected void deleteField(final TableViewer featuresTableViewer, final IObservableValue viewerObservableValue) {
......@@ -523,7 +544,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
fieldsList.removeAll(selection.toList());
}
protected void moveUp(final IObservableValue observeFieldsDetailValue, final IViewerObservableValue observeSingleSelection) {
protected void moveUp(final IObservableValue observeFieldsDetailValue,
final IViewerObservableValue observeSingleSelection) {
final Field selectedFeature = (Field) observeSingleSelection.getValue();
final List<Field> eList = getFieldList(observeFieldsDetailValue);
final int indexOf = eList.indexOf(selectedFeature);
......@@ -537,7 +559,8 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
return (List<Field>) PojoObservables.observeDetailValue(viewerObservableValue, "fields", null).getValue();
}
protected void moveDown(final IObservableValue observeFieldsDetailValue, final IViewerObservableValue observeSingleSelection) {
protected void moveDown(final IObservableValue observeFieldsDetailValue,
final IViewerObservableValue observeSingleSelection) {
final Field selectedFeature = (Field) observeSingleSelection.getValue();
final List<Field> eList = getFieldList(observeFieldsDetailValue);
final int indexOf = eList.indexOf(selectedFeature);
......
......@@ -52,7 +52,8 @@ public class FieldTypeEditingSupport extends EditingSupport {
private final IObservableValue selectedFieldObservableValue;
public FieldTypeEditingSupport(final ColumnViewer viewer, final BusinessObjectModel bom, final IObservableList fieldsList,
public FieldTypeEditingSupport(final ColumnViewer viewer, final BusinessObjectModel bom,
final IObservableList fieldsList,
final IObservableValue selectedFieldObservableValue) {
super(viewer);
this.bom = bom;
......@@ -62,7 +63,8 @@ public class FieldTypeEditingSupport extends EditingSupport {
@Override
protected CellEditor getCellEditor(final Object element) {
final ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl(), SWT.READ_ONLY);
final ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl(),
SWT.READ_ONLY);
cellEditor.setContentProvider(ArrayContentProvider.getInstance());
final FieldTypeLabelProvider labelProvider = new FieldTypeLabelProvider();
cellEditor.setLabelProvider(labelProvider);
......@@ -79,8 +81,9 @@ public class FieldTypeEditingSupport extends EditingSupport {
return labelProvider.getText(o1).compareTo(labelProvider.getText(o2));
}
}).immutableSortedCopy(newArrayList(FieldType.STRING, FieldType.TEXT, FieldType.BOOLEAN, FieldType.INTEGER, FieldType.LONG,
FieldType.FLOAT, FieldType.DOUBLE, FieldType.DATE));
}).immutableSortedCopy(
newArrayList(FieldType.STRING, FieldType.TEXT, FieldType.BOOLEAN, FieldType.INTEGER, FieldType.LONG,
FieldType.FLOAT, FieldType.DOUBLE, FieldType.DATE));
result.addAll(sortedFieldTypes);
result.addAll(bom.getBusinessObjects());
......@@ -120,7 +123,13 @@ public class FieldTypeEditingSupport extends EditingSupport {
updateToSimpleField((RelationField) element, (FieldType) value);
}
}
getViewer().refresh();
getViewer().getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
getViewer().update(element, null);
}
});
}
@SuppressWarnings("unchecked")
......
......@@ -5,12 +5,10 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
......@@ -39,7 +37,6 @@ import org.eclipse.swt.widgets.Control;
/**
* @author Romain Bioteau
*
*/
public class IndexFieldsEditingSupport extends EditingSupport {
......@@ -126,7 +123,7 @@ public class IndexFieldsEditingSupport extends EditingSupport {
* @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
*/
@Override
protected void setValue(Object element, Object value) {
protected void setValue(final Object element, Object value) {
if (value == null) {
return;
}
......@@ -148,7 +145,13 @@ public class IndexFieldsEditingSupport extends EditingSupport {
}
}
((Index) element).setFieldNames(fieldNames);
getViewer().update(element, null);
getViewer().getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
getViewer().update(element, null);
}
});
}
......
......@@ -59,7 +59,8 @@ public class UniqueConstraintFieldsEditingSupport extends EditingSupport {
@Override
protected Object openDialogBox(Control cellEditorWindow) {
ElementCheckboxSelectionDialog dialog = new ElementCheckboxSelectionDialog(cellEditorWindow.getShell(), new FieldLabelProvider());
ElementCheckboxSelectionDialog dialog = new ElementCheckboxSelectionDialog(cellEditorWindow.getShell(),
new FieldLabelProvider());
BusinessObject businessObject = (BusinessObject) viewerObservableValue.getValue();
List<Field> fields = businessObject.getFields();
if (fields == null) {
......@@ -121,7 +122,7 @@ public class UniqueConstraintFieldsEditingSupport extends EditingSupport {
* @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
*/
@Override
protected void setValue(Object element, Object value) {
protected void setValue(final Object element, Object value) {
if (value == null) {
return;
}
......@@ -143,7 +144,13 @@ public class UniqueConstraintFieldsEditingSupport extends EditingSupport {
}
}
((UniqueConstraint) element).setFieldNames(fieldNames);
getViewer().update(element, null);
getViewer().getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
getViewer().update(element, null);
}
});
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment