gvsig-projects-pool / org.gvsig.topology / trunk / org.gvsig.topology / org.gvsig.topology.swing / org.gvsig.topology.swing.impl / src / main / java / org / gvsig / topology / swing / impl / DefaultJTopologyReportView.java @ 727
History | View | Annotate | Download (13.9 KB)
1 |
package org.gvsig.topology.swing.impl; |
---|---|
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.JButton; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JProgressBar; |
18 |
import javax.swing.JScrollPane; |
19 |
import javax.swing.JTabbedPane; |
20 |
import javax.swing.JTable; |
21 |
import javax.swing.JToggleButton; |
22 |
import javax.swing.border.EmptyBorder; |
23 |
|
24 |
|
25 |
public class DefaultJTopologyReportView extends JPanel |
26 |
{ |
27 |
JTabbedPane tabData = new JTabbedPane(); |
28 |
JTable tblErrors = new JTable(); |
29 |
JLabel lblShow = new JLabel(); |
30 |
JComboBox cboRules = new JComboBox(); |
31 |
JToggleButton btnVisibleExtentOnly = new JToggleButton(); |
32 |
JButton btnZoomGeometry = new JButton(); |
33 |
JButton btnActions = new JButton(); |
34 |
JButton btnRefresh = new JButton(); |
35 |
JToggleButton btnShowErrors = new JToggleButton(); |
36 |
JToggleButton btnShowExceptions = new JToggleButton(); |
37 |
JToggleButton btnShowForm = new JToggleButton(); |
38 |
JButton btnCenterError = new JButton(); |
39 |
JButton btnCenterGeometry = new JButton(); |
40 |
JButton btnZoomError = new JButton(); |
41 |
JButton btnEraseErrorMarks = new JButton(); |
42 |
JPanel pnlParameters = new JPanel(); |
43 |
JLabel lblActionDescription = new JLabel(); |
44 |
JLabel lblActionTitle = new JLabel(); |
45 |
JButton btnParametersCancel = new JButton(); |
46 |
JButton btnParametersAccept = new JButton(); |
47 |
JLabel lblTaskStatusMessage = new JLabel(); |
48 |
JProgressBar pbTaskStatusProgress = new JProgressBar(); |
49 |
JButton btnTaskStatusCancel = new JButton(); |
50 |
JLabel lblTaskStatusTitle = new JLabel(); |
51 |
|
52 |
/**
|
53 |
* Default constructor
|
54 |
*/
|
55 |
public DefaultJTopologyReportView()
|
56 |
{ |
57 |
initializePanel(); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
62 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
63 |
* @param cols an array of column indices in the first row where fill components should be added.
|
64 |
* @param rows an array of row indices in the first column where fill components should be added.
|
65 |
*/
|
66 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
67 |
{ |
68 |
Dimension filler = new Dimension(10,10); |
69 |
|
70 |
boolean filled_cell_11 = false; |
71 |
CellConstraints cc = new CellConstraints();
|
72 |
if ( cols.length > 0 && rows.length > 0 ) |
73 |
{ |
74 |
if ( cols[0] == 1 && rows[0] == 1 ) |
75 |
{ |
76 |
/** add a rigid area */
|
77 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
78 |
filled_cell_11 = true;
|
79 |
} |
80 |
} |
81 |
|
82 |
for( int index = 0; index < cols.length; index++ ) |
83 |
{ |
84 |
if ( cols[index] == 1 && filled_cell_11 ) |
85 |
{ |
86 |
continue;
|
87 |
} |
88 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
89 |
} |
90 |
|
91 |
for( int index = 0; index < rows.length; index++ ) |
92 |
{ |
93 |
if ( rows[index] == 1 && filled_cell_11 ) |
94 |
{ |
95 |
continue;
|
96 |
} |
97 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
98 |
} |
99 |
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* Helper method to load an image file from the CLASSPATH
|
104 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
105 |
* @return an ImageIcon instance with the specified image file
|
106 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
107 |
*/
|
108 |
public ImageIcon loadImage( String imageName ) |
109 |
{ |
110 |
try
|
111 |
{ |
112 |
ClassLoader classloader = getClass().getClassLoader();
|
113 |
java.net.URL url = classloader.getResource( imageName ); |
114 |
if ( url != null ) |
115 |
{ |
116 |
ImageIcon icon = new ImageIcon( url ); |
117 |
return icon;
|
118 |
} |
119 |
} |
120 |
catch( Exception e ) |
121 |
{ |
122 |
e.printStackTrace(); |
123 |
} |
124 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
125 |
} |
126 |
|
127 |
/**
|
128 |
* Method for recalculating the component orientation for
|
129 |
* right-to-left Locales.
|
130 |
* @param orientation the component orientation to be applied
|
131 |
*/
|
132 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
133 |
{ |
134 |
// Not yet implemented...
|
135 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
136 |
super.applyComponentOrientation(orientation);
|
137 |
} |
138 |
|
139 |
public JPanel createPanel() |
140 |
{ |
141 |
JPanel jpanel1 = new JPanel(); |
142 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
143 |
CellConstraints cc = new CellConstraints();
|
144 |
jpanel1.setLayout(formlayout1); |
145 |
|
146 |
tabData.setName("tabData");
|
147 |
tabData.addTab("_Errors",null,createPanel1()); |
148 |
tabData.addTab("_Parameters",null,createPanel3()); |
149 |
jpanel1.add(tabData,cc.xy(2,2)); |
150 |
|
151 |
jpanel1.add(createPanel5(),cc.xy(2,4)); |
152 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4 }); |
153 |
return jpanel1;
|
154 |
} |
155 |
|
156 |
public JPanel createPanel1() |
157 |
{ |
158 |
JPanel jpanel1 = new JPanel(); |
159 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
160 |
CellConstraints cc = new CellConstraints();
|
161 |
jpanel1.setLayout(formlayout1); |
162 |
|
163 |
tblErrors.setName("tblErrors");
|
164 |
JScrollPane jscrollpane1 = new JScrollPane(); |
165 |
jscrollpane1.setViewportView(tblErrors); |
166 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
167 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
168 |
jpanel1.add(jscrollpane1,cc.xy(2,5)); |
169 |
|
170 |
jpanel1.add(createPanel2(),cc.xy(2,2)); |
171 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6 }); |
172 |
return jpanel1;
|
173 |
} |
174 |
|
175 |
public JPanel createPanel2() |
176 |
{ |
177 |
JPanel jpanel1 = new JPanel(); |
178 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
179 |
CellConstraints cc = new CellConstraints();
|
180 |
jpanel1.setLayout(formlayout1); |
181 |
|
182 |
lblShow.setName("lblShow");
|
183 |
lblShow.setText("_Show");
|
184 |
jpanel1.add(lblShow,cc.xy(1,1)); |
185 |
|
186 |
cboRules.setName("cboRules");
|
187 |
jpanel1.add(cboRules,cc.xy(3,1)); |
188 |
|
189 |
btnVisibleExtentOnly.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-filter-visible-extent.png"));
|
190 |
btnVisibleExtentOnly.setName("btnVisibleExtentOnly");
|
191 |
btnVisibleExtentOnly.setToolTipText("_Show_only_in_visible_extent");
|
192 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
193 |
btnVisibleExtentOnly.setBorder(emptyborder1); |
194 |
jpanel1.add(btnVisibleExtentOnly,cc.xy(9,1)); |
195 |
|
196 |
btnZoomGeometry.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-zoom-geometry.png"));
|
197 |
btnZoomGeometry.setName("btnZoomGeometry");
|
198 |
btnZoomGeometry.setToolTipText("_Zoom");
|
199 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
200 |
btnZoomGeometry.setBorder(emptyborder2); |
201 |
jpanel1.add(btnZoomGeometry,cc.xy(13,1)); |
202 |
|
203 |
btnActions.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-actions.png"));
|
204 |
btnActions.setName("btnActions");
|
205 |
btnActions.setToolTipText("_Actions");
|
206 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
207 |
btnActions.setBorder(emptyborder3); |
208 |
jpanel1.add(btnActions,cc.xy(23,1)); |
209 |
|
210 |
btnRefresh.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-refresh.png"));
|
211 |
btnRefresh.setName("btnRefresh");
|
212 |
btnRefresh.setToolTipText("_Update");
|
213 |
EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2); |
214 |
btnRefresh.setBorder(emptyborder4); |
215 |
jpanel1.add(btnRefresh,cc.xy(25,1)); |
216 |
|
217 |
btnShowErrors.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-filter-errors.png"));
|
218 |
btnShowErrors.setName("btnShowErrors");
|
219 |
btnShowErrors.setToolTipText("_Show_errors");
|
220 |
EmptyBorder emptyborder5 = new EmptyBorder(2,2,2,2); |
221 |
btnShowErrors.setBorder(emptyborder5); |
222 |
jpanel1.add(btnShowErrors,cc.xy(5,1)); |
223 |
|
224 |
btnShowExceptions.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-filter-exceptions.png"));
|
225 |
btnShowExceptions.setName("btnShowExceptions");
|
226 |
btnShowExceptions.setToolTipText("_Show_exceptions");
|
227 |
EmptyBorder emptyborder6 = new EmptyBorder(2,2,2,2); |
228 |
btnShowExceptions.setBorder(emptyborder6); |
229 |
jpanel1.add(btnShowExceptions,cc.xy(7,1)); |
230 |
|
231 |
btnShowForm.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-show-form.png"));
|
232 |
btnShowForm.setName("btnShowForm");
|
233 |
btnShowForm.setToolTipText("_Show_form_when_modify_geometry");
|
234 |
EmptyBorder emptyborder7 = new EmptyBorder(2,2,2,2); |
235 |
btnShowForm.setBorder(emptyborder7); |
236 |
jpanel1.add(btnShowForm,cc.xy(11,1)); |
237 |
|
238 |
btnCenterError.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-center-error.png"));
|
239 |
btnCenterError.setName("btnCenterError");
|
240 |
btnCenterError.setToolTipText("_Center_error");
|
241 |
EmptyBorder emptyborder8 = new EmptyBorder(2,2,2,2); |
242 |
btnCenterError.setBorder(emptyborder8); |
243 |
jpanel1.add(btnCenterError,cc.xy(19,1)); |
244 |
|
245 |
btnCenterGeometry.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-center-geometry.png"));
|
246 |
btnCenterGeometry.setName("btnCenterGeometry");
|
247 |
btnCenterGeometry.setToolTipText("_Center_geometry");
|
248 |
EmptyBorder emptyborder9 = new EmptyBorder(2,2,2,2); |
249 |
btnCenterGeometry.setBorder(emptyborder9); |
250 |
jpanel1.add(btnCenterGeometry,cc.xy(15,1)); |
251 |
|
252 |
btnZoomError.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-zoom-error.png"));
|
253 |
btnZoomError.setName("btnZoomError");
|
254 |
btnZoomError.setToolTipText("_Zoom");
|
255 |
EmptyBorder emptyborder10 = new EmptyBorder(2,2,2,2); |
256 |
btnZoomError.setBorder(emptyborder10); |
257 |
jpanel1.add(btnZoomError,cc.xy(17,1)); |
258 |
|
259 |
btnEraseErrorMarks.setIcon(loadImage("org/gvsig/topology/swing/impl/images/topology-report-erase-errors.png"));
|
260 |
btnEraseErrorMarks.setName("btnEraseErrorMarks");
|
261 |
btnEraseErrorMarks.setToolTipText("_Erase_error_marks");
|
262 |
EmptyBorder emptyborder11 = new EmptyBorder(2,2,2,2); |
263 |
btnEraseErrorMarks.setBorder(emptyborder11); |
264 |
jpanel1.add(btnEraseErrorMarks,cc.xy(21,1)); |
265 |
|
266 |
addFillComponents(jpanel1,new int[]{ 2,4,6,8,10,12,14,16,18,20,22,24 },new int[0]); |
267 |
return jpanel1;
|
268 |
} |
269 |
|
270 |
public JPanel createPanel3() |
271 |
{ |
272 |
JPanel jpanel1 = new JPanel(); |
273 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
274 |
CellConstraints cc = new CellConstraints();
|
275 |
jpanel1.setLayout(formlayout1); |
276 |
|
277 |
pnlParameters.setName("pnlParameters");
|
278 |
jpanel1.add(pnlParameters,cc.xy(2,6)); |
279 |
|
280 |
lblActionDescription.setName("lblActionDescription");
|
281 |
jpanel1.add(lblActionDescription,cc.xy(2,4)); |
282 |
|
283 |
lblActionTitle.setName("lblActionTitle");
|
284 |
jpanel1.add(lblActionTitle,cc.xy(2,2)); |
285 |
|
286 |
jpanel1.add(createPanel4(),cc.xy(2,8)); |
287 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9 }); |
288 |
return jpanel1;
|
289 |
} |
290 |
|
291 |
public JPanel createPanel4() |
292 |
{ |
293 |
JPanel jpanel1 = new JPanel(); |
294 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
295 |
CellConstraints cc = new CellConstraints();
|
296 |
jpanel1.setLayout(formlayout1); |
297 |
|
298 |
btnParametersCancel.setActionCommand("_Cancel");
|
299 |
btnParametersCancel.setName("btnParametersCancel");
|
300 |
btnParametersCancel.setText("_Cancel");
|
301 |
jpanel1.add(btnParametersCancel,cc.xy(5,1)); |
302 |
|
303 |
btnParametersAccept.setActionCommand("_Execute");
|
304 |
btnParametersAccept.setName("btnParametersAccept");
|
305 |
btnParametersAccept.setText("_Execute");
|
306 |
jpanel1.add(btnParametersAccept,cc.xy(3,1)); |
307 |
|
308 |
addFillComponents(jpanel1,new int[]{ 1,2,4 },new int[]{ 1 }); |
309 |
return jpanel1;
|
310 |
} |
311 |
|
312 |
public JPanel createPanel5() |
313 |
{ |
314 |
JPanel jpanel1 = new JPanel(); |
315 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.3),FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.7),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
316 |
CellConstraints cc = new CellConstraints();
|
317 |
jpanel1.setLayout(formlayout1); |
318 |
|
319 |
lblTaskStatusMessage.setName("lblTaskStatusMessage");
|
320 |
lblTaskStatusMessage.setText("...");
|
321 |
jpanel1.add(lblTaskStatusMessage,cc.xy(3,1)); |
322 |
|
323 |
pbTaskStatusProgress.setName("pbTaskStatusProgress");
|
324 |
pbTaskStatusProgress.setValue(25);
|
325 |
jpanel1.add(pbTaskStatusProgress,cc.xy(5,1)); |
326 |
|
327 |
btnTaskStatusCancel.setName("btnTaskStatusCancel");
|
328 |
btnTaskStatusCancel.setToolTipText("_Zoom");
|
329 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
330 |
btnTaskStatusCancel.setBorder(emptyborder1); |
331 |
jpanel1.add(btnTaskStatusCancel,cc.xy(7,1)); |
332 |
|
333 |
lblTaskStatusTitle.setName("lblTaskStatusTitle");
|
334 |
lblTaskStatusTitle.setText("...");
|
335 |
jpanel1.add(lblTaskStatusTitle,cc.xy(1,1)); |
336 |
|
337 |
addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
338 |
return jpanel1;
|
339 |
} |
340 |
|
341 |
/**
|
342 |
* Initializer
|
343 |
*/
|
344 |
protected void initializePanel() |
345 |
{ |
346 |
setLayout(new BorderLayout()); |
347 |
add(createPanel(), BorderLayout.CENTER);
|
348 |
} |
349 |
|
350 |
|
351 |
} |