Michaël Michaud wrote: Hi,
> > ok. I've attached patch which changes the following: > > > > * new feature collections are again unmodified by default > > * PlugInContext has an added addLayer method taking a > > featureCollectionModified parameter for convenience > > * when OpenJUMP is closed, and no layers have been modified, it still > > asks whether you want to really exit the workbench > > > > What are the opinions on this? > > > Thanks to have worked on this problem. > If I understand correctly, proposed change are : > > 1 - OpenJUMP will always asks for confirmation before closing. > 2 - OpenJUMP will still inform the user that some layers have been > modified if these layers have really been modified (not just created) > 3 - Programmer can now create new layers as unmodified or as modified > layers (see below my remark) > 4 - Existing plugin produce unmodified layers. > > There is point 3 that I dislike for the following reason : If we have > not a clear policy about what is a modified layer, we'll soon have half > newly created layers considered as modified and half considered as > unmodified, thus confusing the user and introducing inconsistencies. yes, I agree, I also think that a sensible default is better that such a confusion. > To solve my initial problem, I think I can rely on the > getDataSourceQuery which returns null for layers which are not yet saved > to disk. > My proposition is to let you change everything you put in the patch > except the new method in PluginContext (there is also a typo in the key > added in language files and in confirmClose method) Yeah, I'm trying to get the message right and end up with a typo in the key ;-) By the way, do I need to insert the keys into all the language files, or are the ones I know a translation for sufficient? > I can see if a test on every Layer.getDataSourceQuery in the > WorkbenchFrame.confirmClose method can solve my initial problem, by > informing the user there is still one, or to, or n layers without > datasource. I think it's a great idea to just check for null datasources, and warn the user if there are such layers. It's the cleanest solution to the problem. I've attached a patch with the following: * new feature collections are again unmodified by default * PlugInContext is unmodified * when OpenJUMP is closed, and there are layers with null data sources, the user is asked whether he still wants to exit the workbench Do we then still need the confirmation dialog when nothing is modified and no datasources are null? For now I've removed it again (personally I don't like to be asked too many questions that could have been avoided), but it would be easy enough to add it back. Best regards, Andreas -- l a t / l o n GmbH Aennchenstrasse 19 53177 Bonn, Germany phone ++49 +228 18496-0 fax ++49 +228 1849629 http://www.lat-lon.de http://www.deegree.org Follow deegree on Twitter: http://twitter.com/deegree_org
Index: src/language/jump.properties =================================================================== --- src/language/jump.properties (revision 2002) +++ src/language/jump.properties (working copy) @@ -1701,6 +1701,8 @@ ui.WorkbenchFrame.committed-memory = Committed Memory ui.WorkbenchFrame.continue = Continue ui.WorkbenchFrame.dataset = Dataset +ui.WorkbenchFrame.do-you-really-want-to-close-openjump-generated-layers-not-saved = Do you really want to close OpenJUMP?\n\ +{0} automatically generated layers have not been saved yet. ui.WorkbenchFrame.do-you-want-to-close-them-also = Do you want to close them also ? ui.WorkbenchFrame.exit = Exit ui.WorkbenchFrame.exit-jump = Exit OpenJUMP Index: src/language/jump_en.properties =================================================================== --- src/language/jump_en.properties (revision 2002) +++ src/language/jump_en.properties (working copy) @@ -1663,6 +1663,8 @@ ui.WorkbenchFrame.committed-memory = Committed Memory ui.WorkbenchFrame.continue = Continue ui.WorkbenchFrame.dataset = Dataset +ui.WorkbenchFrame.do-you-really-want-to-close-openjump-generated-layers-not-saved = Do you really want to close OpenJUMP?\n\ +{0} automatically generated layers have not been saved yet. ui.WorkbenchFrame.do-you-want-to-close-them-also = Do you want to close them also ? ui.WorkbenchFrame.exit = Exit ui.WorkbenchFrame.exit-jump = Exit OpenJUMP Index: src/language/jump_de.properties =================================================================== --- src/language/jump_de.properties (revision 2002) +++ src/language/jump_de.properties (working copy) @@ -1664,6 +1664,8 @@ ui.WorkbenchFrame.committed-memory = Verwendeter Speicher ui.WorkbenchFrame.continue = Weiter ui.WorkbenchFrame.dataset = Datensatz +ui.WorkbenchFrame.do-you-really-want-to-close-openjump-generated-layers-not-saved = Wollen Sie OpenJUMP wirklich beenden?\n\ +{0} automatisch erzeugte Ebenen wurden noch nicht gespeichert. ui.WorkbenchFrame.do-you-want-to-close-them-also = Wollen Sie diese ebenfalls schliessen? ui.WorkbenchFrame.exit = OpenJUMP beenden ui.WorkbenchFrame.exit-jump = JUMP Beenden Index: src/com/vividsolutions/jump/workbench/model/LayerManager.java =================================================================== --- src/com/vividsolutions/jump/workbench/model/LayerManager.java (revision 2002) +++ src/com/vividsolutions/jump/workbench/model/LayerManager.java (working copy) @@ -31,35 +31,34 @@ */ package com.vividsolutions.jump.workbench.model; +import java.awt.Color; +import java.awt.geom.Line2D; +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import javax.swing.JInternalFrame; + import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; import com.vividsolutions.jts.util.Assert; - import com.vividsolutions.jump.coordsys.CoordinateSystem; import com.vividsolutions.jump.coordsys.Reprojector; import com.vividsolutions.jump.feature.Feature; import com.vividsolutions.jump.feature.FeatureCollection; import com.vividsolutions.jump.util.Blackboard; -import com.vividsolutions.jump.util.Block; -import com.vividsolutions.jump.workbench.ui.WorkbenchFrame; import com.vividsolutions.jump.workbench.ui.GUIUtil; -import com.vividsolutions.jump.workbench.ui.LayerViewPanel; import com.vividsolutions.jump.workbench.ui.LayerViewPanelProxy; +import com.vividsolutions.jump.workbench.ui.WorkbenchFrame; import com.vividsolutions.jump.workbench.ui.renderer.style.BasicStyle; import com.vividsolutions.jump.workbench.ui.style.AbstractPalettePanel; -import java.awt.Color; -import java.awt.geom.Line2D; - -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; - -import java.util.*; - -import javax.swing.JInternalFrame; - /** * Registry of Layers in a Task. * @see Task @@ -759,6 +758,19 @@ return layersWithModifiedFeatureCollections; } + public LinkedList getLayersWithNullDataSource(){ + LinkedList list = new LinkedList(); + + for (Iterator i = iterator(); i.hasNext();) { + Layer layer = (Layer) i.next(); + if(layer.getDataSourceQuery() == null) { + list.add(layer); + } + } + + return list; + } + public void setCoordinateSystem(CoordinateSystem coordinateSystem) { this.coordinateSystem = coordinateSystem; Index: src/com/vividsolutions/jump/workbench/model/Layer.java =================================================================== --- src/com/vividsolutions/jump/workbench/model/Layer.java (revision 2002) +++ src/com/vividsolutions/jump/workbench/model/Layer.java (working copy) @@ -115,9 +115,6 @@ getBasicStyle().setLineColor(defaultLineColor(fillColor)); getBasicStyle().setAlpha(150); setFeatureCollection(featureCollection); - // michaelm [2009-02-20] consider that a new layer is modified - // so that a confirmation is asked before application closing - featureCollectionModified = true; } /** Index: src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java =================================================================== --- src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java (revision 2002) +++ src/com/vividsolutions/jump/workbench/ui/WorkbenchFrame.java (working copy) @@ -963,6 +963,15 @@ return layersWithModifiedFeatureCollections; } + private Collection getGeneratedLayers() { + ArrayList list = new ArrayList(); + for (Iterator i = getLayerManagers().iterator(); i.hasNext();) { + LayerManager layerManager = (LayerManager)i.next(); + list.addAll(layerManager.getLayersWithNullDataSource()); + } + return list; + } + private Collection getLayerManagers() { // Multiple windows may point to the same LayerManager, so use // a Set. [Jon Aquino] @@ -1198,7 +1207,8 @@ private class DefaultApplicationExitHandler implements ApplicationExitHandler { public void exitApplication(JFrame mainFrame) { if (confirmClose(I18N.get("ui.WorkbenchFrame.exit-jump"), - getLayersWithModifiedFeatureCollections())) { + getLayersWithModifiedFeatureCollections(), + getGeneratedLayers())) { // PersistentBlackboardPlugIn listens for when the workbench is // hidden [Jon Aquino] saveWindowState(); @@ -1224,7 +1234,8 @@ boolean lastTaskFrame = getTaskFramesAssociatedWith(layerManager).size() == 1; if (lastTaskFrame) { Collection modifiedItems = layerManager.getLayersWithModifiedFeatureCollections(); - if (confirmClose(I18N.get("ui.WorkbenchFrame.close-task"), modifiedItems)) { + Collection generatedItems = layerManager.getLayersWithNullDataSource(); + if (confirmClose(I18N.get("ui.WorkbenchFrame.close-task"), modifiedItems, generatedItems)) { // There are other internal frames associated with this task if (associatedFrames.size() != 0) { // Confirm you want to close them first @@ -1269,10 +1280,19 @@ } } - private boolean confirmClose(String action, Collection modifiedLayers) { - if (modifiedLayers.isEmpty()) { - return true; - } + private boolean confirmClose(String action, Collection modifiedLayers, Collection generatedLayers) { + if (modifiedLayers.isEmpty()) { + if(generatedLayers.isEmpty()){ + return true; + } + JOptionPane pane = new JOptionPane(I18N.getMessage("ui.WorkbenchFrame.do-you-really-want-to-close-openjump-generated-layers-not-saved", new Object[]{Integer.valueOf(generatedLayers.size())}), + JOptionPane.QUESTION_MESSAGE); + pane.setOptions(new String[] { + action, I18N.get("ui.WorkbenchFrame.cancel") + }); + pane.createDialog(this, "JUMP").setVisible(true); + return pane.getValue().equals(action); + } JOptionPane pane = new JOptionPane( StringUtil.split( modifiedLayers.size()
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel