comparison flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 225:9040663aee01

Filled the context menu point 'Open project' of the ProjectList with life - it opens a new window displaying the parameterization of the selected project. flys-client/trunk@1670 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Apr 2011 11:01:09 +0000
parents 907b61e4d702
children 924da6695800
comparison
equal deleted inserted replaced
224:a4a68b4ee2a3 225:9040663aee01
9 import com.smartgwt.client.util.SC; 9 import com.smartgwt.client.util.SC;
10 import com.smartgwt.client.widgets.layout.VLayout; 10 import com.smartgwt.client.widgets.layout.VLayout;
11 import com.smartgwt.client.widgets.layout.HLayout; 11 import com.smartgwt.client.widgets.layout.HLayout;
12 12
13 import de.intevation.flys.client.shared.model.Artifact; 13 import de.intevation.flys.client.shared.model.Artifact;
14 import de.intevation.flys.client.shared.model.Collection;
15 import de.intevation.flys.client.shared.model.CollectionItem;
14 import de.intevation.flys.client.shared.model.River; 16 import de.intevation.flys.client.shared.model.River;
15 import de.intevation.flys.client.shared.model.User; 17 import de.intevation.flys.client.shared.model.User;
16 18
17 import de.intevation.flys.client.client.services.ArtifactService; 19 import de.intevation.flys.client.client.services.ArtifactService;
18 import de.intevation.flys.client.client.services.ArtifactServiceAsync; 20 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
21 import de.intevation.flys.client.client.services.DescribeCollectionService;
22 import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync;
23 import de.intevation.flys.client.client.services.GetArtifactService;
24 import de.intevation.flys.client.client.services.GetArtifactServiceAsync;
19 import de.intevation.flys.client.client.services.RiverService; 25 import de.intevation.flys.client.client.services.RiverService;
20 import de.intevation.flys.client.client.services.RiverServiceAsync; 26 import de.intevation.flys.client.client.services.RiverServiceAsync;
21 import de.intevation.flys.client.client.services.UserService; 27 import de.intevation.flys.client.client.services.UserService;
22 import de.intevation.flys.client.client.services.UserServiceAsync; 28 import de.intevation.flys.client.client.services.UserServiceAsync;
23 import de.intevation.flys.client.client.ui.CollectionView; 29 import de.intevation.flys.client.client.ui.CollectionView;
47 53
48 /** The ArtifactService used to communicate with the Artifact server. */ 54 /** The ArtifactService used to communicate with the Artifact server. */
49 protected ArtifactServiceAsync artifactService = 55 protected ArtifactServiceAsync artifactService =
50 GWT.create(ArtifactService.class); 56 GWT.create(ArtifactService.class);
51 57
58 /** The ArtifactService used to communicate with the Artifact server. */
59 protected DescribeCollectionServiceAsync describeCollectionService =
60 GWT.create(DescribeCollectionService.class);
61
62 /** The GetArtifactService used to open an existing collection. */
63 protected GetArtifactServiceAsync getArtifactService =
64 GWT.create(GetArtifactService.class);
65
66
52 /** The menu bar at the top of the application.*/ 67 /** The menu bar at the top of the application.*/
53 protected MainMenu menu; 68 protected MainMenu menu;
54 69
55 /** The content window. It takes the whole space beneath the menu bar.*/ 70 /** The content window. It takes the whole space beneath the menu bar.*/
56 protected FLYSView view; 71 protected FLYSView view;
113 GWT.log("Found a user. Set '"+ user.getName() + "'"); 128 GWT.log("Found a user. Set '"+ user.getName() + "'");
114 setCurrentUser(user); 129 setCurrentUser(user);
115 130
116 menu.setCurrentUser(user); 131 menu.setCurrentUser(user);
117 132
118 projectList = new ProjectList(user); 133 projectList = new ProjectList(FLYS.this, user);
119 workspace = new FLYSWorkspace(); 134 workspace = new FLYSWorkspace();
120 view.setProjectList(projectList); 135 view.setProjectList(projectList);
121 view.setFLYSWorkspace(workspace); 136 view.setFLYSWorkspace(workspace);
122 137
123 readRivers(); 138 readRivers();
214 229
215 view.addCollectionChangeHandler(getProjectList()); 230 view.addCollectionChangeHandler(getProjectList());
216 } 231 }
217 232
218 233
234 public void openProject(String collectionID) {
235 if (collectionID == null) {
236 return;
237 }
238
239 GWT.log("Open existing project: " + collectionID);
240
241 Config config = Config.getInstance();
242 final String url = config.getServerUrl();
243
244 describeCollectionService.describe(collectionID, url,
245 new AsyncCallback<Collection>() {
246 public void onFailure(Throwable caught) {
247 SC.warn(MSG.getString(caught.getMessage()));
248 }
249
250 public void onSuccess(Collection c) {
251 final Collection collection = c;
252 final CollectionItem item = c.getItem(0);
253
254 if (item == null) {
255 SC.warn(MSG.error_load_parameterization());
256 return;
257 }
258
259 getArtifactService.getArtifact(
260 url,
261 item.identifier(),
262 item.hash(),
263 new AsyncCallback<Artifact>() {
264 public void onFailure(Throwable caught) {
265 SC.warn(MSG.getString(caught.getMessage()));
266 }
267
268 public void onSuccess(Artifact artifact) {
269 CollectionView view = new CollectionView(
270 FLYS.this, collection, artifact);
271
272 view.addCollectionChangeHandler(
273 getProjectList());
274
275 workspace.addView(view);
276 }
277 });
278
279 }
280 });
281 }
282
283
219 /** 284 /**
220 * Create a new Artifact. 285 * Create a new Artifact.
221 */ 286 */
222 public void newArtifact(String factory) { 287 public void newArtifact(String factory) {
223 String url = Config.getInstance().getServerUrl(); 288 String url = Config.getInstance().getServerUrl();

http://dive4elements.wald.intevation.org