Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 14:fe2f4d1dd784
Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
flys-client/trunk@1326 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Feb 2011 11:52:55 +0000 |
parents | 8d9075c07667 |
children | f48b2cb2e219 |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; 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.VLayout; import com.smartgwt.client.widgets.tab.Tab; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; 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.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class CollectionView extends Window { /** The ArtifactService used to communicate with the Artifact server. */ protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class); /** The message class that provides i18n strings.*/ FLYSMessages messages = GWT.create(FLYSMessages.class); /** The FLYS instance used to call services.*/ protected FLYS flys; /** The collection to be displayed.*/ protected Collection collection; /** TODO The artifact needs to be removed here after the Collection stuff in * the server has been finished! */ protected Artifact artifact; /** The parameter tab.*/ protected Tab parameterTab; /** The output tab.*/ protected Tab outputTab; /** * This constructor creates a new CollectionView that is used to display the * <i>collection</i>. * * @param collection The collection to be displayed. */ public CollectionView(FLYS flys, Collection collection) { this.flys = flys; this.collection = collection; init(); } /** * This method handles the initial layout stuff. */ protected void init() { setWidth(600); setHeight(400); 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); if (isNew()) { layout.addMember(renderNew()); } } /** * This method returns true, if the Collection is new and no plugins has * been chosen. * * @return true, if the Collection is new. */ public boolean isNew() { return true; } /** * This method creates a Canvas displaying the plugins of FLYS. * * @return a Canvas that displays the plugins of FLYS. */ protected Canvas renderNew() { VLayout layout = new VLayout(); layout.setWidth100(); DynamicForm form = new DynamicForm(); RadioGroupItem radio = new RadioGroupItem("plugin"); radio.setShowTitle(false); radio.setVertical(false); radio.setValueMap( messages.winfo(), messages.minfo(), messages.map(), messages.fix()); form.setFields(radio); IButton go = new IButton(messages.next()); go.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String serverUrl = Config.getInstance().getServerUrl(); artifactService.create( serverUrl, "winfo", new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Could not create the new artifact."); GWT.log(caught.getMessage()); } public void onSuccess(Artifact artifact) { GWT.log("Successfully created a new artifact."); setArtifact(artifact); } }); } }); layout.addMember(form); layout.addMember(go); return layout; } /** * Set the current artifact. * * @param artifact The new artifact. */ protected void setArtifact(Artifact artifact) { this.artifact = artifact; updateView(); } protected void updateView() { GWT.log("Update the view of the artifact: " + artifact.getUuid()); // TODO display the artifact information / data } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :