Lines 690-697
Link Here
|
690 |
private final class HistoryTableModel extends DefaultTableModel implements ActionListener, DocumentListener { |
690 |
private final class HistoryTableModel extends DefaultTableModel implements ActionListener, DocumentListener { |
691 |
List<String> sqlList; |
691 |
List<String> sqlList; |
692 |
List<String> dateList; |
692 |
List<String> dateList; |
693 |
int sortCol = 0; |
693 |
int sortCol = 1; |
694 |
boolean sortAsc = true; |
694 |
boolean sortAsc = false; |
695 |
|
695 |
|
696 |
@Override |
696 |
@Override |
697 |
public int getRowCount() { |
697 |
public int getRowCount() { |
Lines 791-806
Link Here
|
791 |
int length; |
791 |
int length; |
792 |
int maxLength; |
792 |
int maxLength; |
793 |
for (SQLHistory sqlHistory : sqlHistoryList) { |
793 |
for (SQLHistory sqlHistory : sqlHistoryList) { |
794 |
if (url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"))) { |
794 |
if (url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem")) || |
|
|
795 |
url.equals(sqlHistory.getUrl())) { |
795 |
length = sqlHistory.getSql().trim().length(); |
796 |
length = sqlHistory.getSql().trim().length(); |
796 |
maxLength = length > TABLE_DATA_WIDTH_SQL ? TABLE_DATA_WIDTH_SQL : length; |
797 |
maxLength = length > TABLE_DATA_WIDTH_SQL ? TABLE_DATA_WIDTH_SQL : length; |
797 |
sqlList.add(sqlHistory.getSql().trim().substring(0, maxLength)); |
798 |
sqlList.add(sqlHistory.getSql().trim().substring(0, maxLength)); |
798 |
dateList.add(DateFormat.getInstance().format(sqlHistory.getDate())); |
799 |
dateList.add(DateFormat.getInstance().format(sqlHistory.getDate())); |
799 |
} else if (url.equals(sqlHistory.getUrl())) { |
|
|
800 |
length = sqlHistory.getSql().trim().length(); |
801 |
maxLength = length > TABLE_DATA_WIDTH_SQL ? TABLE_DATA_WIDTH_SQL : length; |
802 |
sqlList.add(sqlHistory.getSql().trim().substring(0, maxLength)); |
803 |
dateList.add(DateFormat.getInstance().format(sqlHistory.getDate())); |
804 |
} |
800 |
} |
805 |
} |
801 |
} |
806 |
// Initialize sql column data |
802 |
// Initialize sql column data |
Lines 828-875
Link Here
|
828 |
} |
824 |
} |
829 |
|
825 |
|
830 |
public void insertUpdate(DocumentEvent evt) { |
826 |
public void insertUpdate(DocumentEvent evt) { |
831 |
List<String> currentSQLList = view.getSQLList(view.getCurrentSQLHistoryList()); |
827 |
processUpdate(evt); |
832 |
|
|
|
833 |
// Read the contents |
834 |
try { |
835 |
String matchText = read(evt.getDocument()); |
836 |
Object[][] localData = new Object[currentSQLList.size()][2]; |
837 |
int row = 0; |
838 |
int length; |
839 |
int maxLength; |
840 |
Iterator dateIterator = dateList.iterator(); |
841 |
for (String sql : currentSQLList) { |
842 |
if (sql.trim().toLowerCase().indexOf(matchText.toLowerCase()) != -1) { |
843 |
length = sql.trim().length(); |
844 |
maxLength = length > TABLE_DATA_WIDTH_SQL ? TABLE_DATA_WIDTH_SQL : length; |
845 |
localData[row][0] = sql.trim().substring(0, maxLength); |
846 |
localData[row][1] = dateIterator.next(); |
847 |
row++; |
848 |
} |
828 |
} |
849 |
} |
|
|
850 |
|
829 |
|
851 |
// Adjust size of data for the table |
830 |
public void removeUpdate(DocumentEvent evt) { |
852 |
if (row > 0) { |
831 |
processUpdate(evt); |
853 |
data = new Object[row][2]; |
|
|
854 |
for (int i = 0; i < row; i++) { |
855 |
data[i][0] = localData[i][0]; |
856 |
data[i][1] = localData[i][1]; |
857 |
} |
832 |
} |
858 |
} else { |
|
|
859 |
data = new Object[0][0]; |
860 |
insertSQLButton.setEnabled(false); |
861 |
} |
862 |
// Refresh the table |
863 |
sqlHistoryTable.revalidate(); |
864 |
} catch (InterruptedException e) { |
865 |
Exceptions.printStackTrace(e); |
866 |
} catch (Exception e) { |
867 |
Exceptions.printStackTrace(e); |
868 |
} |
869 |
} |
870 |
|
833 |
|
871 |
public void removeUpdate(DocumentEvent evt) { |
834 |
private void processUpdate(DocumentEvent evt) { |
872 |
List<String> currentSQLList = view.getSQLList(view.getCurrentSQLHistoryList()); |
835 |
List<String> currentSQLList = view.getSQLList(sortData()); |
873 |
|
836 |
|
874 |
// Read the contents |
837 |
// Read the contents |
875 |
try { |
838 |
try { |
Lines 1103-1110
Link Here
|
1103 |
if (!(sql1 instanceof SQLHistory) || !(sql2 instanceof SQLHistory)) { |
1066 |
if (!(sql1 instanceof SQLHistory) || !(sql2 instanceof SQLHistory)) { |
1104 |
return result; |
1067 |
return result; |
1105 |
} |
1068 |
} |
1106 |
SQLHistory sqlHistory1 = (SQLHistory) sql1; |
1069 |
SQLHistory sqlHistory1 = sql1; |
1107 |
SQLHistory sqlHistory2 = (SQLHistory) sql2; |
1070 |
SQLHistory sqlHistory2 = sql2; |
1108 |
|
1071 |
|
1109 |
switch (sortCol) { |
1072 |
switch (sortCol) { |
1110 |
case 0: // SQL |
1073 |
case 0: // SQL |