Mercurial > dive4elements > river
changeset 276:f4c8ce11df33
UI stub for data cage
flys-client/trunk@1902 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/ChangeLog Wed May 11 14:34:15 2011 +0000 @@ -1,3 +1,30 @@ +2011-05-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java: + Call the service. TODO: transport artifact server result to client. + + * src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/MetaDataService.java: + Extended interfaces to cope with i18n. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: + Error messages if the artifact meta data service is not reachable. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Forward collection view to chart output tab. + + * src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java: + Forward artifact to fetch river name later. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java: + New. UI code for the data cage panel. TODO: build tree from + service data. + + * src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java: + Added simple break in a loop if river was found. + 2011-05-11 Ingo Weinzierl <ingo@intevation.de> ISSUE-56
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed May 11 14:34:15 2011 +0000 @@ -209,5 +209,7 @@ String error_feed_q_values_invalid(); String error_feed_w_values_invalid(); + + String error_no_meta_data_found(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed May 11 14:34:15 2011 +0000 @@ -102,3 +102,5 @@ error_feed_no_wq_mode_selected = No W/Q mode selected. error_feed_q_values_invalid = Selected Q values are outside the valid range. error_feed_w_values_invalid = Selected W values are outside the valid range. + +error_no_meta_data_found = No meta data found.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed May 11 14:34:15 2011 +0000 @@ -102,3 +102,5 @@ error_feed_no_wq_mode_selected = Es ist kein W/Q Modus gew\u00e4hlt. error_feed_q_values_invalid = Die gew\u00e4hlten Q Werte liegen au\u00dferhalb des g\u00fcltigen Bereiches. error_feed_w_values_invalid = Die gew\u00e4hlten W Werte liegen au\u00dferhalb des g\u00fcltigen Bereiches. + +error_no_meta_data_found = Keine Meta-Daten gefunden.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataService.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataService.java Wed May 11 14:34:15 2011 +0000 @@ -10,7 +10,7 @@ @RemoteServiceRelativePath("meta-data") public interface MetaDataService extends RemoteService { - List getMetaData(String serverUrl, String name) + List getMetaData(String serverUrl, String locale, String name) throws ServerException; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MetaDataServiceAsync.java Wed May 11 14:34:15 2011 +0000 @@ -5,7 +5,11 @@ import java.util.List; public interface MetaDataServiceAsync { - void getMetaData(String serverUrl, String name, AsyncCallback<List> cb); + void getMetaData( + String serverUrl, + String locale, + String name, + AsyncCallback<List> cb); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java Wed May 11 14:34:15 2011 +0000 @@ -7,13 +7,21 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.IButton; + import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.CloseClientEvent; + import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.shared.model.Artifact; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> @@ -37,7 +45,12 @@ * @param collection The Collection which this chart belongs to. * @param mode The OutputMode. */ - public ChartOutputTab(String title, Collection collection, OutputMode mode){ + public ChartOutputTab( + String title, + Collection collection, + OutputMode mode, + CollectionView collectionView + ){ super(title, collection, mode); tbarPanel = new Canvas(); @@ -63,7 +76,8 @@ right.addChild(createChartPanel()); left.addChild(createThemeControlPanel()); - tbarPanel.addChild(createTBarPanel()); + tbarPanel.addChild( + createTBarPanel(collectionView)); vLayout.addMember(tbarPanel); vLayout.addMember(hLayout); @@ -72,12 +86,38 @@ } - protected Canvas createTBarPanel() { - Label label = new Label("Werkzeugleiste"); - label.setHeight(25); - label.setMargin(5); + protected Canvas createTBarPanel( + final CollectionView collectionView + ) { + HLayout hLayout = new HLayout(); + hLayout.setWidth100(); + hLayout.setHeight100(); + hLayout.setMembersMargin(10); - return label; + IButton datacage = new IButton("Datenkorb"); + datacage.setHeight(25); + datacage.setMargin(5); + + hLayout.addMember(datacage); + datacage.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + GWT.log("Clicked 'datacage' button."); + openDatacageWindow( + collectionView.getArtifact()); + } + }); + + return hLayout; + } + + protected void openDatacageWindow(Artifact artifact) { + final DatacageWindow dc = new DatacageWindow(artifact); + dc.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent event) { + dc.destroy(); + } + }); + dc.show(); }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 11 14:34:15 2011 +0000 @@ -374,7 +374,8 @@ // TODO Source this out to a factory that creates the different // OutputTabs. String title = messages.getString(name); - OutputTab tab = new ChartOutputTab(title, getCollection(), out); + OutputTab tab = new ChartOutputTab( + title, getCollection(), out, this); outputTabs.put(name, tab); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Wed May 11 14:34:15 2011 +0000 @@ -0,0 +1,94 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; + +import com.google.gwt.core.client.GWT; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import com.smartgwt.client.util.SC; + +import com.smartgwt.client.widgets.Window; + + +import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.ArtifactDescription; +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataList; +import de.intevation.flys.client.shared.model.DataItem; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.Config; + +import de.intevation.flys.client.client.services.MetaDataService; +import de.intevation.flys.client.client.services.MetaDataServiceAsync; + + +public class DatacageWindow +extends Window +{ + protected MetaDataServiceAsync metaDataService = + GWT.create(MetaDataService.class); + + protected FLYSConstants messages = + GWT.create(FLYSConstants.class); + + + protected Artifact artifact; + + public DatacageWindow(Artifact artifact) { + this.artifact = artifact; + setHeight(115); + String river = findRiver(); + setTitle("Datenkorb: " + river); + setShowMinimizeButton(false); + setIsModal(true); + setShowModalMask(true); + centerInPage(); + + triggerTreeBuilding(river); + } + + protected void triggerTreeBuilding(String river) { + Config config = Config.getInstance(); + String url = config.getServerUrl(); + String locale = config.getLocale(); + + metaDataService.getMetaData( + url, locale, river, + new AsyncCallback<List>() { + public void onFailure(Throwable caught) { + GWT.log("Could not load meta data."); + SC.warn(messages.getString(caught.getMessage())); + } + + public void onSuccess(List list) { + GWT.log("Successfully created a new collection."); + } + }); + } + + protected String findRiver() { + + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList [] data = adescr.getOldData(); + + if (data != null && data.length > 0) { + for (int i = 0; i < data.length; i++) { + DataList dl = data[i]; + if (dl.getState().equals("state.winfo.river")) { + for (int j = dl.size()-1; j >= 0; --j) { + Data d = dl.get(j); + DataItem [] di = d.getItems(); + if (di != null && di.length == 1) { + return d.getItems()[0].getStringValue(); + } + } + } + } + } + + return ""; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Wed May 11 14:34:15 2011 +0000 @@ -296,6 +296,7 @@ DataItem[] di = d.getItems(); if (di != null && di.length == 1) { river = d.getItems()[0].getStringValue(); + break; } } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java Wed May 11 14:29:35 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MetaDataServiceImpl.java Wed May 11 14:34:15 2011 +0000 @@ -1,21 +1,65 @@ package de.intevation.flys.client.server; import java.util.List; +import java.util.ArrayList; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import com.google.gwt.user.server.rpc.RemoteServiceServlet; +import de.intevation.artifacts.common.ArtifactNamespaceContext; + +import de.intevation.artifacts.common.utils.XMLUtils; + import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.client.services.MetaDataService; +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; + +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; + public class MetaDataServiceImpl extends RemoteServiceServlet implements MetaDataService { - public List getMetaData(String url, String name) + public static final String ERROR_NO_META_DATA_FOUND = + "error_no_meta_data_found"; + + public List getMetaData(String url, String locale, String river) throws ServerException { - return null; + System.out.println("MetaDataService.getDistanceInfo"); + + Document doc = XMLUtils.newDocument(); + + XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( + doc, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); + + Element riverEl = ec.create("river"); + + riverEl.setTextContent(river); + + doc.appendChild(riverEl); + + HttpClient client = new HttpClientImpl(url, locale); + + try { + Document result = client.callService(url, "metadata", doc); + + return new ArrayList(); + } + catch (ConnectionException ce) { + System.err.println(ce.getLocalizedMessage()); + } + + throw new ServerException(ERROR_NO_META_DATA_FOUND); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :