# HG changeset patch # User Ingo Weinzierl # Date 1307539306 0 # Node ID 92c200887b20cf6c652f824ae26592e926e4ef59 # Parent 046f43e1d3058071fd353eca134751bfa5a8f271 #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 diff -r 046f43e1d305 -r 92c200887b20 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Jun 08 12:43:38 2011 +0000 +++ b/flys-client/ChangeLog Wed Jun 08 13:21:46 2011 +0000 @@ -1,3 +1,21 @@ +2011-06-08 Ingo Weinzierl + + flys/issue21 (Gleiches Projekt kann mehr als einmal gleichzeitig + geƶffnet werden) + + * src/main/java/de/intevation/flys/client/client/FLYS.java: Introduced a + lock mechanism for projects. When a project is opened, it becomes + locked. Further clicks on that project in the project list will have no + effect except it brings up the project window. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Implements the CloseClickHandler interface now. The operations triggered + by the "x" in the upper right corner of the window will close and + destroy the window. This has been done automatically before. + + * src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java: + Added a new method that brings up a project window. + 2011-06-08 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java: diff -r 046f43e1d305 -r 92c200887b20 flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java --- 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 openProjects; + /** * This is the entry point method. */ public void onModuleLoad() { + openProjects = new ArrayList(); 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() { 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 : diff -r 046f43e1d305 -r 92c200887b20 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Jun 08 12:43:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Jun 08 13:21:46 2011 +0000 @@ -11,6 +11,8 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.events.CloseClientEvent; +import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.TabSet; @@ -49,7 +51,7 @@ extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, OutputModesChangeHandler, HasOutputModesChangeHandlers, - ParameterChangeHandler + ParameterChangeHandler, CloseClickHandler { /** The ArtifactService used to communicate with the Artifact server. */ protected CreateCollectionServiceAsync createCollectionService = @@ -113,6 +115,7 @@ addCollectionChangeHandler(parameterList); addOutputModesChangeHandler(this); addOutputModesChangeHandler(parameterList); + addCloseClickHandler(this); parameterList.addParameterChangeHandler(this); @@ -137,6 +140,7 @@ addCollectionChangeHandler(parameterList); addOutputModesChangeHandler(this); addOutputModesChangeHandler(parameterList); + addCloseClickHandler(this); parameterList.addParameterChangeHandler(this); @@ -476,5 +480,11 @@ } } } + + + public void onCloseClick(CloseClientEvent event) { + hide(); + destroy(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 046f43e1d305 -r 92c200887b20 flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java Wed Jun 08 12:43:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java Wed Jun 08 13:21:46 2011 +0000 @@ -2,8 +2,8 @@ import com.smartgwt.client.widgets.Canvas; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; /** @@ -20,7 +20,7 @@ /** A map that contains the open CollectionViews. */ - protected List views; + protected Map views; /** @@ -28,7 +28,7 @@ * CollectionViews opened. */ public FLYSWorkspace() { - views = new ArrayList(); + views = new HashMap(); } @@ -38,14 +38,26 @@ * * @param collectionView A new CollectionView. */ - public void addView(CollectionView collectionView) { + public void addView(String uuid, CollectionView collectionView) { int num = views != null ? views.size() : 0; int factor = num % MAX_WINDOWS; collectionView.moveTo(factor * WINDOW_OFFSET, factor * WINDOW_OFFSET); - views.add(collectionView); + views.put(uuid, collectionView); addChild(collectionView); } + + + public void removeProject(String uuid) { + views.remove(uuid); + } + + + public void bringUp(String uuid) { + CollectionView view = views.get(uuid); + + view.show(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :