Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Tue Apr 12 10:54:59 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Tue Apr 12 11:01:09 2011 +0000 @@ -11,11 +11,17 @@ import com.smartgwt.client.widgets.layout.HLayout; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.CollectionItem; import de.intevation.flys.client.shared.model.River; import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; +import de.intevation.flys.client.client.services.DescribeCollectionService; +import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync; +import de.intevation.flys.client.client.services.GetArtifactService; +import de.intevation.flys.client.client.services.GetArtifactServiceAsync; import de.intevation.flys.client.client.services.RiverService; import de.intevation.flys.client.client.services.RiverServiceAsync; import de.intevation.flys.client.client.services.UserService; @@ -49,6 +55,15 @@ protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class); + /** The ArtifactService used to communicate with the Artifact server. */ + protected DescribeCollectionServiceAsync describeCollectionService = + GWT.create(DescribeCollectionService.class); + + /** The GetArtifactService used to open an existing collection. */ + protected GetArtifactServiceAsync getArtifactService = + GWT.create(GetArtifactService.class); + + /** The menu bar at the top of the application.*/ protected MainMenu menu; @@ -115,7 +130,7 @@ menu.setCurrentUser(user); - projectList = new ProjectList(user); + projectList = new ProjectList(FLYS.this, user); workspace = new FLYSWorkspace(); view.setProjectList(projectList); view.setFLYSWorkspace(workspace); @@ -216,6 +231,56 @@ } + public void openProject(String collectionID) { + if (collectionID == null) { + return; + } + + GWT.log("Open existing project: " + collectionID); + + Config config = Config.getInstance(); + final String url = config.getServerUrl(); + + describeCollectionService.describe(collectionID, url, + new AsyncCallback<Collection>() { + public void onFailure(Throwable caught) { + SC.warn(MSG.getString(caught.getMessage())); + } + + public void onSuccess(Collection c) { + final Collection collection = c; + final CollectionItem item = c.getItem(0); + + if (item == null) { + SC.warn(MSG.error_load_parameterization()); + return; + } + + getArtifactService.getArtifact( + url, + item.identifier(), + item.hash(), + new AsyncCallback<Artifact>() { + public void onFailure(Throwable caught) { + SC.warn(MSG.getString(caught.getMessage())); + } + + public void onSuccess(Artifact artifact) { + CollectionView view = new CollectionView( + FLYS.this, collection, artifact); + + view.addCollectionChangeHandler( + getProjectList()); + + workspace.addView(view); + } + }); + + } + }); + } + + /** * Create a new Artifact. */