Index: DefaultJTopologyReport.java
===================================================================
--- DefaultJTopologyReport.java	(revision 759)
+++ DefaultJTopologyReport.java	(revision 760)
@@ -12,11 +12,13 @@
 import java.util.List;
 import java.util.Set;
 import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.ImageIcon;
 import javax.swing.JComponent;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
 import javax.swing.SwingUtilities;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -70,8 +72,8 @@
         implements JTopologyReport {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DefaultJTopologyReport.class);
+    private ListSelectionModel selection;
 
-    
     private class TopologyRuleActionParametersListener implements ActionListener {
 
         private final TopologyRule rule;
@@ -97,7 +99,6 @@
         }
     }
 
-
     private class TopologyRuleActionListener implements ActionListener {
 
         private final TopologyRule rule;
@@ -116,14 +117,14 @@
 
         @Override
         public void actionPerformed(ActionEvent e) {
-            if ( this.action.hasParameters() ) {
+            if (this.action.hasParameters()) {
                 doShowActionParametersPanel(this.rule, this.lines, this.action);
             } else {
                 doExecuteRuleAction(rule, lines, action, null);
             }
         }
     }
-    
+
     private ReportTable linesModel;
     private final TopologySwingServices services;
     private TaskStatusController taskStatusController;
@@ -137,7 +138,9 @@
 
     private void initComponents() {
         I18nManager i18n = ToolsLocator.getI18nManager();
+        this.selection = this.tblErrors.getSelectionModel();
         this.linesModel = new ReportTable();
+
         this.workingAreaChangedListener = new WorkingAreaChangedListener() {
             @Override
             public void workingAreaChanged(Envelope workingArea) {
@@ -146,6 +149,7 @@
         };
         this.tblErrors.setModel(this.linesModel);
         this.tblErrors.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
+
         this.btnZoomGeometry.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -185,12 +189,12 @@
         this.tblErrors.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseClicked(MouseEvent e) {
-                if( e.getButton()==MouseEvent.BUTTON1 && e.getClickCount()==2 ) {
+                if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                     doCenterError();
                 }
             }
         });
-        
+
         this.btnActions.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -237,7 +241,7 @@
             }
         });
         DefaultComboBoxModel<ListElement<TopologyRuleFactory>> modelRules = new DefaultComboBoxModel<>();
-        modelRules.addElement(new ListElement<>(i18n.getTranslation("_Any_rule"), (TopologyRuleFactory)null));
+        modelRules.addElement(new ListElement<>(i18n.getTranslation("_Any_rule"), (TopologyRuleFactory) null));
         List<TopologyRuleFactory> factories = TopologyLocator.getTopologyManager().getRuleFactories();
         for (TopologyRuleFactory factory : factories) {
             modelRules.addElement(new ListElement<>(factory.getName(), factory));
@@ -269,11 +273,11 @@
         this.btnShowErrors.setSelected(false);
         this.btnShowExceptions.setSelected(false);
         this.btnVisibleExtentOnly.setSelected(false);
-        
+
         this.tabData.setEnabledAt(1, false);
 
     }
-    
+
     @Override
     public ImageIcon loadImage(String imageName) {
         String name = FilenameUtils.getBaseName(imageName);
@@ -281,7 +285,7 @@
         if (theme.exists(name)) {
             return theme.get(name);
         }
-        URL url = this.getClass().getResource("/"+imageName);
+        URL url = this.getClass().getResource("/" + imageName);
         if (url == null) {
             return null;
         }
@@ -332,38 +336,38 @@
     private String getFilter() {
         ExpressionBuilder builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
         TopologyRuleFactory ruleFactory = (TopologyRuleFactory) ListElement.getSelected(cboRules);
-        if( ruleFactory != null ) {
+        if (ruleFactory != null) {
             builder.setValue(
-                builder.eq(
-                    builder.column(TopologyReport.RULE_ID),
-                    builder.constant(ruleFactory.getId())
-                )
+                    builder.eq(
+                            builder.column(TopologyReport.RULE_ID),
+                            builder.constant(ruleFactory.getId())
+                    )
             );
         }
-        if( this.btnShowErrors.isSelected() ) {
-            if( btnShowExceptions.isSelected()) {
+        if (this.btnShowErrors.isSelected()) {
+            if (btnShowExceptions.isSelected()) {
                 builder.and(
                         builder.or(
-                            builder.column(TopologyReport.IS_ERROR), 
-                            builder.column(TopologyReport.IS_EXCEPTION)
+                                builder.column(TopologyReport.IS_ERROR),
+                                builder.column(TopologyReport.IS_EXCEPTION)
                         )
                 );
             } else {
                 builder.and(
-                    builder.column(TopologyReport.IS_ERROR)
+                        builder.column(TopologyReport.IS_ERROR)
                 );
             }
-        } else if( btnShowExceptions.isSelected()) {
+        } else if (btnShowExceptions.isSelected()) {
             builder.and(
-                builder.column(TopologyReport.IS_EXCEPTION)
+                    builder.column(TopologyReport.IS_EXCEPTION)
             );
         }
-        if( this.btnVisibleExtentOnly.isSelected() ) {
+        if (this.btnVisibleExtentOnly.isSelected()) {
             Envelope workingArea = this.services.getWorkingArea();
-            if( workingArea!=null ) {
+            if (workingArea != null) {
                 builder.and(
                         builder.ST_Intersects(
-                                builder.column(TopologyReport.GEOMETRY), 
+                                builder.column(TopologyReport.GEOMETRY),
                                 builder.geometry(workingArea.getGeometry())
                         )
                 );
@@ -372,12 +376,12 @@
         } else {
             this.services.removeWorkingAreaChangedListener(this.workingAreaChangedListener);
         }
-        if( builder.getValue()==null ) {
+        if (builder.getValue() == null) {
             return null;
         }
         return builder.toString();
     }
-    
+
     private void doExecutePlan() {
         Thread th = new Thread(new Runnable() {
             @Override
@@ -401,14 +405,14 @@
             return;
         }
         TaskStatus taskStatus = (TaskStatus) observable;
-        if (taskStatus==null || !taskStatus.isRunning()) {
+        if (taskStatus == null || !taskStatus.isRunning()) {
             this.lblTaskStatusTitle.setVisible(false);
             this.lblTaskStatusMessage.setVisible(false);
             this.pbTaskStatusProgress.setVisible(false);
             this.btnTaskStatusCancel.setVisible(false);
             this.btnRefresh.setEnabled(true);
             I18nManager i18n = ToolsLocator.getI18nManager();
-            message(i18n.getTranslation("_Errors")+": "+this.linesModel.getRowCount());
+            message(i18n.getTranslation("_Errors") + ": " + this.linesModel.getRowCount());
             return;
         }
         if (!this.pbTaskStatusProgress.isVisible()) {
@@ -424,7 +428,7 @@
         this.lblTaskStatusTitle.setText(msg);
         this.lblTaskStatusTitle.setVisible(true);
     }
-    
+
     private void doSelectAction() {
         int n = this.tblErrors.getSelectedRow();
         if (n < 0) {
@@ -435,24 +439,24 @@
         List<TopologyRuleAction> actions = rule.getActions();
         if (actions == null || actions.isEmpty()) {
             return;
-        }        
-        List<TopologyReportLine>lines = new ArrayList<>();
+        }
+        List<TopologyReportLine> lines = new ArrayList<>();
         for (int selectedRow : selectedRows) {
             TopologyReportLine line = this.linesModel.getLine(selectedRow);
-            if( line.getRule()==rule ) {
+            if (line.getRule() == rule) {
                 lines.add(line);
             }
         }
         JPopupMenu menu = new JPopupMenu();
         for (TopologyRuleAction action : actions) {
             JMenuItem item;
-            if( action.hasParameters() ) {
-                item = new JMenuItem(action.getName()+"..."); 
+            if (action.hasParameters()) {
+                item = new JMenuItem(action.getName() + "...");
             } else {
-                item = new JMenuItem(action.getName()); 
+                item = new JMenuItem(action.getName());
             }
             item.addActionListener(new TopologyRuleActionListener(rule, lines, action));
-            if( lines.size()>1 && action.hasParameters() ) {
+            if (lines.size() > 1 && action.hasParameters()) {
                 item.setEnabled(false);
             }
             menu.add(item);
@@ -467,9 +471,9 @@
             JDynForm form
     ) {
         DynObject parameters = null;
-        if( form!=null ) {
+        if (form != null) {
             parameters = action.createParameters();
-            if( parameters!=null ) {
+            if (parameters != null) {
                 form.getValues(parameters);
             }
         }
@@ -496,17 +500,17 @@
         try {
             JDynForm form = null;
             this.lblActionTitle.setText(
-                    "<html>" +
-                    i18n.getTranslation("_Rule") + ": <b>" +
-                    rule.getName() + "</b>, " +
-                    i18n.getTranslation("_Action") + ": <b>" +
-                    action.getName() + "</b></html>"
+                    "<html>"
+                    + i18n.getTranslation("_Rule") + ": <b>"
+                    + rule.getName() + "</b>, "
+                    + i18n.getTranslation("_Action") + ": <b>"
+                    + action.getName() + "</b></html>"
             );
-            this.lblActionDescription.setText("<html>"+action.getShortDescription()+"</html>");
+            this.lblActionDescription.setText("<html>" + action.getShortDescription() + "</html>");
             DynObject parameters = action.createParameters();
-            if( parameters!=null ) {
+            if (parameters != null) {
                 form = DynFormLocator.getDynFormManager().createJDynForm(parameters);
-                if( form!=null ) {
+                if (form != null) {
                     this.pnlParameters.setLayout(new BorderLayout());
                     this.pnlParameters.removeAll();
                     this.pnlParameters.add(form.asJComponent(), BorderLayout.CENTER);
@@ -515,10 +519,10 @@
                 }
             }
             this.btnParametersAccept.addActionListener(
-                new TopologyRuleActionParametersListener(rule, lines, action, form)
+                    new TopologyRuleActionParametersListener(rule, lines, action, form)
             );
         } catch (Exception ex) {
-            LOGGER.warn("Can't show action parameters panel.",ex);
+            LOGGER.warn("Can't show action parameters panel.", ex);
         }
     }
 
@@ -539,7 +543,7 @@
         }
         TopologyReportLine line = this.linesModel.getLine(n);
         Geometry geom = line.getError();
-        if( geom == null ) {
+        if (geom == null) {
             geom = line.getGeometry();
             services.addError(null);
         } else {
@@ -570,7 +574,7 @@
             }
             TopologyReportLine line = this.linesModel.getLine(n);
             Geometry geom = line.getError();
-            if( geom == null ) {
+            if (geom == null) {
                 geom = line.getGeometry();
                 services.addError(null);
             } else {
@@ -601,7 +605,7 @@
         }
     }
 
-    private static class ReportTable implements TableModel {
+    private class ReportTable implements TableModel {
 
         private TopologyReport report;
         private TopologyReportLineSet lines;
@@ -633,7 +637,7 @@
             this.reportListener = new ChangeListener() {
                 @Override
                 public void stateChanged(final ChangeEvent e) {
-                    if( !SwingUtilities.isEventDispatchThread() ) {
+                    if (!SwingUtilities.isEventDispatchThread()) {
                         SwingUtilities.invokeLater(new Runnable() {
                             @Override
                             public void run() {
@@ -657,7 +661,7 @@
         }
 
         public void setFilter(String filter) {
-            if( StringUtils.equals(filter, this.lastFilter) ) {
+            if (StringUtils.equals(filter, this.lastFilter)) {
                 return;
             }
             this.lines = this.report.getLineSet(filter);
@@ -665,7 +669,7 @@
             this.lastFilter = filter;
             this.fireTableChanged();
         }
-        
+
         public TopologyReport getReport() {
             return this.report;
         }
@@ -738,9 +742,11 @@
         }
 
         private void fireTableChanged() {
+            saveCurrentSelection();
             for (TableModelListener tableListener : this.tableListeners) {
                 tableListener.tableChanged(new TableModelEvent(this));
             }
+            restoreCurrentSelection();
         }
 
         public TopologyReportLine getLine(int lineNum) {
@@ -748,4 +754,12 @@
         }
 
     }
+
+    private void saveCurrentSelection() {
+        this.tblErrors.setSelectionModel(new DefaultListSelectionModel());
+    }
+
+    private void restoreCurrentSelection() {
+        this.tblErrors.setSelectionModel(this.selection);
+    }
 }
