comparison 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
comparison
equal deleted inserted replaced
8:9cb3ee7ed8ba 9:8facd8545a12
2 2
3 import com.google.gwt.core.client.EntryPoint; 3 import com.google.gwt.core.client.EntryPoint;
4 import com.google.gwt.core.client.GWT; 4 import com.google.gwt.core.client.GWT;
5 import com.google.gwt.user.client.rpc.AsyncCallback; 5 import com.google.gwt.user.client.rpc.AsyncCallback;
6 import com.google.gwt.user.client.ui.RootPanel; 6 import com.google.gwt.user.client.ui.RootPanel;
7 import com.google.gwt.xml.client.XMLParser;
7 8
8 import com.smartgwt.client.widgets.layout.VLayout; 9 import com.smartgwt.client.widgets.layout.VLayout;
9 10
10 import de.intevation.artifacts.common.model.User; 11 import de.intevation.artifacts.common.model.User;
11 12
13 import de.intevation.flys.client.shared.model.Artifact;
12 import de.intevation.flys.client.shared.model.Collection; 14 import de.intevation.flys.client.shared.model.Collection;
13 import de.intevation.flys.client.shared.model.DefaultCollection; 15 import de.intevation.flys.client.shared.model.DefaultCollection;
14 16
17 import de.intevation.flys.client.client.services.ArtifactService;
18 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
15 import de.intevation.flys.client.client.services.UserService; 19 import de.intevation.flys.client.client.services.UserService;
16 import de.intevation.flys.client.client.services.UserServiceAsync; 20 import de.intevation.flys.client.client.services.UserServiceAsync;
17 import de.intevation.flys.client.client.ui.CollectionView; 21 import de.intevation.flys.client.client.ui.CollectionView;
18 import de.intevation.flys.client.client.ui.FLYSView; 22 import de.intevation.flys.client.client.ui.FLYSView;
19 import de.intevation.flys.client.client.ui.FLYSWorkspace; 23 import de.intevation.flys.client.client.ui.FLYSWorkspace;
28 */ 32 */
29 public class FLYS implements EntryPoint { 33 public class FLYS implements EntryPoint {
30 34
31 /** The UserService used to retrieve information about the current user. */ 35 /** The UserService used to retrieve information about the current user. */
32 protected UserServiceAsync userService = GWT.create(UserService.class); 36 protected UserServiceAsync userService = GWT.create(UserService.class);
37
38 /** The ArtifactService used to communicate with the Artifact server. */
39 protected ArtifactServiceAsync artifactService =
40 GWT.create(ArtifactService.class);
33 41
34 /** The menu bar at the top of the application.*/ 42 /** The menu bar at the top of the application.*/
35 protected MainMenu menu; 43 protected MainMenu menu;
36 44
37 /** The content window. It takes the whole space beneath the menu bar.*/ 45 /** The content window. It takes the whole space beneath the menu bar.*/
61 vertical.addMember(menu); 69 vertical.addMember(menu);
62 vertical.addMember(view); 70 vertical.addMember(view);
63 71
64 RootPanel.get("app").add(vertical); 72 RootPanel.get("app").add(vertical);
65 73
74 initConfiguration();
75
66 userService.getCurrentUser(new AsyncCallback<User>() { 76 userService.getCurrentUser(new AsyncCallback<User>() {
67 public void onFailure(Throwable caught) { 77 public void onFailure(Throwable caught) {
68 GWT.log("Could not find a logged in user."); 78 GWT.log("Could not find a logged in user.");
69 // TODO do something 79 // TODO do something
70 } 80 }
81 }); 91 });
82 } 92 }
83 93
84 94
85 /** 95 /**
96 * This method should be called at system start. It initialzes the client
97 * configuration.
98 */
99 protected void initConfiguration() {
100 String xml = FLYSResources.INSTANCE.initialConfiguration().getText();
101 Config.getInstance(XMLParser.parse(xml));
102 }
103
104
105 /**
86 * This method creates a new CollectionView and adds it to the workspace. 106 * This method creates a new CollectionView and adds it to the workspace.
87 */ 107 */
88 public void newProject() { 108 public void newProject() {
89 // TODO Call the REST service to create a new Collection 109 // TODO Call the REST service to create a new Collection
90 // TODO Use the UUID of the Collection to add a new CollectionView! 110 // TODO Use the UUID of the Collection to add a new CollectionView!
91 Collection c = new DefaultCollection(new java.util.Date().toString()); 111 Collection c = new DefaultCollection(new java.util.Date().toString());
92 workspace.addView(c.identifier(), new CollectionView(c)); 112 workspace.addView(c.identifier(), new CollectionView(this, c));
113 }
114
115
116 /**
117 * Create a new Artifact.
118 */
119 public void newArtifact(String factory) {
120 artifactService.create(factory, new AsyncCallback<Artifact>() {
121 public void onFailure(Throwable caught) {
122 GWT.log("Could not create the new artifact.");
123 GWT.log(caught.getMessage());
124 }
125
126 public void onSuccess(Artifact artifact) {
127 GWT.log("Successfully created a new artifact.");
128 }
129 });
93 } 130 }
94 } 131 }
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org