Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 557:92c200887b20
#21 There might be just a single window for each project now. Users can't open a project twice.
flys-client/trunk@2083 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 08 Jun 2011 13:21:46 +0000 |
parents | 924da6695800 |
children | 347cf4a5a486 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Jun 08 12:43:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Jun 08 13:21:46 2011 +0000 @@ -1,5 +1,8 @@ package de.intevation.flys.client.client; +import java.util.ArrayList; +import java.util.List; + import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -9,6 +12,8 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.CloseClientEvent; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; @@ -85,11 +90,15 @@ /** The list of rivers supported by the server.*/ protected River[] rivers; + /** This list is used to track the opened projects.*/ + protected List<String> openProjects; + /** * This is the entry point method. */ public void onModuleLoad() { + openProjects = new ArrayList<String>(); VLayout vertical = new VLayout(); vertical.setLayoutMargin(1); @@ -231,17 +240,43 @@ } CollectionView view = new CollectionView(this); - workspace.addView(view); + workspace.addView("new-project", view); view.addCollectionChangeHandler(getProjectList()); } - public void openProject(String collectionID) { + protected void lockProject(String uuid) { + if (isProjectLocked(uuid)) { + return; + } + + openProjects.add(uuid); + } + + + protected void unlockProject(String uuid) { + openProjects.remove(uuid); + } + + + protected boolean isProjectLocked(String uuid) { + return openProjects.contains(uuid); + } + + + public void openProject(final String collectionID) { if (collectionID == null) { return; } + if (isProjectLocked(collectionID)) { + workspace.bringUp(collectionID); + return; + } + + lockProject(collectionID); + GWT.log("Open existing project: " + collectionID); Config config = Config.getInstance(); @@ -270,6 +305,7 @@ item.hash(), new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { + unlockProject(collectionID); SC.warn(MSG.getString(caught.getMessage())); } @@ -279,8 +315,11 @@ view.addCollectionChangeHandler( getProjectList()); + view.addCloseClickHandler( + new CloseCollectionViewHandler( + FLYS.this, collectionID)); - workspace.addView(view); + workspace.addView(collectionID, view); } }); @@ -309,5 +348,26 @@ } }); } + + + + /** + * This CloseClickHandler is used to remove lock on a specific Collection so + * that is might be opened again. + */ + private class CloseCollectionViewHandler implements CloseClickHandler { + protected FLYS flys; + protected String uuid; + + public CloseCollectionViewHandler(FLYS flys, String uuid) { + this.flys = flys; + this.uuid = uuid; + } + + public void onCloseClick(CloseClientEvent event) { + flys.unlockProject(uuid); + workspace.removeProject(uuid); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :