Revision: 5083
          http://sourceforge.net/p/jump-pilot/code/5083
Author:   michaudm
Date:     2016-10-18 19:16:56 +0000 (Tue, 18 Oct 2016)
Log Message:
-----------
Second attempt to avoid editing invisible layers

Modified Paths:
--------------
    core/trunk/ChangeLog
    
core/trunk/src/com/vividsolutions/jump/workbench/model/AbstractLayerable.java
    core/trunk/src/com/vividsolutions/jump/workbench/model/LayerManager.java
    core/trunk/src/com/vividsolutions/jump/workbench/ui/TreeLayerNamePanel.java
    
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2016-10-17 11:57:53 UTC (rev 5082)
+++ core/trunk/ChangeLog        2016-10-18 19:16:56 UTC (rev 5083)
@@ -6,6 +6,7 @@
 2016-10-15 mmichaud <m.michael.mich...@orange.fr>
   * FR #237 : add an option in ViewOptionsPlugIn to synchronize/desynchronize
     selection in LayerView AttributePanel (synchronized by default)
+  * Fix #436 : make invisible layers not editable.
 
 2016-10-13 mmichaud <m.michael.mich...@orange.fr>
   * EditOptions are now persistent except rolling back invalid edits which is

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/model/AbstractLayerable.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/model/AbstractLayerable.java   
    2016-10-17 11:57:53 UTC (rev 5082)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/model/AbstractLayerable.java   
    2016-10-18 19:16:56 UTC (rev 5083)
@@ -132,7 +132,6 @@
       return;
     }
     this.visible = visible;
-    editable = visible && editable;
     fireLayerChanged(LayerEventType.VISIBILITY_CHANGED);
   }
 

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/model/LayerManager.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/model/LayerManager.java    
2016-10-17 11:57:53 UTC (rev 5082)
+++ core/trunk/src/com/vividsolutions/jump/workbench/model/LayerManager.java    
2016-10-18 19:16:56 UTC (rev 5083)
@@ -787,8 +787,8 @@
      * Editability is not enforced; all parties are responsible for heeding the
      * editability of a layer.
      */
-    public Collection getEditableLayers() {
-        ArrayList editableLayers = new ArrayList();
+    public Collection<Layer> getEditableLayers() {
+        ArrayList<Layer> editableLayers = new ArrayList<>();
 
         for (Iterator i = getLayers().iterator(); i.hasNext();) {
             Layer layer = (Layer) i.next();

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/TreeLayerNamePanel.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/ui/TreeLayerNamePanel.java 
2016-10-17 11:57:53 UTC (rev 5082)
+++ core/trunk/src/com/vividsolutions/jump/workbench/ui/TreeLayerNamePanel.java 
2016-10-18 19:16:56 UTC (rev 5083)
@@ -900,21 +900,17 @@
   }
 
   public static Layer chooseEditableLayer(LayerNamePanel panel) {
-    for (Iterator i = Arrays.asList(panel.getSelectedLayers()).iterator(); i
-        .hasNext();) {
-      Layer layer = (Layer) i.next();
-
-      if (layer.isEditable()) {
+    for (Layer layer : panel.getSelectedLayers()) {
+      if (layer.isEditable() && layer.isVisible()) {
         return layer;
       }
     }
-
-    if (panel.getLayerManager().getEditableLayers().isEmpty()) {
-      return null;
+    for (Layer layer : panel.getLayerManager().getEditableLayers()) {
+      if (layer.isVisible()) {
+        return layer;
+      }
     }
-
-    return (Layer) panel.getLayerManager().getEditableLayers().iterator()
-        .next();
+    return null;
   }
 
   public Layer chooseEditableLayer() {

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java  
    2016-10-17 11:57:53 UTC (rev 5082)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/EditablePlugIn.java  
    2016-10-18 19:16:56 UTC (rev 5083)
@@ -82,11 +82,11 @@
     // set states for each
 
     for (Layerable layerable : layers) {
-      if (isWritable(layerable) && layerable.isVisible()) {
+      if (isWritable(layerable)) {
         if (single) setAllLayersToUneditable(context);
         //if (makeEditable) setAllLayersToUneditable(context);
         layerable.setEditable(makeEditable);
-      } else if (layerable.isVisible()) {
+      } else {
         String message = "<html><br>" + I18N.getMessage(CONFIRMATION_1, 
"<i>'"+layerable.getName()+"'</i>");
         message += "<br><br>" + I18N.get(CONFIRMATION_2) + "<br></html>";
         JLabel label = new JLabel(message);


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to