Revision: 5058
          http://sourceforge.net/p/jump-pilot/code/5058
Author:   michaudm
Date:     2016-10-08 21:27:44 +0000 (Sat, 08 Oct 2016)
Log Message:
-----------
Improve Move Selected Layerables to another category

Modified Paths:
--------------
    core/trunk/ChangeLog
    core/trunk/src/language/jump_fr.properties
    
core/trunk/src/org/openjump/core/ui/plugin/layer/MoveSelectedLayersPlugIn.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2016-10-08 17:19:35 UTC (rev 5057)
+++ core/trunk/ChangeLog        2016-10-08 21:27:44 UTC (rev 5058)
@@ -7,6 +7,7 @@
   * Fix bug #433 throwing exception when applying scale limits in bad order
   * Optimization : changeStyle was applying the new style two times
   * Fix #432 Zipped datasource should be unmodifiable
+  * Improve MoveSelectedLayerable to another category
 
 2016-10-08 Giuseppe Aruta  <[email protected]>
   * Upgraded Sextante (Correct bug #410. Added Sextante Data Explorer)

Modified: core/trunk/src/language/jump_fr.properties
===================================================================
--- core/trunk/src/language/jump_fr.properties  2016-10-08 17:19:35 UTC (rev 
5057)
+++ core/trunk/src/language/jump_fr.properties  2016-10-08 21:27:44 UTC (rev 
5058)
@@ -1969,7 +1969,7 @@
 ui.plugin.MoveLayerablePlugIn.move-layer-down = D\u00e9placer la couche vers 
le bas
 ui.plugin.MoveLayerablePlugIn.move-layer-up = D\u00e9placer la couche vers le 
haut
 ui.plugin.MoveLayerablePlugIn.destination-category = Cat\u00e9gorie cible
-ui.plugin.MoveLayerablePlugIn.move-to-category = D\u00e9placer la couche 
s\u00e9lectionn\u00e9e vers une autre cat\u00e9gorie
+ui.plugin.MoveLayerablePlugIn.move-to-category = D\u00e9placer les couches 
s\u00e9lectionn\u00e9es vers une autre cat\u00e9gorie
 ui.plugin.MoveLayerablePlugIn.move-to-top = D\u00e9placer en haut
 ui.plugin.MoveLayerablePlugIn.move-to-bottom = D\u00e9placer en bas
 
ui.plugin.OpenProjectPlugIn.The-project-has-been-moved-Do-you-want-to-update-paths-below-the-project-folder
 = Le projet a \u00e9t\u00e9 d\u00e9plac\u00e9. Voulez-vous mettre \u00e0 jour 
les chemins des fichiers situ\u00e9s dans le r\u00e9pertoire du projet ?.

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/layer/MoveSelectedLayersPlugIn.java
===================================================================
--- 
core/trunk/src/org/openjump/core/ui/plugin/layer/MoveSelectedLayersPlugIn.java  
    2016-10-08 17:19:35 UTC (rev 5057)
+++ 
core/trunk/src/org/openjump/core/ui/plugin/layer/MoveSelectedLayersPlugIn.java  
    2016-10-08 21:27:44 UTC (rev 5058)
@@ -1,7 +1,5 @@
 package org.openjump.core.ui.plugin.layer;
 
-
-
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.ArrayList;
@@ -11,70 +9,42 @@
 import javax.swing.JComboBox;
 import com.vividsolutions.jump.I18N;
 import com.vividsolutions.jump.workbench.WorkbenchContext;
-import com.vividsolutions.jump.workbench.model.Layer;
 import com.vividsolutions.jump.workbench.model.Layerable;
 import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
 import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
 import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.ui.GUIUtil;
 import com.vividsolutions.jump.workbench.ui.LayerNamePanel;
-import com.vividsolutions.jump.workbench.ui.TreeLayerNamePanel;
 import com.vividsolutions.jump.workbench.ui.images.IconLoader;
 import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller;
 import com.vividsolutions.jump.workbench.model.LayerManager;
 import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
 import com.vividsolutions.jump.workbench.model.Category;
 
+/**
+ * Move selected layer to category plugin
+ * @author Giuseppe Aruta 2013-11-24
+ */
+public class MoveSelectedLayersPlugIn extends AbstractPlugIn {
 
-public class MoveSelectedLayersPlugIn extends AbstractPlugIn
-{    
-        
+       // Adapted from Skyjump MoveSelectedLayers PlugIn to OpenJUMP 
(2013-11-24)
+       // - Internationalized
+       // - Extended the Plugin to WMS layers and Sextante Raster layers
+       // TODO: make undoable
        
-       
-       /**
-        * 
-        * @author Giuseppe Aruta 2013-11-24
-        * Move selected layer to category plugin
-        * Adapted from Skyjump MoveSelectedLayers PlugIn to OpenJUMP
-        * (2013-11-24)
-        * - Internationalized
-        * - Extended the Plugin to WMS layers and Sextante Raster layers
-        * TODO: make undoable
-        * 
-        */
-       
        private final static String CATEGORIES = I18N
                      
.get("ui.plugin.MoveLayerablePlugIn.destination-category");
+
        private boolean moveToTop = true;
-       public static final ImageIcon ICON = 
IconLoader.icon("bullet_arrow_up_down.png"); 
+
+       public static final ImageIcon ICON = 
IconLoader.icon("bullet_arrow_up_down.png");
+
        public String getName() {
-                   return I18N
-                             
.get("ui.plugin.MoveLayerablePlugIn.move-to-category");
-               }
-       
-    public void initialize(PlugInContext context) throws Exception
-    {
-        WorkbenchContext workbenchContext = context.getWorkbenchContext();
-        FeatureInstaller featureInstaller = new 
FeatureInstaller(workbenchContext);
-        @SuppressWarnings("unused")
-               JPopupMenu layerNamePopupMenu = workbenchContext.getWorkbench()
-                                                        .getFrame()
-                                                        
.getLayerNamePopupMenu();
-        
-       
-                       
-           ///Deactivated as it loads through Default-Plugins.xml   
-         /*     
-        featureInstaller.addPopupMenuPlugin(layerNamePopupMenu,
-            this, getName(),
-            false, null,
-            createEnableCheck(workbenchContext));     */    
-    }
-    
+               return 
I18N.get("ui.plugin.MoveLayerablePlugIn.move-to-category");
+       }
 
-    protected Layerable selectedLayerable(LayerNamePanel layerNamePanel) {
-        return (Layerable) 
layerNamePanel.selectedNodes(Layerable.class).iterator().next();
-    }
+       // Initialized through through Default-Plugins.xml
 
     public boolean execute(PlugInContext context) throws Exception
     {
@@ -96,8 +66,8 @@
                              
.get("ui.plugin.MoveLayerablePlugIn.move-to-top"), "position", moveToTop, 
"Insert at top of category");
                dialog.addRadioButton(I18N
                              
.get("ui.plugin.MoveLayerablePlugIn.move-to-bottom"), "position", !moveToTop, 
"Insert at bottom of category");
-               dialog.setVisible(true);
-               
+                       GUIUtil.centreOnWindow(dialog);
+                       dialog.setVisible(true);
                if (! dialog.wasOKPressed()) 
                { 
                        return false; 
@@ -113,19 +83,15 @@
                        
                        
                    
context.getWorkbenchFrame().getOutputFrame().createNewDocument();
-                   Collection layerCollection = (Collection) 
context.getWorkbenchContext().getLayerNamePanel().selectedNodes(Layerable.class);
-                   //Layer[] selectedLayers = (Layer[]) 
layerCollection.toArray(new Layer[]{});
+                   Collection layerCollection = context.getWorkbenchContext()
+                                               
.getLayerNamePanel().selectedNodes(Layerable.class);
                    Layerable[] selectedLayers = (Layerable[]) 
layerCollection.toArray(new Layerable[]{});
-                   
-                   
-                   
+
                    if (moveToTop)
                    {
                            for (int i = selectedLayers.length - 1; i >= 0; i--)
                            {
-                               
-                               
-                               Layerable layerable = (Layerable) 
selectedLayers[i];
+                               Layerable layerable = selectedLayers[i];
                                layerManager.remove(layerable);
                                layerManager.addLayerable(categoryName, 
layerable);
                            }
@@ -137,7 +103,7 @@
                        
                            for (int i = selectedLayers.length - 1; i >= 0; i--)
                            {
-                               Layerable layerable = (Layerable) 
selectedLayers[i];
+                               Layerable layerable = selectedLayers[i];
                                Category layerCat = 
layerManager.getCategory(layerable);
                                layerManager.remove(layerable);
                                if (layerCat == destCat) 
@@ -146,8 +112,8 @@
                            }
                    }
                    //Deactivate as setCelectedLayers dosn't work with Sextante 
Raster Layer
-                  // TreeLayerNamePanel lnp = 
(TreeLayerNamePanel)context.getWorkbenchContext().getLayerNamePanel();
-                  // lnp.setSelectedLayers( selectedLayers);
+                   // TreeLayerNamePanel lnp = 
(TreeLayerNamePanel)context.getWorkbenchContext().getLayerNamePanel();
+                   // lnp.setSelectedLayers( selectedLayers);
                    return true;
                }
         }


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to