Revision 43100

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/AddLayer.java
29 29
import java.util.List;
30 30

  
31 31
import javax.swing.JOptionPane;
32
import org.apache.commons.collections.ListUtils;
33
import org.apache.commons.lang3.ArrayUtils;
32 34

  
33 35
import org.cresques.cts.ICoordTrans;
34 36
import org.cresques.cts.IProjection;
......
50 52
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
51 53
import org.gvsig.fmap.mapcontrol.MapControl;
52 54
import org.gvsig.tools.ToolsLocator;
55
import org.gvsig.tools.dataTypes.CoercionException;
56
import org.gvsig.tools.dataTypes.DataType;
57
import org.gvsig.tools.dataTypes.DataTypesManager;
53 58
import org.gvsig.tools.dispose.DisposeUtils;
54 59
import org.gvsig.tools.i18n.I18nManager;
55 60
import org.slf4j.Logger;
......
144 149
        this.execute(actionCommand, null);
145 150
    }
146 151

  
152
    public static class ArrayUtils {
153
        
154
        // FIXME: Use the class in org.gvsig.tools when this is available and remove this.
155

  
156
        /**
157
         * Return the element of the array. If the array is null or don't have
158
         * the element indicated return null.
159
         *
160
         * @param array
161
         * @param n
162
         * @return
163
         */
164
        public static Object get(Object[] array, int n) {
165
            if (array == null) {
166
                return null;
167
            }
168
            if (array.length <= n || n < 0) {
169
                return null;
170
            }
171
            return array[n];
172
        }
173

  
174
        /**
175
         * Return the element of the array if exists and if of the type
176
         * indicated. If the array is null, don't have the element indicated of
177
         * is not of the type required return null.
178
         *
179
         * @param array
180
         * @param n
181
         * @param elementClass
182
         * @return
183
         */
184
        public static Object get(Object[] array, int n, Class elementClass) {
185
            Object o = get(array, n);
186
            if (elementClass.isInstance(o)) {
187
                return o;
188
            }
189
            return null;
190
        }
191

  
192
        /**
193
         * Return the element of the array if this is a list of the indiqued
194
         * type. If the array don't have elements, is null, not is a list or the
195
         * elements of the list is not the indicated return null.
196
         *
197
         * @param array
198
         * @param n
199
         * @param elementClass
200
         * @return
201
         */
202
        public static List getListOf(Object[] array, int n, Class elementClass) {
203
            List list = (List) get(array, n, List.class);
204
            if (list == null) {
205
                return null;
206
            }
207
            if (list.isEmpty()) {
208
                return null;
209
            }
210
            if (elementClass.isInstance(list.get(0))) {
211
                return list;
212
            }
213
            return null;
214
        }
215

  
216
    }
217

  
147 218
    @Override
148 219
    public void execute(String command, Object[] args) {
149
        List<File> files = null;
150
        if (args != null && args.length >= 1 && args[0] instanceof List) {
151
            files = (List<File>) args[0];
152
        }
220
        List<File> files = ArrayUtils.getListOf(args,0,File.class);
221
        
153 222
        ApplicationManager application = ApplicationLocator.getManager();
154 223

  
155 224
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/ViewPageView.xml
24 24
    </at>
25 25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26 26
   </super>
27
   <at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/ViewPageView.xml</at>
28
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0)</at>
27
   <at name="id">/home/jjdelcerro/data/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/ViewPageView.xml</at>
28
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)</at>
29 29
   <at name="colspecs">FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE</at>
30 30
   <at name="components">
31 31
    <object classname="java.util.LinkedList">
......
106 106
         </at>
107 107
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
108 108
        </super>
109
        <at name="id">embedded.98388840</at>
109
        <at name="id">embedded.1107954882</at>
110 110
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
111 111
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
112 112
        <at name="components">
......
214 214
                 <at name="background" object="color">236,233,216</at>
215 215
                 <at name="editable">false</at>
216 216
                 <at name="name">txtDefaultProjection</at>
217
                 <at name="width">328</at>
217
                 <at name="width">623</at>
218 218
                 <at name="height">20</at>
219 219
                </object>
220 220
               </at>
......
240 240
              </at>
241 241
             </object>
242 242
            </at>
243
            <at name="name"></at>
243
            <at name="name"/>
244 244
            <at name="fill">
245 245
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
246 246
              <at name="name">fill</at>
......
382 382
         </at>
383 383
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
384 384
        </super>
385
        <at name="id">embedded.243492398</at>
385
        <at name="id">embedded.819690561</at>
386 386
        <at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE</at>
387 387
        <at name="colspecs">FILL:DEFAULT:GROW(1.0)</at>
388 388
        <at name="components">
......
433 433
                 </at>
434 434
                 <at name="actionCommand">Add new layers in invisible mode</at>
435 435
                 <at name="name">chkInvisibleNewLayers</at>
436
                 <at name="width">414</at>
436
                 <at name="width">709</at>
437 437
                 <at name="text">Add new layers in invisible mode</at>
438 438
                 <at name="height">16</at>
439 439
                </object>
......
489 489
                 </at>
490 490
                 <at name="actionCommand">Keep scale on resizing</at>
491 491
                 <at name="name">chkKeepScaleOnResizing</at>
492
                 <at name="width">414</at>
492
                 <at name="width">709</at>
493 493
                 <at name="text">Keep scale on resizing</at>
494 494
                 <at name="height">16</at>
495 495
                </object>
......
545 545
                 </at>
546 546
                 <at name="actionCommand">Open with a new maximized  view </at>
547 547
                 <at name="name">chkOpenWithANewMaximizedView</at>
548
                 <at name="width">414</at>
548
                 <at name="width">709</at>
549 549
                 <at name="text">Open with a new maximized  view </at>
550 550
                 <at name="height">16</at>
551 551
                </object>
......
572 572
              </at>
573 573
             </object>
574 574
            </at>
575
            <at name="name"></at>
575
            <at name="name"/>
576 576
            <at name="fill">
577 577
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
578 578
              <at name="name">fill</at>
......
780 780
           <at name="colspan">1</at>
781 781
           <at name="rowspan">1</at>
782 782
           <at name="halign">default</at>
783
           <at name="valign">default</at>
783
           <at name="valign">center</at>
784 784
           <at name="insets" object="insets">0,0,0,0</at>
785 785
          </object>
786 786
         </at>
......
1054 1054
             </object>
1055 1055
            </at>
1056 1056
            <at name="name">jCmbMapUnits</at>
1057
            <at name="width">419</at>
1057
            <at name="width">714</at>
1058 1058
            <at name="items">
1059 1059
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
1060 1060
              <at name="name">items</at>
......
1113 1113
             </object>
1114 1114
            </at>
1115 1115
            <at name="name">jCmbDistanceUnits</at>
1116
            <at name="width">419</at>
1116
            <at name="width">714</at>
1117 1117
            <at name="items">
1118 1118
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
1119 1119
              <at name="name">items</at>
......
1172 1172
             </object>
1173 1173
            </at>
1174 1174
            <at name="name">jCmbDistanceArea</at>
1175
            <at name="width">419</at>
1175
            <at name="width">714</at>
1176 1176
            <at name="items">
1177 1177
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
1178 1178
              <at name="name">items</at>
......
1203 1203
         </at>
1204 1204
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1205 1205
        </super>
1206
        <at name="id">embedded.519008065</at>
1206
        <at name="id">embedded.749496609</at>
1207 1207
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
1208 1208
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
1209 1209
        <at name="components">
......
1300 1300
                       <object classname="com.jeta.forms.store.properties.BevelBorderProperty">
1301 1301
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1302 1302
                         <at name="name">border</at>
1303
                         <at name="title"></at>
1304 1303
                        </super>
1305 1304
                        <at name="type">1</at>
1306 1305
                        <at name="highlightouter">
......
1309 1308
                          <at name="colorkey">default</at>
1310 1309
                         </object>
1311 1310
                        </at>
1312
                        <at name="highlightinner">
1313
                         <object classname="com.jeta.forms.store.properties.ColorProperty">
1314
                          <at name="name">dyncolor</at>
1315
                          <at name="colorkey">default</at>
1316
                         </object>
1317
                        </at>
1318 1311
                        <at name="shadowouter">
1319 1312
                         <object classname="com.jeta.forms.store.properties.ColorProperty">
1320 1313
                          <at name="name">dyncolor</at>
......
1335 1328
                  </object>
1336 1329
                 </at>
1337 1330
                 <at name="name">txtDefaultViewBackColor</at>
1338
                 <at name="width">359</at>
1331
                 <at name="width">654</at>
1339 1332
                 <at name="enabled">false</at>
1340 1333
                 <at name="height">18</at>
1341 1334
                </object>
......
1362 1355
              </at>
1363 1356
             </object>
1364 1357
            </at>
1365
            <at name="name"></at>
1358
            <at name="name"/>
1366 1359
            <at name="fill">
1367 1360
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1368 1361
              <at name="name">fill</at>
......
1444 1437
         </at>
1445 1438
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1446 1439
        </super>
1447
        <at name="id">embedded.49262127</at>
1440
        <at name="id">embedded.74096434</at>
1448 1441
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
1449 1442
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,LEFT:50DLU:NONE</at>
1450 1443
        <at name="components">
......
1485 1478
                       <object classname="com.jeta.forms.store.properties.BevelBorderProperty">
1486 1479
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1487 1480
                         <at name="name">border</at>
1488
                         <at name="title"></at>
1489 1481
                        </super>
1490 1482
                        <at name="type">1</at>
1491 1483
                        <at name="highlightouter">
......
1494 1486
                          <at name="colorkey">default</at>
1495 1487
                         </object>
1496 1488
                        </at>
1497
                        <at name="highlightinner">
1498
                         <object classname="com.jeta.forms.store.properties.ColorProperty">
1499
                          <at name="name">dyncolor</at>
1500
                          <at name="colorkey">default</at>
1501
                         </object>
1502
                        </at>
1503 1489
                        <at name="shadowouter">
1504 1490
                         <object classname="com.jeta.forms.store.properties.ColorProperty">
1505 1491
                          <at name="name">dyncolor</at>
......
1521 1507
                 </at>
1522 1508
                 <at name="background" object="color">255,255,0</at>
1523 1509
                 <at name="name">txtDefaultSelectionColor</at>
1524
                 <at name="width">222</at>
1510
                 <at name="width">517</at>
1525 1511
                 <at name="enabled">false</at>
1526 1512
                 <at name="height">18</at>
1527 1513
                </object>
......
1691 1677
                 </at>
1692 1678
                 <at name="name"></at>
1693 1679
                 <at name="width">31</at>
1694
                 <at name="text">alpha</at>
1680
                 <at name="text">Alpha</at>
1695 1681
                 <at name="fill">
1696 1682
                  <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1697 1683
                   <at name="name">fill</at>
......
1722 1708
              </at>
1723 1709
             </object>
1724 1710
            </at>
1725
            <at name="name"></at>
1711
            <at name="name"/>
1726 1712
            <at name="fill">
1727 1713
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1728 1714
              <at name="name">fill</at>
......
1812 1798
          <at name="properties">
1813 1799
           <object classname="com.jeta.forms.store.support.PropertyMap">
1814 1800
            <at name="name">txtZoomInFactor</at>
1815
            <at name="width">419</at>
1801
            <at name="width">714</at>
1816 1802
            <at name="height">20</at>
1817 1803
           </object>
1818 1804
          </at>
......
1846 1832
          <at name="properties">
1847 1833
           <object classname="com.jeta.forms.store.support.PropertyMap">
1848 1834
            <at name="name">txtZoomOutFactor</at>
1849
            <at name="width">419</at>
1835
            <at name="width">714</at>
1850 1836
            <at name="height">20</at>
1851 1837
           </object>
1852 1838
          </at>
......
1855 1841
       </object>
1856 1842
      </at>
1857 1843
     </item>
1844
     <item >
1845
      <at name="value">
1846
       <object classname="com.jeta.forms.store.memento.BeanMemento">
1847
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
1848
         <at name="cellconstraints">
1849
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1850
           <at name="column">2</at>
1851
           <at name="row">20</at>
1852
           <at name="colspan">1</at>
1853
           <at name="rowspan">1</at>
1854
           <at name="halign">default</at>
1855
           <at name="valign">top</at>
1856
           <at name="insets" object="insets">0,0,0,0</at>
1857
          </object>
1858
         </at>
1859
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1860
        </super>
1861
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1862
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
1863
        <at name="beanproperties">
1864
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1865
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
1866
          <at name="properties">
1867
           <object classname="com.jeta.forms.store.support.PropertyMap">
1868
            <at name="border">
1869
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1870
              <super classname="com.jeta.forms.store.properties.BorderProperty">
1871
               <at name="name">border</at>
1872
              </super>
1873
              <at name="borders">
1874
               <object classname="java.util.LinkedList">
1875
                <item >
1876
                 <at name="value">
1877
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
1878
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1879
                    <at name="name">border</at>
1880
                   </super>
1881
                  </object>
1882
                 </at>
1883
                </item>
1884
               </object>
1885
              </at>
1886
             </object>
1887
            </at>
1888
            <at name="name">lblToC</at>
1889
            <at name="width">131</at>
1890
            <at name="text">ToC</at>
1891
            <at name="fill">
1892
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1893
              <at name="name">fill</at>
1894
             </object>
1895
            </at>
1896
            <at name="height">14</at>
1897
           </object>
1898
          </at>
1899
         </object>
1900
        </at>
1901
       </object>
1902
      </at>
1903
     </item>
1904
     <item >
1905
      <at name="value">
1906
       <object classname="com.jeta.forms.store.memento.FormMemento">
1907
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
1908
         <at name="cellconstraints">
1909
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1910
           <at name="column">4</at>
1911
           <at name="row">20</at>
1912
           <at name="colspan">1</at>
1913
           <at name="rowspan">1</at>
1914
           <at name="halign">default</at>
1915
           <at name="valign">default</at>
1916
           <at name="insets" object="insets">0,0,0,0</at>
1917
          </object>
1918
         </at>
1919
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1920
        </super>
1921
        <at name="id">embedded.1795503997</at>
1922
        <at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE</at>
1923
        <at name="colspecs">FILL:12DLU:NONE,FILL:DEFAULT:GROW(1.0)</at>
1924
        <at name="components">
1925
         <object classname="java.util.LinkedList">
1926
          <item >
1927
           <at name="value">
1928
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1929
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1930
              <at name="cellconstraints">
1931
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1932
                <at name="column">1</at>
1933
                <at name="row">1</at>
1934
                <at name="colspan">2</at>
1935
                <at name="rowspan">1</at>
1936
                <at name="halign">default</at>
1937
                <at name="valign">default</at>
1938
                <at name="insets" object="insets">0,0,0,0</at>
1939
               </object>
1940
              </at>
1941
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1942
             </super>
1943
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1944
             <at name="beanclass">javax.swing.JCheckBox</at>
1945
             <at name="beanproperties">
1946
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1947
               <at name="classname">javax.swing.JCheckBox</at>
1948
               <at name="properties">
1949
                <object classname="com.jeta.forms.store.support.PropertyMap">
1950
                 <at name="border">
1951
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1952
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1953
                    <at name="name">border</at>
1954
                   </super>
1955
                   <at name="borders">
1956
                    <object classname="java.util.LinkedList">
1957
                     <item >
1958
                      <at name="value">
1959
                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
1960
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1961
                         <at name="name">border</at>
1962
                        </super>
1963
                       </object>
1964
                      </at>
1965
                     </item>
1966
                    </object>
1967
                   </at>
1968
                  </object>
1969
                 </at>
1970
                 <at name="actionCommand">Hide legend of non visible layers</at>
1971
                 <at name="name">chkHideLegendOfNonVisibleLayers</at>
1972
                 <at name="width">709</at>
1973
                 <at name="text">Hide legend of non visible layers</at>
1974
                 <at name="height">16</at>
1975
                </object>
1976
               </at>
1977
              </object>
1978
             </at>
1979
            </object>
1980
           </at>
1981
          </item>
1982
          <item >
1983
           <at name="value">
1984
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1985
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1986
              <at name="cellconstraints">
1987
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1988
                <at name="column">1</at>
1989
                <at name="row">2</at>
1990
                <at name="colspan">1</at>
1991
                <at name="rowspan">1</at>
1992
                <at name="halign">default</at>
1993
                <at name="valign">default</at>
1994
                <at name="insets" object="insets">0,0,0,0</at>
1995
               </object>
1996
              </at>
1997
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1998
             </super>
1999
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
2000
             <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
2001
             <at name="beanproperties">
2002
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
2003
               <at name="classname">com.jeta.forms.components.label.JETALabel</at>
2004
               <at name="properties">
2005
                <object classname="com.jeta.forms.store.support.PropertyMap">
2006
                 <at name="border">
2007
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
2008
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
2009
                    <at name="name">border</at>
2010
                   </super>
2011
                   <at name="borders">
2012
                    <object classname="java.util.LinkedList">
2013
                     <item >
2014
                      <at name="value">
2015
                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
2016
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
2017
                         <at name="name">border</at>
2018
                        </super>
2019
                       </object>
2020
                      </at>
2021
                     </item>
2022
                    </object>
2023
                   </at>
2024
                  </object>
2025
                 </at>
2026
                 <at name="width">17</at>
2027
                 <at name="name"/>
2028
                 <at name="fill">
2029
                  <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
2030
                   <at name="name">fill</at>
2031
                  </object>
2032
                 </at>
2033
                 <at name="height">12</at>
2034
                </object>
2035
               </at>
2036
              </object>
2037
             </at>
2038
            </object>
2039
           </at>
2040
          </item>
2041
         </object>
2042
        </at>
2043
        <at name="properties">
2044
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
2045
          <at name="classname">com.jeta.forms.gui.form.GridView</at>
2046
          <at name="properties">
2047
           <object classname="com.jeta.forms.store.support.PropertyMap">
2048
            <at name="border">
2049
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
2050
              <super classname="com.jeta.forms.store.properties.BorderProperty">
2051
               <at name="name">border</at>
2052
              </super>
2053
              <at name="borders">
2054
               <object classname="java.util.LinkedList"/>
2055
              </at>
2056
             </object>
2057
            </at>
2058
            <at name="name"/>
2059
            <at name="fill">
2060
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
2061
              <at name="name">fill</at>
2062
             </object>
2063
            </at>
2064
            <at name="scollBars">
2065
             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
2066
              <at name="name">scollBars</at>
2067
              <at name="verticalpolicy">21</at>
2068
              <at name="horizontalpolicy">31</at>
2069
              <at name="border">
2070
               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
2071
                <super classname="com.jeta.forms.store.properties.BorderProperty">
2072
                 <at name="name">border</at>
2073
                </super>
2074
                <at name="borders">
2075
                 <object classname="java.util.LinkedList">
2076
                  <item >
2077
                   <at name="value">
2078
                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
2079
                     <super classname="com.jeta.forms.store.properties.BorderProperty">
2080
                      <at name="name">border</at>
2081
                     </super>
2082
                    </object>
2083
                   </at>
2084
                  </item>
2085
                 </object>
2086
                </at>
2087
               </object>
2088
              </at>
2089
             </object>
2090
            </at>
2091
           </object>
2092
          </at>
2093
         </object>
2094
        </at>
2095
        <at name="cellpainters">
2096
         <object classname="com.jeta.forms.store.support.Matrix">
2097
          <at name="rows">
2098
           <object classname="[Ljava.lang.Object;" size="2">
2099
            <at name="item" index="0">
2100
             <object classname="[Ljava.lang.Object;" size="2"/>
2101
            </at>
2102
            <at name="item" index="1">
2103
             <object classname="[Ljava.lang.Object;" size="2"/>
2104
            </at>
2105
           </object>
2106
          </at>
2107
         </object>
2108
        </at>
2109
        <at name="rowgroups">
2110
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
2111
          <at name="groups">
2112
           <object classname="java.util.HashMap"/>
2113
          </at>
2114
         </object>
2115
        </at>
2116
        <at name="colgroups">
2117
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
2118
          <at name="groups">
2119
           <object classname="java.util.HashMap"/>
2120
          </at>
2121
         </object>
2122
        </at>
2123
       </object>
2124
      </at>
2125
     </item>
1858 2126
    </object>
1859 2127
   </at>
1860 2128
   <at name="properties">
......
1872 2140
         </at>
1873 2141
        </object>
1874 2142
       </at>
1875
       <at name="name"></at>
2143
       <at name="name"/>
1876 2144
       <at name="fill">
1877 2145
        <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1878 2146
         <at name="name">fill</at>
......
1912 2180
   <at name="cellpainters">
1913 2181
    <object classname="com.jeta.forms.store.support.Matrix">
1914 2182
     <at name="rows">
1915
      <object classname="[Ljava.lang.Object;" size="20">
2183
      <object classname="[Ljava.lang.Object;" size="21">
1916 2184
       <at name="item" index="0">
1917 2185
        <object classname="[Ljava.lang.Object;" size="8"/>
1918 2186
       </at>
......
1973 2241
       <at name="item" index="19">
1974 2242
        <object classname="[Ljava.lang.Object;" size="8"/>
1975 2243
       </at>
2244
       <at name="item" index="20">
2245
        <object classname="[Ljava.lang.Object;" size="8"/>
2246
       </at>
1976 2247
      </object>
1977 2248
     </at>
1978 2249
    </object>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/ViewPageView.java
48 48
   JButton btnDefaultSelectionColor = new JButton();
49 49
   JSpinner txtZoomInFactor = new JSpinner();
50 50
   JSpinner txtZoomOutFactor = new JSpinner();
51
   JLabel lblToC = new JLabel();
52
   JCheckBox chkHideLegendOfNonVisibleLayers = new JCheckBox();
51 53

  
52 54
   /**
53 55
    * Default constructor
......
139 141
   public JPanel createPanel()
140 142
   {
141 143
      JPanel jpanel1 = new JPanel();
142
      FormLayout formlayout1 = new FormLayout("FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0)");
144
      FormLayout formlayout1 = new FormLayout("FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)");
143 145
      CellConstraints cc = new CellConstraints();
144 146
      jpanel1.setLayout(formlayout1);
145 147

  
......
163 165

  
164 166
      lblDefaultSelectionColor.setName("lblDefaultSelectionColor");
165 167
      lblDefaultSelectionColor.setText("Default selection color");
166
      jpanel1.add(lblDefaultSelectionColor,cc.xy(2,12));
168
      jpanel1.add(lblDefaultSelectionColor,new CellConstraints(2,12,1,1,CellConstraints.DEFAULT,CellConstraints.CENTER));
167 169

  
168 170
      lblMapUnits.setName("lblMapUnits");
169 171
      lblMapUnits.setText("Map units");
......
194 196
      txtZoomOutFactor.setName("txtZoomOutFactor");
195 197
      jpanel1.add(txtZoomOutFactor,cc.xy(4,8));
196 198

  
197
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 });
199
      lblToC.setName("lblToC");
200
      lblToC.setText("ToC");
201
      jpanel1.add(lblToC,new CellConstraints(2,20,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
202

  
203
      jpanel1.add(createPanel5(),cc.xy(4,20));
204
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 });
198 205
      return jpanel1;
199 206
   }
200 207

  
......
259 266

  
260 267
      txtDefaultViewBackColor.setEnabled(false);
261 268
      txtDefaultViewBackColor.setName("txtDefaultViewBackColor");
262
      BevelBorder bevelborder1 = new BevelBorder(BevelBorder.LOWERED,null,null,null,null);
263
      txtDefaultViewBackColor.setBorder(bevelborder1);
264 269
      jpanel1.add(txtDefaultViewBackColor,cc.xy(1,1));
265 270

  
266 271
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
......
277 282
      txtDefaultSelectionColor.setBackground(new Color(255,255,0));
278 283
      txtDefaultSelectionColor.setEnabled(false);
279 284
      txtDefaultSelectionColor.setName("txtDefaultSelectionColor");
280
      BevelBorder bevelborder1 = new BevelBorder(BevelBorder.LOWERED,null,null,null,null);
281
      txtDefaultSelectionColor.setBorder(bevelborder1);
282 285
      jpanel1.add(txtDefaultSelectionColor,cc.xy(1,1));
283 286

  
284 287
      sldDefaultSelectionColor.setMajorTickSpacing(10);
......
294 297
      jpanel1.add(btnDefaultSelectionColor,cc.xy(3,1));
295 298

  
296 299
      JLabel jlabel1 = new JLabel();
297
      jlabel1.setText("alpha");
300
      jlabel1.setText("Alpha");
298 301
      jpanel1.add(jlabel1,cc.xy(5,1));
299 302

  
300 303
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
301 304
      return jpanel1;
302 305
   }
303 306

  
307
   public JPanel createPanel5()
308
   {
309
      JPanel jpanel1 = new JPanel();
310
      FormLayout formlayout1 = new FormLayout("FILL:12DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
311
      CellConstraints cc = new CellConstraints();
312
      jpanel1.setLayout(formlayout1);
313

  
314
      chkHideLegendOfNonVisibleLayers.setActionCommand("Hide legend of non visible layers");
315
      chkHideLegendOfNonVisibleLayers.setName("chkHideLegendOfNonVisibleLayers");
316
      chkHideLegendOfNonVisibleLayers.setText("Hide legend of non visible layers");
317
      jpanel1.add(chkHideLegendOfNonVisibleLayers,cc.xywh(1,1,2,1));
318

  
319
      JLabel jlabel1 = new JLabel();
320
      jpanel1.add(jlabel1,cc.xy(1,2));
321

  
322
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
323
      return jpanel1;
324
   }
325

  
304 326
   /**
305 327
    * Initializer
306 328
    */
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/ViewPage.java
69 69
 *
70 70
 */
71 71
public class ViewPage extends ViewPageView implements ChangeListener, ItemListener, IPreference {
72
    // The class ViewPageView can extend from AbstractPreferencePage, not JPanel
72
    //
73
    // The class ViewPageView can extend from AbstractPreferencePage, not JPanel,
74
    // if rereate it from the GUI builder change te class declaration to:
73 75
    //    public abstract class ViewPageView extends AbstractPreferencePage
74 76

  
75 77
    private static final long serialVersionUID = 1204688910771374514L;
......
303 305
        this.lblMapUnits.setText(i18nManager.getTranslation("map_units"));
304 306
        this.lblDistanceUnits.setText(i18nManager.getTranslation("distance_units"));
305 307
        this.lblDistanceArea.setText(i18nManager.getTranslation("distance_area"));
308
        this.chkHideLegendOfNonVisibleLayers.setText(i18nManager.getTranslation("_Hide_legend_of_non_visible_layers"));
306 309
    }
307 310

  
308 311
    @Override
......
322 325

  
323 326
        this.defaultProjection.set(projectPreferences.getDefaultProjection());
324 327

  
325
        chkInvisibleNewLayers.setSelected(projectPreferences.getAddNewLayersInInvisibleMode());
326
        chkKeepScaleOnResizing.setSelected(projectPreferences.getKeepScaleOnResizing());
327
        chkOpenWithANewMaximizedView.setSelected(projectPreferences.getOpenWithANewMaximizedView());
328

  
329
        txtZoomInFactor.setModel(
328
        this.chkInvisibleNewLayers.setSelected(projectPreferences.getAddNewLayersInInvisibleMode());
329
        this.chkKeepScaleOnResizing.setSelected(projectPreferences.getKeepScaleOnResizing());
330
        this.chkOpenWithANewMaximizedView.setSelected(projectPreferences.getOpenWithANewMaximizedView());
331
        this.chkHideLegendOfNonVisibleLayers.setSelected(projectPreferences.getHideLegendInToCOfNonVisibleLayers());
332
        this.txtZoomInFactor.setModel(
330 333
                new SpinnerNumberModel(
331 334
                        projectPreferences.getZoomInFactor(), //initial value
332 335
                        0.01, //min
......
334 337
                        0.25 //step
335 338
                )
336 339
        );
337
        txtZoomOutFactor.setModel(
340
        this.txtZoomOutFactor.setModel(
338 341
                new SpinnerNumberModel(
339
                        projectPreferences.getZoomInFactor(), //initial value
342
                        projectPreferences.getZoomOutFactor(), //initial value
340 343
                        0.01, //min
341 344
                        1000, //max
342 345
                        0.25 //step
343 346
                )
344 347
        );
345
//        txtZoomInFactor.setValue(projectPreferences.getZoomInFactor());
346
//        txtZoomOutFactor.setValue(projectPreferences.getZoomOutFactor());
347 348
        MapContext.ZOOMINFACTOR = projectPreferences.getZoomInFactor();
348 349
        MapContext.ZOOMOUTFACTOR = projectPreferences.getZoomOutFactor();
349 350

  
......
414 415
            projectPreferences.setAddNewLayersInInvisibleMode(chkInvisibleNewLayers.isSelected());
415 416
            projectPreferences.setKeepScaleOnResizing(chkKeepScaleOnResizing.isSelected());
416 417
            projectPreferences.setOpenWithANewMaximizedView(chkOpenWithANewMaximizedView.isSelected());
417

  
418
            projectPreferences.setHideLegendInToCOfNonVisibleLayers(this.chkHideLegendOfNonVisibleLayers.isSelected());
419
            
418 420
        } catch (Exception e) {
419 421
            throw new StoreException(PluginServices.getText(this, "factor_zoom_incorrecto"));
420 422
        }
......
441 443
        );        
442 444
//        txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
443 445
//        txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
444
        chkInvisibleNewLayers.setSelected(false);
445
        chkKeepScaleOnResizing.setSelected(false);
446
        defaultViewBackColor.set(FACTORY_DEFAULT_VIEW_BACK_COLOR);
447
        defaultSelectionColor.set(FACTORY_DEFAULT_SELECTION_COLOR);
448
        jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS);
449
        jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS);
450
        jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA);
446
        this.chkInvisibleNewLayers.setSelected(false);
447
        this.chkKeepScaleOnResizing.setSelected(false);
448
        this.chkHideLegendOfNonVisibleLayers.setSelected(true);
449
        this.defaultViewBackColor.set(FACTORY_DEFAULT_VIEW_BACK_COLOR);
450
        this.defaultSelectionColor.set(FACTORY_DEFAULT_SELECTION_COLOR);
451
        this.jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS);
452
        this.jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS);
453
        this.jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA);
451 454

  
452 455
    }
453 456

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/ProjectPreferences.java
69 69

  
70 70
    private int defaultDistanceArea = -1;
71 71

  
72
    private final PluginServices plugin;
73
    private final DynObject pluginPreferences;
74

  
72 75
    public ProjectPreferences() {
76
        this.plugin = PluginsLocator.getManager().getPlugin(this);
77
        this.pluginPreferences = plugin.getPluginProperties();
73 78
    }
74 79

  
75 80
    /**
......
80 85
    public void setDefaultProjection(IProjection defaultProjection) {
81 86
        this.defaultProjection = defaultProjection;
82 87
        if (defaultProjection != null) {
83
            PluginServices plugin = PluginServices.getPluginServices("org.gvsig.app");
84 88
            XMLEntity xml = plugin.getPersistentXML();
85 89
            xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, defaultProjection.getAbrev());
86 90
        }
......
94 98

  
95 99
    public IProjection getDefaultProjection() {
96 100
        if (this.defaultProjection == null) {
97
            PluginServices plugin = PluginServices.getPluginServices("org.gvsig.app");
98 101
            XMLEntity xml = plugin.getPersistentXML();
99 102
            if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
100 103
                String projCode = xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME);
......
127 130
     */
128 131
    public void setDefaultSelectionColor(Color color) {
129 132
        defaultSelectionColor = color;
130
        PluginServices ps = PluginServices.getPluginServices(this);
131
        XMLEntity xml = ps.getPersistentXML();
133
        XMLEntity xml = plugin.getPersistentXML();
132 134
        xml.putProperty("DefaultSelectionColor", StringUtilities.color2String(color));
133 135
    }
134 136

  
......
139 141
     * @return java.awt.Color
140 142
     */
141 143
    public Color getDefaultSelectionColor() {
142
        PluginServices ps = PluginServices.getPluginServices(this);
143
        XMLEntity xml = ps.getPersistentXML();
144
        XMLEntity xml = plugin.getPersistentXML();
144 145
        if (xml.contains("DefaultSelectionColor")) {
145 146
            defaultSelectionColor = StringUtilities.string2Color(xml
146 147
                    .getStringProperty("DefaultSelectionColor"));
......
159 160

  
160 161
    public void setDefaultViewBackColor(Color color) {
161 162
        defaultViewBackColor = color;
162
        PluginServices ps = PluginServices.getPluginServices(this);
163
        XMLEntity xml = ps.getPersistentXML();
163
        XMLEntity xml = plugin.getPersistentXML();
164 164
        xml.putProperty("DefaultViewBackColor", StringUtilities.color2String(color));
165 165
    }
166 166

  
167 167
    public Color getDefaultOverviewBackColor() {
168
        XMLEntity xml = PluginServices.getPluginServices("org.gvsig.app")
169
                .getPersistentXML();
168
        XMLEntity xml = plugin.getPersistentXML();
170 169
        if (xml.contains("defaultOverviewBackColor")) {
171 170
            defaultOverviewBackColor = StringUtilities.string2Color(xml
172 171
                    .getStringProperty("defaultOverviewBackColor"));
......
187 186
     */
188 187
    public int getDefaultMapUnits() {
189 188
        if (defaultMapUnits == -1) {
190
            XMLEntity xml = PluginServices.getPluginServices(
191
                    "org.gvsig.app").getPersistentXML();
189
            XMLEntity xml = plugin.getPersistentXML();
192 190
            if (xml.contains("DefaultMapUnits")) {
193 191
                defaultMapUnits = xml.getIntProperty("DefaultMapUnits");
194 192
            } else {
......
217 215
     */
218 216
    public int getDefaultDistanceUnits() {
219 217
        if (defaultDistanceUnits == -1) {
220
            XMLEntity xml = PluginServices.getPluginServices(
221
                    "org.gvsig.app").getPersistentXML();
218
            XMLEntity xml = plugin.getPersistentXML();
222 219
            if (xml.contains("DefaultDistanceUnits")) {
223 220
                defaultDistanceUnits = xml
224 221
                        .getIntProperty("DefaultDistanceUnits");
......
248 245
     */
249 246
    public int getDefaultDistanceArea() {
250 247
        if (defaultDistanceArea == -1) {
251
            XMLEntity xml = PluginServices.getPluginServices(
252
                    "org.gvsig.app").getPersistentXML();
248
            XMLEntity xml = plugin.getPersistentXML();
253 249
            if (xml.contains("DefaultDistanceArea")) {
254 250
                defaultDistanceArea = xml
255 251
                        .getIntProperty("DefaultDistanceArea");
......
278 274
     */
279 275
    public void setDefaultMapUnits(int mapUnits) {
280 276
        defaultMapUnits = mapUnits;
281
        PluginServices ps = PluginServices.getPluginServices(this);
282
        XMLEntity xml = ps.getPersistentXML();
277
        XMLEntity xml = plugin.getPersistentXML();
283 278
        xml.putProperty("DefaultMapUnits", mapUnits);
284 279
    }
285 280

  
......
290 285
     */
291 286
    public void setDefaultDistanceUnits(int distanceUnits) {
292 287
        defaultDistanceUnits = distanceUnits;
293
        PluginServices ps = PluginServices.getPluginServices(this);
294
        XMLEntity xml = ps.getPersistentXML();
288
        XMLEntity xml = plugin.getPersistentXML();
295 289
        xml.putProperty("DefaultDistanceUnits", distanceUnits);
296 290
    }
297 291

  
......
302 296
     */
303 297
    public void setDefaultDistanceArea(int distanceArea) {
304 298
        defaultDistanceArea = distanceArea;
305
        PluginServices ps = PluginServices.getPluginServices(this);
306
        XMLEntity xml = ps.getPersistentXML();
299
        XMLEntity xml = plugin.getPersistentXML();
307 300
        xml.putProperty("DefaultDistanceArea", distanceArea);
308 301
    }
309 302

  
310 303
    public boolean getAddNewLayersInInvisibleMode() {
311
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
312
        DynObject props = plugin.getPluginProperties();
313
        XMLEntity xml = plugin.getPersistentXML();
314

  
315
        Boolean addNewLayersInInvisibleMode = (Boolean) props.getDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE);
304
        Boolean addNewLayersInInvisibleMode = (Boolean) this.pluginPreferences.getDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE);
316 305
        if (addNewLayersInInvisibleMode == null) {
306
            XMLEntity xml = plugin.getPersistentXML();
317 307
            if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE)) {
318 308
                addNewLayersInInvisibleMode = xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE);
319 309
            } else {
320 310
                addNewLayersInInvisibleMode = false;
321 311
            }
322
            props.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
312
            this.pluginPreferences.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
323 313
        }
324 314
        return BooleanUtils.isTrue(addNewLayersInInvisibleMode);
325 315
    }
326 316

  
327 317
    public void setAddNewLayersInInvisibleMode(boolean addNewLayersInInvisibleMode) {
328
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
329
        DynObject props = plugin.getPluginProperties();
330
        props.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
318
        this.pluginPreferences.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
331 319
    }
332 320

  
333

  
334 321
    public boolean getOpenWithANewMaximizedView() {
335
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
336
        DynObject props = plugin.getPluginProperties();
337
        XMLEntity xml = plugin.getPersistentXML();
338

  
339
        Boolean openWithANewMaximizedView = (Boolean) props.getDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW);
322
        Boolean openWithANewMaximizedView = (Boolean) this.pluginPreferences.getDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW);
340 323
        if (openWithANewMaximizedView == null) {
324
            XMLEntity xml = plugin.getPersistentXML();
341 325
            if (xml.contains(OPEN_WITH_A_NEW_MAXIMIZED_VIEW)) {
342 326
                openWithANewMaximizedView = xml.getBooleanProperty(OPEN_WITH_A_NEW_MAXIMIZED_VIEW);
343 327
            } else {
344 328
                openWithANewMaximizedView = true;
345 329
            }
346
            props.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
330
            this.pluginPreferences.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
347 331
        }
348 332
        return BooleanUtils.isTrue(openWithANewMaximizedView);
349 333
    }
350 334

  
351 335
    public void setOpenWithANewMaximizedView(boolean openWithANewMaximizedView) {
352
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
353
        DynObject props = plugin.getPluginProperties();
354
        props.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
336
        this.pluginPreferences.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
355 337
    }
356 338

  
357

  
358 339
    public boolean getKeepScaleOnResizing() {
359
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
360
        DynObject props = plugin.getPluginProperties();
361
        XMLEntity xml = plugin.getPersistentXML();
362

  
363
        Boolean keepScaleOnResizing = (Boolean) props.getDynValue(KEEP_SCALE_ON_RESIZING);
340
        Boolean keepScaleOnResizing = (Boolean) this.pluginPreferences.getDynValue(KEEP_SCALE_ON_RESIZING);
364 341
        if (keepScaleOnResizing == null) {
342
            XMLEntity xml = plugin.getPersistentXML();
365 343
            if (xml.contains(KEEP_SCALE_ON_RESIZING)) {
366 344
                keepScaleOnResizing = xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING);
367 345
            } else {
368 346
                keepScaleOnResizing = false;
369 347
            }
370
            props.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
348
            this.pluginPreferences.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
371 349
        }
372 350
        return BooleanUtils.isTrue(keepScaleOnResizing);
373 351
    }
374 352

  
375 353
    public void setKeepScaleOnResizing(boolean keepScaleOnResizing) {
376
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
377
        DynObject props = plugin.getPluginProperties();
378
        props.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
354
        this.pluginPreferences.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
379 355
    }
380 356

  
381 357
    public double getZoomInFactor() {
382
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
383
        DynObject props = plugin.getPluginProperties();
384
        XMLEntity xml = plugin.getPersistentXML();
385

  
386
        Double zoomInFactor = (Double) props.getDynValue(ZOOM_IN_FACTOR);
358
        Double zoomInFactor = (Double) this.pluginPreferences.getDynValue(ZOOM_IN_FACTOR);
387 359
        if (zoomInFactor == null) {
360
            XMLEntity xml = plugin.getPersistentXML();
388 361
            if (xml.contains(ZOOM_IN_FACTOR)) {
389 362
                zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR);
390 363
            } else {
391 364
                zoomInFactor = MapContext.ZOOMINFACTOR;
392 365
            }
393
            props.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
366
            this.pluginPreferences.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
394 367
        }
395 368
        return zoomInFactor;
396 369
    }
397
    
370

  
398 371
    public void setZoomInFactor(double zoomInFactor) {
399
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
400
        DynObject props = plugin.getPluginProperties();
401
        props.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
372
        this.pluginPreferences.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
402 373
    }
403 374

  
404 375
    public double getZoomOutFactor() {
405
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
406
        DynObject props = plugin.getPluginProperties();
407
        XMLEntity xml = plugin.getPersistentXML();
408

  
409
        Double zoomOutFactor = (Double) props.getDynValue(ZOOM_OUT_FACTOR);
376
        Double zoomOutFactor = (Double) this.pluginPreferences.getDynValue(ZOOM_OUT_FACTOR);
410 377
        if (zoomOutFactor == null) {
378
            XMLEntity xml = plugin.getPersistentXML();
411 379
            if (xml.contains(ZOOM_OUT_FACTOR)) {
412 380
                zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR);
413 381
            } else {
414 382
                zoomOutFactor = MapContext.ZOOMINFACTOR;
415 383
            }
416
            props.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
384
            this.pluginPreferences.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
417 385
        }
418 386
        return zoomOutFactor;
419 387
    }
420
    
388

  
421 389
    public void setZoomOutFactor(double zoomOutFactor) {
422
        PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
423
        DynObject props = plugin.getPluginProperties();
424
        props.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
390
        this.pluginPreferences.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
425 391
    }
426 392

  
393
    public boolean getHideLegendInToCOfNonVisibleLayers() {
394
        Boolean hideLegendInToCOfNonVisibleLayers = (Boolean)this.pluginPreferences.getDynValue("hideLegendInToCOfNonVisibleLayers");
395
        return BooleanUtils.toBooleanDefaultIfNull(hideLegendInToCOfNonVisibleLayers,true);
396
    }
427 397

  
398
    public void setHideLegendInToCOfNonVisibleLayers(boolean hideLegendInToCOfNonVisibleLayers) {
399
        this.pluginPreferences.setDynValue("hideLegendInToCOfNonVisibleLayers", hideLegendInToCOfNonVisibleLayers);
400
    }
401

  
428 402
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/DefaultViewPanel.java
151 151
     * layout properties were set using the
152 152
     * <code>setWindowData(WindowData)</code> method, the window will be
153 153
     * populated according to this properties.
154
     * @param mapContext
154 155
     */
155 156
    protected void initialize(MapContext mapContext) {
156 157
        super.initialize();
......
182 183

  
183 184
        // Se configura el mapControl
184 185
        m_TOC.setMapContext(fmap);
185
        m_MapControl.getMapContext().getLayers().addLegendListener(m_TOC);
186 186

  
187 187
        m_MapControl.setBackground(new Color(255, 255, 255));
188 188
        if (modelo.getMapOverViewContext() != null) {
......
547 547
    }
548 548

  
549 549
    /**
550
     * @param color
550 551
     * @deprecated use instead Project.getPreferences().setDefaultViewBackColor
551 552
     */
552 553
    public static void setDefaultBackColor(Color color) {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/gui/TOCRenderer.java
64 64

  
65 65
    /**
66 66
     * Creates a new TOCRenderer object.
67
     * @param tocBackground
67 68
     */
68 69
    public TOCRenderer(Color tocBackground) {
69 70
        this(Color.RED, tocBackground);
......
71 72

  
72 73
    /**
73 74
     * Creates a new TOCRenderer object.
75
     * @param editingColor
76
     * @param tocBackground
74 77
     */
75 78
    public TOCRenderer(Color editingColor, Color tocBackground) {
76 79
        
......
128 131
     * 
129 132
     * @return
130 133
     */
134
    @Override
131 135
    public Component getTreeCellRendererComponent(JTree tree, Object value,
132 136
        boolean isSelected, boolean expanded, boolean leaf, int row,
133 137
        boolean hasFocus) {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/gui/TOC.java
3 3
 *
4 4
 * Copyright (C) 2007-2013 gvSIG Association.
5 5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 19
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
23 22
 */
24 23
package org.gvsig.app.project.documents.view.toc.gui;
25 24

  
......
30 29
import java.awt.Image;
31 30
import java.awt.Point;
32 31
import java.awt.Rectangle;
33
import java.awt.event.ActionEvent;
34
import java.awt.event.ActionListener;
35 32
import java.awt.event.ComponentEvent;
36 33
import java.awt.event.ComponentListener;
37 34
import java.awt.event.InputEvent;
......
42 39
import java.util.Enumeration;
43 40
import java.util.HashMap;
44 41
import java.util.Map;
45

  
46 42
import javax.swing.BorderFactory;
47 43
import javax.swing.JColorChooser;
48 44
import javax.swing.JComponent;
......
54 50
import javax.swing.event.TreeExpansionListener;
55 51
import javax.swing.tree.DefaultMutableTreeNode;
56 52
import javax.swing.tree.DefaultTreeModel;
53
import javax.swing.tree.TreeNode;
57 54
import javax.swing.tree.TreePath;
58 55
import javax.swing.tree.TreeSelectionModel;
59
import org.apache.commons.lang3.BooleanUtils;
60

  
56
import org.apache.commons.lang.BooleanUtils;
61 57
import org.gvsig.andami.PluginServices;
62
import org.gvsig.andami.PluginsLocator;
63
import org.gvsig.andami.actioninfo.ActionInfo;
64
import org.gvsig.andami.actioninfo.ActionInfoManager;
65 58
import org.gvsig.andami.messages.NotificationManager;
66 59
import org.gvsig.app.ApplicationLocator;
67
import org.gvsig.app.gui.preferencespage.ViewPage;
68 60
import org.gvsig.app.project.ProjectPreferences;
69 61
import org.gvsig.app.project.documents.view.IContextMenuAction;
70 62
import org.gvsig.app.project.documents.view.toc.DnDJTree;
......
72 64
import org.gvsig.app.project.documents.view.toc.ITocOrderListener;
73 65
import org.gvsig.app.project.documents.view.toc.TocItemBranch;
74 66
import org.gvsig.app.project.documents.view.toc.TocItemLeaf;
75
import org.gvsig.fmap.dal.exception.ReadException;
76 67
import org.gvsig.fmap.mapcontext.MapContext;
77 68
import org.gvsig.fmap.mapcontext.events.AtomicEvent;
78 69
import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener;
......
80 71
import org.gvsig.fmap.mapcontext.layers.FLayer;
81 72
import org.gvsig.fmap.mapcontext.layers.FLayers;
82 73
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
83
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
84
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent;
85 74
import org.gvsig.fmap.mapcontext.layers.operations.Classifiable;
86 75
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
87 76
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection;
......
89 78
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
90 79
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
91 80
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
92
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
93 81
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent;
94
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent;
95
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
96
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
97 82
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener;
98 83
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
99
import org.gvsig.tools.dynobject.DynObject;
100
import org.gvsig.utils.XMLEntity;
101 84
import org.slf4j.Logger;
102 85
import org.slf4j.LoggerFactory;
103 86

  
......
105 88
 *
106 89
 * @author fjp
107 90
 */
108
public class TOC extends JComponent implements ITocOrderListener,
109
    LegendListener, LayerCollectionListener, TreeExpansionListener,
110
    ComponentListener, LegendContentsChangedListener {
91
public class TOC extends JComponent // implements
92
//        ITocOrderListener,
93
//        LegendListener, 
94
//        LayerCollectionListener, 
95
//        LegendContentsChangedListener, 
96
// TreeExpansionListener 
97
{
111 98

  
112 99
    /**
113 100
     *
114 101
     */
115 102
    private static final long serialVersionUID = 5689047685537359038L;
116 103

  
117
    /**
118
     * Useful for debug the problems during the implementation.
119
     */
120
    private static Logger logger = LoggerFactory.getLogger(TOC.class);
104
    private static final Logger logger = LoggerFactory.getLogger(TOC.class);
121 105

  
122
    private MapContext mapContext;
106
    private static class ItemsExpandeds {
123 107

  
124
    private DnDJTree m_Tree;
108
        private final Map<Object, Boolean> itemsExpanded = new HashMap<>();
109
        private boolean expandingNodes = false;
125 110

  
126
    private DefaultTreeModel m_TreeModel;
111
        public boolean isMarked(ITocItem item) {
112
            Object key = item.getLabel();
113
            boolean isItemExpanded = BooleanUtils.isTrue(this.itemsExpanded.get(key));
114
            return isItemExpanded;
115
        }
127 116

  
128
    private DefaultMutableTreeNode m_Root;
117
        public void setMark(ITocItem item, boolean expanded) {
118
            Object key = item.getLabel();
119
            this.itemsExpanded.put(key, expanded);
120
        }
129 121

  
130
    private TOCRenderer m_TocRenderer;
122
        public void removeLayer(FLayer layer) {
123
            Object key = layer.getName();
124
            this.itemsExpanded.remove(key);
125
        }
131 126

  
132
    private JScrollPane m_Scroller;
127
        public void update(JTree tree, TreeNode node) {
128
            if (expandingNodes) {
129
                return;
130
            }
131
            try {
132
                expandingNodes = true;
133
                DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
134
                Enumeration<DefaultMutableTreeNode> nodes = node.children();
135
                while (nodes.hasMoreElements()) {
136
                    DefaultMutableTreeNode curNode = nodes.nextElement();
137
                    if (curNode.getChildCount() > 0) {
138
                        update(tree, curNode);
139
                    }
140
                    TreePath path = new TreePath(treeModel.getPathToRoot(curNode));
141
                    ITocItem item = (ITocItem) curNode.getUserObject();
142
                    if (this.isMarked(item)) {
143
                        tree.expandPath(path);
144
                    } else {
145
                        tree.collapsePath(path);
146
                    }
147
                }
148
            } finally {
149
                expandingNodes = false;
150
            }
133 151

  
134
    // private ArrayList m_Listeners;
135
    private Map<String, Boolean> m_ItemsExpanded =
136
        new HashMap<String, Boolean>();
152
        }
153
    }
137 154

  
155
    private MapContext mapContext;
156

  
157
    private final DnDJTree m_Tree;
158
    private final DefaultTreeModel m_TreeModel;
159
    private final DefaultMutableTreeNode m_Root;
160
    private final TOCRenderer m_TocRenderer;
161
    private final JScrollPane m_Scroller;
162

  
163
    private final ItemsExpandeds itemsExpandeds = new ItemsExpandeds();
164

  
138 165
    private NodeSelectionListener nodeSelectionListener = null;
139 166

  
140 167
    /**
......
146 173
        this.setMinimumSize(new Dimension(100, 80));
147 174
        this.setPreferredSize(new Dimension(100, 80));
148 175

  
149
        // Construct the tree.
150 176
        m_Root = new DefaultMutableTreeNode(java.lang.Object.class);
151 177
        m_TreeModel = new DefaultTreeModel(m_Root);
152 178
        m_Tree = new DnDJTree(m_TreeModel);
153 179

  
154 180
        m_TocRenderer = new TOCRenderer(m_Tree.getBackground());
155 181
        m_Tree.setCellRenderer(m_TocRenderer);
156

  
157 182
        m_Tree.setRootVisible(false);
158

  
159
        // m_Tree.setExpandsSelectedPaths(true);
160
        // m_Tree.setAutoscrolls(true);
161 183
        m_Tree.setShowsRootHandles(true);
162

  
163
        // Posibilidad de seleccionar de forma aleatoria nodos de la leyenda.
164 184
        m_Tree.getSelectionModel().setSelectionMode(
165
            TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
185
                TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
186
        );
166 187
        nodeSelectionListener = new NodeSelectionListener(m_Tree);
167 188
        m_Tree.addMouseListener(nodeSelectionListener);
168
        // m_Tree.setBackground(UIManager.getColor("Button.background"));
169
        // m_Tree.setBorder(BorderFactory.createEtchedBorder());
170 189

  
171
        this.addComponentListener(this);
190
        this.addComponentListener(new ComponentListener() {
172 191

  
173
        m_Tree.addTreeExpansionListener(this);
192
            @Override
193
            public void componentResized(ComponentEvent e) {
194
                tocResized();
195
            }
174 196

  
175
        m_Tree.addOrderListener(this);
197
            @Override
198
            public void componentMoved(ComponentEvent e) {
199
            }
176 200

  
201
            @Override
202
            public void componentShown(ComponentEvent e) {
203
            }
204

  
205
            @Override
206
            public void componentHidden(ComponentEvent e) {
207
            }
208
        });
209

  
210
        m_Tree.addOrderListener(new ITocOrderListener() {
211
            @Override
212
            public void orderChanged(int oldPos, int newPos, FLayers layers) {
213
                try {
214
                    layers.moveTo(oldPos, newPos);
215
                } catch (Exception e) {
216
                    logger.warn("Can't change order of layers in TOC", e);
217
                }
218
                mapContext.invalidate();
219
            }
220

  
221
            @Override
222
            public void parentChanged(FLayers source, FLayers targer, FLayer layer) {
223
                try {
224
                    source.move(layer, targer);
225
                } catch (Exception e) {
226
                    logger.warn("Can't move layers in TOC", e);
227
                }
228
                mapContext.invalidate();
229
            }
230
        });
231

  
232
        m_Tree.addTreeExpansionListener(new TreeExpansionListener() {
233
            @Override
234
            public void treeCollapsed(TreeExpansionEvent event) {
235
                TreePath path = event.getPath();
236
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
237
                if (node.getUserObject() instanceof ITocItem) {
238
                    itemsExpandeds.setMark((ITocItem) node.getUserObject(), false);
239
                }
240
            }
241

  
242
            @Override
243
            public void treeExpanded(TreeExpansionEvent event) {
244
                TreePath path = event.getPath();
245
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
246
                if (node.getUserObject() instanceof ITocItem) {
247
                    itemsExpandeds.setMark((ITocItem) node.getUserObject(), true);
248
                }
249
            }
250
        });
251

  
177 252
        m_Tree.setRowHeight(0); // Para que lo determine el renderer
178 253

  
179 254
        m_Scroller = new JScrollPane(m_Tree);
180 255
        m_Scroller.setBorder(BorderFactory.createEmptyBorder());
181 256

  
182
        // scrollPane.setPreferredSize(new Dimension(80,80));
183
        // Add everything to this panel.
184
        /*
185
         * GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c =
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff