Mercurial > dive4elements > river
changeset 23:dc086030e6a3
The CollectionView is able to create new instances of a WINFO artifact and to display the artifact's state.
flys-client/trunk@1337 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 22 Feb 2011 17:39:23 +0000 |
parents | a85bac235069 |
children | 8825ce0a537e |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java |
diffstat | 3 files changed, 186 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Feb 22 17:29:51 2011 +0000 +++ b/flys-client/ChangeLog Tue Feb 22 17:39:23 2011 +0000 @@ -1,3 +1,15 @@ +2011-02-22 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/ParameterList.java: A UI + widget that stores and displays the data of former states and the current + data. The widget displaying of the current data is created by the + UIProvider that is stored in the Data object. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: We + are able to create new WINFO artifacts. After the artifact has been + created, the first 'state' is rendered in a 'WINFO tab' using the + ParameterList. + 2011-02-22 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Tue Feb 22 17:29:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Tue Feb 22 17:39:23 2011 +0000 @@ -14,18 +14,25 @@ import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.RadioGroupItem; +import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.Tab; +import com.smartgwt.client.widgets.tab.TabSet; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DefaultCollection; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSMessages; import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; +import de.intevation.flys.client.client.event.HasStepForwardHandlers; import de.intevation.flys.client.client.event.CollectionChangeEvent; +import de.intevation.flys.client.client.event.StepForwardEvent; +import de.intevation.flys.client.client.event.StepForwardHandler; import de.intevation.flys.client.client.event.CollectionChangeHandler; import de.intevation.flys.client.client.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; @@ -36,8 +43,9 @@ */ public class CollectionView extends Window -implements CollectionChangeHandler, HasCollectionChangeHandlers { - +implements CollectionChangeHandler, HasCollectionChangeHandlers, + StepForwardHandler +{ /** The ArtifactService used to communicate with the Artifact server. */ protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class); @@ -48,18 +56,26 @@ /** The FLYS instance used to call services.*/ protected FLYS flys; + /** The ParameterList.*/ + protected ParameterList parameterList; + /** The list of ValueChangeHandlers.*/ protected List<CollectionChangeHandler> handlers; /** The collection to be displayed.*/ protected Collection collection; + protected TabSet tabs; + /** The parameter tab.*/ protected Tab parameterTab; /** The output tab.*/ protected Tab outputTab; + /** The layout.*/ + protected Layout layout; + /** * This constructor creates a new CollectionView that is used to display the @@ -71,7 +87,11 @@ this.flys = flys; this.collection = collection; - this.handlers = new ArrayList<CollectionChangeHandler>(); + this.tabs = new TabSet(); + this.parameterTab = new Tab(messages.winfo()); + this.parameterList = new ParameterList(); + this.handlers = new ArrayList<CollectionChangeHandler>(); + this.layout = new VLayout(); addCollectionChangeHandler(this); @@ -86,17 +106,22 @@ setWidth(600); setHeight(400); + layout.setWidth100(); + setCanDragResize(true); DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format()); String lastAccess = dtf.format(collection.getLastAccess()); setTitle(lastAccess + " - " + collection.getName()); - VLayout layout = new VLayout(); addItem(layout); + layout.addMember(tabs); + tabs.addTab(parameterTab); + if (isNew()) { - layout.addMember(renderNew()); + tabs.setTabTitle(0, "MODUL"); + tabs.updateTab(0, renderNew()); } } @@ -143,8 +168,7 @@ * @return a Canvas that displays the plugins of FLYS. */ protected Canvas renderNew() { - VLayout layout = new VLayout(); - layout.setWidth100(); + VLayout newLayout = new VLayout(); DynamicForm form = new DynamicForm(); RadioGroupItem radio = new RadioGroupItem("plugin"); @@ -175,18 +199,18 @@ public void onSuccess(Artifact artifact) { GWT.log("Successfully created a new artifact."); Collection c = new DefaultCollection("TODO"); + c.addArtifact(artifact); - setCollection(c); } }); } }); - layout.addMember(form); - layout.addMember(go); + newLayout.addMember(form); + newLayout.addMember(go); - return layout; + return newLayout; } @@ -208,9 +232,35 @@ } + public void onStepForward(StepForwardEvent event) { + GWT.log("CollectionView - onStepForward()"); + GWT.log("TODO: IMPLEMENT FEED!"); + } + + + /** + * Update the view (refresh the list of old and current data). + */ protected void updateView() { GWT.log("Update view of the collection: " + collection.identifier()); - // TODO display the artifact information / data + Artifact artifact = collection.getArtifact(0); + ArtifactDescription desc = artifact.getArtifactDescription(); + + Data currentData = desc.getCurrentData(); + if (currentData != null) { + String uiProvider = currentData.getUIProvider(); + UIProvider provider = UIProviderFactory.getProvider(uiProvider); + + HasStepForwardHandlers handler = (HasStepForwardHandlers) provider; + handler.addStepForwardHandler(this); + + parameterList.setCurrentData(currentData, provider); + } + + parameterList.addOldDatas(desc.getOldData()); + + tabs.setTabTitle(0, messages.winfo()); + tabs.updateTab(0, parameterList); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Tue Feb 22 17:39:23 2011 +0000 @@ -0,0 +1,112 @@ +package de.intevation.flys.client.client.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.smartgwt.client.types.VerticalAlignment; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; + + +public class ParameterList extends VLayout { + + protected List<Data> old; + protected Data current; + + protected UIProvider uiProvider; + + protected VLayout oldItems; + protected VLayout currentItems; + + public ParameterList() { + old = new ArrayList<Data>(); + oldItems = new VLayout(); + currentItems = new VLayout(); + + init(); + } + + + protected void init() { + oldItems.setHeight(20); + currentItems.setHeight("*"); + currentItems.setAlign(VerticalAlignment.TOP); + + addMember(oldItems); + addMember(currentItems); + } + + + public void addOldData(Data old) { + if (old != null) { + this.old.add(old); + } + + refreshOld(); + } + + + public void addOldDatas(Data[] old) { + if (old != null && old.length > 0) { + for (Data o: old) { + addOldData(o); + } + + return; + } + + addOldData(null); + } + + + public void setCurrentData(Data current, UIProvider uiProvider) { + this.current = current; + this.uiProvider = uiProvider; + + refreshCurrent(); + } + + + public void refreshOld() { + // XXX maybe we should not remove all items but just add the newest item + // to the list. + oldItems.removeMembers(oldItems.getMembers()); + + for (Data data: old) { + HLayout h = new HLayout(); + h.setAlign(VerticalAlignment.TOP); + h.setHeight(20); + + DataItem[] items = data.getItems(); + Label label = new Label(data.getLabel()); + Label value = new Label(items[0].getLabel()); + + h.addMember(label); + h.addMember(value); + + oldItems.addMember(h); + } + + int minHeight = oldItems.getMinHeight(); + if (minHeight <= 20) { + oldItems.setHeight(20); + } + else { + oldItems.setHeight(minHeight); + } + } + + + /** + * This method refreshes the part displaying the data of the current state. + * The UI is created using the UIProvider stored in the Data object. + */ + public void refreshCurrent() { + currentItems.addMember(uiProvider.create(current)); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :