diff -ubNr -x private.xml -x project.xml.orig nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/Bundle.properties nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/Bundle.properties
--- nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/Bundle.properties 2011-11-01 20:03:06.000000000 +0100
+++ nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/Bundle.properties 2011-11-01 22:50:22.000000000 +0100
@@ -71,12 +71,14 @@
ACSD_Match=Matching SQL matchbox
ACSD_Save=Limit the number of SQL statements to save
ACSD_Insert=Insert SQL statement in the SQL editor
+ACSD_Delete=Delete SQL statement from history
ACSD_Apply=Save SQL limit to preferences
ASCN_ConnectionCombo=Connections Used Combo box
ACSN_Match=Matching SQL matchbox
ACSN_Save=SQL limit field
ACSN_Insert=&Insert
+ACSN_Delete=&Delete
ACSN_Apply=&Apply
LBL_Connection=Connection
@@ -99,3 +101,7 @@
SQLHistoryPanel_PleaseWait=Please wait...
\ Kein Zeilenumbruch am Dateiende.
+LBL_Delete=&Delete
+LBL_DeleteAll=Delete All
+DESC_DeleteAll=Really delete all entries from the SQL history?
+ACSD_DeleteAll=Delete all SQL statements from history
diff -ubNr -x private.xml -x project.xml.orig nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form
--- nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form 2011-11-01 21:54:54.000000000 +0100
+++ nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.form 2011-11-01 22:53:59.000000000 +0100
@@ -21,11 +21,11 @@
-
+
-
+
@@ -33,11 +33,15 @@
-
+
+
+
+
+
-
+
@@ -63,9 +67,15 @@
-
-
+
+
+
+
+
+
+
+
@@ -74,8 +84,6 @@
-
-
@@ -132,6 +140,9 @@
+
+
+
@@ -242,5 +253,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -ubNr -x private.xml -x project.xml.orig nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java
--- nb-trunk/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java 2011-11-01 21:54:54.000000000 +0100
+++ nb-trunk-2/db.core//src/org/netbeans/modules/db/sql/execute/ui/SQLHistoryPanel.java 2011-11-01 22:53:59.000000000 +0100
@@ -84,9 +84,12 @@
import javax.swing.text.Caret;
import javax.swing.text.Document;
import org.netbeans.api.editor.EditorRegistry;
+import org.netbeans.modules.db.sql.history.SQLHistory;
import org.netbeans.modules.db.sql.history.SQLHistoryEntry;
import org.netbeans.modules.db.sql.history.SQLHistoryManager;
import org.netbeans.modules.db.sql.loader.SQLDataLoader;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
import org.openide.awt.MouseUtils;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
@@ -168,8 +171,10 @@
public void valueChanged(ListSelectionEvent e) {
if (sqlTableSelektion.isSelectionEmpty()) {
insertSQLButton.setEnabled(false);
+ deleteSQLButtton.setEnabled(false);
} else {
insertSQLButton.setEnabled(true);
+ deleteSQLButtton.setEnabled(true);
}
}
});
@@ -188,7 +193,7 @@
String url = (String) connectionUrlComboBox.getSelectedItem();
- if ( url != null && !url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"))) {
+ if (url != null && !url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"))) {
rowFilter.add(new EqualsFilter(url, 0));
}
@@ -208,7 +213,7 @@
urls.add(0, NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"));
Object selected = connectionUrlComboBox.getSelectedItem();
connectionUrlComboBox.setModel(new DefaultComboBoxModel(urls.toArray()));
- if(selected != null && urls.contains(selected)) {
+ if (selected != null && urls.contains(selected)) {
connectionUrlComboBox.setSelectedItem(selected);
} else {
connectionUrlComboBox.setSelectedIndex(0);
@@ -245,6 +250,8 @@
sqlLimitTextField = new javax.swing.JTextField();
sqlLimitButton = new javax.swing.JButton();
inputWarningLabel = new javax.swing.JLabel();
+ deleteSQLButtton = new javax.swing.JButton();
+ deleteAllSQLButton = new javax.swing.JButton();
jLabel1.setText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Connection")); // NOI18N
@@ -254,6 +261,7 @@
searchTextField.setMinimumSize(new java.awt.Dimension(20, 22));
org.openide.awt.Mnemonics.setLocalizedText(insertSQLButton, org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Insert")); // NOI18N
+ insertSQLButton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_Insert")); // NOI18N
insertSQLButton.setEnabled(false);
insertSQLButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -313,6 +321,23 @@
inputWarningLabel.setRequestFocusEnabled(false);
inputWarningLabel.setVerifyInputWhenFocusTarget(false);
+ org.openide.awt.Mnemonics.setLocalizedText(deleteSQLButtton, org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Delete")); // NOI18N
+ deleteSQLButtton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_Delete")); // NOI18N
+ deleteSQLButtton.setEnabled(false);
+ deleteSQLButtton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ deleteSQLButttonActionPerformed(evt);
+ }
+ });
+
+ deleteAllSQLButton.setText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_DeleteAll")); // NOI18N
+ deleteAllSQLButton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_DeleteAll")); // NOI18N
+ deleteAllSQLButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ deleteAllSQLButtonActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -322,20 +347,23 @@
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 645, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(connectionUrlComboBox, 0, 301, Short.MAX_VALUE)
+ .addComponent(connectionUrlComboBox, 0, 224, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(insertSQLButton)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(insertSQLButton, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
+ .addComponent(deleteSQLButtton, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
+ .addComponent(deleteAllSQLButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
- .addComponent(inputWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
+ .addComponent(inputWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
.addGap(493, 493, 493))
.addGroup(layout.createSequentialGroup()
.addComponent(sqlLimitLabel)
@@ -355,16 +383,20 @@
.addComponent(connectionUrlComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(insertSQLButton)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
+ .addComponent(insertSQLButton)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
+ .addComponent(deleteAllSQLButton)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(deleteSQLButtton))
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sqlLimitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sqlLimitButton)
.addComponent(sqlLimitLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(inputWarningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addComponent(inputWarningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@@ -395,6 +427,14 @@
verifySQLLimit();
}//GEN-LAST:event_sqlLimitButtonActionPerformed
+ private void deleteSQLButttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSQLButttonActionPerformed
+ deleteSQL();
+ }//GEN-LAST:event_deleteSQLButttonActionPerformed
+
+ private void deleteAllSQLButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteAllSQLButtonActionPerformed
+ deleteAllSQL();
+ }//GEN-LAST:event_deleteAllSQLButtonActionPerformed
+
private void insertSQL() {
try {
JEditorPane pane = (JEditorPane) EditorRegistry.lastFocusedComponent();
@@ -416,6 +456,36 @@
}
}
+ private void deleteSQL() {
+ SQLHistoryManager shm = SQLHistoryManager.getInstance();
+ SQLHistory history = shm.getSQLHistory();
+ int min = sqlTableSelektion.getMinSelectionIndex();
+ int max = sqlTableSelektion.getMaxSelectionIndex();
+ for (int i = min; i <= max; i++) {
+ if (sqlHistoryTable.isRowSelected(i)) {
+ int modelIndex = sqlHistoryTable.convertRowIndexToModel(i);
+ SQLHistoryEntry sql = (SQLHistoryEntry) htm.getValueAt(modelIndex, 3);
+ history.remove(sql);
+ }
+ }
+ shm.save();
+ htm.refresh();
+ }
+
+ private void deleteAllSQL() {
+ NotifyDescriptor d = new NotifyDescriptor.Confirmation(
+ NbBundle.getMessage(SQLHistoryPanel.class, "DESC_DeleteAll"),
+ NbBundle.getMessage(SQLHistoryPanel.class, "LBL_DeleteAll"),
+ NotifyDescriptor.YES_NO_OPTION);
+ if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.YES_OPTION) {
+ SQLHistoryManager shm = SQLHistoryManager.getInstance();
+ SQLHistory history = shm.getSQLHistory();
+ history.clear();
+ shm.save();
+ htm.refresh();
+ }
+ }
+
private void verifySQLLimit() {
String enteredLimitString = sqlLimitTextField.getText();
String currentLimit = Integer.toString(SQLHistoryManager.getInstance().getListSize());
@@ -481,6 +551,8 @@
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox connectionUrlComboBox;
+ private javax.swing.JButton deleteAllSQLButton;
+ private javax.swing.JButton deleteSQLButtton;
private javax.swing.JLabel inputWarningLabel;
private javax.swing.JButton insertSQLButton;
private javax.swing.JLabel jLabel1;