Commit 9e1e332a authored by Adrien's avatar Adrien Committed by Romain Bioteau
Browse files

fix(bdm) fix issue when renaming a field present in several bo (#311)

fixes [BS-16262](https://bonitasoft.atlassian.net/browse/BS-16262)
parent be2ece6e
......@@ -216,7 +216,7 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
}
protected String[] getStringLengthValues() {
final List<String> values = new ArrayList<String>();
final List<String> values = new ArrayList<>();
values.add("64");
values.add("128");
values.add("255");
......@@ -341,14 +341,27 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
createMultipleColumn(featuresTableViewer);
createMandatoryColumn(featuresTableViewer);
featuresTableViewer.setInput(fieldsList);
//Resetting viewer input to avoid BS-16262
viewerObservableValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
featuresTableViewer.setInput(fieldsList);
}
});
fieldsList.addListChangeListener(new IListChangeListener() {
@Override
public void handleListChange(final ListChangeEvent event) {
final IObservableList observableList = event.getObservableList();
if (observableList != null && !observableList.isEmpty()) {
featuresTableViewer.getTable().select(0);
featuresTableViewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
featuresTableViewer.getTable().select(0);
}
});
}
}
});
......@@ -570,7 +583,7 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
}
protected String generateAttributeName(final IViewerObservableValue viewerObseravble) {
final Set<String> existingNames = new HashSet<String>();
final Set<String> existingNames = new HashSet<>();
final BusinessObject businessObject = (BusinessObject) viewerObseravble.getValue();
for (final Field feature : businessObject.getFields()) {
existingNames.add(feature.getName());
......
......@@ -43,7 +43,8 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport {
private final IObservableValue viewerObservableValue;
public FieldNameEditingSupport(final IObservableValue viewerObservableValue, final ColumnViewer viewer, final DataBindingContext dbc) {
public FieldNameEditingSupport(final IObservableValue viewerObservableValue, final ColumnViewer viewer,
final DataBindingContext dbc) {
super(viewer, dbc);
this.dbc = dbc;
this.viewerObservableValue = viewerObservableValue;
......@@ -78,9 +79,9 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport {
protected Binding createBinding(final IObservableValue target, final IObservableValue model) {
final UpdateValueStrategy targetToModel = new UpdateValueStrategy(
UpdateValueStrategy.POLICY_CONVERT);
targetToModel.setAfterGetValidator(new FieldNameCellEditorValidator((BusinessObject) viewerObservableValue.getValue(),
(Field) ((BeanObservableValueDecorator) model).getObserved()));
targetToModel
.setAfterGetValidator(new FieldNameCellEditorValidator((BusinessObject) viewerObservableValue.getValue(),
(Field) ((BeanObservableValueDecorator) model).getObserved()));
return dbc.bindValue(target, model, targetToModel, null);
}
}
......@@ -5,17 +5,18 @@
* 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/>.
*/
package org.bonitasoft.studio.businessobject.ui.wizard.validator;
import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.field.Field;
import org.bonitasoft.engine.bdm.validator.SQLNameValidator;
import org.bonitasoft.studio.businessobject.i18n.Messages;
import org.bonitasoft.studio.common.jface.databinding.validator.InputLengthValidator;
import org.eclipse.core.databinding.validation.IValidator;
......@@ -25,13 +26,8 @@ import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.field.Field;
import org.bonitasoft.engine.bdm.validator.SQLNameValidator;
/**
* @author Romain Bioteau
*
*/
public class FieldNameCellEditorValidator implements ICellEditorValidator, IValidator {
......
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