svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / featuretype / DefaultFeatureAttributesSelectionPanelView.java @ 47426
History | View | Annotate | Download (10.2 KB)
1 | 44707 | jjdelcerro | package org.gvsig.fmap.dal.swing.impl.featuretype; |
---|---|---|---|
2 | 44644 | jjdelcerro | 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 | 45155 | omartinez | import java.awt.event.WindowAdapter; |
10 | import java.awt.event.WindowEvent; |
||
11 | 44644 | jjdelcerro | import javax.swing.Box; |
12 | import javax.swing.ImageIcon; |
||
13 | import javax.swing.JButton; |
||
14 | import javax.swing.JFrame; |
||
15 | import javax.swing.JList; |
||
16 | import javax.swing.JPanel; |
||
17 | import javax.swing.JScrollPane; |
||
18 | import javax.swing.JTextField; |
||
19 | import javax.swing.border.EmptyBorder; |
||
20 | |||
21 | |||
22 | 44712 | jjdelcerro | public class DefaultFeatureAttributesSelectionPanelView extends JPanel |
23 | 44644 | jjdelcerro | { |
24 | JList lstAvailableColumns = new JList(); |
||
25 | 44707 | jjdelcerro | JList lstSelectedColumns = new JList(); |
26 | 44644 | jjdelcerro | JButton btnColumnDown = new JButton(); |
27 | JButton btnColumnUp = new JButton(); |
||
28 | JButton btnColumnAdd = new JButton(); |
||
29 | JButton btnColumnRemove = new JButton(); |
||
30 | JTextField txtColumnsFilter = new JTextField(); |
||
31 | JButton btnColumnsFilter = new JButton(); |
||
32 | 45155 | omartinez | JButton btnHistory = new JButton(); |
33 | JButton btnBookmarks = new JButton(); |
||
34 | JButton btnExpression = new JButton(); |
||
35 | JTextField txtExpression = new JTextField(); |
||
36 | 44644 | jjdelcerro | |
37 | /**
|
||
38 | * Default constructor
|
||
39 | */
|
||
40 | 44712 | jjdelcerro | public DefaultFeatureAttributesSelectionPanelView()
|
41 | 44644 | jjdelcerro | { |
42 | initializePanel(); |
||
43 | } |
||
44 | |||
45 | /**
|
||
46 | 45155 | omartinez | * 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 DefaultFeatureAttributesSelectionPanelView());
|
||
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 | 44644 | jjdelcerro | * 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:4DLU:NONE,FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.4),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
||
148 | CellConstraints cc = new CellConstraints();
|
||
149 | jpanel1.setLayout(formlayout1); |
||
150 | |||
151 | lstAvailableColumns.setName("lstAvailableColumns");
|
||
152 | JScrollPane jscrollpane1 = new JScrollPane(); |
||
153 | jscrollpane1.setViewportView(lstAvailableColumns); |
||
154 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
155 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
156 | 45155 | omartinez | jpanel1.add(jscrollpane1,cc.xy(2,4)); |
157 | 44644 | jjdelcerro | |
158 | 44707 | jjdelcerro | lstSelectedColumns.setName("lstSelectedColumns");
|
159 | 44644 | jjdelcerro | JScrollPane jscrollpane2 = new JScrollPane(); |
160 | 44707 | jjdelcerro | jscrollpane2.setViewportView(lstSelectedColumns); |
161 | 44644 | jjdelcerro | jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
162 | jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
163 | jpanel1.add(jscrollpane2,cc.xy(6,4)); |
||
164 | |||
165 | jpanel1.add(createPanel1(),cc.xy(6,6)); |
||
166 | jpanel1.add(createPanel2(),cc.xy(4,4)); |
||
167 | jpanel1.add(createPanel3(),cc.xy(2,2)); |
||
168 | 45155 | omartinez | jpanel1.add(createPanel4(),cc.xy(2,6)); |
169 | 44644 | jjdelcerro | addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7 }); |
170 | return jpanel1;
|
||
171 | } |
||
172 | |||
173 | public JPanel createPanel1() |
||
174 | { |
||
175 | JPanel jpanel1 = new JPanel(); |
||
176 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
||
177 | CellConstraints cc = new CellConstraints();
|
||
178 | jpanel1.setLayout(formlayout1); |
||
179 | |||
180 | btnColumnDown.setActionCommand("...");
|
||
181 | 47426 | jjdelcerro | btnColumnDown.setIcon(loadImage("common-arrow-down.png"));
|
182 | 44644 | jjdelcerro | btnColumnDown.setName("btnColumnDown");
|
183 | EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
||
184 | btnColumnDown.setBorder(emptyborder1); |
||
185 | jpanel1.add(btnColumnDown,cc.xy(8,1)); |
||
186 | |||
187 | btnColumnUp.setActionCommand("...");
|
||
188 | 47426 | jjdelcerro | btnColumnUp.setIcon(loadImage("common-arrow-up.png"));
|
189 | 44644 | jjdelcerro | btnColumnUp.setName("btnColumnUp");
|
190 | EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
||
191 | btnColumnUp.setBorder(emptyborder2); |
||
192 | jpanel1.add(btnColumnUp,cc.xy(6,1)); |
||
193 | |||
194 | 44707 | jjdelcerro | addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,7 },new int[]{ 1 }); |
195 | 44644 | jjdelcerro | return jpanel1;
|
196 | } |
||
197 | |||
198 | public JPanel createPanel2() |
||
199 | { |
||
200 | JPanel jpanel1 = new JPanel(); |
||
201 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
||
202 | CellConstraints cc = new CellConstraints();
|
||
203 | jpanel1.setLayout(formlayout1); |
||
204 | |||
205 | btnColumnAdd.setActionCommand("...");
|
||
206 | 47426 | jjdelcerro | btnColumnAdd.setIcon(loadImage("common-arrow-right.png"));
|
207 | 44644 | jjdelcerro | btnColumnAdd.setName("btnColumnAdd");
|
208 | EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
||
209 | btnColumnAdd.setBorder(emptyborder1); |
||
210 | jpanel1.add(btnColumnAdd,cc.xy(1,1)); |
||
211 | |||
212 | btnColumnRemove.setActionCommand("...");
|
||
213 | 47426 | jjdelcerro | btnColumnRemove.setIcon(loadImage("common-arrow-left.png"));
|
214 | 44644 | jjdelcerro | btnColumnRemove.setName("btnColumnRemove");
|
215 | EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
||
216 | btnColumnRemove.setBorder(emptyborder2); |
||
217 | jpanel1.add(btnColumnRemove,cc.xy(1,3)); |
||
218 | |||
219 | addFillComponents(jpanel1,new int[0],new int[]{ 2 }); |
||
220 | return jpanel1;
|
||
221 | } |
||
222 | |||
223 | public JPanel createPanel3() |
||
224 | { |
||
225 | JPanel jpanel1 = new JPanel(); |
||
226 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
||
227 | CellConstraints cc = new CellConstraints();
|
||
228 | jpanel1.setLayout(formlayout1); |
||
229 | |||
230 | txtColumnsFilter.setName("txtColumnsFilter");
|
||
231 | jpanel1.add(txtColumnsFilter,cc.xy(1,1)); |
||
232 | |||
233 | btnColumnsFilter.setActionCommand("...");
|
||
234 | 47426 | jjdelcerro | btnColumnsFilter.setIcon(loadImage("common-filter.png"));
|
235 | 44644 | jjdelcerro | btnColumnsFilter.setName("btnColumnsFilter");
|
236 | EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
||
237 | btnColumnsFilter.setBorder(emptyborder1); |
||
238 | jpanel1.add(btnColumnsFilter,cc.xy(3,1)); |
||
239 | |||
240 | addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
||
241 | return jpanel1;
|
||
242 | } |
||
243 | |||
244 | 45155 | omartinez | public JPanel createPanel4() |
245 | { |
||
246 | JPanel jpanel1 = new JPanel(); |
||
247 | FormLayout formlayout1 = new FormLayout("FILL:390PX:GROW(1.0),FILL:4PX:NONE,FILL:DEFAULT:NONE,FILL:2DLU:NONE,FILL:DEFAULT:NONE,FILL:1DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
||
248 | CellConstraints cc = new CellConstraints();
|
||
249 | jpanel1.setLayout(formlayout1); |
||
250 | |||
251 | btnHistory.setActionCommand("...");
|
||
252 | 47426 | jjdelcerro | btnHistory.setIcon(loadImage("picker-history.png"));
|
253 | 45155 | omartinez | btnHistory.setName("btnHistory");
|
254 | EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
||
255 | btnHistory.setBorder(emptyborder1); |
||
256 | jpanel1.add(btnHistory,cc.xy(7,1)); |
||
257 | |||
258 | btnBookmarks.setActionCommand("...");
|
||
259 | 47426 | jjdelcerro | btnBookmarks.setIcon(loadImage("picker-bookmarks.png"));
|
260 | 45155 | omartinez | btnBookmarks.setName("btnBookmarks");
|
261 | EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
||
262 | btnBookmarks.setBorder(emptyborder2); |
||
263 | jpanel1.add(btnBookmarks,cc.xy(5,1)); |
||
264 | |||
265 | btnExpression.setActionCommand("...");
|
||
266 | 47426 | jjdelcerro | btnExpression.setIcon(loadImage("picker-expression.png"));
|
267 | 45155 | omartinez | btnExpression.setName("btnExpression");
|
268 | EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
||
269 | btnExpression.setBorder(emptyborder3); |
||
270 | jpanel1.add(btnExpression,cc.xy(3,1)); |
||
271 | |||
272 | txtExpression.setName("txtExpression");
|
||
273 | jpanel1.add(txtExpression,cc.xy(1,1)); |
||
274 | |||
275 | addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
||
276 | return jpanel1;
|
||
277 | } |
||
278 | |||
279 | 44644 | jjdelcerro | /**
|
280 | * Initializer
|
||
281 | */
|
||
282 | protected void initializePanel() |
||
283 | { |
||
284 | setLayout(new BorderLayout()); |
||
285 | add(createPanel(), BorderLayout.CENTER);
|
||
286 | } |
||
287 | |||
288 | |||
289 | } |