diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java index 46a817fa9447ff8924b6a485aa62c0ffcf762ede..7214f9882313eb252999b1d8fc134fa7d18b662a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java @@ -410,8 +410,9 @@ public interface ICommonClientService extends IClientService public String prepareExportDataSetTypes(final TableExportCriteria<DataSetType> criteria) throws UserFailureException; - public ResultSet<FileFormatType> listFileTypes( - DefaultResultSetConfig<String, FileFormatType> criteria) throws UserFailureException; + public TypedTableResultSet<FileFormatType> listFileTypes( + DefaultResultSetConfig<String, TableModelRowWithObject<FileFormatType>> criteria) + throws UserFailureException; public List<FileFormatType> listFileTypes() throws UserFailureException; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java index d366fbe4b7f3db5dd3de757a9f48d45bf0f78c08..6e5cec5481d11eab1e94ea7794c8f1064aeb0282 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java @@ -342,12 +342,14 @@ public interface ICommonClientServiceAsync extends IClientServiceAsync AsyncCallback<String> callback); /** @see ICommonClientService#listFileTypes(DefaultResultSetConfig) */ - public void listFileTypes(DefaultResultSetConfig<String, AbstractType> criteria, - final AsyncCallback<ResultSet<AbstractType>> asyncCallback) + public void listFileTypes( + DefaultResultSetConfig<String, TableModelRowWithObject<FileFormatType>> criteria, + final AsyncCallback<TypedTableResultSet<FileFormatType>> asyncCallback) throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; /** @see ICommonClientService#prepareExportFileTypes(TableExportCriteria) */ - public void prepareExportFileTypes(TableExportCriteria<AbstractType> criteria, + public void prepareExportFileTypes( + TableExportCriteria<TableModelRowWithObject<FileFormatType>> criteria, AsyncCallback<String> callback) throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/TypeColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/TypeColDefKind.java deleted file mode 100644 index e2a0f58a2991508b77cc4475bf2d8e639ec226f0..0000000000000000000000000000000000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/TypeColDefKind.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2009 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific; - -import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractType; - -/** - * Generic columns for a grid of types. - * - * @author Franz-Josef Elmer - */ -public enum TypeColDefKind implements IColumnDefinitionKind<AbstractType> -{ - CODE(new AbstractColumnDefinitionKind<AbstractType>(Dict.CODE) - { - @Override - public String tryGetValue(AbstractType entity) - { - return entity.getCode(); - } - }), - - DESCRIPTION(new AbstractColumnDefinitionKind<AbstractType>(Dict.DESCRIPTION, 300) - { - @Override - public String tryGetValue(AbstractType entity) - { - return entity.getDescription(); - } - }); - - private final AbstractColumnDefinitionKind<AbstractType> columnDefinitionKind; - - private TypeColDefKind(AbstractColumnDefinitionKind<AbstractType> columnDefinitionKind) - { - this.columnDefinitionKind = columnDefinitionKind; - } - - public String id() - { - return name(); - } - - public AbstractColumnDefinitionKind<AbstractType> getDescriptor() - { - return columnDefinitionKind; - } -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/FileFormatTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/FileFormatTypeGrid.java index 1a1bba4a178b2cb09ac5cd86e0be5aee74b12476..0f52b8f66d7ebb21b9febc5a95f800772507eb54 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/FileFormatTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/FileFormatTypeGrid.java @@ -34,11 +34,9 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericCon import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplayTypeIDGenerator; import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.BaseEntityModel; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.TypeColDefKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.TypedTableGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.entity_type.AddTypeDialog; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.DescriptionField; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.AbstractSimpleBrowserGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ColumnDefsAndConfigs; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.AbstractRegistrationDialog; @@ -46,21 +44,22 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget. import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.TextToolItem; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.FileFormatTypeGridColumnIDs; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TypedTableResultSet; import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; /** * @author Franz-Josef Elmer */ -public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> +public class FileFormatTypeGrid extends TypedTableGrid<FileFormatType> { public static final String BROWSER_ID = GenericConstants.ID_PREFIX + "file-format-type-browser"; - public static final String GRID_ID = BROWSER_ID + "_grid"; + public static final String GRID_ID = BROWSER_ID + TypedTableGrid.GRID_POSTFIX; public static final String ADD_NEW_TYPE_BUTTON_ID = GRID_ID + "-" + Dict.ADD_NEW_TYPE_BUTTON; @@ -75,7 +74,7 @@ public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> private FileFormatTypeGrid(IViewContext<ICommonClientServiceAsync> viewContext) { - super(viewContext, BROWSER_ID, GRID_ID, + super(viewContext, BROWSER_ID, true, DisplayTypeIDGenerator.FILE_FORMAT_TYPE_BROWSER_GRID); postRegistrationCallback = createRefreshGridAction(); extendBottomToolbar(); @@ -100,13 +99,15 @@ public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> addButton(createItem); Button editButton = createSelectedItemButton(viewContext.getMessage(Dict.EDIT_TYPE_BUTTON), - new ISelectedEntityInvoker<BaseEntityModel<AbstractType>>() + new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<FileFormatType>>>() { - public void invoke(BaseEntityModel<AbstractType> selectedItem, + public void invoke( + BaseEntityModel<TableModelRowWithObject<FileFormatType>> selectedItem, boolean keyPressed) { - AbstractType entityType = selectedItem.getBaseObject(); + FileFormatType entityType = + selectedItem.getBaseObject().getObjectOrNull(); createEditEntityTypeDialog(entityType).show(); } @@ -144,15 +145,16 @@ public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> @Override public void componentSelected(ButtonEvent ce) { - List<BaseEntityModel<AbstractType>> types = getSelectedItems(); + List<BaseEntityModel<TableModelRowWithObject<FileFormatType>>> types = + getSelectedItems(); if (types.isEmpty()) { return; } final List<String> selectedTypeCodes = new ArrayList<String>(); - for (BaseEntityModel<AbstractType> model : types) + for (BaseEntityModel<TableModelRowWithObject<FileFormatType>> model : types) { - AbstractType term = model.getBaseObject(); + FileFormatType term = model.getBaseObject().getObjectOrNull(); selectedTypeCodes.add(term.getCode()); } ConfirmationDialog confirmationDialog = @@ -175,7 +177,7 @@ public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> return deleteButton; } - private Window createEditEntityTypeDialog(final AbstractType type) + private Window createEditEntityTypeDialog(final FileFormatType type) { final String code = type.getCode(); String title = @@ -214,43 +216,47 @@ public class FileFormatTypeGrid extends AbstractSimpleBrowserGrid<AbstractType> } @Override - protected IColumnDefinitionKind<AbstractType>[] getStaticColumnsDefinition() + protected ColumnDefsAndConfigs<TableModelRowWithObject<FileFormatType>> createColumnsDefinition() { - return TypeColDefKind.values(); - } - - @Override - protected ColumnDefsAndConfigs<AbstractType> createColumnsDefinition() - { - ColumnDefsAndConfigs<AbstractType> schema = super.createColumnsDefinition(); - schema.setGridCellRendererFor(TypeColDefKind.DESCRIPTION.id(), + ColumnDefsAndConfigs<TableModelRowWithObject<FileFormatType>> schema = + super.createColumnsDefinition(); + schema.setGridCellRendererFor(FileFormatTypeGridColumnIDs.DESCRIPTION, createMultilineStringCellRenderer()); return schema; } @Override - protected List<IColumnDefinition<AbstractType>> getInitialFilters() + protected List<IColumnDefinition<TableModelRowWithObject<FileFormatType>>> getInitialFilters() { return Collections.emptyList(); } @Override - protected void listEntities(DefaultResultSetConfig<String, AbstractType> resultSetConfig, - AbstractAsyncCallback<ResultSet<AbstractType>> callback) + protected void listTableRows( + DefaultResultSetConfig<String, TableModelRowWithObject<FileFormatType>> resultSetConfig, + AsyncCallback<TypedTableResultSet<FileFormatType>> callback) { viewContext.getService().listFileTypes(resultSetConfig, callback); } @Override - protected void prepareExportEntities(TableExportCriteria<AbstractType> exportCriteria, + protected void prepareExportEntities( + TableExportCriteria<TableModelRowWithObject<FileFormatType>> exportCriteria, AbstractAsyncCallback<String> callback) { viewContext.getService().prepareExportFileTypes(exportCriteria, callback); } + @Override public DatabaseModificationKind[] getRelevantModifications() { return new DatabaseModificationKind[] {}; } + @Override + protected String translateColumnIdToDictionaryKey(String columnID) + { + return columnID.toLowerCase(); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java index 5c846d321b8ac0d36afd72fbb7dc2a7e571dc34e..3f3267295bd552f4139e729b89738f24ad203350 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyGrid.java @@ -88,95 +88,6 @@ public class VocabularyGrid extends TypedTableGrid<Vocabulary> return grid.asDisposableWithoutToolbar(); } - private void extendBottomToolbar() - { - addEntityOperationsLabel(); - - final Button addButton = - new Button(viewContext.getMessage(Dict.BUTTON_ADD, "Vocabulary"), - new SelectionListener<ButtonEvent>() - { - @Override - public void componentSelected(ButtonEvent ce) - { - DispatcherHelper.dispatchNaviEvent(new ComponentProvider( - viewContext).getVocabularyRegistration()); - } - }); - addButton(addButton); - - Button showDetailsButton = - createSelectedItemButton( - viewContext.getMessage(Dict.BUTTON_SHOW_DETAILS), - new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<Vocabulary>>>() - { - public void invoke( - BaseEntityModel<TableModelRowWithObject<Vocabulary>> selectedItem, - boolean keyPressed) - { - showEntityViewer(selectedItem.getBaseObject(), false, - keyPressed); - } - }); - showDetailsButton.setId(SHOW_DETAILS_BUTTON_ID); - addButton(showDetailsButton); - - addButton(createSelectedItemButton(viewContext.getMessage(Dict.BUTTON_EDIT), - new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<Vocabulary>>>() - { - - public void invoke( - BaseEntityModel<TableModelRowWithObject<Vocabulary>> selectedItem, - boolean keyPressed) - { - Vocabulary vocabulary = selectedItem.getBaseObject().getObjectOrNull(); - if (vocabulary.isManagedInternally()) - { - String errorMsg = "Internally managed vocabulary cannot be edited."; - MessageBox.alert("Error", errorMsg, null); - } else - { - createEditEntityDialog(vocabulary).show(); - } - } - - })); - - addButton(createSelectedItemsButton(viewContext.getMessage(Dict.BUTTON_DELETE), - new AbstractCreateDialogListener() - { - - @Override - protected Dialog createDialog( - List<TableModelRowWithObject<Vocabulary>> vocabularies, - IBrowserGridActionInvoker invoker) - { - return new VocabularyListDeletionConfirmationDialog(viewContext, - vocabularies, createDeletionCallback(invoker)); - } - - @Override - protected boolean validateSelectedData( - List<TableModelRowWithObject<Vocabulary>> data) - { - String errorMsg = "Internally managed vocabularies cannot be deleted."; - for (TableModelRowWithObject<Vocabulary> vocabulary : data) - { - if (vocabulary.getObjectOrNull().isManagedInternally()) - { - MessageBox.alert("Error", errorMsg, null); - return false; - } - } - return true; - } - })); - - allowMultipleSelection(); // we allow deletion of multiple vocabularies - - addEntityOperationsSeparator(); - } - private VocabularyGrid(IViewContext<ICommonClientServiceAsync> viewContext) { super(viewContext, BROWSER_ID, true, DisplayTypeIDGenerator.VOCABULARY_BROWSER_GRID); @@ -268,6 +179,96 @@ public class VocabularyGrid extends TypedTableGrid<Vocabulary> tabFactory.setInBackground(inBackground); DispatcherHelper.dispatchNaviEvent(tabFactory); } + + private void extendBottomToolbar() + { + addEntityOperationsLabel(); + + final Button addButton = + new Button(viewContext.getMessage(Dict.BUTTON_ADD, "Vocabulary"), + new SelectionListener<ButtonEvent>() + { + @Override + public void componentSelected(ButtonEvent ce) + { + DispatcherHelper.dispatchNaviEvent(new ComponentProvider( + viewContext).getVocabularyRegistration()); + } + }); + addButton(addButton); + + Button showDetailsButton = + createSelectedItemButton( + viewContext.getMessage(Dict.BUTTON_SHOW_DETAILS), + new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<Vocabulary>>>() + { + public void invoke( + BaseEntityModel<TableModelRowWithObject<Vocabulary>> selectedItem, + boolean keyPressed) + { + showEntityViewer(selectedItem.getBaseObject(), false, + keyPressed); + } + }); + showDetailsButton.setId(SHOW_DETAILS_BUTTON_ID); + addButton(showDetailsButton); + + addButton(createSelectedItemButton(viewContext.getMessage(Dict.BUTTON_EDIT), + new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<Vocabulary>>>() + { + + public void invoke( + BaseEntityModel<TableModelRowWithObject<Vocabulary>> selectedItem, + boolean keyPressed) + { + Vocabulary vocabulary = selectedItem.getBaseObject().getObjectOrNull(); + if (vocabulary.isManagedInternally()) + { + String errorMsg = "Internally managed vocabulary cannot be edited."; + MessageBox.alert("Error", errorMsg, null); + } else + { + createEditEntityDialog(vocabulary).show(); + } + } + + })); + + addButton(createSelectedItemsButton(viewContext.getMessage(Dict.BUTTON_DELETE), + new AbstractCreateDialogListener() + { + + @Override + protected Dialog createDialog( + List<TableModelRowWithObject<Vocabulary>> vocabularies, + IBrowserGridActionInvoker invoker) + { + return new VocabularyListDeletionConfirmationDialog(viewContext, + vocabularies, createDeletionCallback(invoker)); + } + + @Override + protected boolean validateSelectedData( + List<TableModelRowWithObject<Vocabulary>> data) + { + String errorMsg = "Internally managed vocabularies cannot be deleted."; + for (TableModelRowWithObject<Vocabulary> vocabulary : data) + { + if (vocabulary.getObjectOrNull().isManagedInternally()) + { + MessageBox.alert("Error", errorMsg, null); + return false; + } + } + return true; + } + })); + + allowMultipleSelection(); // we allow deletion of multiple vocabularies + + addEntityOperationsSeparator(); + } + private Component createEditEntityDialog(final Vocabulary vocabulary) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/FileFormatTypeGridColumnIDs.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/FileFormatTypeGridColumnIDs.java new file mode 100644 index 0000000000000000000000000000000000000000..3d76412fe17211a40f12f7c058a9eb2b6ad903d6 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/FileFormatTypeGridColumnIDs.java @@ -0,0 +1,29 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.dto; + +/** + * @author Kaloyan Enimanev + */ +public class FileFormatTypeGridColumnIDs +{ + + public static final String CODE = "CODE"; + + public static final String DESCRIPTION = "DESCRIPTION"; + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index 8f6db520a0c40351aa25896f71de05993ba5ca9b..afc4c034f5cba352bfe85c0bc24f1fe0f8dd0ece 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -67,6 +67,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.exception.InvalidSessi import ch.systemsx.cisd.openbis.generic.client.web.server.calculator.ITableDataProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.CacheManager; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.DataProviderAdapter; +import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.FileFormatTypesProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.IOriginalDataProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.IResultSet; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.MatchingEntitiesProvider; @@ -786,21 +787,6 @@ public final class CommonClientService extends AbstractClientService implements return new TypedTableResultSet<Vocabulary>(resultSet); } - private List<Vocabulary> listVocabularies(final boolean withTerms, boolean excludeInternal) - throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException - { - try - { - final String sessionToken = getSessionToken(); - final List<Vocabulary> vocabularies = - commonServer.listVocabularies(sessionToken, withTerms, excludeInternal); - return vocabularies; - } catch (final UserFailureException e) - { - throw UserFailureExceptionTranslator.translate(e); - } - } - public TypedTableResultSet<VocabularyTermWithStats> listVocabularyTerms( final Vocabulary vocabulary, DefaultResultSetConfig<String, TableModelRowWithObject<VocabularyTermWithStats>> criteria) @@ -867,18 +853,17 @@ public final class CommonClientService extends AbstractClientService implements }); } - public ResultSet<FileFormatType> listFileTypes( - DefaultResultSetConfig<String, FileFormatType> criteria) + public TypedTableResultSet<FileFormatType> listFileTypes( + DefaultResultSetConfig<String, TableModelRowWithObject<FileFormatType>> criteria) throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException { - return listEntities(criteria, - new AbstractOriginalDataProviderWithoutHeaders<FileFormatType>() - { - public List<FileFormatType> getOriginalData() throws UserFailureException - { - return listFileTypes(); - } - }); + FileFormatTypesProvider provider = + new FileFormatTypesProvider(commonServer, getSessionToken()); + DataProviderAdapter<FileFormatType> dataProvider = + new DataProviderAdapter<FileFormatType>(provider); + ResultSet<TableModelRowWithObject<FileFormatType>> resultSet = + listEntities(criteria, dataProvider); + return new TypedTableResultSet<FileFormatType>(resultSet); } public ResultSetWithEntityTypes<ExternalData> listSampleDataSets(final TechId sampleId, diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..ea88ba19f6ef16cc862194dd4072521fb458681c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProvider.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.server.resultset; + +import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.FileFormatTypeGridColumnIDs.CODE; +import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.FileFormatTypeGridColumnIDs.DESCRIPTION; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.ICommonServer; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TypedTableModel; +import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder; + +/** + * @author Kaloyan Enimanev + */ +public class FileFormatTypesProvider extends AbstractCommonTableModelProvider<FileFormatType> +{ + + public FileFormatTypesProvider(ICommonServer commonServer, String sessionToken) + { + super(commonServer, sessionToken); + } + + @Override + protected TypedTableModel<FileFormatType> createTableModel() + { + List<FileFormatType> fileFormats = commonServer.listFileFormatTypes(sessionToken); + + TypedTableModelBuilder<FileFormatType> builder = + new TypedTableModelBuilder<FileFormatType>(); + builder.addColumn(CODE).withDefaultWidth(150); + builder.addColumn(DESCRIPTION).withDefaultWidth(300); + + for (FileFormatType fileFormat : fileFormats) + { + builder.addRow(fileFormat); + builder.column(CODE).addString(fileFormat.getCode()); + builder.column(DESCRIPTION).addString(fileFormat.getDescription()); + } + return builder.getModel(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/VocabulariesProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/VocabulariesProvider.java index 1f993cd344f68ed2d6a9091817ebcfbc2a4d5daf..fc2e14b7d54891e111a9eec76477daf5aaf7fef5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/VocabulariesProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/VocabulariesProvider.java @@ -33,7 +33,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder; /** - * @author kaloyane + * @author Kaloyan Enimanev */ public class VocabulariesProvider extends AbstractCommonTableModelProvider<Vocabulary> { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/FileFormatTypeGridTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/FileFormatTypeGridTest.java index a2b5e1bd680571e924f14c83bb8f64e372b4fbd0..7feea9666a40e88b9ff778baff66757f586c3c49 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/FileFormatTypeGridTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/FileFormatTypeGridTest.java @@ -21,10 +21,10 @@ import com.extjs.gxt.ui.client.event.Events; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.MainTabPanel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.menu.TopMenu.ActionMenuKind; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.TypeColDefKind; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.FileFormatTypeGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.entity_type.AddTypeDialog; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.TextToolItem; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.FileFormatTypeGridColumnIDs; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractGWTTestCase; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.CheckTableCommand; @@ -40,7 +40,7 @@ public class FileFormatTypeGridTest extends AbstractGWTTestCase { loginAndInvokeAction(ActionMenuKind.DATA_SET_MENU_FILE_FORMATS); CheckTableCommand table = new CheckTableCommand(FileFormatTypeGrid.GRID_ID); - table.expectedRow(new Row().withCell(TypeColDefKind.CODE.id(), "XML")); + table.expectedRow(new Row().withCell(FileFormatTypeGridColumnIDs.CODE, "XML")); remoteConsole.prepare(table.expectedSize(8)); launchTest(); @@ -54,8 +54,8 @@ public class FileFormatTypeGridTest extends AbstractGWTTestCase remoteConsole.prepare(table); remoteConsole.prepare(addNewTypeCommand()); table = new CheckTableCommand(FileFormatTypeGrid.GRID_ID); - table.expectedRow(new Row().withCell(TypeColDefKind.CODE.id(), "MY-TYPE").withCell( - TypeColDefKind.DESCRIPTION.id(), "hello")); + table.expectedRow(new Row().withCell(FileFormatTypeGridColumnIDs.CODE, "MY-TYPE").withCell( + FileFormatTypeGridColumnIDs.DESCRIPTION, "hello")); table.expectedSize(9); remoteConsole.prepare(table); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProviderTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProviderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0ed3fee1efc3f120ae3f01fd61c7fb935a1adece --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/FileFormatTypesProviderTest.java @@ -0,0 +1,78 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.server.resultset; + +import java.util.Arrays; +import java.util.List; + +import org.jmock.Expectations; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TypedTableModel; + +/** + * @author Kaloyan Enimanev + */ +public class FileFormatTypesProviderTest extends AbstractProviderTest +{ + private FileFormatType fft1; + + private FileFormatType fft2; + + @BeforeMethod + public final void setUpExpectations() + { + context.checking(new Expectations() + { + { + one(server).listFileFormatTypes(SESSION_TOKEN); + + fft1 = new FileFormatType("SH"); + fft1.setDescription("Bash scripts"); + + fft2 = new FileFormatType("PY"); + fft2.setDescription("Python scripts"); + + will(returnValue(Arrays.asList(fft1, fft2))); + } + }); + } + + @Test + public void testBrowse() + { + FileFormatTypesProvider vocabulariesProvider = + new FileFormatTypesProvider(server, SESSION_TOKEN); + TypedTableModel<FileFormatType> tableModel = vocabulariesProvider.getTableModel(); + + assertEquals("[CODE, DESCRIPTION]", getHeaderIDs(tableModel).toString()); + + List<TableModelRowWithObject<FileFormatType>> rows = tableModel.getRows(); + assertSame(fft1, rows.get(0).getObjectOrNull()); + assertSame(fft2, rows.get(1).getObjectOrNull()); + + List<String> expectedValues = Arrays.asList(fft2.getCode(), fft2.getDescription()); + + assertEquals(expectedValues.toString(), rows.get(1).getValues().toString()); + assertEquals(2, rows.size()); + context.assertIsSatisfied(); + } + +}