Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extTopology / src / org / gvsig / topology / ui / TopologyErrorPanel.java @ 18999

History | View | Annotate | Download (19.8 KB)

1 18063 azabala
/*
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 18258 azabala
 *
46
 * $Id:
47
 * $Log:
48
 */
49 18063 azabala
package org.gvsig.topology.ui;
50
51 18999 azabala
import java.awt.BorderLayout;
52
import java.awt.Dimension;
53 18258 azabala
import java.awt.Point;
54 18063 azabala
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionListener;
56 18258 azabala
import java.awt.event.MouseAdapter;
57
import java.awt.event.MouseEvent;
58 18063 azabala
import java.awt.geom.Rectangle2D;
59 18999 azabala
import java.net.URL;
60 18258 azabala
import java.util.ArrayList;
61 18063 azabala
import java.util.HashMap;
62 18258 azabala
import java.util.List;
63 18063 azabala
import java.util.Map;
64
65 18999 azabala
import javax.swing.BoxLayout;
66 18063 azabala
import javax.swing.JCheckBox;
67
import javax.swing.JComboBox;
68
import javax.swing.JComponent;
69 18999 azabala
import javax.swing.JDialog;
70
import javax.swing.JEditorPane;
71 18063 azabala
import javax.swing.JLabel;
72 18258 azabala
import javax.swing.JMenuItem;
73
import javax.swing.JOptionPane;
74 18999 azabala
import javax.swing.JPanel;
75 18258 azabala
import javax.swing.JPopupMenu;
76 18063 azabala
import javax.swing.JScrollPane;
77
import javax.swing.JTable;
78 18258 azabala
import javax.swing.event.ListSelectionEvent;
79
import javax.swing.event.ListSelectionListener;
80 18063 azabala
import javax.swing.table.AbstractTableModel;
81 18999 azabala
import javax.swing.text.html.HTMLEditorKit;
82 18063 azabala
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 18258 azabala
import com.iver.andami.ui.mdiManager.IWindow;
95
import com.iver.cit.gvsig.fmap.MapContext;
96
import com.iver.cit.gvsig.fmap.MapControl;
97 18063 azabala
import com.iver.cit.gvsig.fmap.core.FShape;
98
import com.iver.cit.gvsig.fmap.core.IFeature;
99 18258 azabala
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 18063 azabala
import com.iver.cit.gvsig.project.documents.view.gui.View;
107
108
/**
109
 * Panel to show topology errors in a ITopologyErrorContainer.
110
 *
111 18258 azabala
 * 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 18063 azabala
 *
114
 * @author Alvaro Zabala
115 18258 azabala
 *
116 18063 azabala
 */
117
public class TopologyErrorPanel extends BoxLayoutPanel {
118
119
        private final class TopologyErrorTableModel extends AbstractTableModel {
120 18258 azabala
121 18063 azabala
                private static final long serialVersionUID = -5615838036054987191L;
122 18258 azabala
123 18063 azabala
                private ITopologyErrorContainer errorContainer;
124
125 18258 azabala
                public void setErrorContainer(ITopologyErrorContainer errorContainer) {
126 18063 azabala
                        this.errorContainer = errorContainer;
127
                }
128 18258 azabala
129 18063 azabala
                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 18258 azabala
142
                        switch (col) {
143 18063 azabala
                        case 0:
144
                                violatedRule = error.getViolatedRule();
145
                                solution = violatedRule.getName();
146 18258 azabala
                                break;
147 18063 azabala
                        case 1:
148
                                violatedRule = error.getViolatedRule();
149 18258 azabala
                                solution = ((IOneLyrRule) violatedRule).getOriginLyr()
150
                                                .getName();
151
                                break;
152 18063 azabala
                        case 2:
153
                                violatedRule = error.getViolatedRule();
154 18258 azabala
                                if (violatedRule instanceof ITwoLyrRule) {
155 18063 azabala
                                        ITwoLyrRule twoLyrRule = (ITwoLyrRule) violatedRule;
156
                                        solution = twoLyrRule.getDestinationLyr().getName();
157 18258 azabala
                                } else {
158 18063 azabala
                                        solution = "";
159
                                }
160 18258 azabala
161
                                break;
162 18063 azabala
                        case 3:
163
                                int shapeType = error.getShapeType();
164 18258 azabala
                                switch (shapeType) {
165 18063 azabala
                                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 18258 azabala
                                break;
186
187 18063 azabala
                        case 4:
188
                                IFeature lyr1Feature = error.getFeature1();
189
                                solution = lyr1Feature.getID();
190 18258 azabala
                                break;
191
192 18063 azabala
                        case 5:
193
                                IFeature lyr2Feature = error.getFeature2();
194 18258 azabala
                                if (lyr2Feature != null)
195 18063 azabala
                                        solution = lyr2Feature.getID();
196
                                else
197
                                        solution = "";
198 18258 azabala
                                break;
199
200 18063 azabala
                        case 6:
201 18258 azabala
                                if (error.isException())
202 18063 azabala
                                        solution = PluginServices.getText(this, "SI");
203
                                else
204
                                        solution = PluginServices.getText(this, "NO");
205 18258 azabala
                                break;
206 18063 azabala
                        }
207
                        return solution;
208
                }
209
        }
210
211 18258 azabala
        private static final long serialVersionUID = 768284651667411053L;
212 18063 azabala
213
        /**
214
         * Has topology errors to show in this component (component's model)
215
         */
216
        private ITopologyErrorContainer errorContainer;
217 18258 azabala
218 18063 azabala
        /*
219
         * GUI components
220 18258 azabala
         */
221 18063 azabala
        private JTable errorInspectorTable;
222
        private TopologyErrorTableModel dataModel;
223
        private JComboBox ruleFilterComboBox;
224
        private JCheckBox showErrors;
225
        private JCheckBox showExceptions;
226
        private JCheckBox showViewExtent;
227 18258 azabala
228
        private final static String ALL_RULES_OPTION = PluginServices.getText(null,
229
                        "ERROR_INSPECTOR_ALL_RULES");
230
231 18063 azabala
        /**
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 18258 azabala
237
//        private List<FGraphic> selectedErrors;
238 18063 azabala
239 18258 azabala
        /**
240
         * Code of the symbol used to mark selections
241
         */
242
//        int symbolSelectionCode;
243 18063 azabala
244 18258 azabala
245 18063 azabala
        /**
246
         * Constructor
247 18258 azabala
         *
248 18063 azabala
         * @param errorContainer
249
         */
250 18258 azabala
        public TopologyErrorPanel(ITopologyErrorContainer errorContainer) {
251 18063 azabala
                this.errorContainer = errorContainer;
252 18258 azabala
//                this.selectedErrors = new ArrayList<FGraphic>();
253 18063 azabala
254 18258 azabala
//                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 18063 azabala
262 18258 azabala
                initialize();
263 18063 azabala
        }
264 18258 azabala
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 18063 azabala
                        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 18258 azabala
292
                        Map<ITopologyRule, ITopologyRule> violatedRules = new HashMap<ITopologyRule, ITopologyRule>();
293 18063 azabala
                        int errorCount = this.errorContainer.getNumberOfErrors();
294 18258 azabala
                        for (int i = 0; i < errorCount; i++) {
295
                                TopologyError topologyError = errorContainer
296
                                                .getTopologyError(i);
297 18063 azabala
                                ITopologyRule violatedRule = topologyError.getViolatedRule();
298 18258 azabala
                                if (violatedRules.get(violatedRule) != null)
299 18063 azabala
                                        continue;
300 18258 azabala
301 18063 azabala
                                violatedRules.put(violatedRule, violatedRule);
302 18258 azabala
                                String rule_option = ((IOneLyrRule) violatedRule)
303
                                                .getOriginLyr().getName()
304
                                                + " - ";
305
                                if (violatedRule instanceof ITwoLyrRule) {
306 18063 azabala
                                        ITwoLyrRule twoLyrRule = (ITwoLyrRule) violatedRule;
307
                                        rule_option += twoLyrRule.getName() + " - ";
308
                                }
309 18258 azabala
                                rule_option += violatedRule.getName();
310
311 18063 azabala
                                ruleOption_rule.put(rule_option, violatedRule);
312
                                ruleFilterComboBox.addItem(rule_option);
313 18258 azabala
                        }// for
314
                }// if
315 18063 azabala
                return ruleFilterComboBox;
316
        }
317 18258 azabala
318
        private JCheckBox getShowErrorsCb() {
319
                if (showErrors == null) {
320 18063 azabala
                        showErrors = new JCheckBox(PluginServices.getText(this, "ERRORS"));
321
                        showErrors.setSelected(true);
322
                }
323
                return showErrors;
324
        }
325 18258 azabala
326
        private JCheckBox getShowExceptionsCb() {
327
                if (showExceptions == null) {
328
                        showExceptions = new JCheckBox(PluginServices.getText(this,
329
                                        "EXCEPTIONS"));
330 18063 azabala
                        showExceptions.setSelected(true);
331
                }
332
                return showExceptions;
333
        }
334 18258 azabala
335
        private JCheckBox getShowViewExtentCb() {
336
                showViewExtent = new JCheckBox(PluginServices.getText(this,
337
                                "VIEW_EXTENT"));
338 18063 azabala
                return showViewExtent;
339
        }
340 18258 azabala
341
        private JButton getUpdateButton() {
342
                JButton updateButton = new JButton(PluginServices.getText(this,
343
                                "UPDATE"));
344
                updateButton.addActionListener(new ActionListener() {
345 18063 azabala
                        public void actionPerformed(ActionEvent arg0) {
346
                                updateErrorTable();
347 18258 azabala
                        }
348
                });
349 18063 azabala
                return updateButton;
350
        }
351 18258 azabala
352
        private JTable getErrorInspectorTable() {
353
                if (errorInspectorTable == null) {
354 18063 azabala
                        errorInspectorTable = new JTable();
355
                        dataModel = new TopologyErrorTableModel();
356
                        dataModel.setErrorContainer(errorContainer);
357
                        errorInspectorTable.setModel(dataModel);
358 18258 azabala
                        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 18063 azabala
382 18258 azabala
                        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 18999 azabala
                                                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 18258 azabala
                                        }
486
                                });
487
                                contextMenu.add(viewDescriptionMenu);
488
                                contextMenu.addSeparator();
489
490 18999 azabala
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 18258 azabala
                                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 18063 azabala
509 18258 azabala
                        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 18063 azabala
                return errorInspectorTable;
551
        }
552 18258 azabala
553
        public void updateErrorTable() {
554 18063 azabala
                ITopologyRule filterRule = getSelectedRule();
555
                boolean showExceptions = isExceptionsSelected();
556
                boolean showErrors = isErrorsSelected();
557 18258 azabala
                // show all topology errors
558
                if (filterRule == null && showExceptions && showErrors) {
559 18063 azabala
                        dataModel.setErrorContainer(errorContainer);
560
                        getErrorInspectorTable().revalidate();
561
                        return;
562
                }
563
                boolean filterByViewExtent = isOnlyViewExtentSelected();
564 18258 azabala
                SimpleTopologyErrorContainer filteredErrorContainer = new SimpleTopologyErrorContainer();
565
                for (int i = 0; i < errorContainer.getNumberOfErrors(); i++) {
566 18063 azabala
                        TopologyError error = errorContainer.getTopologyError(i);
567 18258 azabala
568
                        if (filterByViewExtent) {
569 18063 azabala
                                Rectangle2D errorExtent = error.getGeometry().getBounds2D();
570 18258 azabala
                                View activeView = (View) PluginServices.getMDIManager()
571
                                                .getActiveWindow();
572 18063 azabala
                                Rectangle2D viewExtent = null;
573
                                try {
574 18258 azabala
                                        viewExtent = activeView.getMapControl().getMapContext()
575
                                                        .getFullExtent();
576
577
                                        if (!errorExtent.intersects(viewExtent))
578 18063 azabala
                                                continue;
579
                                } catch (ReadDriverException e) {
580
                                        e.printStackTrace();
581
                                }
582
                        }
583 18258 azabala
                        if (error.isException() && !showExceptions) {
584 18063 azabala
                                continue;
585 18258 azabala
                        } else {
586
                                if (!error.isException() && !showErrors) {
587 18063 azabala
                                        continue;
588
                                }
589
                        }
590 18258 azabala
                        if(filterRule != null &&  error.getViolatedRule() != filterRule)
591
                                continue;
592
593 18063 azabala
                        filteredErrorContainer.addTopologyError(error);
594 18258 azabala
                }// for
595
596 18063 azabala
                dataModel.setErrorContainer(filteredErrorContainer);
597
                getErrorInspectorTable().revalidate();
598 18258 azabala
599 18063 azabala
        }
600 18258 azabala
601
        public boolean isErrorsSelected() {
602 18063 azabala
                return showErrors.isSelected();
603
        }
604 18258 azabala
605
        public boolean isExceptionsSelected() {
606 18063 azabala
                return showExceptions.isSelected();
607
        }
608 18258 azabala
609
        public boolean isOnlyViewExtentSelected() {
610 18063 azabala
                return showViewExtent.isSelected();
611
        }
612 18258 azabala
613
        public ITopologyRule getSelectedRule() {
614 18063 azabala
                return ruleOption_rule.get(ruleFilterComboBox.getSelectedItem());
615
        }
616 18258 azabala
617 18063 azabala
}