Revision 43152

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/BasicSymbologyExtension.java
40 40
import org.gvsig.app.project.documents.view.legend.gui.AttrInTableLabeling;
41 41
import org.gvsig.app.project.documents.view.legend.gui.Categories;
42 42
import org.gvsig.app.project.documents.view.legend.gui.Features;
43
import org.gvsig.app.project.documents.view.legend.gui.General;
44 43
import org.gvsig.app.project.documents.view.legend.gui.GeneralLayerPropertiesPage.GeneralLayerPropertiesPageFactory;
45
import org.gvsig.app.project.documents.view.legend.gui.InformationLayerPropertiesPageFactory;
46 44
import org.gvsig.app.project.documents.view.legend.gui.LabelingManager;
47 45
import org.gvsig.app.project.documents.view.legend.gui.LegendManager;
48 46
import org.gvsig.app.project.documents.view.legend.gui.MultipleAttributes;
49 47
import org.gvsig.app.project.documents.view.legend.gui.Quantities;
50 48
import org.gvsig.app.project.documents.view.legend.gui.SingleSymbol;
51 49
import org.gvsig.app.project.documents.view.legend.gui.ThemeManagerWindow;
52
import static org.gvsig.app.project.documents.view.legend.gui.ThemeManagerWindow.addPage;
53 50
import org.gvsig.app.project.documents.view.legend.gui.VectorialInterval;
54 51
import org.gvsig.app.project.documents.view.legend.gui.VectorialUniqueValue;
55 52
import org.gvsig.fmap.geom.Geometry;
......
77 74
        symbologySwingManager.registerSymbolEditor(SimpleMarker.class, Geometry.TYPES.MULTIPOINT);
78 75
        symbologySwingManager.registerSymbolEditor(SimpleLine.class, Geometry.TYPES.MULTICURVE);
79 76

  
80
        //FIXME 
77
        //FIXME
81 78
        symbologySwingManager.registerSymbolEditor(PictureMarker.class, Geometry.TYPES.POINT);
82 79
        symbologySwingManager.registerSymbolEditor(PictureLine.class, Geometry.TYPES.CURVE);
83 80
        symbologySwingManager.registerSymbolEditor(PictureFill.class, Geometry.TYPES.SURFACE);
......
88 85
        symbologySwingManager.registerSymbolEditor(PictureFill.class, Geometry.TYPES.MULTISURFACE);
89 86
        symbologySwingManager.registerSymbolEditor(MarkerFill.class, Geometry.TYPES.MULTISURFACE);
90 87

  
91
        // legends available 
88
        // legends available
92 89
        symbologySwingManager.registerLegendEditor(Quantities.class);
93 90
        symbologySwingManager.registerLegendEditor(Features.class);
94 91
        symbologySwingManager.registerLegendEditor(Categories.class);
......
104 101
        // Registry property page of layers
105 102
        PropertiesPageManager propertiesPageManager = MapControlLocator.getPropertiesPageManager();
106 103
        propertiesPageManager.registerFactory(new GeneralLayerPropertiesPageFactory());
107
        propertiesPageManager.registerFactory(new InformationLayerPropertiesPageFactory());
108
        
104

  
109 105
        // Registry old style property page of layers
110 106
        // These must be updated to use "PropertiesPage" instead of "ThemeManagerWindow"
111 107
        // Do not use this procedure more!!!
......
121 117
	@Override
122 118
	public void postInitialize() {
123 119
		super.postInitialize();
124
		
120

  
125 121
		SymbologySwingLocator.getSwingManager().setColorTablesFactory(
126 122
				ApplicationLocator.getManager().getColorTablesFactory());
127 123
	}
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;
34 32

  
35 33
import org.cresques.cts.ICoordTrans;
36 34
import org.cresques.cts.IProjection;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
37 38
import org.gvsig.andami.IconThemeHelper;
38 39
import org.gvsig.andami.PluginServices;
39 40
import org.gvsig.andami.plugins.Extension;
......
43 44
import org.gvsig.app.gui.WizardPanel;
44 45
import org.gvsig.app.project.documents.view.ViewDocument;
45 46
import org.gvsig.app.project.documents.view.gui.IView;
46
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerAddLayerWizardPanel;
47 47
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanel;
48 48
import org.gvsig.fmap.mapcontext.MapContext;
49 49
import org.gvsig.fmap.mapcontext.ViewPort;
......
52 52
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
53 53
import org.gvsig.fmap.mapcontrol.MapControl;
54 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;
58 55
import org.gvsig.tools.dispose.DisposeUtils;
59 56
import org.gvsig.tools.i18n.I18nManager;
60
import org.slf4j.Logger;
61
import org.slf4j.LoggerFactory;
62 57

  
63 58
/**
64 59
 * Extensi�n que abre un di�logo para seleccionar la capa o capas que se
......
73 68

  
74 69
    static {
75 70
        AddLayer.wizardStack = new ArrayList<>();
76
        // Anadimos el panel al wizard de cargar capa. 
77
        AddLayer.addWizard(FilesystemExplorerAddLayerWizardPanel.class);
71
        // Anadimos el panel al wizard de cargar capa.
72
        AddLayer.addWizard(FilesystemExplorerWizardPanel.class);
78 73
    }
79 74

  
80 75
    public static void addWizard(Class<? extends WizardPanel> wpClass) {
......
150 145
    }
151 146

  
152 147
    public static class ArrayUtils {
153
        
148

  
154 149
        // FIXME: Use the class in org.gvsig.tools when this is available and remove this.
155 150

  
156 151
        /**
......
218 213
    @Override
219 214
    public void execute(String command, Object[] args) {
220 215
        List<File> files = ArrayUtils.getListOf(args,0,File.class);
221
        
216

  
222 217
        ApplicationManager application = ApplicationLocator.getManager();
223 218

  
224 219
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
......
254 249
                wp = wpClass.getConstructor()
255 250
                        .newInstance(params);
256 251
                application.message(
257
                        i18nManager.getTranslation("Adding tab...") + wp.getTabName(), 
252
                        i18nManager.getTranslation("Adding tab...") + wp.getTabName(),
258 253
                        JOptionPane.INFORMATION_MESSAGE
259 254
                );
260 255
                wp.setMapCtrl(mapControl);
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/InformationPropertiesPage.java
1
package org.gvsig.app.project.documents.view.legend.gui;
2

  
3
import javax.swing.JComponent;
4

  
5
import org.gvsig.fmap.mapcontext.layers.FLayer;
6
import org.gvsig.propertypage.PropertiesPage;
7
import org.gvsig.tools.ToolsLocator;
8
import org.gvsig.tools.i18n.I18nManager;
9

  
10

  
11
/**
12
 * @author fdiaz
13
 *
14
 */
15
public class InformationPropertiesPage extends javax.swing.JPanel implements PropertiesPage {
16

  
17
    /**
18
     *
19
     */
20
    private static final long serialVersionUID = -912777742097628569L;
21
    private InformationPanelController informationPanel;
22
    private final FLayer layer;
23

  
24

  
25

  
26
    public InformationPropertiesPage(FLayer layer) {
27
        this.layer = layer;
28
    }
29

  
30
    @Override
31
    public JComponent asJComponent() {
32
        if (this.informationPanel == null) {
33
            informationPanel = new InformationPanelController();
34
            informationPanel.set(layer);
35
        }
36
        return (JComponent) informationPanel;
37
    }
38

  
39
    @Override
40
    public String getTitle() {
41
        I18nManager i18nManager = ToolsLocator.getI18nManager();
42
        return i18nManager.getTranslation("_information");
43
    }
44

  
45
    @Override
46
    public int getPriority() {
47
        return 1000;
48
    }
49

  
50
    @Override
51
    public boolean whenAccept() {
52
        this.whenApply();
53
        return true;
54
    }
55

  
56
    @Override
57
    public boolean whenApply() {
58
        this.informationPanel.fetch(layer);
59
        return true;
60
    }
61

  
62
    @Override
63
    public boolean whenCancel() {
64
        // Do nothing
65
        return true;
66
    }
67

  
68
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/InformationPanelView.java
1
package org.gvsig.app.project.documents.view.legend.gui;
2

  
3
import com.jeta.forms.components.separator.TitledSeparator;
4
import com.jeta.open.i18n.I18NUtils;
5
import com.jgoodies.forms.layout.CellConstraints;
6
import com.jgoodies.forms.layout.FormLayout;
7
import java.awt.BorderLayout;
8
import java.awt.ComponentOrientation;
9
import java.awt.Container;
10
import java.awt.Dimension;
11
import javax.swing.Box;
12
import javax.swing.ImageIcon;
13
import javax.swing.JEditorPane;
14
import javax.swing.JFrame;
15
import javax.swing.JPanel;
16
import javax.swing.JScrollPane;
17
import javax.swing.JTextField;
18

  
19

  
20
public class InformationPanelView extends JPanel
21
{
22
   JTextField txtFieldName = new JTextField();
23
   JEditorPane txtAreaInformation = new JEditorPane();
24
   TitledSeparator informationLabel = new TitledSeparator();
25
   TitledSeparator nameLabel = new TitledSeparator();
26

  
27
   /**
28
    * Default constructor
29
    */
30
   public InformationPanelView()
31
   {
32
      initializePanel();
33
   }
34

  
35
   /**
36
    * Adds fill components to empty cells in the first row and first column of the grid.
37
    * This ensures that the grid spacing will be the same as shown in the designer.
38
    * @param cols an array of column indices in the first row where fill components should be added.
39
    * @param rows an array of row indices in the first column where fill components should be added.
40
    */
41
   void addFillComponents( Container panel, int[] cols, int[] rows )
42
   {
43
      Dimension filler = new Dimension(10,10);
44

  
45
      boolean filled_cell_11 = false;
46
      CellConstraints cc = new CellConstraints();
47
      if ( cols.length > 0 && rows.length > 0 )
48
      {
49
         if ( cols[0] == 1 && rows[0] == 1 )
50
         {
51
            /** add a rigid area  */
52
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
53
            filled_cell_11 = true;
54
         }
55
      }
56

  
57
      for( int index = 0; index < cols.length; index++ )
58
      {
59
         if ( cols[index] == 1 && filled_cell_11 )
60
         {
61
            continue;
62
         }
63
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
64
      }
65

  
66
      for( int index = 0; index < rows.length; index++ )
67
      {
68
         if ( rows[index] == 1 && filled_cell_11 )
69
         {
70
            continue;
71
         }
72
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
73
      }
74

  
75
   }
76

  
77
   /**
78
    * Helper method to load an image file from the CLASSPATH
79
    * @param imageName the package and name of the file to load relative to the CLASSPATH
80
    * @return an ImageIcon instance with the specified image file
81
    * @throws IllegalArgumentException if the image resource cannot be loaded.
82
    */
83
   public ImageIcon loadImage( String imageName )
84
   {
85
      try
86
      {
87
         ClassLoader classloader = getClass().getClassLoader();
88
         java.net.URL url = classloader.getResource( imageName );
89
         if ( url != null )
90
         {
91
            ImageIcon icon = new ImageIcon( url );
92
            return icon;
93
         }
94
      }
95
      catch( Exception e )
96
      {
97
         e.printStackTrace();
98
      }
99
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
100
   }
101

  
102
   /**
103
    * Method for recalculating the component orientation for 
104
    * right-to-left Locales.
105
    * @param orientation the component orientation to be applied
106
    */
107
   public void applyComponentOrientation( ComponentOrientation orientation )
108
   {
109
      // Not yet implemented...
110
      // I18NUtils.applyComponentOrientation(this, orientation);
111
      super.applyComponentOrientation(orientation);
112
   }
113

  
114
   public JPanel createPanel()
115
   {
116
      JPanel jpanel1 = new JPanel();
117
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
118
      CellConstraints cc = new CellConstraints();
119
      jpanel1.setLayout(formlayout1);
120

  
121
      txtFieldName.setName("txtFieldName");
122
      txtFieldName.setToolTipText("_name");
123
      jpanel1.add(txtFieldName,new CellConstraints(2,4,1,1,CellConstraints.FILL,CellConstraints.FILL));
124

  
125
      txtAreaInformation.setContentType("text/html");
126
      txtAreaInformation.setEditable(false);
127
      txtAreaInformation.setName("txtAreaInformation");
128
      txtAreaInformation.setSelectionEnd(1);
129
      txtAreaInformation.setSelectionStart(1);
130
      txtAreaInformation.setText("<html>\n  <head>\n    \n  </head>\n  <body>\n  </body>\n</html>\n");
131
      txtAreaInformation.setToolTipText("_information");
132
      JScrollPane jscrollpane1 = new JScrollPane();
133
      jscrollpane1.setViewportView(txtAreaInformation);
134
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
135
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
136
      jpanel1.add(jscrollpane1,new CellConstraints(2,9,1,1,CellConstraints.FILL,CellConstraints.FILL));
137

  
138
      informationLabel.setName("informationLabel");
139
      informationLabel.setText("_information");
140
      jpanel1.add(informationLabel,cc.xy(2,7));
141

  
142
      nameLabel.setName("nameLabel");
143
      nameLabel.setText("_name");
144
      jpanel1.add(nameLabel,cc.xy(2,2));
145

  
146
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10 });
147
      return jpanel1;
148
   }
149

  
150
   /**
151
    * Initializer
152
    */
153
   protected void initializePanel()
154
   {
155
      setLayout(new BorderLayout());
156
      add(createPanel(), BorderLayout.CENTER);
157
   }
158

  
159

  
160
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/InformationPanelController.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.app.project.documents.view.legend.gui;
24

  
25
import java.util.Locale;
26

  
27
import javax.swing.JComponent;
28

  
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.i18n.I18nManager;
35
import org.gvsig.tools.swing.api.Component;
36

  
37

  
38
/**
39
 * @author fdiaz
40
 *
41
 */
42
public class InformationPanelController extends InformationPanelView implements Component {
43

  
44
    /**
45
     *
46
     */
47
    private static final long serialVersionUID = 2386492505441108866L;
48

  
49
    @SuppressWarnings("unused")
50
    private static final Logger LOG = LoggerFactory.getLogger(InformationPanelController.class);
51

  
52

  
53
    public InformationPanelController() {
54
        translate();
55
    }
56

  
57
    private void translate() {
58
        I18nManager i18nManager = ToolsLocator.getI18nManager();
59
        txtFieldName.setToolTipText(i18nManager.getTranslation(txtFieldName.getToolTipText()));
60
        nameLabel.setText(i18nManager.getTranslation(nameLabel.getText()));
61
        txtAreaInformation.setToolTipText(i18nManager.getTranslation(txtAreaInformation.getToolTipText()));
62
        informationLabel.setText(i18nManager.getTranslation(informationLabel.getText()));
63
    }
64

  
65
    /**
66
     * @param locale
67
    *
68
    */
69
    public void setLocate(Locale locale) {
70
        Locale l = super.getLocale();
71
        if (!l.equals(locale)) {
72
            translate();
73
        }
74
        super.setLocale(locale);
75
    }
76

  
77
    /**
78
     * @param layer
79
     */
80
    public void set(FLayer layer){
81
//        this.layer = layer;
82
        txtFieldName.setText(layer.getName());
83
        txtAreaInformation.setText(layer.getInfoString());
84
    }
85

  
86
    /**
87
     * @param layer
88
     * @return 
89
     */
90
    public boolean fetch(FLayer layer){
91
        layer.setName(txtFieldName.getText());
92
        layer.getMapContext().invalidate();
93
        return true;
94
    }
95

  
96
    @Override
97
    public JComponent asJComponent() {
98
        return this;
99
    }
100

  
101
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/InformationPanelView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
19
      <at name="rowspan">1</at>
20
      <at name="halign">default</at>
21
      <at name="valign">default</at>
22
      <at name="insets" object="insets">0,0,0,0</at>
23
     </object>
24
    </at>
25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
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/project/documents/view/legend/gui/InformationPanelView.xml</at>
28
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE</at>
29
   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at>
30
   <at name="components">
31
    <object classname="java.util.LinkedList">
32
     <item >
33
      <at name="value">
34
       <object classname="com.jeta.forms.store.memento.BeanMemento">
35
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
36
         <at name="cellconstraints">
37
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
38
           <at name="column">2</at>
39
           <at name="row">4</at>
40
           <at name="colspan">1</at>
41
           <at name="rowspan">1</at>
42
           <at name="halign">fill</at>
43
           <at name="valign">fill</at>
44
           <at name="insets" object="insets">0,0,0,0</at>
45
          </object>
46
         </at>
47
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
48
        </super>
49
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
50
        <at name="beanclass">javax.swing.JTextField</at>
51
        <at name="beanproperties">
52
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
53
          <at name="classname">javax.swing.JTextField</at>
54
          <at name="properties">
55
           <object classname="com.jeta.forms.store.support.PropertyMap">
56
            <at name="border">
57
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
58
              <super classname="com.jeta.forms.store.properties.BorderProperty">
59
               <at name="name">border</at>
60
              </super>
61
              <at name="borders">
62
               <object classname="java.util.LinkedList">
63
                <item >
64
                 <at name="value">
65
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
66
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
67
                    <at name="name">border</at>
68
                   </super>
69
                  </object>
70
                 </at>
71
                </item>
72
               </object>
73
              </at>
74
             </object>
75
            </at>
76
            <at name="name">txtFieldName</at>
77
            <at name="width">935</at>
78
            <at name="toolTipText">_name</at>
79
            <at name="height">20</at>
80
           </object>
81
          </at>
82
         </object>
83
        </at>
84
       </object>
85
      </at>
86
     </item>
87
     <item >
88
      <at name="value">
89
       <object classname="com.jeta.forms.store.memento.BeanMemento">
90
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
91
         <at name="cellconstraints">
92
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
93
           <at name="column">2</at>
94
           <at name="row">9</at>
95
           <at name="colspan">1</at>
96
           <at name="rowspan">1</at>
97
           <at name="halign">fill</at>
98
           <at name="valign">fill</at>
99
           <at name="insets" object="insets">0,0,0,0</at>
100
          </object>
101
         </at>
102
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
103
        </super>
104
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
105
        <at name="beanclass">javax.swing.JEditorPane</at>
106
        <at name="beanproperties">
107
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
108
          <at name="classname">javax.swing.JEditorPane</at>
109
          <at name="properties">
110
           <object classname="com.jeta.forms.store.support.PropertyMap">
111
            <at name="border">
112
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
113
              <super classname="com.jeta.forms.store.properties.BorderProperty">
114
               <at name="name">border</at>
115
              </super>
116
              <at name="borders">
117
               <object classname="java.util.LinkedList">
118
                <item >
119
                 <at name="value">
120
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
121
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
122
                    <at name="name">border</at>
123
                   </super>
124
                  </object>
125
                 </at>
126
                </item>
127
               </object>
128
              </at>
129
             </object>
130
            </at>
131
            <at name="selectionStart">1</at>
132
            <at name="editable">false</at>
133
            <at name="scrollableTracksViewportHeight">true</at>
134
            <at name="scrollableTracksViewportWidth">true</at>
135
            <at name="selectionEnd">1</at>
136
            <at name="name">txtAreaInformation</at>
137
            <at name="width">933</at>
138
            <at name="text">&lt;html&gt;
139
  &lt;head&gt;
140
    
141
  &lt;/head&gt;
142
  &lt;body&gt;
143
  &lt;/body&gt;
144
&lt;/html&gt;
145
</at>
146
            <at name="contentType">text/html</at>
147
            <at name="scollBars">
148
             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
149
              <at name="name">scollBars</at>
150
              <at name="verticalpolicy">20</at>
151
              <at name="horizontalpolicy">30</at>
152
              <at name="border">
153
               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
154
                <super classname="com.jeta.forms.store.properties.BorderProperty">
155
                 <at name="name">border</at>
156
                </super>
157
                <at name="borders">
158
                 <object classname="java.util.LinkedList">
159
                  <item >
160
                   <at name="value">
161
                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
162
                     <super classname="com.jeta.forms.store.properties.BorderProperty">
163
                      <at name="name">border</at>
164
                     </super>
165
                    </object>
166
                   </at>
167
                  </item>
168
                 </object>
169
                </at>
170
               </object>
171
              </at>
172
             </object>
173
            </at>
174
            <at name="toolTipText">_information</at>
175
            <at name="height">477</at>
176
           </object>
177
          </at>
178
         </object>
179
        </at>
180
       </object>
181
      </at>
182
     </item>
183
     <item >
184
      <at name="value">
185
       <object classname="com.jeta.forms.store.memento.BeanMemento">
186
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
187
         <at name="cellconstraints">
188
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
189
           <at name="column">2</at>
190
           <at name="row">7</at>
191
           <at name="colspan">1</at>
192
           <at name="rowspan">1</at>
193
           <at name="halign">default</at>
194
           <at name="valign">default</at>
195
           <at name="insets" object="insets">0,0,0,0</at>
196
          </object>
197
         </at>
198
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
199
        </super>
200
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
201
        <at name="beanclass">com.jeta.forms.components.separator.TitledSeparator</at>
202
        <at name="beanproperties">
203
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
204
          <at name="classname">com.jeta.forms.components.separator.TitledSeparator</at>
205
          <at name="properties">
206
           <object classname="com.jeta.forms.store.support.PropertyMap">
207
            <at name="border">
208
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
209
              <super classname="com.jeta.forms.store.properties.BorderProperty">
210
               <at name="name">border</at>
211
              </super>
212
              <at name="borders">
213
               <object classname="java.util.LinkedList">
214
                <item >
215
                 <at name="value">
216
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
217
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
218
                    <at name="name">border</at>
219
                   </super>
220
                  </object>
221
                 </at>
222
                </item>
223
               </object>
224
              </at>
225
             </object>
226
            </at>
227
            <at name="name">informationLabel</at>
228
            <at name="width">935</at>
229
            <at name="text">_information</at>
230
            <at name="height">15</at>
231
           </object>
232
          </at>
233
         </object>
234
        </at>
235
       </object>
236
      </at>
237
     </item>
238
     <item >
239
      <at name="value">
240
       <object classname="com.jeta.forms.store.memento.BeanMemento">
241
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
242
         <at name="cellconstraints">
243
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
244
           <at name="column">2</at>
245
           <at name="row">2</at>
246
           <at name="colspan">1</at>
247
           <at name="rowspan">1</at>
248
           <at name="halign">default</at>
249
           <at name="valign">default</at>
250
           <at name="insets" object="insets">0,0,0,0</at>
251
          </object>
252
         </at>
253
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
254
        </super>
255
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
256
        <at name="beanclass">com.jeta.forms.components.separator.TitledSeparator</at>
257
        <at name="beanproperties">
258
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
259
          <at name="classname">com.jeta.forms.components.separator.TitledSeparator</at>
260
          <at name="properties">
261
           <object classname="com.jeta.forms.store.support.PropertyMap">
262
            <at name="border">
263
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
264
              <super classname="com.jeta.forms.store.properties.BorderProperty">
265
               <at name="name">border</at>
266
              </super>
267
              <at name="borders">
268
               <object classname="java.util.LinkedList">
269
                <item >
270
                 <at name="value">
271
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
272
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
273
                    <at name="name">border</at>
274
                   </super>
275
                  </object>
276
                 </at>
277
                </item>
278
               </object>
279
              </at>
280
             </object>
281
            </at>
282
            <at name="name">nameLabel</at>
283
            <at name="width">935</at>
284
            <at name="text">_name</at>
285
            <at name="height">15</at>
286
           </object>
287
          </at>
288
         </object>
289
        </at>
290
       </object>
291
      </at>
292
     </item>
293
    </object>
294
   </at>
295
   <at name="properties">
296
    <object classname="com.jeta.forms.store.memento.PropertiesMemento">
297
     <at name="classname">com.jeta.forms.gui.form.GridView</at>
298
     <at name="properties">
299
      <object classname="com.jeta.forms.store.support.PropertyMap">
300
       <at name="border">
301
        <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
302
         <super classname="com.jeta.forms.store.properties.BorderProperty">
303
          <at name="name">border</at>
304
         </super>
305
         <at name="borders">
306
          <object classname="java.util.LinkedList"/>
307
         </at>
308
        </object>
309
       </at>
310
       <at name="name"/>
311
       <at name="fill">
312
        <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
313
         <at name="name">fill</at>
314
        </object>
315
       </at>
316
       <at name="scollBars">
317
        <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
318
         <at name="name">scollBars</at>
319
         <at name="verticalpolicy">21</at>
320
         <at name="horizontalpolicy">31</at>
321
         <at name="border">
322
          <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
323
           <super classname="com.jeta.forms.store.properties.BorderProperty">
324
            <at name="name">border</at>
325
           </super>
326
           <at name="borders">
327
            <object classname="java.util.LinkedList">
328
             <item >
329
              <at name="value">
330
               <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
331
                <super classname="com.jeta.forms.store.properties.BorderProperty">
332
                 <at name="name">border</at>
333
                </super>
334
               </object>
335
              </at>
336
             </item>
337
            </object>
338
           </at>
339
          </object>
340
         </at>
341
        </object>
342
       </at>
343
      </object>
344
     </at>
345
    </object>
346
   </at>
347
   <at name="cellpainters">
348
    <object classname="com.jeta.forms.store.support.Matrix">
349
     <at name="rows">
350
      <object classname="[Ljava.lang.Object;" size="10">
351
       <at name="item" index="0">
352
        <object classname="[Ljava.lang.Object;" size="3"/>
353
       </at>
354
       <at name="item" index="1">
355
        <object classname="[Ljava.lang.Object;" size="3"/>
356
       </at>
357
       <at name="item" index="2">
358
        <object classname="[Ljava.lang.Object;" size="3"/>
359
       </at>
360
       <at name="item" index="3">
361
        <object classname="[Ljava.lang.Object;" size="3"/>
362
       </at>
363
       <at name="item" index="4">
364
        <object classname="[Ljava.lang.Object;" size="3"/>
365
       </at>
366
       <at name="item" index="5">
367
        <object classname="[Ljava.lang.Object;" size="3"/>
368
       </at>
369
       <at name="item" index="6">
370
        <object classname="[Ljava.lang.Object;" size="3"/>
371
       </at>
372
       <at name="item" index="7">
373
        <object classname="[Ljava.lang.Object;" size="3"/>
374
       </at>
375
       <at name="item" index="8">
376
        <object classname="[Ljava.lang.Object;" size="3"/>
377
       </at>
378
       <at name="item" index="9">
379
        <object classname="[Ljava.lang.Object;" size="3"/>
380
       </at>
381
      </object>
382
     </at>
383
    </object>
384
   </at>
385
   <at name="rowgroups">
386
    <object classname="com.jeta.forms.store.memento.FormGroupSet">
387
     <at name="groups">
388
      <object classname="java.util.HashMap"/>
389
     </at>
390
    </object>
391
   </at>
392
   <at name="colgroups">
393
    <object classname="com.jeta.forms.store.memento.FormGroupSet">
394
     <at name="groups">
395
      <object classname="java.util.HashMap"/>
396
     </at>
397
    </object>
398
   </at>
399
  </object>
400
 </at>
401
</object>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/InformationLayerPropertiesPageFactory.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.app.project.documents.view.legend.gui;
24

  
25
import org.gvsig.app.project.documents.view.ViewDocument;
26
import org.gvsig.fmap.mapcontext.layers.FLayer;
27
import org.gvsig.propertypage.PropertiesPage;
28
import org.gvsig.propertypage.PropertiesPageFactory;
29

  
30

  
31
/**
32
 * @author fdiaz
33
 *
34
 */
35
public class InformationLayerPropertiesPageFactory implements PropertiesPageFactory {
36

  
37
    @Override
38
    public String getGroupID() {
39
        return ViewDocument.LAYER_PROPERTIES_PAGE_GROUP;
40
    }
41

  
42
    @Override
43
    public boolean isVisible(Object obj) {
44
        return obj instanceof FLayer;
45
    }
46

  
47
    @Override
48
    public PropertiesPage create(Object obj) {
49
        return (PropertiesPage) new InformationPropertiesPage((FLayer) obj);
50
    }
51

  
52
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerAddLayerWizardPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
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
 *
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
 *
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.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
24

  
25
import java.awt.Color;
26
import java.awt.Component;
27
import java.awt.Font;
28
import java.awt.GridLayout;
29
import java.awt.Window;
30

  
31
import javax.swing.JLabel;
32
import javax.swing.JList;
33
import javax.swing.JPanel;
34
import javax.swing.ListCellRenderer;
35
import javax.swing.ListModel;
36
import javax.swing.UIDefaults;
37

  
38
import org.cresques.cts.IProjection;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

  
42
import org.gvsig.andami.messages.Messages;
43
import org.gvsig.app.ApplicationLocator;
44
import org.gvsig.app.prepareAction.PrepareContext;
45
import org.gvsig.app.prepareAction.PrepareContextView;
46
import org.gvsig.fmap.dal.DataStore;
47
import org.gvsig.fmap.dal.DataStoreParameters;
48
import org.gvsig.fmap.dal.DataTypes;
49
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
50
import org.gvsig.fmap.mapcontrol.MapControl;
51
import org.gvsig.tools.dynobject.DynField;
52
import org.gvsig.tools.dynobject.DynObject;
53
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
54

  
55
/**
56
 * @author jmvivo
57
 *
58
 */
59
public class FilesystemExplorerAddLayerWizardPanel extends
60
        FilesystemExplorerWizardPanel {
61

  
62
    private static final long serialVersionUID = -5054057255129168139L;
63

  
64
    private static final Logger LOG = LoggerFactory
65
            .getLogger(FilesystemExplorerAddLayerWizardPanel.class);
66

  
67
    private PrepareContext prepareContext;
68

  
69
    @Override
70
    public void initWizard() {
71

  
72
        super.initWizard();
73
        this.getFileList().setCellRenderer(
74
                new TwoColumnFileListCellRenderer(this.getMapCtrl()));
75
    }
76

  
77
    @Override
78
    public void execute() {
79
        if (this.getMapCtrl() == null) {
80
            throw new IllegalArgumentException("MapControl need");
81
        }
82
        String layerName;
83

  
84
        for (DataStoreParameters params : this.getParameters()) {
85
            IProjection proj = this.getMapCtrl().getProjection();
86

  
87
            // Buscamos por el parametro de la proyeccion
88
            // que sean obligatorios y estén a null
89
            // y le ponemos la proyeccion de la vista
90
            DynField[] fields = params.getDynClass().getDynFields();
91
            for (DynField field : fields) {
92
                if (field.getType() == DataTypes.CRS && field.isMandatory()) {
93
                    if (params.getDynValue(field.getName()) == null) {
94
                        params.setDynValue(field.getName(), proj);
95
                    }
96
                }
97
            }
98

  
99
            layerName
100
                    = ((FilesystemStoreParameters) params).getFile().getName();
101

  
102
            this.doAddLayer(this.getMapCtrl(), layerName, params);
103
        }
104
    }
105

  
106
    protected void showPropertiesDialog(final DynObject parameters) {
107
        // For store parameters with a CRS field, add the current view
108
        // CRS as default value when null.
109
        try {
110
            IProjection projection = (IProjection) parameters.getDynValue("CRS");
111
            if (projection == null) {
112
                projection = getDefaultProjection();
113
                parameters.setDynValue("CRS", projection);
114
            }
115
        } catch (DynFieldNotFoundException e1) {
116
            LOG.info("Loading a store whose parameters don't have a CRS field");
117
        }
118

  
119
        FilesystemExplorerPropertiesPanelManager manager = ApplicationLocator.getFilesystemExplorerPropertiesPanelManager();
120
        FilesystemExplorerPropertiesPanel panel = manager.createPanel(parameters);   
121
        panel.setExcludeGeometryOptions(false);
122
        manager.showPropertiesDialog(parameters, panel);
123
        
124
        refreshFileList();
125
    }
126

  
127

  
128
    /**
129
     * @return
130
     */
131
    private IProjection getDefaultProjection() {
132
        return getMapCtrl().getViewPort().getProjection();
133
    }
134

  
135
    @Override
136
    protected PrepareContext getPrepareDataStoreContext() {
137
        if (this.prepareContext == null) {
138
            this.prepareContext = new PrepareContextView() {
139

  
140
                @Override
141
                public Window getOwnerWindow() {
142
                    return null;
143
                }
144

  
145
                @Override
146
                public MapControl getMapControl() {
147
                    return FilesystemExplorerAddLayerWizardPanel.this
148
                            .getMapCtrl();
149
                }
150

  
151
                @Override
152
                public IProjection getViewProjection() {
153
                    return getMapControl().getProjection();
154
                }
155

  
156
            };
157
        }
158
        return this.prepareContext;
159
    }
160

  
161
    // =================
162
    private class TwoColumnFileListCellRenderer extends JPanel implements ListCellRenderer {
163

  
164
        private JLabel fileName = null;
165
        private JLabel crsName = null;
166

  
167
        private Color selBC = null;
168
        private Color selFC = null;
169
        private Color unselBC = null;
170
        private Color unselFC = null;
171

  
172
        private MapControl mapCtrl = null;
173

  
174
        public TwoColumnFileListCellRenderer(MapControl mct) {
175
            // 1 col for name, one for crs
176
            setLayout(new GridLayout(0, 2));
177
            fileName = new JLabel();
178
            crsName = new JLabel();
179

  
180
            Font fnt = crsName.getFont();
181
            fnt = fnt.deriveFont((float) (fnt.getSize() - 1));
182
            crsName.setFont(fnt);
183

  
184
            add(fileName);
185
            add(crsName);
186
            mapCtrl = mct;
187

  
188
            UIDefaults defaults = javax.swing.UIManager.getDefaults();
189
            selBC = defaults.getColor("List.selectionBackground");
190
            selFC = defaults.getColor("List.selectionForeground");
191
            unselBC = this.getBackground();
192
            unselFC = this.getForeground();
193
        }
194

  
195
        @Override
196
        public Component getListCellRendererComponent(
197
                JList list, Object _value,
198
                int index, boolean isSelected, boolean cellHasFocus) {
199

  
200
            if (isSelected) {
201
                setBackground(selBC);
202
                fileName.setForeground(selFC);
203
                crsName.setForeground(selFC);
204
            } else {
205
                setBackground(unselBC);
206
                fileName.setForeground(unselFC);
207
                crsName.setForeground(unselFC);
208
            }
209

  
210
            // ===========================
211
            fileName.setText(_value == null
212
                    ? "?" : fixString(_value.toString()));
213

  
214
            ListModel lm = list.getModel();
215
            String unkown_tag = Messages.get("_Unknown_CRS_so_assumed");
216
            String view_crs = getViewCRS();
217

  
218
            if (lm instanceof FilesystemStoreListModel) {
219

  
220
                FilesystemStoreListModel fsslm = (FilesystemStoreListModel) lm;
221
                DynObject dyno = fsslm.getDynObjectAt(index);
222

  
223
                try {
224
                    Object crs_obj = dyno.getDynValue(DataStore.METADATA_CRS);
225
                    if (crs_obj == null || crs_obj.toString().compareToIgnoreCase("null") == 0) {
226
                        crsName.setText(unkown_tag + " " + view_crs);
227
                    } else {
228
                        if (crs_obj instanceof IProjection) {
229
                            IProjection ipr = (IProjection) crs_obj;
230
                            if (ipr.getAbrev().compareToIgnoreCase(view_crs) == 0) {
231
                                // CRS set but same as view's
232
                                crsName.setText(view_crs);
233
                            } else {
234
                                // CRS set and not same as view's
235
                                crsName.setText(ipr.getAbrev()
236
                                        + " ("
237
                                        + Messages.get("_reprojected_on_the_fly")
238
                                        + ")");
239
                            }
240
                        } else {
241
                            // CRS parameter class not expected
242
                            crsName.setText(unkown_tag + " " + view_crs);
243
                        }
244

  
245
                    }
246
                } catch (Exception ex) {
247
                    // CRS parameter not found
248
                    crsName.setText(unkown_tag + " " + view_crs);
249
                }
250

  
251
            } else {
252
                // list model not of expected class
253
                crsName.setText(unkown_tag + " " + view_crs);
254
            }
255

  
256
            return this;
257
        }
258

  
259
        /**
260
         * @param string
261
         * @return
262
         */
263
        private String fixString(String str) {
264

  
265
            int len = str.length();
266
            String resp = str;
267
            if (len < 32) {
268
                // return str;
269
            } else {
270
                int cut = len - 14;
271
                resp = resp.substring(0, 14)
272
                        + "..." + resp.substring(cut);
273
            }
274
            return resp + "    ";
275
        }
276

  
277
        private String getViewCRS() {
278
            if (this.mapCtrl == null) {
279
                return "CRS?";
280
            } else {
281
                return mapCtrl.getProjection().getAbrev();
282
            }
283
        }
284

  
285
    }
286

  
287
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerWizardPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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.
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.
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.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24 1
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
25 2

  
26
import java.awt.Component;
27 3
import java.awt.GridBagConstraints;
28 4
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
5
import java.awt.Window;
32 6
import java.io.File;
33 7
import java.util.ArrayList;
34 8
import java.util.Iterator;
35 9
import java.util.List;
36 10
import java.util.prefs.Preferences;
37 11

  
38
import javax.swing.AbstractListModel;
39
import javax.swing.JButton;
40
import javax.swing.JList;
41
import javax.swing.JPanel;
42
import javax.swing.JScrollPane;
43
import javax.swing.ListModel;
44
import javax.swing.ScrollPaneConstants;
45
import javax.swing.SwingUtilities;
12
import javax.swing.JOptionPane;
46 13
import javax.swing.event.AncestorEvent;
47 14
import javax.swing.event.AncestorListener;
48
import javax.swing.event.ListSelectionEvent;
49
import javax.swing.event.ListSelectionListener;
50 15
import javax.swing.filechooser.FileFilter;
51 16

  
52
import org.gvsig.andami.PluginServices;
53
import org.gvsig.andami.messages.Messages;
54
import org.gvsig.andami.messages.NotificationManager;
17
import org.cresques.cts.IProjection;
18
import org.slf4j.Logger;
19
import org.slf4j.LoggerFactory;
20

  
21
import org.gvsig.andami.Launcher;
55 22
import org.gvsig.app.ApplicationLocator;
56 23
import org.gvsig.app.ApplicationManager;
57 24
import org.gvsig.app.gui.WizardPanel;
58 25
import org.gvsig.app.prepareAction.PrepareContext;
26
import org.gvsig.app.prepareAction.PrepareContextView_v1;
27
import org.gvsig.app.project.documents.view.toc.actions.LayerErrorsPanel;
59 28
import org.gvsig.fmap.dal.DALLocator;
60 29
import org.gvsig.fmap.dal.DataManager;
30
import org.gvsig.fmap.dal.DataStore;
61 31
import org.gvsig.fmap.dal.DataStoreParameters;
32
import org.gvsig.fmap.dal.DataStoreProviderFactory;
33
import org.gvsig.fmap.dal.DataTypes;
62 34
import org.gvsig.fmap.dal.exception.DataException;
63 35
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter;
64 36
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
65 37
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
66 38
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
67
import org.gvsig.gui.beans.swing.JFileChooser;
39
import org.gvsig.fmap.mapcontext.MapContext;
40
import org.gvsig.fmap.mapcontext.MapContextLocator;
41
import org.gvsig.fmap.mapcontext.MapContextManager;
42
import org.gvsig.fmap.mapcontext.layers.FLayer;
43
import org.gvsig.fmap.mapcontrol.MapControl;
68 44
import org.gvsig.tools.ToolsLocator;
69
import org.gvsig.tools.dispose.Disposable;
45
import org.gvsig.tools.dispose.DisposeUtils;
46
import org.gvsig.tools.dynobject.DynField;
70 47
import org.gvsig.tools.dynobject.DynObject;
71 48
import org.gvsig.tools.i18n.I18nManager;
49
import org.gvsig.tools.identitymanagement.UnauthorizedException;
72 50
import org.gvsig.tools.swing.api.ToolsSwingLocator;
73
import org.slf4j.Logger;
74
import org.slf4j.LoggerFactory;
51
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
75 52

  
53

  
76 54
/**
77
 * @author jmvivo
78
 * 
55
 * @author fdiaz
56
 *
79 57
 */
80
public abstract class FilesystemExplorerWizardPanel extends WizardPanel
81
    implements ActionListener, ListSelectionListener, Disposable {
58
public class FilesystemExplorerWizardPanel extends WizardPanel {
82 59

  
83 60
    /**
84
	 *
85
	 */
86
    private static final long serialVersionUID = -3371957786521876903L;
61
     *
62
     */
63
    private static final long serialVersionUID = 788115220334290212L;
87 64

  
88
    private static final Logger LOG = LoggerFactory
89
        .getLogger(FilesystemExplorerWizardPanel.class);
65
    private static final Logger logger = LoggerFactory.getLogger(FilesystemExplorerWizardPanel.class);
90 66

  
67
    private static final String DEFAULT_FILTER = "All_supported";
68

  
91 69
    public static final String OPEN_LAYER_FILE_CHOOSER_ID =
92 70
        "OPEN_LAYER_FILE_CHOOSER_ID";
93 71

  
94
    protected static final String ADD_COMMAND = "ADD";
95
    protected static final String EDIT_COMMAND = "PROPERTIES";
96
    protected static final String REMOVE_COMMAND = "REMOVE";
97
    protected static final String UP_COMMAND = "UP";
98
    protected static final String DOWN_COMMAND = "DOWN";
72
    protected FilesystemServerExplorer explorer;
73
    private ArrayList<MyFileFilter> filters;
99 74

  
100 75
    private static String lastPath = null;
101
    private static MyFileFilter lastFilter = null;
102
    private static final String DEFAULT_FILTER = "All_supported";
76
    private FilesystemExplorerWizardPanelController panel = null;
103 77

  
104
    private JList fileList;
105
    private JScrollPane fileListScroll;
106
    private JPanel buttonsPanel;
107
    private JButton addButton;
108
    private JButton propertiesButton;
109
    private JButton removeButton;
110
    private JButton upButton;
111
    private JButton downButton;
112

  
113
    protected FilesystemServerExplorer explorer;
114
    private ArrayList<MyFileFilter> filters;
115
    
78
    /**
79
     *
80
     */
116 81
    public FilesystemExplorerWizardPanel() {
117 82
        super();
118 83
        this.addAncestorListener(new AncestorListener() {
119 84
            public void ancestorAdded(AncestorEvent ae) {
120 85
                initExplorer();
121 86
                initFilters();
87
                updatePanel();
122 88
            }
123 89
            public void ancestorRemoved(AncestorEvent ae) {
124 90
                dispose();
......
127 93
            }
128 94
        });
129 95
    }
130
    
131
    public void setTabName(String name) {
132
        super.setTabName(name);
133
    }
134 96

  
135
    public DataStoreParameters[] getParameters() {
136
        return ((FilesystemStoreListModel) getFileList().getModel())
137
            .getParameters();
97
    protected void updatePanel() {
98
        this.panel.setExplorer(this.explorer);
99
        this.panel.setFilters(this.filters);
138 100
    }
139 101

  
102
    @Override
140 103
    public void initWizard() {
141
        setTabName(PluginServices.getText(this, "Fichero"));
104
        I18nManager i18nManager = ToolsLocator.getI18nManager();
105
        setTabName(i18nManager.getTranslation("Fichero"));
142 106
        if (lastPath == null) {
143 107
            Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
144 108
            lastPath = prefs.get("DataFolder", null);
......
148 112
        initUI();
149 113
    }
150 114

  
115
    private void initUI() {
116

  
117
        setLayout(new GridBagLayout());
118
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
119
        gridBagConstraints.fill = GridBagConstraints.BOTH;
120
        gridBagConstraints.weightx = 1.0;
121
        gridBagConstraints.weighty = 1.0;
122

  
123
        panel = new FilesystemExplorerWizardPanelController(getMapContext(),explorer, filters);
124
        this.add(panel, gridBagConstraints);
125

  
126
    }
127

  
128
    @Override
129
    public void execute() {
130
        if (this.getMapCtrl() == null) {
131
            throw new IllegalArgumentException("MapControl need");
132
        }
133
        String layerName;
134

  
135
        for (DataStoreParameters params : this.getParameters()) {
136
            IProjection proj = this.getMapCtrl().getProjection();
137

  
138
            // Buscamos por el parametro de la proyeccion
139
            // que sean obligatorios y est?n a null
140
            // y le ponemos la proyeccion de la vista
141
            DynField[] fields = params.getDynClass().getDynFields();
142
            for (DynField field : fields) {
143
                if (field.getType() == DataTypes.CRS && field.isMandatory()) {
144
                    if (params.getDynValue(field.getName()) == null) {
145
                        params.setDynValue(field.getName(), proj);
146
                    }
147
                }
148
            }
149

  
150
            layerName = ((FilesystemStoreParameters) params).getFile().getName();
151

  
152
            this.doAddLayer(layerName, params);
153
        }
154
    }
155

  
156
    @Override
157
    public void close() {
158
        this.dispose();
159
    }
160

  
161
    /**
162
     * Dispose filters and explorer
163
     */
164
    public void dispose() {
165
        if (explorer != null) {
166
            explorer.dispose();
167
            explorer = null;
168
        }
169
        if (filters != null) {
170
            filters.clear();
171
            filters = null;
172
        }
173
        panel.dispose();
174
    }
175

  
176
    @Override
177
    public DataStoreParameters[] getParameters() {
178
        return this.panel.getParameters();
179
    }
180

  
181
    /**
182
     * @param files
183
     */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff