Skip to content
Snippets Groups Projects
Commit 3dd95ad4 authored by buczekp's avatar buczekp
Browse files

[LMS-1075] added project properties to project detail view and improved project deletion

SVN: 13954
parent d847a1c7
No related branches found
No related tags found
No related merge requests found
/*
* 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;
/*
* 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.
*/
import java.util.LinkedHashMap;
import java.util.Map;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.PropertyValueRenderers;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property.PropertyGrid;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.MultilineHTML;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
/**
* {@link ContentPanel} containing project properties.
*
* @author Piotr Buczek
*/
public class ProjectPropertiesPanel extends ContentPanel
{
public static final String PROPERTIES_ID_PREFIX =
GenericConstants.ID_PREFIX + "project-properties-section_";
private final Project project;
private final IViewContext<?> viewContext;
public ProjectPropertiesPanel(final Project project, final IViewContext<?> viewContext)
{
setHeading("Project Properties");
this.project = project;
this.viewContext = viewContext;
final PropertyGrid propertyGrid = createPropertyGrid();
add(propertyGrid);
}
private final PropertyGrid createPropertyGrid()
{
final Map<String, Object> properties = createProperties(viewContext);
final PropertyGrid propertyGrid = new PropertyGrid(viewContext, properties.size());
propertyGrid.getElement().setId(PROPERTIES_ID_PREFIX + project.getIdentifier());
propertyGrid.registerPropertyValueRenderer(Person.class, PropertyValueRenderers
.createPersonPropertyValueRenderer(viewContext));
propertyGrid.setProperties(properties);
return propertyGrid;
}
private final Map<String, Object> createProperties(final IMessageProvider messageProvider)
{
final Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put(messageProvider.getMessage(Dict.PROJECT), project.getIdentifier());
properties.put(messageProvider.getMessage(Dict.REGISTRATOR), project.getRegistrator());
properties.put(messageProvider.getMessage(Dict.REGISTRATION_DATE), project
.getRegistrationDate());
// show description in multiple lines (renderer would need to be assigned to String.class)
final String description =
project.getDescription() == null ? null : new MultilineHTML(project
.getDescription()).toString();
properties.put(messageProvider.getMessage(Dict.DESCRIPTION), description);
return properties;
}
}
...@@ -16,25 +16,36 @@ ...@@ -16,25 +16,36 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application; package ch.systemsx.cisd.openbis.generic.client.web.client.application;
import java.util.Set;
import com.extjs.gxt.ui.client.Style.LayoutRegion; import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll; import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.CompositeDatabaseModificationObserver;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DatabaseModificationAwareComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DatabaseModificationAwareComponent;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.IDatabaseModificationObserver;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.AbstractViewer; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.AbstractViewer;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.BorderLayoutDataFactory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.project.ProjectGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.project.ProjectGrid;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.project.ProjectListDeletionConfirmationDialog;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolder;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind;
/** /**
* Presents details of the project. * Presents details of the project.
* *
* @author Izabela Adamczyk * @author Izabela Adamczyk
* @author Piotr Buczek
*/ */
public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder> public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder> implements
IDatabaseModificationObserver
{ {
private static final String PREFIX = "project-viewer_"; private static final String PREFIX = "project-viewer_";
...@@ -47,29 +58,39 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder ...@@ -47,29 +58,39 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder
// cannot use 'originalData' because Project does not implement IEntityInformationHolder // cannot use 'originalData' because Project does not implement IEntityInformationHolder
private Project originalProject; private Project originalProject;
private final CompositeDatabaseModificationObserver modificationObserver;
public static DatabaseModificationAwareComponent create( public static DatabaseModificationAwareComponent create(
final IViewContext<ICommonClientServiceAsync> viewContext, final TechId projectId) final IViewContext<ICommonClientServiceAsync> viewContext, final TechId projectId)
{ {
ProjectViewer viewer = new ProjectViewer(viewContext, projectId); ProjectViewer viewer = new ProjectViewer(viewContext, projectId);
return new DatabaseModificationAwareComponent(viewer, viewer.modificationObserver); return new DatabaseModificationAwareComponent(viewer, viewer);
} }
private ProjectViewer(final IViewContext<ICommonClientServiceAsync> viewContext, private ProjectViewer(final IViewContext<ICommonClientServiceAsync> viewContext,
final TechId projectId) final TechId projectId)
{ {
super(viewContext, createId(projectId)); super(viewContext, createId(projectId));
setLayout(new BorderLayout());
this.projectId = projectId; this.projectId = projectId;
this.modificationObserver = new CompositeDatabaseModificationObserver();
this.viewContext = viewContext; this.viewContext = viewContext;
setLayout(new BorderLayout());
extendToolBar();
reloadAllData(); reloadAllData();
} }
private void extendToolBar()
{
addToolBarButton(createDeleteButton(new IDelegatedAction()
{
public void execute()
{
new ProjectListDeletionConfirmationDialog(viewContext, originalProject,
createDeletionCallback()).show();
}
}));
}
private void reloadAllData() private void reloadAllData()
{ {
reloadData(new ProjectInfoCallback(viewContext, this, modificationObserver)); reloadData(new ProjectInfoCallback(viewContext, this));
} }
public static String createId(final TechId projectId) public static String createId(final TechId projectId)
...@@ -94,15 +115,11 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder ...@@ -94,15 +115,11 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder
{ {
private final ProjectViewer viewer; private final ProjectViewer viewer;
private final CompositeDatabaseModificationObserver modificationObserver;
private ProjectInfoCallback(final IViewContext<ICommonClientServiceAsync> viewContext, private ProjectInfoCallback(final IViewContext<ICommonClientServiceAsync> viewContext,
final ProjectViewer viewer, final ProjectViewer viewer)
final CompositeDatabaseModificationObserver modificationObserver)
{ {
super(viewContext); super(viewContext);
this.viewer = viewer; this.viewer = viewer;
this.modificationObserver = modificationObserver;
} }
@Override @Override
...@@ -110,25 +127,54 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder ...@@ -110,25 +127,54 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder
{ {
viewer.updateOriginalProject(result); viewer.updateOriginalProject(result);
viewer.removeAll(); viewer.removeAll();
viewer.setScrollMode(Scroll.AUTO); // Top panel
AttachmentVersionsSection<Project> attachmentsSection = final Component topPanel = viewer.createTopPanel(result);
viewer.createAttachmentsSection(result); viewer.add(topPanel, BorderLayoutDataFactory.create(LayoutRegion.NORTH, 150));
viewer.add(attachmentsSection, createBorderLayoutData(LayoutRegion.NORTH)); // Central panel
modificationObserver.addObserver(attachmentsSection.getDatabaseModificationObserver()); final Component centerPanel = viewer.createCenterPanel(result);
viewer.add(centerPanel, BorderLayoutDataFactory.create(LayoutRegion.CENTER));
viewer.layout(); viewer.layout();
} }
@Override
public void finishOnFailure(Throwable caught)
{
viewer.setupRemovedEntityView();
}
} }
private void updateOriginalProject(Project result) private void updateOriginalProject(Project result)
{ {
this.originalProject = result; this.originalProject = result;
editButton.enable(); updateTitle(getOriginalDataDescription());
updateTitle(); setToolBarButtonsEnabled(true);
}
@Override
public void setupRemovedEntityView()
{
removeAll();
updateTitle(getOriginalDataDescription() + " does not exist any more.");
setToolBarButtonsEnabled(false);
}
public Component createCenterPanel(Project result)
{
final ContentPanel panel = createAttachmentsSection(result);
return panel;
}
public Component createTopPanel(Project result)
{
final ContentPanel panel = new ProjectPropertiesPanel(result, viewContext);
panel.setScrollMode(Scroll.AUTOY);
return panel;
} }
private void updateTitle() private String getOriginalDataDescription()
{ {
updateTitle(viewContext.getMessage(Dict.PROJECT) + " " + originalProject.getIdentifier()); return viewContext.getMessage(Dict.PROJECT) + " " + originalProject.getIdentifier();
} }
@Override @Override
...@@ -137,4 +183,14 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder ...@@ -137,4 +183,14 @@ public final class ProjectViewer extends AbstractViewer<IEntityInformationHolder
assert originalProject != null; assert originalProject != null;
ProjectGrid.showEntityViewer(originalProject, true, viewContext); ProjectGrid.showEntityViewer(originalProject, true, viewContext);
} }
public void update(Set<DatabaseModificationKind> observedModifications)
{
reloadAllData();
}
public DatabaseModificationKind[] getRelevantModifications()
{
return DatabaseModificationKind.any(ObjectKind.PROJECT);
}
} }
...@@ -193,7 +193,7 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends ...@@ -193,7 +193,7 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends
setToolBarButtonsEnabled(false); setToolBarButtonsEnabled(false);
} }
private void setToolBarButtonsEnabled(boolean enabled) protected void setToolBarButtonsEnabled(boolean enabled)
{ {
for (Button button : toolBarButtons) for (Button button : toolBarButtons)
{ {
...@@ -203,8 +203,8 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends ...@@ -203,8 +203,8 @@ public abstract class AbstractViewer<D extends IEntityInformationHolder> extends
private String getOriginalDataDescription() private String getOriginalDataDescription()
{ {
return originalData.getEntityKind().getDescription() + " " + originalData.getCode() + "(" return originalData.getEntityKind().getDescription() + " " + originalData.getCode() + " ["
+ originalData.getEntityType().getCode() + ")"; + originalData.getEntityType().getCode() + "]";
} }
protected final static BorderLayoutData createLeftBorderLayoutData() protected final static BorderLayoutData createLeftBorderLayoutData()
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.project; package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.project;
import java.util.Collections;
import java.util.List; import java.util.List;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
...@@ -43,6 +44,13 @@ public final class ProjectListDeletionConfirmationDialog extends ...@@ -43,6 +44,13 @@ public final class ProjectListDeletionConfirmationDialog extends
this.callback = callback; this.callback = callback;
} }
public ProjectListDeletionConfirmationDialog(
IViewContext<ICommonClientServiceAsync> viewContext, Project project,
AbstractAsyncCallback<Void> callback)
{
this(viewContext, Collections.singletonList(project), callback);
}
@Override @Override
protected void executeConfirmedAction() protected void executeConfirmedAction()
{ {
......
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