# HG changeset patch # User Ingo Weinzierl # Date 1298396363 0 # Node ID dc086030e6a37a3cde9818ac07be66e6aaba5e52 # Parent a85bac23506913cf422e385bd00ab0bbaef7ca07 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 diff -r a85bac235069 -r dc086030e6a3 flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java: diff -r a85bac235069 -r dc086030e6a3 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.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 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(); + this.tabs = new TabSet(); + this.parameterTab = new Tab(messages.winfo()); + this.parameterList = new ParameterList(); + this.handlers = new ArrayList(); + 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 : diff -r a85bac235069 -r dc086030e6a3 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java --- /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 old; + protected Data current; + + protected UIProvider uiProvider; + + protected VLayout oldItems; + protected VLayout currentItems; + + public ParameterList() { + old = new ArrayList(); + 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 :