[hg] main-silver: #231218: Removing field selectedRows from Data...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #231218: Removing field selectedRows from Data...
  • Date: Mon, 17 Jun 2013 19:59:53 -0700

changeset 071dc065358f in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/071dc065358f
description:
        #231218: Removing field selectedRows from DataViewTableUI

diffstat:

 db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java 
|  22 +++++-----
 1 files changed, 11 insertions(+), 11 deletions(-)

diffs (77 lines):

diff --git 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
--- 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
+++ 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
@@ -96,7 +96,6 @@
     private DataViewActionHandler handler;
     private int selectedRow = -1;
     private int selectedColumn = -1;
-    private int[] selectedRows = new int[0];
     private TableModelListener dataChangedListener = new 
TableModelListener() {
         @Override
         public void tableChanged(TableModelEvent e) {
@@ -308,7 +307,7 @@
             }
 
             if (e.getSource() == table.getSelectionModel() && 
table.getRowSelectionAllowed()) {
-                boolean rowSelected = selectedRows.length > 0;
+                boolean rowSelected = table.getSelectedRows().length > 0;
                 if (rowSelected && getModel().isEditable()) {
                     dataviewUI.enableDeleteBtn(true);
                 } else {
@@ -439,9 +438,10 @@
             @Override
             public void actionPerformed(ActionEvent e) {
                 try {
+                    int[] rows = getSelectedRows();
                     String insertSQL = "";
-                    for (int j = 0; j < selectedRows.length; j++) {
-                        int modelIndex = 
convertRowIndexToModel(selectedRows[j]);
+                    for (int j = 0; j < rows.length; j++) {
+                        int modelIndex = convertRowIndexToModel(rows[j]);
                         Object[] insertRow = 
getModel().getRowData(modelIndex);
                         // @todo make table configurable
                         DBTable table = 
pageContext.getTableMetaData().getTable(0);
@@ -466,10 +466,11 @@
 
             @Override
             public void actionPerformed(ActionEvent e) {
+                int[] rows = getSelectedRows();
                 String rawDeleteStmt = "";
-                for (int j = 0; j < selectedRows.length; j++) {
+                for (int j = 0; j < rows.length; j++) {
                     SQLStatementGenerator generator = 
dataView.getSQLStatementGenerator();
-                    int modelIndex = convertRowIndexToModel(selectedRows[j]);
+                    int modelIndex = convertRowIndexToModel(rows[j]);
                     // @todo make table configurable
                     DBTable table = 
pageContext.getTableMetaData().getTable(0);
                     final String deleteStmt = 
generator.generateDeleteStatement(table, modelIndex, getModel());
@@ -548,9 +549,9 @@
                     selectedRow = rowAtPoint(e.getPoint());
                     selectedColumn = columnAtPoint(e.getPoint());
                     boolean inSelection = false;
-                    selectedRows = getSelectedRows();
-                    for (int a = 0; a < selectedRows.length; a++) {
-                        if (selectedRows[a] == selectedRow) {
+                    int[] rows = getSelectedRows();
+                    for (int a = 0; a < rows.length; a++) {
+                        if (rows[a] == selectedRow) {
                             inSelection = true;
                             break;
                         }
@@ -567,7 +568,6 @@
                     }
                     if (!inSelection) {
                         changeSelection(selectedRow, selectedColumn, false, 
false);
-                        selectedRows = getSelectedRows();
                     }
                     if (! getModel().isEditable()) {
                         miInsertAction.setEnabled(false);
@@ -587,7 +587,7 @@
                         miCancelEdits.setEnabled(true);
                         miCommitSQLScript.setEnabled(true);
                     }
-                    if(selectedRows.length > 0) {
+                    if(getSelectedRows().length > 0) {
                         miCopyRowValues.setEnabled(true);
                         miCopyRowValuesH.setEnabled(true);
                         miInsertSQLScript.setEnabled(true);

[hg] main-silver: #231218: Removing field selectedRows from Data...

Jaroslav Havlin 06/18/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close