diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriteriaWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriteriaWidget.java index f20ad9e75f34fbdfe8af496eb9ff69b7b442cd7e..c81c34d5bcdd512b4d9cfe0b2ffb73eb442db5a0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriteriaWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriteriaWidget.java @@ -113,6 +113,31 @@ public class CriteriaWidget extends VerticalPanel } + /** description of the search criteria for the user */ + public String getCriteriaDescription() + { + StringBuffer sb = new StringBuffer(); + sb.append(matchRadios.getSelectedLabel()); + sb.append(": "); + boolean first = true; + for (CriterionWidget cw : criteriaWidgets) + { + String desc = cw.tryGetDescription(); + if (desc != null) + { + if (first == false) + { + sb.append(", "); + } else + { + first = false; + } + sb.append(desc); + } + } + return sb.toString(); + } + /** * Resets "match criteria" radio buttons to initial values, removes unnecessary criteria widgets * and resets the remaining ones. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriterionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriterionWidget.java index f91b859416fa5abe4149a91ebaaddb0556ceaac3..c15a5c90868ebed4eec6ac3487bbcfe04b4a5632 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriterionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/CriterionWidget.java @@ -60,15 +60,19 @@ public class CriterionWidget extends HorizontalPanel generatedChildren = 0; this.parent = parent; this.idSuffix = idSuffix; + this.nameField = nameField; + this.valueField = new TextField<String>(); + this.removeButton = createRemoveButton(); + final TableData tableData = new TableData(HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM); tableData.setPadding(1); - add(this.nameField = nameField, tableData); - nameField.setWidth(300); - add(valueField = new TextField<String>(), tableData); + add(this.nameField, tableData); + this.nameField.setWidth(300); + add(valueField, tableData); valueField.setWidth(150); add(createAddButton(), tableData); - add(removeButton = createRemoveButton(), tableData); + add(removeButton, tableData); } /** @@ -155,4 +159,16 @@ public class CriterionWidget extends HorizontalPanel return null; } + + public String tryGetDescription() + { + DataSetSearchCriterion criterion = tryGetValue(); + String name = nameField.tryGetSelectedCode(); + if (criterion == null || name == null) + { + return null; + } + + return name + " = " + criterion.getValue(); + } } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java index 4d97f8f8ecf9e829d757ee75c1a19a1aa6d55422..5fa7cc77283ae5a15725f53702db35acb655778a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetSearchFieldsSelectionWidget.java @@ -86,6 +86,14 @@ public final class DataSetSearchFieldsSelectionWidget extends return (DataSetSearchField) GWTUtils.tryGetSingleSelected(this); } + /** + * Returns code of the selected option, or null - if nothing selected. + */ + public String tryGetSelectedCode() + { + return GWTUtils.tryGetSingleSelectedCode(this); + } + public DataSetSearchFieldsSelectionWidget(DataSetSearchFieldsSelectionWidget source, final String idSuffix) { @@ -181,8 +189,9 @@ public final class DataSetSearchFieldsSelectionWidget extends private DataSetSearchFieldComboModel createComboModel(final PropertyType propertyType, DataSetSearchField searchField, boolean useCode) { - String prefix = getDisplayName(searchField.getKind()) + ": "; - String code = prefix + (useCode ? propertyType.getCode() : propertyType.getLabel()); + String prefix = getDisplayName(searchField.getKind()); + String property = (useCode ? propertyType.getCode() : propertyType.getLabel()); + String code = prefix + " \'" + property + "\'"; return new DataSetSearchFieldComboModel(code, searchField); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/MatchCriteriaRadio.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/MatchCriteriaRadio.java index edc0ece0bfe043db8c07a3e1349a83b3e03688d2..a10836aca7eb3fd65a0490faf9833fc8d5e4407f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/MatchCriteriaRadio.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/MatchCriteriaRadio.java @@ -62,9 +62,14 @@ public class MatchCriteriaRadio extends HorizontalPanel orRadio.setValue(true); } + String getSelectedLabel() + { + return isAndSelected() ? andRadio.getBoxLabel() : orRadio.getBoxLabel(); + } + SearchCriteria.CriteriaConnection getSelected() { - if (andRadio.getValue() != null && andRadio.getValue().booleanValue() == true) + if (isAndSelected()) { return SearchCriteria.CriteriaConnection.AND; } else @@ -72,4 +77,9 @@ public class MatchCriteriaRadio extends HorizontalPanel return SearchCriteria.CriteriaConnection.OR; } } + + private boolean isAndSelected() + { + return andRadio.getValue() != null && andRadio.getValue().booleanValue() == true; + } } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java index 41c0d1a2bb8692c418914a93e55ce44113e132bb..d8f2f47df9d86ad340cd87c547010e31afbb2b61 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeRegistrationForm.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type; -import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.event.SelectionChangedEvent; import com.extjs.gxt.ui.client.event.SelectionChangedListener; import com.extjs.gxt.ui.client.widget.LayoutContainer; @@ -155,16 +154,15 @@ public final class PropertyTypeRegistrationForm extends AbstractRegistrationForm propertyType.setDataType(selectedDataType); if (DataTypeCode.CONTROLLEDVOCABULARY.equals(selectedDataType.getCode())) { - final BaseModelData vocabulary = - GWTUtils.tryGetSingleSelectedModel(vocabularySelectionWidget); - if (VocabularySelectionWidget.NEW_VOCABULARY_CODE.equals(vocabulary - .get(ModelDataPropertyNames.CODE))) + final String selectedVocabularyCode = + GWTUtils.tryGetSingleSelectedCode(vocabularySelectionWidget); + if (VocabularySelectionWidget.NEW_VOCABULARY_CODE.equals(selectedVocabularyCode)) { propertyType.setVocabulary(vocabularyRegistrationFieldSet.createVocabulary()); } else { - propertyType.setVocabulary((Vocabulary) vocabulary - .get(ModelDataPropertyNames.OBJECT)); + propertyType.setVocabulary((Vocabulary) GWTUtils + .tryGetSingleSelected(vocabularySelectionWidget)); } } return propertyType; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java index 334ef4b9596c3056b96b35d8c22b86bcdd367bc9..93e53a5a8ee4e0e265862266de1600bec4a1da53 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java @@ -139,7 +139,8 @@ public final class GWTUtils * * @returns <code>null</code> if nothing is selected. */ - public final static <T extends ModelData> T tryGetSingleSelectedModel(final ComboBox<T> comboBox) + private final static <T extends ModelData> T tryGetSingleSelectedModel( + final ComboBox<T> comboBox) { assert comboBox != null : "Unspecified combo box."; final List<T> selection = comboBox.getSelection(); @@ -152,6 +153,23 @@ public final class GWTUtils return null; } + /** + * Tries to return the selected object code (saved as {@link ModelDataPropertyNames#CODE} in the + * model) from the given {@link ComboBox}. + * + * @returns <code>null</code> if nothing is selected. + */ + public final static <T extends ModelData, O> String tryGetSingleSelectedCode( + final ComboBox<T> comboBox) + { + T selectedModel = GWTUtils.tryGetSingleSelectedModel(comboBox); + if (selectedModel == null) + { + return null; + } + return selectedModel.get(ModelDataPropertyNames.CODE); + } + /** * Tries to return the selected object (saved as {@link ModelDataPropertyNames#OBJECT} in the * model) from the given {@link ComboBox}.