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 { ...@@ -216,7 +216,7 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
} }
protected String[] getStringLengthValues() { protected String[] getStringLengthValues() {
final List<String> values = new ArrayList<String>(); final List<String> values = new ArrayList<>();
values.add("64"); values.add("64");
values.add("128"); values.add("128");
values.add("255"); values.add("255");
...@@ -341,14 +341,27 @@ public class AttributesTabItemControl extends AbstractTabItemControl { ...@@ -341,14 +341,27 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
createMultipleColumn(featuresTableViewer); createMultipleColumn(featuresTableViewer);
createMandatoryColumn(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() { fieldsList.addListChangeListener(new IListChangeListener() {
@Override @Override
public void handleListChange(final ListChangeEvent event) { public void handleListChange(final ListChangeEvent event) {
final IObservableList observableList = event.getObservableList(); final IObservableList observableList = event.getObservableList();
if (observableList != null && !observableList.isEmpty()) { 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 { ...@@ -570,7 +583,7 @@ public class AttributesTabItemControl extends AbstractTabItemControl {
} }
protected String generateAttributeName(final IViewerObservableValue viewerObseravble) { 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(); final BusinessObject businessObject = (BusinessObject) viewerObseravble.getValue();
for (final Field feature : businessObject.getFields()) { for (final Field feature : businessObject.getFields()) {
existingNames.add(feature.getName()); existingNames.add(feature.getName());
......
...@@ -43,7 +43,8 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport { ...@@ -43,7 +43,8 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport {
private final IObservableValue viewerObservableValue; 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); super(viewer, dbc);
this.dbc = dbc; this.dbc = dbc;
this.viewerObservableValue = viewerObservableValue; this.viewerObservableValue = viewerObservableValue;
...@@ -78,9 +79,9 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport { ...@@ -78,9 +79,9 @@ public class FieldNameEditingSupport extends ObservableValueEditingSupport {
protected Binding createBinding(final IObservableValue target, final IObservableValue model) { protected Binding createBinding(final IObservableValue target, final IObservableValue model) {
final UpdateValueStrategy targetToModel = new UpdateValueStrategy( final UpdateValueStrategy targetToModel = new UpdateValueStrategy(
UpdateValueStrategy.POLICY_CONVERT); UpdateValueStrategy.POLICY_CONVERT);
targetToModel.setAfterGetValidator(new FieldNameCellEditorValidator((BusinessObject) viewerObservableValue.getValue(), targetToModel
(Field) ((BeanObservableValueDecorator) model).getObserved())); .setAfterGetValidator(new FieldNameCellEditorValidator((BusinessObject) viewerObservableValue.getValue(),
(Field) ((BeanObservableValueDecorator) model).getObserved()));
return dbc.bindValue(target, model, targetToModel, null); return dbc.bindValue(target, model, targetToModel, null);
} }
} }
...@@ -5,17 +5,18 @@ ...@@ -5,17 +5,18 @@
* it under the terms of the GNU General Public License as published by * 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 * the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version. * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.bonitasoft.studio.businessobject.ui.wizard.validator; 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.businessobject.i18n.Messages;
import org.bonitasoft.studio.common.jface.databinding.validator.InputLengthValidator; import org.bonitasoft.studio.common.jface.databinding.validator.InputLengthValidator;
import org.eclipse.core.databinding.validation.IValidator; import org.eclipse.core.databinding.validation.IValidator;
...@@ -25,13 +26,8 @@ import org.eclipse.jdt.core.JavaConventions; ...@@ -25,13 +26,8 @@ import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.ICellEditorValidator; 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 * @author Romain Bioteau
*
*/ */
public class FieldNameCellEditorValidator implements ICellEditorValidator, IValidator { 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