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