svn-gvsig-desktop / trunk / extensions / extTopology / src / org / gvsig / topology / ui / TopologyErrorPanel.java @ 18999
History | View | Annotate | Download (19.8 KB)
1 |
/*
|
---|---|
2 |
* Created on 10-abr-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id:
|
47 |
* $Log:
|
48 |
*/
|
49 |
package org.gvsig.topology.ui; |
50 |
|
51 |
import java.awt.BorderLayout; |
52 |
import java.awt.Dimension; |
53 |
import java.awt.Point; |
54 |
import java.awt.event.ActionEvent; |
55 |
import java.awt.event.ActionListener; |
56 |
import java.awt.event.MouseAdapter; |
57 |
import java.awt.event.MouseEvent; |
58 |
import java.awt.geom.Rectangle2D; |
59 |
import java.net.URL; |
60 |
import java.util.ArrayList; |
61 |
import java.util.HashMap; |
62 |
import java.util.List; |
63 |
import java.util.Map; |
64 |
|
65 |
import javax.swing.BoxLayout; |
66 |
import javax.swing.JCheckBox; |
67 |
import javax.swing.JComboBox; |
68 |
import javax.swing.JComponent; |
69 |
import javax.swing.JDialog; |
70 |
import javax.swing.JEditorPane; |
71 |
import javax.swing.JLabel; |
72 |
import javax.swing.JMenuItem; |
73 |
import javax.swing.JOptionPane; |
74 |
import javax.swing.JPanel; |
75 |
import javax.swing.JPopupMenu; |
76 |
import javax.swing.JScrollPane; |
77 |
import javax.swing.JTable; |
78 |
import javax.swing.event.ListSelectionEvent; |
79 |
import javax.swing.event.ListSelectionListener; |
80 |
import javax.swing.table.AbstractTableModel; |
81 |
import javax.swing.text.html.HTMLEditorKit; |
82 |
|
83 |
import org.gvsig.gui.beans.swing.JButton; |
84 |
import org.gvsig.topology.IOneLyrRule; |
85 |
import org.gvsig.topology.ITopologyErrorContainer; |
86 |
import org.gvsig.topology.ITopologyRule; |
87 |
import org.gvsig.topology.ITwoLyrRule; |
88 |
import org.gvsig.topology.SimpleTopologyErrorContainer; |
89 |
import org.gvsig.topology.TopologyError; |
90 |
import org.gvsig.topology.ui.util.BoxLayoutPanel; |
91 |
|
92 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
93 |
import com.iver.andami.PluginServices; |
94 |
import com.iver.andami.ui.mdiManager.IWindow; |
95 |
import com.iver.cit.gvsig.fmap.MapContext; |
96 |
import com.iver.cit.gvsig.fmap.MapControl; |
97 |
import com.iver.cit.gvsig.fmap.core.FShape; |
98 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
99 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
100 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
101 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
102 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
103 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
104 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
105 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
106 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
107 |
|
108 |
/**
|
109 |
* Panel to show topology errors in a ITopologyErrorContainer.
|
110 |
*
|
111 |
* Each topology error in the panel will have associated a popup menu which
|
112 |
* allows to manage the error (view it in a gvSIG view, correct it, etc)
|
113 |
*
|
114 |
* @author Alvaro Zabala
|
115 |
*
|
116 |
*/
|
117 |
public class TopologyErrorPanel extends BoxLayoutPanel { |
118 |
|
119 |
private final class TopologyErrorTableModel extends AbstractTableModel { |
120 |
|
121 |
private static final long serialVersionUID = -5615838036054987191L; |
122 |
|
123 |
private ITopologyErrorContainer errorContainer;
|
124 |
|
125 |
public void setErrorContainer(ITopologyErrorContainer errorContainer) { |
126 |
this.errorContainer = errorContainer;
|
127 |
} |
128 |
|
129 |
public int getColumnCount() { |
130 |
return 7; |
131 |
} |
132 |
|
133 |
public int getRowCount() { |
134 |
return errorContainer.getNumberOfErrors();
|
135 |
} |
136 |
|
137 |
public Object getValueAt(int row, int col) { |
138 |
Object solution = null; |
139 |
TopologyError error = errorContainer.getTopologyError(row); |
140 |
ITopologyRule violatedRule = null;
|
141 |
|
142 |
switch (col) {
|
143 |
case 0: |
144 |
violatedRule = error.getViolatedRule(); |
145 |
solution = violatedRule.getName(); |
146 |
break;
|
147 |
case 1: |
148 |
violatedRule = error.getViolatedRule(); |
149 |
solution = ((IOneLyrRule) violatedRule).getOriginLyr() |
150 |
.getName(); |
151 |
break;
|
152 |
case 2: |
153 |
violatedRule = error.getViolatedRule(); |
154 |
if (violatedRule instanceof ITwoLyrRule) { |
155 |
ITwoLyrRule twoLyrRule = (ITwoLyrRule) violatedRule; |
156 |
solution = twoLyrRule.getDestinationLyr().getName(); |
157 |
} else {
|
158 |
solution = "";
|
159 |
} |
160 |
|
161 |
break;
|
162 |
case 3: |
163 |
int shapeType = error.getShapeType();
|
164 |
switch (shapeType) {
|
165 |
case FShape.POINT:
|
166 |
case FShape.TEXT:
|
167 |
solution = PluginServices.getText(this, "POINT"); |
168 |
break;
|
169 |
case FShape.POLYGON:
|
170 |
solution = PluginServices.getText(this, "POLYGON"); |
171 |
break;
|
172 |
case FShape.LINE:
|
173 |
case FShape.ARC:
|
174 |
case FShape.CIRCLE:
|
175 |
case FShape.ELLIPSE:
|
176 |
solution = PluginServices.getText(this, "LINE"); |
177 |
break;
|
178 |
case FShape.MULTI:
|
179 |
solution = PluginServices.getText(this, "MULTI"); |
180 |
break;
|
181 |
case FShape.MULTIPOINT:
|
182 |
solution = PluginServices.getText(this, "MULTIPOINT"); |
183 |
break;
|
184 |
} |
185 |
break;
|
186 |
|
187 |
case 4: |
188 |
IFeature lyr1Feature = error.getFeature1(); |
189 |
solution = lyr1Feature.getID(); |
190 |
break;
|
191 |
|
192 |
case 5: |
193 |
IFeature lyr2Feature = error.getFeature2(); |
194 |
if (lyr2Feature != null) |
195 |
solution = lyr2Feature.getID(); |
196 |
else
|
197 |
solution = "";
|
198 |
break;
|
199 |
|
200 |
case 6: |
201 |
if (error.isException())
|
202 |
solution = PluginServices.getText(this, "SI"); |
203 |
else
|
204 |
solution = PluginServices.getText(this, "NO"); |
205 |
break;
|
206 |
} |
207 |
return solution;
|
208 |
} |
209 |
} |
210 |
|
211 |
private static final long serialVersionUID = 768284651667411053L; |
212 |
|
213 |
/**
|
214 |
* Has topology errors to show in this component (component's model)
|
215 |
*/
|
216 |
private ITopologyErrorContainer errorContainer;
|
217 |
|
218 |
/*
|
219 |
* GUI components
|
220 |
*/
|
221 |
private JTable errorInspectorTable; |
222 |
private TopologyErrorTableModel dataModel;
|
223 |
private JComboBox ruleFilterComboBox; |
224 |
private JCheckBox showErrors; |
225 |
private JCheckBox showExceptions; |
226 |
private JCheckBox showViewExtent; |
227 |
|
228 |
private final static String ALL_RULES_OPTION = PluginServices.getText(null, |
229 |
"ERROR_INSPECTOR_ALL_RULES");
|
230 |
|
231 |
/**
|
232 |
* links the text showed in the combobox with the filter option of the
|
233 |
* topology error table
|
234 |
*/
|
235 |
private Map<String, ITopologyRule> ruleOption_rule; |
236 |
|
237 |
// private List<FGraphic> selectedErrors;
|
238 |
|
239 |
/**
|
240 |
* Code of the symbol used to mark selections
|
241 |
*/
|
242 |
// int symbolSelectionCode;
|
243 |
|
244 |
|
245 |
/**
|
246 |
* Constructor
|
247 |
*
|
248 |
* @param errorContainer
|
249 |
*/
|
250 |
public TopologyErrorPanel(ITopologyErrorContainer errorContainer) {
|
251 |
this.errorContainer = errorContainer;
|
252 |
// this.selectedErrors = new ArrayList<FGraphic>();
|
253 |
|
254 |
// ISymbol selectionSymbol = new SimpleFillSymbol().getSymbolForSelection();
|
255 |
// IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
256 |
// View vista = (View)f;
|
257 |
// symbolSelectionCode = vista.getMapControl().
|
258 |
// getMapContext().
|
259 |
// getGraphicsLayer().
|
260 |
// addSymbol(selectionSymbol);
|
261 |
|
262 |
initialize(); |
263 |
} |
264 |
|
265 |
private void initialize() { |
266 |
this.addRow(new JComponent[] { new JLabel(PluginServices.getText(this, |
267 |
"ERROR_INSPECTOR_TITLE")) });
|
268 |
|
269 |
this.addComponent(PluginServices.getText(this, "MOSTRAR"), |
270 |
getRuleFilterComboBox()); |
271 |
|
272 |
JComponent[] row = new JComponent[] { getShowErrorsCb(), |
273 |
getShowExceptionsCb(), getShowViewExtentCb() }; |
274 |
this.addRow(row, 600, DEFAULT_HEIGHT); |
275 |
|
276 |
this
|
277 |
.addRow(new JComponent[] { getUpdateButton() }, 600, |
278 |
DEFAULT_HEIGHT); |
279 |
|
280 |
this.addRow(
|
281 |
new JComponent[] { new JScrollPane(getErrorInspectorTable()) }, |
282 |
600, 300); |
283 |
} |
284 |
|
285 |
private JComboBox getRuleFilterComboBox() { |
286 |
if (ruleFilterComboBox == null) { |
287 |
ruleFilterComboBox = new JComboBox(); |
288 |
ruleOption_rule = new HashMap<String, ITopologyRule>(); |
289 |
ruleFilterComboBox.addItem(ALL_RULES_OPTION); |
290 |
ruleOption_rule.put(ALL_RULES_OPTION, null);
|
291 |
|
292 |
Map<ITopologyRule, ITopologyRule> violatedRules = new HashMap<ITopologyRule, ITopologyRule>(); |
293 |
int errorCount = this.errorContainer.getNumberOfErrors(); |
294 |
for (int i = 0; i < errorCount; i++) { |
295 |
TopologyError topologyError = errorContainer |
296 |
.getTopologyError(i); |
297 |
ITopologyRule violatedRule = topologyError.getViolatedRule(); |
298 |
if (violatedRules.get(violatedRule) != null) |
299 |
continue;
|
300 |
|
301 |
violatedRules.put(violatedRule, violatedRule); |
302 |
String rule_option = ((IOneLyrRule) violatedRule)
|
303 |
.getOriginLyr().getName() |
304 |
+ " - ";
|
305 |
if (violatedRule instanceof ITwoLyrRule) { |
306 |
ITwoLyrRule twoLyrRule = (ITwoLyrRule) violatedRule; |
307 |
rule_option += twoLyrRule.getName() + " - ";
|
308 |
} |
309 |
rule_option += violatedRule.getName(); |
310 |
|
311 |
ruleOption_rule.put(rule_option, violatedRule); |
312 |
ruleFilterComboBox.addItem(rule_option); |
313 |
}// for
|
314 |
}// if
|
315 |
return ruleFilterComboBox;
|
316 |
} |
317 |
|
318 |
private JCheckBox getShowErrorsCb() { |
319 |
if (showErrors == null) { |
320 |
showErrors = new JCheckBox(PluginServices.getText(this, "ERRORS")); |
321 |
showErrors.setSelected(true);
|
322 |
} |
323 |
return showErrors;
|
324 |
} |
325 |
|
326 |
private JCheckBox getShowExceptionsCb() { |
327 |
if (showExceptions == null) { |
328 |
showExceptions = new JCheckBox(PluginServices.getText(this, |
329 |
"EXCEPTIONS"));
|
330 |
showExceptions.setSelected(true);
|
331 |
} |
332 |
return showExceptions;
|
333 |
} |
334 |
|
335 |
private JCheckBox getShowViewExtentCb() { |
336 |
showViewExtent = new JCheckBox(PluginServices.getText(this, |
337 |
"VIEW_EXTENT"));
|
338 |
return showViewExtent;
|
339 |
} |
340 |
|
341 |
private JButton getUpdateButton() { |
342 |
JButton updateButton = new JButton(PluginServices.getText(this, |
343 |
"UPDATE"));
|
344 |
updateButton.addActionListener(new ActionListener() { |
345 |
public void actionPerformed(ActionEvent arg0) { |
346 |
updateErrorTable(); |
347 |
} |
348 |
}); |
349 |
return updateButton;
|
350 |
} |
351 |
|
352 |
private JTable getErrorInspectorTable() { |
353 |
if (errorInspectorTable == null) { |
354 |
errorInspectorTable = new JTable(); |
355 |
dataModel = new TopologyErrorTableModel();
|
356 |
dataModel.setErrorContainer(errorContainer); |
357 |
errorInspectorTable.setModel(dataModel); |
358 |
errorInspectorTable.getColumnModel().getColumn(0).setHeaderValue(
|
359 |
PluginServices.getText(this, "Rule_type")); |
360 |
|
361 |
errorInspectorTable.getColumnModel().getColumn(1).setHeaderValue(
|
362 |
PluginServices.getText(this, "Layer_1")); |
363 |
|
364 |
errorInspectorTable.getColumnModel().getColumn(2).setHeaderValue(
|
365 |
PluginServices.getText(this, "Layer_2")); |
366 |
|
367 |
errorInspectorTable.getColumnModel().getColumn(3).setHeaderValue(
|
368 |
PluginServices.getText(this, "Shape_Type")); |
369 |
|
370 |
errorInspectorTable.getColumnModel().getColumn(4).setHeaderValue(
|
371 |
PluginServices.getText(this, "Feature_1")); |
372 |
|
373 |
errorInspectorTable.getColumnModel().getColumn(5).setHeaderValue(
|
374 |
PluginServices.getText(this, "Feature_2")); |
375 |
|
376 |
errorInspectorTable.getColumnModel().getColumn(6).setHeaderValue(
|
377 |
PluginServices.getText(this, "Exception")); |
378 |
} |
379 |
|
380 |
errorInspectorTable.addMouseListener(new MouseAdapter() { |
381 |
|
382 |
private void maybeShowPopup(MouseEvent e) { |
383 |
if (e.isPopupTrigger() && errorInspectorTable.isEnabled()) {
|
384 |
Point p = new Point(e.getX(), e.getY()); |
385 |
int row = errorInspectorTable.rowAtPoint(p);
|
386 |
if (row >= 0 && row < errorInspectorTable.getRowCount()) { |
387 |
JPopupMenu contextMenu = createContextMenu(row);
|
388 |
if (contextMenu != null |
389 |
&& contextMenu.getComponentCount() > 0) {
|
390 |
contextMenu.show(errorInspectorTable, p.x, p.y); |
391 |
}//if
|
392 |
}//if
|
393 |
}//if
|
394 |
} |
395 |
|
396 |
private JPopupMenu createContextMenu(int row) { |
397 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
398 |
if(! (f instanceof View)) |
399 |
return null; |
400 |
final View vista = (View)f; |
401 |
final TopologyError error = errorContainer.getTopologyError(row);
|
402 |
|
403 |
JPopupMenu contextMenu = new JPopupMenu(); |
404 |
JMenuItem panMenu = new JMenuItem(); |
405 |
panMenu.setText(PluginServices.getText(this, "PAN_TO")); |
406 |
panMenu.addActionListener(new ActionListener() { |
407 |
public void actionPerformed(ActionEvent e) { |
408 |
IProjectView model = vista.getModel(); |
409 |
MapContext mapa = model.getMapContext(); |
410 |
Rectangle2D currentExtent = mapa.getViewPort().getExtent();
|
411 |
double width = currentExtent.getWidth();
|
412 |
double height = currentExtent.getHeight();
|
413 |
|
414 |
Rectangle2D errorBounds = error.getGeometry().getBounds2D();
|
415 |
double centerX = errorBounds.getCenterX();
|
416 |
double centerY = errorBounds.getCenterY();
|
417 |
|
418 |
Rectangle2D newExtent = new Rectangle2D.Double(centerX - (width / 2), |
419 |
centerY - (height / 2),
|
420 |
width, |
421 |
height); |
422 |
mapa.getViewPort().setExtent(newExtent); |
423 |
((ProjectDocument)vista.getModel()).setModified(true);
|
424 |
|
425 |
} |
426 |
|
427 |
}); |
428 |
contextMenu.add(panMenu); |
429 |
|
430 |
|
431 |
JMenuItem zoomMenu = new JMenuItem(); |
432 |
zoomMenu.setText(PluginServices.getText(this, "ZOOM_TO")); |
433 |
zoomMenu.addActionListener(new ActionListener() { |
434 |
public void actionPerformed(ActionEvent e) { |
435 |
IProjectView model = vista.getModel(); |
436 |
MapContext mapa = model.getMapContext(); |
437 |
|
438 |
Rectangle2D errorBounds = error.getGeometry().getBounds2D();
|
439 |
mapa.getViewPort().setExtent(errorBounds); |
440 |
((ProjectDocument)vista.getModel()).setModified(true);
|
441 |
} |
442 |
}); |
443 |
contextMenu.add(zoomMenu); |
444 |
contextMenu.addSeparator(); |
445 |
|
446 |
JMenuItem viewDescriptionMenu = new JMenuItem(); |
447 |
viewDescriptionMenu.setText(PluginServices.getText(this, "VIEW_RULE_DESCRIPTION")); |
448 |
viewDescriptionMenu.addActionListener(new ActionListener() { |
449 |
public void actionPerformed(ActionEvent e) { |
450 |
final JDialog descriptionDialog = new JDialog(); |
451 |
descriptionDialog.setLayout(new BorderLayout()); |
452 |
JScrollPane rightPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
453 |
JEditorPane htmlViewer = new JEditorPane(){ |
454 |
public URL getPage() { |
455 |
return null; |
456 |
} |
457 |
}; |
458 |
htmlViewer.setEditable(false);
|
459 |
htmlViewer.setEditorKit(new HTMLEditorKit()); |
460 |
rightPanel.setViewportView(htmlViewer); |
461 |
rightPanel.setPreferredSize(new Dimension(250, 140)); |
462 |
try {
|
463 |
ITopologyRule rule = error.getViolatedRule(); |
464 |
URL description = rule.getDescription();
|
465 |
htmlViewer.setPage(description); |
466 |
} catch (Exception ex) { |
467 |
htmlViewer.setText("<p>"+PluginServices.getText(this, "UNAVAILABLE_DESCRIPTION")+"</p>"); |
468 |
} |
469 |
|
470 |
|
471 |
JPanel southPanel = new JPanel(); |
472 |
JButton okButton = new JButton(PluginServices.getText(this, "OK")); |
473 |
okButton.addActionListener(new ActionListener(){ |
474 |
public void actionPerformed(ActionEvent arg0) { |
475 |
descriptionDialog.dispose(); |
476 |
}}); |
477 |
southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); |
478 |
southPanel.add(okButton); |
479 |
|
480 |
descriptionDialog.add(rightPanel, BorderLayout.CENTER);
|
481 |
descriptionDialog.add(southPanel, BorderLayout.SOUTH);
|
482 |
descriptionDialog.setSize(new Dimension(300, 300)); |
483 |
descriptionDialog.setVisible(true);
|
484 |
// JOptionPane.showConfirmDialog(TopologyErrorPanel.this, "DESARROLLO: Aqu? se mostrar? una descripci?n de la regla violada");
|
485 |
} |
486 |
}); |
487 |
contextMenu.add(viewDescriptionMenu); |
488 |
contextMenu.addSeparator(); |
489 |
|
490 |
|
491 |
JMenuItem markAsExceptionMenu = new JMenuItem(); |
492 |
markAsExceptionMenu.setText(PluginServices.getText(this, "MARK_AS_EXCEPTION")); |
493 |
markAsExceptionMenu.addActionListener(new ActionListener() { |
494 |
public void actionPerformed(ActionEvent e) { |
495 |
error.getTopology().markAsTopologyException(error); |
496 |
updateErrorTable(); |
497 |
} |
498 |
}); |
499 |
contextMenu.add(markAsExceptionMenu); |
500 |
|
501 |
|
502 |
ITopologyRule violatedRule = error.getViolatedRule(); |
503 |
//TODO Obtener las correcciones predefinidas para cada tipo de regla
|
504 |
//violada (Milestone 4)
|
505 |
return contextMenu;
|
506 |
} |
507 |
|
508 |
|
509 |
public void mousePressed(MouseEvent e) { |
510 |
maybeShowPopup(e); |
511 |
} |
512 |
|
513 |
public void mouseReleased(MouseEvent e) { |
514 |
maybeShowPopup(e); |
515 |
} |
516 |
}); |
517 |
/*
|
518 |
errorInspectorTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
|
519 |
public void valueChanged(ListSelectionEvent e) {
|
520 |
if (e.getSource() == errorInspectorTable.getSelectionModel() && errorInspectorTable.getRowSelectionAllowed()) {
|
521 |
IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
522 |
final View vista = (View)f;
|
523 |
MapControl mapControl = vista.getMapControl();
|
524 |
MapContext map = mapControl.getMapContext();
|
525 |
|
526 |
//first of all we delete the graphics of the previous selection
|
527 |
// for(int i = 0; i < selectedErrors.size(); i++){
|
528 |
// FGraphic oldGraphic = selectedErrors.get(i);
|
529 |
// map.getGraphicsLayer().removeGraphic(oldGraphic);
|
530 |
// }
|
531 |
// mapControl.drawGraphics();
|
532 |
// mapControl.repaint();
|
533 |
// selectedErrors.clear();
|
534 |
|
535 |
int first = e.getFirstIndex();
|
536 |
int last = e.getLastIndex();
|
537 |
// for(int i = first; i <= last; i++){
|
538 |
// TopologyError error = errorContainer.getTopologyError(i);
|
539 |
// IGeometry errorGeometry = error.getGeometry();
|
540 |
// FGraphic newGraphic =
|
541 |
// new FGraphic(errorGeometry, symbolSelectionCode);
|
542 |
// map.getGraphicsLayer().addGraphic(newGraphic);
|
543 |
// selectedErrors.add(newGraphic);
|
544 |
// }//for
|
545 |
// mapControl.drawGraphics();
|
546 |
// mapControl.repaint();
|
547 |
}//if
|
548 |
}});
|
549 |
*/
|
550 |
return errorInspectorTable;
|
551 |
} |
552 |
|
553 |
public void updateErrorTable() { |
554 |
ITopologyRule filterRule = getSelectedRule(); |
555 |
boolean showExceptions = isExceptionsSelected();
|
556 |
boolean showErrors = isErrorsSelected();
|
557 |
// show all topology errors
|
558 |
if (filterRule == null && showExceptions && showErrors) { |
559 |
dataModel.setErrorContainer(errorContainer); |
560 |
getErrorInspectorTable().revalidate(); |
561 |
return;
|
562 |
} |
563 |
boolean filterByViewExtent = isOnlyViewExtentSelected();
|
564 |
SimpleTopologyErrorContainer filteredErrorContainer = new SimpleTopologyErrorContainer();
|
565 |
for (int i = 0; i < errorContainer.getNumberOfErrors(); i++) { |
566 |
TopologyError error = errorContainer.getTopologyError(i); |
567 |
|
568 |
if (filterByViewExtent) {
|
569 |
Rectangle2D errorExtent = error.getGeometry().getBounds2D();
|
570 |
View activeView = (View) PluginServices.getMDIManager() |
571 |
.getActiveWindow(); |
572 |
Rectangle2D viewExtent = null; |
573 |
try {
|
574 |
viewExtent = activeView.getMapControl().getMapContext() |
575 |
.getFullExtent(); |
576 |
|
577 |
if (!errorExtent.intersects(viewExtent))
|
578 |
continue;
|
579 |
} catch (ReadDriverException e) {
|
580 |
e.printStackTrace(); |
581 |
} |
582 |
} |
583 |
if (error.isException() && !showExceptions) {
|
584 |
continue;
|
585 |
} else {
|
586 |
if (!error.isException() && !showErrors) {
|
587 |
continue;
|
588 |
} |
589 |
} |
590 |
if(filterRule != null && error.getViolatedRule() != filterRule) |
591 |
continue;
|
592 |
|
593 |
filteredErrorContainer.addTopologyError(error); |
594 |
}// for
|
595 |
|
596 |
dataModel.setErrorContainer(filteredErrorContainer); |
597 |
getErrorInspectorTable().revalidate(); |
598 |
|
599 |
} |
600 |
|
601 |
public boolean isErrorsSelected() { |
602 |
return showErrors.isSelected();
|
603 |
} |
604 |
|
605 |
public boolean isExceptionsSelected() { |
606 |
return showExceptions.isSelected();
|
607 |
} |
608 |
|
609 |
public boolean isOnlyViewExtentSelected() { |
610 |
return showViewExtent.isSelected();
|
611 |
} |
612 |
|
613 |
public ITopologyRule getSelectedRule() {
|
614 |
return ruleOption_rule.get(ruleFilterComboBox.getSelectedItem());
|
615 |
} |
616 |
|
617 |
} |