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 / export / jdbc / swing / panels / IdentifiersOptionsPanelView.java @ 44198
History | View | Annotate | Download (5.52 KB)
1 | 43925 | jjdelcerro | package org.gvsig.export.jdbc.swing.panels; |
---|---|---|---|
2 | 43377 | jjdelcerro | |
3 | import com.jgoodies.forms.layout.CellConstraints; |
||
4 | import com.jgoodies.forms.layout.FormLayout; |
||
5 | import java.awt.BorderLayout; |
||
6 | import java.awt.ComponentOrientation; |
||
7 | import java.awt.Container; |
||
8 | import java.awt.Dimension; |
||
9 | import javax.swing.Box; |
||
10 | import javax.swing.ImageIcon; |
||
11 | import javax.swing.JCheckBox; |
||
12 | import javax.swing.JLabel; |
||
13 | import javax.swing.JPanel; |
||
14 | |||
15 | |||
16 | public class IdentifiersOptionsPanelView extends JPanel |
||
17 | { |
||
18 | JLabel lblHeader = new JLabel(); |
||
19 | JCheckBox chkTraslateToLowerCase = new JCheckBox(); |
||
20 | JCheckBox chkRemoveSpaces = new JCheckBox(); |
||
21 | JCheckBox chkTraslateHyphens = new JCheckBox(); |
||
22 | |||
23 | /**
|
||
24 | * Default constructor
|
||
25 | */
|
||
26 | public IdentifiersOptionsPanelView()
|
||
27 | { |
||
28 | initializePanel(); |
||
29 | } |
||
30 | |||
31 | /**
|
||
32 | * Adds fill components to empty cells in the first row and first column of the grid.
|
||
33 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
34 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
35 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
36 | */
|
||
37 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
38 | { |
||
39 | Dimension filler = new Dimension(10,10); |
||
40 | |||
41 | boolean filled_cell_11 = false; |
||
42 | CellConstraints cc = new CellConstraints();
|
||
43 | if ( cols.length > 0 && rows.length > 0 ) |
||
44 | { |
||
45 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
46 | { |
||
47 | /** add a rigid area */
|
||
48 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
49 | filled_cell_11 = true;
|
||
50 | } |
||
51 | } |
||
52 | |||
53 | for( int index = 0; index < cols.length; index++ ) |
||
54 | { |
||
55 | if ( cols[index] == 1 && filled_cell_11 ) |
||
56 | { |
||
57 | continue;
|
||
58 | } |
||
59 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
60 | } |
||
61 | |||
62 | for( int index = 0; index < rows.length; index++ ) |
||
63 | { |
||
64 | if ( rows[index] == 1 && filled_cell_11 ) |
||
65 | { |
||
66 | continue;
|
||
67 | } |
||
68 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
69 | } |
||
70 | |||
71 | } |
||
72 | |||
73 | /**
|
||
74 | * Helper method to load an image file from the CLASSPATH
|
||
75 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
76 | * @return an ImageIcon instance with the specified image file
|
||
77 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
78 | */
|
||
79 | public ImageIcon loadImage( String imageName ) |
||
80 | { |
||
81 | try
|
||
82 | { |
||
83 | ClassLoader classloader = getClass().getClassLoader();
|
||
84 | java.net.URL url = classloader.getResource( imageName ); |
||
85 | if ( url != null ) |
||
86 | { |
||
87 | ImageIcon icon = new ImageIcon( url ); |
||
88 | return icon;
|
||
89 | } |
||
90 | } |
||
91 | catch( Exception e ) |
||
92 | { |
||
93 | e.printStackTrace(); |
||
94 | } |
||
95 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
96 | } |
||
97 | |||
98 | /**
|
||
99 | * Method for recalculating the component orientation for
|
||
100 | * right-to-left Locales.
|
||
101 | * @param orientation the component orientation to be applied
|
||
102 | */
|
||
103 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
104 | { |
||
105 | // Not yet implemented...
|
||
106 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
107 | super.applyComponentOrientation(orientation);
|
||
108 | } |
||
109 | |||
110 | public JPanel createPanel() |
||
111 | { |
||
112 | JPanel jpanel1 = new JPanel(); |
||
113 | 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"); |
||
114 | CellConstraints cc = new CellConstraints();
|
||
115 | jpanel1.setLayout(formlayout1); |
||
116 | |||
117 | lblHeader.setName("lblHeader");
|
||
118 | 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>");
|
||
119 | jpanel1.add(lblHeader,cc.xy(2,2)); |
||
120 | |||
121 | chkTraslateToLowerCase.setActionCommand("Trasladar identificadores de campo y tabla a minusculas");
|
||
122 | chkTraslateToLowerCase.setName("chkTraslateToLowerCase");
|
||
123 | chkTraslateToLowerCase.setSelected(true);
|
||
124 | chkTraslateToLowerCase.setText("Trasladar identificadores de campo y tabla a minusculas");
|
||
125 | jpanel1.add(chkTraslateToLowerCase,cc.xy(2,4)); |
||
126 | |||
127 | chkRemoveSpaces.setActionCommand("Trasladar espacios en blanco en los identificadores a \"_\"");
|
||
128 | chkRemoveSpaces.setName("chkRemoveSpaces");
|
||
129 | chkRemoveSpaces.setSelected(true);
|
||
130 | chkRemoveSpaces.setText("Trasladar espacios en blanco en los identificadores a \"_\"");
|
||
131 | jpanel1.add(chkRemoveSpaces,cc.xy(2,6)); |
||
132 | |||
133 | chkTraslateHyphens.setActionCommand("Trasladar guines, \"-\", en los identificadores a \"_\".");
|
||
134 | chkTraslateHyphens.setName("chkTraslateHyphens");
|
||
135 | chkTraslateHyphens.setSelected(true);
|
||
136 | chkTraslateHyphens.setText("Trasladar guines, \"-\", en los identificadores a \"_\".");
|
||
137 | jpanel1.add(chkTraslateHyphens,cc.xy(2,8)); |
||
138 | |||
139 | addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9 }); |
||
140 | return jpanel1;
|
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * Initializer
|
||
145 | */
|
||
146 | protected void initializePanel() |
||
147 | { |
||
148 | setLayout(new BorderLayout()); |
||
149 | add(createPanel(), BorderLayout.CENTER);
|
||
150 | } |
||
151 | |||
152 | |||
153 | } |