Lines 56-62
Link Here
|
56 |
import java.util.Collections; |
56 |
import java.util.Collections; |
57 |
import java.util.Comparator; |
57 |
import java.util.Comparator; |
58 |
import java.util.Date; |
58 |
import java.util.Date; |
59 |
import java.util.Iterator; |
|
|
60 |
import java.util.List; |
59 |
import java.util.List; |
61 |
import java.util.logging.Level; |
60 |
import java.util.logging.Level; |
62 |
import java.util.logging.Logger; |
61 |
import java.util.logging.Logger; |
Lines 409-415
Link Here
|
409 |
} catch (SQLHistoryException ex) { |
408 |
} catch (SQLHistoryException ex) { |
410 |
handleSQLHistoryException(); |
409 |
handleSQLHistoryException(); |
411 |
} |
410 |
} |
412 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(null, sqlHistoryList); |
411 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(sqlHistoryList); |
413 |
NbPreferences.forModule(SQLHistoryPanel.class).put("SQL_STATEMENTS_SAVED_FOR_HISTORY", Integer.toString(iLimit)); // NOI18N |
412 |
NbPreferences.forModule(SQLHistoryPanel.class).put("SQL_STATEMENTS_SAVED_FOR_HISTORY", Integer.toString(iLimit)); // NOI18N |
414 |
sqlLimitTextField.setText(SAVE_STATEMENTS_MAX_LIMIT_ENTERED); |
413 |
sqlLimitTextField.setText(SAVE_STATEMENTS_MAX_LIMIT_ENTERED); |
415 |
} |
414 |
} |
Lines 433-439
Link Here
|
433 |
if (SQLHistoryPersistenceManager.getInstance().updateSQLSaved(iLimit, historyRoot).size() > 0) { |
432 |
if (SQLHistoryPersistenceManager.getInstance().updateSQLSaved(iLimit, historyRoot).size() > 0) { |
434 |
List<SQLHistory> sqlHistoryList = SQLHistoryPersistenceManager.getInstance().retrieve(historyFilePath, historyRoot); |
433 |
List<SQLHistory> sqlHistoryList = SQLHistoryPersistenceManager.getInstance().retrieve(historyFilePath, historyRoot); |
435 |
view.setCurrentSQLHistoryList(sqlHistoryList); |
434 |
view.setCurrentSQLHistoryList(sqlHistoryList); |
436 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(null, sqlHistoryList); |
435 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(sqlHistoryList); |
437 |
view.updateConnectionUrl(); |
436 |
view.updateConnectionUrl(); |
438 |
NbPreferences.forModule(SQLHistoryPanel.class).put("SQL_STATEMENTS_SAVED_FOR_HISTORY", Integer.toString(iLimit)); // NOI18N |
437 |
NbPreferences.forModule(SQLHistoryPanel.class).put("SQL_STATEMENTS_SAVED_FOR_HISTORY", Integer.toString(iLimit)); // NOI18N |
439 |
} |
438 |
} |
Lines 458-464
Link Here
|
458 |
LOGGER.log(Level.WARNING, NbBundle.getMessage(SQLHistoryPanel.class, "LBL_ErrorParsingSQLHistory")); |
457 |
LOGGER.log(Level.WARNING, NbBundle.getMessage(SQLHistoryPanel.class, "LBL_ErrorParsingSQLHistory")); |
459 |
List<SQLHistory> sqlHistoryList = SQLHistoryPersistenceManager.getInstance().retrieve(); |
458 |
List<SQLHistory> sqlHistoryList = SQLHistoryPersistenceManager.getInstance().retrieve(); |
460 |
view.setCurrentSQLHistoryList(sqlHistoryList); |
459 |
view.setCurrentSQLHistoryList(sqlHistoryList); |
461 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(null, sqlHistoryList); |
460 |
((HistoryTableModel) sqlHistoryTable.getModel()).refreshTable(sqlHistoryList); |
462 |
view.updateConnectionUrl(); |
461 |
view.updateConnectionUrl(); |
463 |
} |
462 |
} |
464 |
|
463 |
|
Lines 771-783
Link Here
|
771 |
} |
770 |
} |
772 |
|
771 |
|
773 |
public void actionPerformed(ActionEvent evt) { |
772 |
public void actionPerformed(ActionEvent evt) { |
774 |
view.setCurrentSQLHistoryList(view.filterSQLHistoryList()); |
773 |
processUpdate(); |
775 |
sqlHistoryTable.repaint(); |
|
|
776 |
sqlHistoryTable.clearSelection(); |
777 |
refreshTable(evt, view.getCurrentSQLHistoryList()); |
778 |
} |
774 |
} |
779 |
|
775 |
|
780 |
public void refreshTable(ActionEvent evt, List<SQLHistory> sqlHistoryList) { |
776 |
public void refreshTable(List<SQLHistory> sqlHistoryList) { |
781 |
String url; |
777 |
String url; |
782 |
// Get the connection url from the combo box |
778 |
// Get the connection url from the combo box |
783 |
if (sqlHistoryList.size() > 0) { |
779 |
if (sqlHistoryList.size() > 0) { |
Lines 824-879
Link Here
|
824 |
} |
820 |
} |
825 |
|
821 |
|
826 |
public void insertUpdate(DocumentEvent evt) { |
822 |
public void insertUpdate(DocumentEvent evt) { |
827 |
processUpdate(evt); |
823 |
processUpdate(); |
828 |
} |
824 |
} |
829 |
|
825 |
|
830 |
public void removeUpdate(DocumentEvent evt) { |
826 |
public void removeUpdate(DocumentEvent evt) { |
831 |
processUpdate(evt); |
827 |
processUpdate(); |
832 |
} |
828 |
} |
833 |
|
829 |
|
834 |
private void processUpdate(DocumentEvent evt) { |
830 |
private void processUpdate() { |
835 |
List<String> currentSQLList = view.getSQLList(sortData()); |
831 |
view.setCurrentSQLHistoryList(view.filterSQLHistoryList()); |
836 |
|
832 |
sqlHistoryTable.repaint(); |
837 |
// Read the contents |
833 |
sqlHistoryTable.clearSelection(); |
838 |
try { |
834 |
refreshTable(view.getCurrentSQLHistoryList()); |
839 |
String matchText = read(evt.getDocument()); |
|
|
840 |
Object[][] localData = new Object[currentSQLList.size()][2]; |
841 |
int row = 0; |
842 |
int length; |
843 |
int maxLength; |
844 |
Iterator dateIterator = dateList.iterator(); |
845 |
for (String sql : currentSQLList) { |
846 |
if (sql.trim().toLowerCase().indexOf(matchText.toLowerCase()) != -1) { |
847 |
length = sql.trim().length(); |
848 |
maxLength = length > TABLE_DATA_WIDTH_SQL ? TABLE_DATA_WIDTH_SQL : length; |
849 |
localData[row][0] = sql.trim().substring(0, maxLength); |
850 |
localData[row][1] = dateIterator.next(); |
851 |
row++; |
852 |
} |
835 |
} |
853 |
} |
|
|
854 |
// no matches so clean the table |
855 |
if (row == 0) { |
856 |
cleanTable(); |
857 |
} |
858 |
// Adjust size of data for the table |
859 |
if (row > 0) { |
860 |
data = new Object[row][2]; |
861 |
for (int i = 0; i < row; i++) { |
862 |
data[i][0] = localData[i][0]; |
863 |
data[i][1] = localData[i][1]; |
864 |
} |
865 |
} else { |
866 |
data = new Object[0][0]; |
867 |
insertSQLButton.setEnabled(false); |
868 |
} |
869 |
// Refresh the table |
870 |
sqlHistoryTable.revalidate(); |
871 |
} catch (InterruptedException e) { |
872 |
Exceptions.printStackTrace(e); |
873 |
} catch (Exception e) { |
874 |
Exceptions.printStackTrace(e); |
875 |
} |
876 |
} |
877 |
|
836 |
|
878 |
public void changedUpdate(DocumentEvent arg0) { |
837 |
public void changedUpdate(DocumentEvent arg0) { |
879 |
// unused |
838 |
// unused |
Lines 892-898
Link Here
|
892 |
SQLComparator sqlComparator = new SQLComparator(sortCol, sortAsc); |
851 |
SQLComparator sqlComparator = new SQLComparator(sortCol, sortAsc); |
893 |
Collections.sort(filteredSQLHistoryList, sqlComparator); |
852 |
Collections.sort(filteredSQLHistoryList, sqlComparator); |
894 |
view.setCurrentSQLHistoryList(filteredSQLHistoryList); |
853 |
view.setCurrentSQLHistoryList(filteredSQLHistoryList); |
895 |
refreshTable(null, filteredSQLHistoryList); |
854 |
refreshTable( filteredSQLHistoryList); |
896 |
return filteredSQLHistoryList; |
855 |
return filteredSQLHistoryList; |
897 |
} |
856 |
} |
898 |
} |
857 |
} |