Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / export / swing / impl / panels / CheckGeometriesPanelView.java @ 44168

History | View | Annotate | Download (6.53 KB)

1 43925 jjdelcerro
package org.gvsig.export.swing.impl.panels;
2
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ButtonGroup;
12
import javax.swing.ImageIcon;
13
import javax.swing.JCheckBox;
14
import javax.swing.JComboBox;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JPanel;
18
import javax.swing.JRadioButton;
19
20
21
public class CheckGeometriesPanelView extends JPanel
22
{
23
   JLabel lblHeader = new JLabel();
24
   JRadioButton rdbCheckNone = new JRadioButton();
25
   ButtonGroup buttongroup1 = new ButtonGroup();
26
   JRadioButton rdbCheckIsCorrupt = new JRadioButton();
27
   JLabel lblCheckIsCorrupt = new JLabel();
28
   JComboBox cboActionIsCorrupt = new JComboBox();
29
   JRadioButton rdbCheckIsValid = new JRadioButton();
30
   JLabel lblCheckIsvalid = new JLabel();
31
   JCheckBox chkTryFixGeometry = new JCheckBox();
32
   JComboBox cboActionIsValid = new JComboBox();
33
34
   /**
35
    * Default constructor
36
    */
37
   public CheckGeometriesPanelView()
38
   {
39
      initializePanel();
40
   }
41
42
   /**
43
    * Adds fill components to empty cells in the first row and first column of the grid.
44
    * This ensures that the grid spacing will be the same as shown in the designer.
45
    * @param cols an array of column indices in the first row where fill components should be added.
46
    * @param rows an array of row indices in the first column where fill components should be added.
47
    */
48
   void addFillComponents( Container panel, int[] cols, int[] rows )
49
   {
50
      Dimension filler = new Dimension(10,10);
51
52
      boolean filled_cell_11 = false;
53
      CellConstraints cc = new CellConstraints();
54
      if ( cols.length > 0 && rows.length > 0 )
55
      {
56
         if ( cols[0] == 1 && rows[0] == 1 )
57
         {
58
            /** add a rigid area  */
59
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
60
            filled_cell_11 = true;
61
         }
62
      }
63
64
      for( int index = 0; index < cols.length; index++ )
65
      {
66
         if ( cols[index] == 1 && filled_cell_11 )
67
         {
68
            continue;
69
         }
70
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
71
      }
72
73
      for( int index = 0; index < rows.length; index++ )
74
      {
75
         if ( rows[index] == 1 && filled_cell_11 )
76
         {
77
            continue;
78
         }
79
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
80
      }
81
82
   }
83
84
   /**
85
    * Helper method to load an image file from the CLASSPATH
86
    * @param imageName the package and name of the file to load relative to the CLASSPATH
87
    * @return an ImageIcon instance with the specified image file
88
    * @throws IllegalArgumentException if the image resource cannot be loaded.
89
    */
90
   public ImageIcon loadImage( String imageName )
91
   {
92
      try
93
      {
94
         ClassLoader classloader = getClass().getClassLoader();
95
         java.net.URL url = classloader.getResource( imageName );
96
         if ( url != null )
97
         {
98
            ImageIcon icon = new ImageIcon( url );
99
            return icon;
100
         }
101
      }
102
      catch( Exception e )
103
      {
104
         e.printStackTrace();
105
      }
106
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
107
   }
108
109
   /**
110
    * Method for recalculating the component orientation for
111
    * right-to-left Locales.
112
    * @param orientation the component orientation to be applied
113
    */
114
   public void applyComponentOrientation( ComponentOrientation orientation )
115
   {
116
      // Not yet implemented...
117
      // I18NUtils.applyComponentOrientation(this, orientation);
118
      super.applyComponentOrientation(orientation);
119
   }
120
121
   public JPanel createPanel()
122
   {
123
      JPanel jpanel1 = new JPanel();
124
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
125
      CellConstraints cc = new CellConstraints();
126
      jpanel1.setLayout(formlayout1);
127
128
      lblHeader.setName("lblHeader");
129
      lblHeader.setText("_check_geometries_before_export_header");
130
      jpanel1.add(lblHeader,cc.xywh(2,2,2,1));
131
132
      rdbCheckNone.setActionCommand("_No_realizar_ninguna_comprobacion_sobre_las_geometrias");
133
      rdbCheckNone.setName("rdbCheckNone");
134
      rdbCheckNone.setText("_No_realizar_ninguna_comprobacion_sobre_las_geometrias");
135
      buttongroup1.add(rdbCheckNone);
136
      jpanel1.add(rdbCheckNone,cc.xywh(2,4,2,1));
137
138
      rdbCheckIsCorrupt.setActionCommand("_Comprobar_que_la_geometria_no_este_corrupta");
139
      rdbCheckIsCorrupt.setName("rdbCheckIsCorrupt");
140
      rdbCheckIsCorrupt.setText("_Comprobar_que_la_geometria_no_este_corrupta");
141
      buttongroup1.add(rdbCheckIsCorrupt);
142
      jpanel1.add(rdbCheckIsCorrupt,cc.xywh(2,6,2,1));
143
144
      lblCheckIsCorrupt.setName("lblCheckIsCorrupt");
145
      lblCheckIsCorrupt.setText("_Cuando_la_geometria_este_corrupta");
146
      jpanel1.add(lblCheckIsCorrupt,cc.xy(3,8));
147
148
      cboActionIsCorrupt.setName("cboActionIsCorrupt");
149
      jpanel1.add(cboActionIsCorrupt,cc.xy(3,10));
150
151
      rdbCheckIsValid.setActionCommand("_Comprobar_la_validez_de_las_geometrias_antes_de_insertarlas");
152
      rdbCheckIsValid.setName("rdbCheckIsValid");
153
      rdbCheckIsValid.setText("_Comprobar_la_validez_de_las_geometrias_antes_de_insertarlas");
154
      buttongroup1.add(rdbCheckIsValid);
155
      jpanel1.add(rdbCheckIsValid,cc.xywh(2,12,2,1));
156
157
      lblCheckIsvalid.setName("lblCheckIsvalid");
158
      lblCheckIsvalid.setText("_Cuando_la_geometria_no_sea_valida");
159
      jpanel1.add(lblCheckIsvalid,cc.xy(3,14));
160
161
      chkTryFixGeometry.setActionCommand("_Intentar_reparar_la_geometria");
162
      chkTryFixGeometry.setName("chkTryFixGeometry");
163
      chkTryFixGeometry.setText("_Intentar_reparar_la_geometria");
164
      jpanel1.add(chkTryFixGeometry,cc.xy(3,16));
165
166
      cboActionIsValid.setName("cboActionIsValid");
167
      jpanel1.add(cboActionIsValid,cc.xy(3,18));
168
169
      addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 });
170
      return jpanel1;
171
   }
172
173
   /**
174
    * Initializer
175
    */
176
   protected void initializePanel()
177
   {
178
      setLayout(new BorderLayout());
179
      add(createPanel(), BorderLayout.CENTER);
180
   }
181
182
183
}