Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 9:8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
flys-client/trunk@1317 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 16 Feb 2011 14:50:06 +0000 |
parents | e2b3966b40ca |
children | fe2f4d1dd784 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Fri Feb 11 13:48:17 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Feb 16 14:50:06 2011 +0000 @@ -4,14 +4,18 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.xml.client.XMLParser; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.artifacts.common.model.User; +import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.DefaultCollection; +import de.intevation.flys.client.client.services.ArtifactService; +import de.intevation.flys.client.client.services.ArtifactServiceAsync; import de.intevation.flys.client.client.services.UserService; import de.intevation.flys.client.client.services.UserServiceAsync; import de.intevation.flys.client.client.ui.CollectionView; @@ -31,6 +35,10 @@ /** The UserService used to retrieve information about the current user. */ protected UserServiceAsync userService = GWT.create(UserService.class); + /** The ArtifactService used to communicate with the Artifact server. */ + protected ArtifactServiceAsync artifactService = + GWT.create(ArtifactService.class); + /** The menu bar at the top of the application.*/ protected MainMenu menu; @@ -63,6 +71,8 @@ RootPanel.get("app").add(vertical); + initConfiguration(); + userService.getCurrentUser(new AsyncCallback<User>() { public void onFailure(Throwable caught) { GWT.log("Could not find a logged in user."); @@ -83,13 +93,40 @@ /** + * This method should be called at system start. It initialzes the client + * configuration. + */ + protected void initConfiguration() { + String xml = FLYSResources.INSTANCE.initialConfiguration().getText(); + Config.getInstance(XMLParser.parse(xml)); + } + + + /** * This method creates a new CollectionView and adds it to the workspace. */ public void newProject() { // TODO Call the REST service to create a new Collection // TODO Use the UUID of the Collection to add a new CollectionView! Collection c = new DefaultCollection(new java.util.Date().toString()); - workspace.addView(c.identifier(), new CollectionView(c)); + workspace.addView(c.identifier(), new CollectionView(this, c)); + } + + + /** + * Create a new Artifact. + */ + public void newArtifact(String factory) { + artifactService.create(factory, 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."); + } + }); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :