Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.jdbc / src / main / java / org / gvsig / exportto / swing / prov / jdbc / panel / IdentifiersOptionsPanelView.java @ 43377

History | View | Annotate | Download (5.59 KB)

1
package org.gvsig.exportto.swing.prov.jdbc.panel;
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.ImageIcon;
12
import javax.swing.JCheckBox;
13
import javax.swing.JFrame;
14
import javax.swing.JLabel;
15
import javax.swing.JPanel;
16

    
17

    
18
public class IdentifiersOptionsPanelView extends JPanel
19
{
20
   JLabel lblHeader = new JLabel();
21
   JCheckBox chkTraslateToLowerCase = new JCheckBox();
22
   JCheckBox chkRemoveSpaces = new JCheckBox();
23
   JCheckBox chkTraslateHyphens = new JCheckBox();
24

    
25
   /**
26
    * Default constructor
27
    */
28
   public IdentifiersOptionsPanelView()
29
   {
30
      initializePanel();
31
   }
32

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

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

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

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

    
73
   }
74

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

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

    
112
   public JPanel createPanel()
113
   {
114
      JPanel jpanel1 = new JPanel();
115
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:GROW(1.0),FILL:4DLU: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");
116
      CellConstraints cc = new CellConstraints();
117
      jpanel1.setLayout(formlayout1);
118

    
119
      lblHeader.setName("lblHeader");
120
      lblHeader.setText("<html> Algunas bases de datos precisan tratar los identificadores de tabla o campo que tienen mayusculas y minusculas mezcladas, o espacios en blanco de forma especial a la hora de referirse a ellos.  Es recomendable que no los utilice para evitar problemas.<br> Puede indicar al asistente que traslade todos los nombres de campo a minusculas y que use \"_\" en lugar de espacios en blanco en el nombre de tabla si los hubiese. </html>");
121
      jpanel1.add(lblHeader,cc.xy(2,2));
122

    
123
      chkTraslateToLowerCase.setActionCommand("Trasladar identificadores de campo y tabla a minusculas");
124
      chkTraslateToLowerCase.setName("chkTraslateToLowerCase");
125
      chkTraslateToLowerCase.setSelected(true);
126
      chkTraslateToLowerCase.setText("Trasladar identificadores de campo y tabla a minusculas");
127
      jpanel1.add(chkTraslateToLowerCase,cc.xy(2,4));
128

    
129
      chkRemoveSpaces.setActionCommand("Trasladar espacios en blanco en los identificadores a  \"_\"");
130
      chkRemoveSpaces.setName("chkRemoveSpaces");
131
      chkRemoveSpaces.setSelected(true);
132
      chkRemoveSpaces.setText("Trasladar espacios en blanco en los identificadores a  \"_\"");
133
      jpanel1.add(chkRemoveSpaces,cc.xy(2,6));
134

    
135
      chkTraslateHyphens.setActionCommand("Trasladar guines, \"-\", en los identificadores a \"_\".");
136
      chkTraslateHyphens.setName("chkTraslateHyphens");
137
      chkTraslateHyphens.setSelected(true);
138
      chkTraslateHyphens.setText("Trasladar guines, \"-\", en los identificadores a \"_\".");
139
      jpanel1.add(chkTraslateHyphens,cc.xy(2,8));
140

    
141
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9 });
142
      return jpanel1;
143
   }
144

    
145
   /**
146
    * Initializer
147
    */
148
   protected void initializePanel()
149
   {
150
      setLayout(new BorderLayout());
151
      add(createPanel(), BorderLayout.CENTER);
152
   }
153

    
154

    
155
}