Skip to content
Snippets Groups Projects
Commit 7567af4e authored by izabel's avatar izabel
Browse files

[LMS-717] browsing of materials - missing files

SVN: 9930
parent 32015987
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2008 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.model;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.data.ModelData;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionUI;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.material.CommonMaterialColDefKind;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.material.PropertyMaterialColDef;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ColumnDefsAndConfigs;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Material;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialTypePropertyType;
/**
* {@link ModelData} for {@link Material}
*
* @author Izabela Adamczyk
*/
public final class MaterialModel extends BaseEntityModel<Material>
{
private static final long serialVersionUID = 1L;
public MaterialModel(final Material entity)
{
super(entity, createColumnsSchema(entity));
}
// here we create the columns definition having just one table row. We need them only to render
// column values (headers have been already created), so no message provider is needed.
private static List<IColumnDefinitionUI<Material>> createColumnsSchema(Material entity)
{
List<IColumnDefinitionUI<Material>> list = createCommonColumnsSchema(null);
for (MaterialProperty prop : entity.getProperties())
{
MaterialTypePropertyType etpt = prop.getEntityTypePropertyType();
list.add(new PropertyMaterialColDef(etpt.getPropertyType()));
}
return list;
}
public static ColumnDefsAndConfigs<Material> createColumnsSchema(
IMessageProvider messageProvider, MaterialType selectedTypeOrNull)
{
List<IColumnDefinitionUI<Material>> commonColumnsSchema =
createCommonColumnsSchema(messageProvider);
ColumnDefsAndConfigs<Material> columns = ColumnDefsAndConfigs.create(commonColumnsSchema);
if (selectedTypeOrNull != null)
{
List<IColumnDefinitionUI<Material>> propertyColumnsSchema =
createPropertyColumnsSchema(selectedTypeOrNull);
columns.addColumns(propertyColumnsSchema);
}
return columns;
}
private static List<IColumnDefinitionUI<Material>> createPropertyColumnsSchema(
MaterialType selectedType)
{
List<MaterialTypePropertyType> entityTypePropertyTypes =
selectedType.getMaterialTypePropertyTypes();
List<IColumnDefinitionUI<Material>> list = createColDefList();
for (MaterialTypePropertyType etpt : entityTypePropertyTypes)
{
list.add(new PropertyMaterialColDef(etpt.getPropertyType()));
}
return list;
}
private static List<IColumnDefinitionUI<Material>> createCommonColumnsSchema(
IMessageProvider msgProviderOrNull)
{
return createColumnsDefinition(CommonMaterialColDefKind.values(), msgProviderOrNull);
}
private static ArrayList<IColumnDefinitionUI<Material>> createColDefList()
{
return new ArrayList<IColumnDefinitionUI<Material>>();
}
}
/*
* Copyright 2008 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.model;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType;
/**
* {@link ModelData} for {@link MaterialType}.
*
* @author Izabela Adamczyk
*/
public class MaterialTypeModel extends BaseModelData
{
private static final long serialVersionUID = 1L;
public MaterialTypeModel(final MaterialType type)
{
set(ModelDataPropertyNames.CODE, type.getCode());
set(ModelDataPropertyNames.OBJECT, type);
}
public final static List<MaterialTypeModel> convert(final List<MaterialType> types)
{
final List<MaterialTypeModel> result = new ArrayList<MaterialTypeModel>();
for (final MaterialType st : types)
{
result.add(new MaterialTypeModel(st));
}
return result;
}
}
/*
* Copyright 2008 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.material;
import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand;
import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.CheckTableCommand;
/**
* A {@link AbstractDefaultTestCommand} extension to check whether a list of materials has been
* loaded.
*
* @author Izabela Adamczyk
*/
public class CheckMaterialTable extends CheckTableCommand
{
public CheckMaterialTable()
{
super(MaterialBrowserGrid.GRID_ID, MaterialBrowserGrid.ListEntitiesCallback.class);
}
}
/*
* Copyright 2008 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.material;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.MaterialTypeModel;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.BrowserGridPagingToolBar;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.material.MaterialTypeSelectionWidget;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand;
import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestUtil;
/**
* A {@link AbstractDefaultTestCommand} extension for creating materials list.
*
* @author Izabela Adamczyk
*/
public class ListMaterials extends AbstractDefaultTestCommand
{
private final String materialTypeName;
public ListMaterials(final String materialTypeNameOrNull)
{
this.materialTypeName = materialTypeNameOrNull;
addCallbackClass(MaterialTypeSelectionWidget.ListItemsCallback.class);
}
//
// AbstractDefaultTestCommand
//
public void execute()
{
final ComboBox<MaterialTypeModel> typeSelector =
(MaterialTypeSelectionWidget) GWTTestUtil
.getWidgetWithID(MaterialTypeSelectionWidget.ID
+ MaterialTypeSelectionWidget.SUFFIX + MaterialBrowserToolbar.ID);
GWTUtils.setSelectedItem(typeSelector, ModelDataPropertyNames.CODE,
materialTypeName);
final Button refresh =
(Button) GWTTestUtil.getWidgetWithID(BrowserGridPagingToolBar.REFRESH_BUTTON_ID);
assertTrue(refresh.isEnabled());
GWTTestUtil.clickButtonWithID(BrowserGridPagingToolBar.REFRESH_BUTTON_ID);
}
}
/*
* Copyright 2008 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.material;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.material.CommonMaterialColDefKind;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.material.PropertyMaterialColDef;
import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.Row;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType;
/**
* Allows to define material table row expectations.
*
* @author Izabela Adamczyk
*/
public class MaterialRow extends Row
{
public MaterialRow(final String code)
{
super();
withCell(CommonMaterialColDefKind.CODE.id(), code);
}
public final MaterialRow userProperty(final String propertyCode, final Object value)
{
return property(propertyCode, value, false);
}
public final MaterialRow internalProperty(final String propertyCode, final Object value)
{
return property(propertyCode, value, true);
}
private final MaterialRow property(final String propertyCode, final Object value,
boolean internalNamespace)
{
final PropertyType propertyType = createPropertyType(propertyCode, internalNamespace);
final String propertyIdentifier = new PropertyMaterialColDef(propertyType).getIdentifier();
withCell(propertyIdentifier, value);
return this;
}
private final static PropertyType createPropertyType(final String propertyCode,
boolean internalNamespace)
{
final PropertyType propertyType = new PropertyType();
propertyType.setInternalNamespace(internalNamespace);
propertyType.setSimpleCode(propertyCode);
return propertyType;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment