[hg] main-silver: #231218: IndexOutOfBoundsException: valid view...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #231218: IndexOutOfBoundsException: valid view...
  • Date: Mon, 17 Jun 2013 09:53:07 -0700

changeset 73af42a196d5 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/73af42a196d5
description:
        #231218: IndexOutOfBoundsException: valid viewIndex: 0 <= index < 0 
but was: -1

        Patch by Matthias42.

diffstat:

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

diffs (93 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,6 +96,7 @@
     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) {
@@ -307,7 +308,7 @@
             }
 
             if (e.getSource() == table.getSelectionModel() && 
table.getRowSelectionAllowed()) {
-                boolean rowSelected = table.getSelectedRows().length > 0;
+                boolean rowSelected = selectedRows.length > 0;
                 if (rowSelected && getModel().isEditable()) {
                     dataviewUI.enableDeleteBtn(true);
                 } else {
@@ -438,10 +439,9 @@
             @Override
             public void actionPerformed(ActionEvent e) {
                 try {
-                    int[] rows = getSelectedRows();
                     String insertSQL = "";
-                    for (int j = 0; j < rows.length; j++) {
-                        int modelIndex = convertRowIndexToModel(rows[j]);
+                    for (int j = 0; j < selectedRows.length; j++) {
+                        int modelIndex = 
convertRowIndexToModel(selectedRows[j]);
                         Object[] insertRow = 
getModel().getRowData(modelIndex);
                         // @todo make table configurable
                         DBTable table = 
pageContext.getTableMetaData().getTable(0);
@@ -466,11 +466,10 @@
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                int[] rows = getSelectedRows();
                 String rawDeleteStmt = "";
-                for (int j = 0; j < rows.length; j++) {
+                for (int j = 0; j < selectedRows.length; j++) {
                     SQLStatementGenerator generator = 
dataView.getSQLStatementGenerator();
-                    int modelIndex = convertRowIndexToModel(rows[j]);
+                    int modelIndex = convertRowIndexToModel(selectedRows[j]);
                     // @todo make table configurable
                     DBTable table = 
pageContext.getTableMetaData().getTable(0);
                     final String deleteStmt = 
generator.generateDeleteStatement(table, modelIndex, getModel());
@@ -549,9 +548,9 @@
                     selectedRow = rowAtPoint(e.getPoint());
                     selectedColumn = columnAtPoint(e.getPoint());
                     boolean inSelection = false;
-                    int[] rows = getSelectedRows();
-                    for (int a = 0; a < rows.length; a++) {
-                        if (rows[a] == selectedRow) {
+                    selectedRows = getSelectedRows();
+                    for (int a = 0; a < selectedRows.length; a++) {
+                        if (selectedRows[a] == selectedRow) {
                             inSelection = true;
                             break;
                         }
@@ -568,6 +567,7 @@
                     }
                     if (!inSelection) {
                         changeSelection(selectedRow, selectedColumn, false, 
false);
+                        selectedRows = getSelectedRows();
                     }
                     if (! getModel().isEditable()) {
                         miInsertAction.setEnabled(false);
@@ -587,6 +587,24 @@
                         miCancelEdits.setEnabled(true);
                         miCommitSQLScript.setEnabled(true);
                     }
+                    if(selectedRows.length > 0) {
+                        miCopyRowValues.setEnabled(true);
+                        miCopyRowValuesH.setEnabled(true);
+                        miInsertSQLScript.setEnabled(true);
+                        miDeleteSQLScript.setEnabled(true);
+                        miDeleteAction.setEnabled(true);
+                    } else {
+                        miCopyRowValues.setEnabled(false);
+                        miCopyRowValuesH.setEnabled(false);
+                        miInsertSQLScript.setEnabled(false);
+                        miDeleteSQLScript.setEnabled(false);
+                        miDeleteAction.setEnabled(false);
+                    }
+                    if(selectedColumn >= 0 && selectedRow >= 0) {
+                        miCopyValue.setEnabled(true);
+                    } else {
+                        miCopyValue.setEnabled(false);
+                    }
                     tablePopupMenu.show(DataViewTableUI.this, e.getX(), 
e.getY());
                 }
             }

[hg] main-silver: #231218: IndexOutOfBoundsException: valid view...

Jaroslav Havlin 06/17/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 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close