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.csv / src / main / java / org / gvsig / export / csv / swing / panels / CSVExportParametersPanelView.java @ 44395
History | View | Annotate | Download (6.83 KB)
1 |
package org.gvsig.export.csv.swing.panels; |
---|---|
2 |
import com.jeta.open.i18n.I18NUtils; |
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 java.awt.event.WindowAdapter; |
10 |
import java.awt.event.WindowEvent; |
11 |
import javax.swing.Box; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JTextField; |
18 |
|
19 |
|
20 |
public class CSVExportParametersPanelView extends JPanel |
21 |
{ |
22 |
JLabel lblQuotePolicy = new JLabel(); |
23 |
JLabel lblProfile = new JLabel(); |
24 |
JLabel lblLocale = new JLabel(); |
25 |
JLabel lblRecordSeparator = new JLabel(); |
26 |
JLabel lblDelimiter = new JLabel(); |
27 |
JLabel lblQuoteCharacter = new JLabel(); |
28 |
JLabel lblCommentStartMarker = new JLabel(); |
29 |
JComboBox cmbProfile = new JComboBox(); |
30 |
JComboBox cmbQuotePolicy = new JComboBox(); |
31 |
JComboBox cmbLocale = new JComboBox(); |
32 |
JTextField txtRecordSeparator = new JTextField(); |
33 |
JTextField txtDelimiter = new JTextField(); |
34 |
JTextField txtQuoteCharacter = new JTextField(); |
35 |
JTextField txtCommentStartMarker = new JTextField(); |
36 |
|
37 |
/**
|
38 |
* Default constructor
|
39 |
*/
|
40 |
public CSVExportParametersPanelView()
|
41 |
{ |
42 |
initializePanel(); |
43 |
} |
44 |
|
45 |
/**
|
46 |
* Main method for panel
|
47 |
*/
|
48 |
public static void main(String[] args) |
49 |
{ |
50 |
JFrame frame = new JFrame(); |
51 |
frame.setSize(600, 400); |
52 |
frame.setLocation(100, 100); |
53 |
frame.getContentPane().add(new CSVExportParametersPanelView());
|
54 |
frame.setVisible(true);
|
55 |
|
56 |
frame.addWindowListener( new WindowAdapter() |
57 |
{ |
58 |
public void windowClosing( WindowEvent evt ) |
59 |
{ |
60 |
System.exit(0); |
61 |
} |
62 |
}); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
67 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
68 |
* @param cols an array of column indices in the first row where fill components should be added.
|
69 |
* @param rows an array of row indices in the first column where fill components should be added.
|
70 |
*/
|
71 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
72 |
{ |
73 |
Dimension filler = new Dimension(10,10); |
74 |
|
75 |
boolean filled_cell_11 = false; |
76 |
CellConstraints cc = new CellConstraints();
|
77 |
if ( cols.length > 0 && rows.length > 0 ) |
78 |
{ |
79 |
if ( cols[0] == 1 && rows[0] == 1 ) |
80 |
{ |
81 |
/** add a rigid area */
|
82 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
83 |
filled_cell_11 = true;
|
84 |
} |
85 |
} |
86 |
|
87 |
for( int index = 0; index < cols.length; index++ ) |
88 |
{ |
89 |
if ( cols[index] == 1 && filled_cell_11 ) |
90 |
{ |
91 |
continue;
|
92 |
} |
93 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
94 |
} |
95 |
|
96 |
for( int index = 0; index < rows.length; index++ ) |
97 |
{ |
98 |
if ( rows[index] == 1 && filled_cell_11 ) |
99 |
{ |
100 |
continue;
|
101 |
} |
102 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
103 |
} |
104 |
|
105 |
} |
106 |
|
107 |
/**
|
108 |
* Helper method to load an image file from the CLASSPATH
|
109 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
110 |
* @return an ImageIcon instance with the specified image file
|
111 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
112 |
*/
|
113 |
public ImageIcon loadImage( String imageName ) |
114 |
{ |
115 |
try
|
116 |
{ |
117 |
ClassLoader classloader = getClass().getClassLoader();
|
118 |
java.net.URL url = classloader.getResource( imageName ); |
119 |
if ( url != null ) |
120 |
{ |
121 |
ImageIcon icon = new ImageIcon( url ); |
122 |
return icon;
|
123 |
} |
124 |
} |
125 |
catch( Exception e ) |
126 |
{ |
127 |
e.printStackTrace(); |
128 |
} |
129 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
130 |
} |
131 |
|
132 |
/**
|
133 |
* Method for recalculating the component orientation for
|
134 |
* right-to-left Locales.
|
135 |
* @param orientation the component orientation to be applied
|
136 |
*/
|
137 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
138 |
{ |
139 |
// Not yet implemented...
|
140 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
141 |
super.applyComponentOrientation(orientation);
|
142 |
} |
143 |
|
144 |
public JPanel createPanel() |
145 |
{ |
146 |
JPanel jpanel1 = new JPanel(); |
147 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:106DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE,CENTER:4PX:NONE,CENTER:DEFAULT:NONE"); |
148 |
CellConstraints cc = new CellConstraints();
|
149 |
jpanel1.setLayout(formlayout1); |
150 |
|
151 |
lblQuotePolicy.setName("lblQuotePolicy");
|
152 |
lblQuotePolicy.setText("_Quote_Policy");
|
153 |
jpanel1.add(lblQuotePolicy,cc.xy(2,4)); |
154 |
|
155 |
lblProfile.setName("lblProfile");
|
156 |
lblProfile.setText("_Profile");
|
157 |
jpanel1.add(lblProfile,cc.xy(2,2)); |
158 |
|
159 |
lblLocale.setName("lblLocale");
|
160 |
lblLocale.setText("_Locale");
|
161 |
jpanel1.add(lblLocale,cc.xy(2,6)); |
162 |
|
163 |
lblRecordSeparator.setName("lblRecordSeparator");
|
164 |
lblRecordSeparator.setText("_Record_separator");
|
165 |
jpanel1.add(lblRecordSeparator,cc.xy(2,8)); |
166 |
|
167 |
lblDelimiter.setName("lblDelimiter");
|
168 |
lblDelimiter.setText("_Delimiter");
|
169 |
jpanel1.add(lblDelimiter,cc.xy(2,10)); |
170 |
|
171 |
lblQuoteCharacter.setName("lblQuoteCharacter");
|
172 |
lblQuoteCharacter.setText("_Quote_character");
|
173 |
jpanel1.add(lblQuoteCharacter,cc.xy(2,12)); |
174 |
|
175 |
lblCommentStartMarker.setName("lblCommentStartMarker");
|
176 |
lblCommentStartMarker.setText("_Comment_start_marker");
|
177 |
jpanel1.add(lblCommentStartMarker,cc.xy(2,14)); |
178 |
|
179 |
cmbProfile.setName("cmbProfile");
|
180 |
jpanel1.add(cmbProfile,cc.xy(3,2)); |
181 |
|
182 |
cmbQuotePolicy.setName("cmbQuotePolicy");
|
183 |
jpanel1.add(cmbQuotePolicy,cc.xy(3,4)); |
184 |
|
185 |
cmbLocale.setName("cmbLocale");
|
186 |
jpanel1.add(cmbLocale,cc.xy(3,6)); |
187 |
|
188 |
txtRecordSeparator.setName("txtRecordSeparator");
|
189 |
jpanel1.add(txtRecordSeparator,cc.xy(3,8)); |
190 |
|
191 |
txtDelimiter.setName("txtDelimiter");
|
192 |
jpanel1.add(txtDelimiter,cc.xy(3,10)); |
193 |
|
194 |
txtQuoteCharacter.setName("txtQuoteCharacter");
|
195 |
jpanel1.add(txtQuoteCharacter,cc.xy(3,12)); |
196 |
|
197 |
txtCommentStartMarker.setName("txtCommentStartMarker");
|
198 |
jpanel1.add(txtCommentStartMarker,cc.xy(3,14)); |
199 |
|
200 |
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 }); |
201 |
return jpanel1;
|
202 |
} |
203 |
|
204 |
/**
|
205 |
* Initializer
|
206 |
*/
|
207 |
protected void initializePanel() |
208 |
{ |
209 |
setLayout(new BorderLayout()); |
210 |
add(createPanel(), BorderLayout.CENTER);
|
211 |
} |
212 |
|
213 |
|
214 |
} |