Lines 84-92
Link Here
|
84 |
import javax.swing.text.Caret; |
84 |
import javax.swing.text.Caret; |
85 |
import javax.swing.text.Document; |
85 |
import javax.swing.text.Document; |
86 |
import org.netbeans.api.editor.EditorRegistry; |
86 |
import org.netbeans.api.editor.EditorRegistry; |
|
|
87 |
import org.netbeans.modules.db.sql.history.SQLHistory; |
87 |
import org.netbeans.modules.db.sql.history.SQLHistoryEntry; |
88 |
import org.netbeans.modules.db.sql.history.SQLHistoryEntry; |
88 |
import org.netbeans.modules.db.sql.history.SQLHistoryManager; |
89 |
import org.netbeans.modules.db.sql.history.SQLHistoryManager; |
89 |
import org.netbeans.modules.db.sql.loader.SQLDataLoader; |
90 |
import org.netbeans.modules.db.sql.loader.SQLDataLoader; |
|
|
91 |
import org.openide.DialogDisplayer; |
92 |
import org.openide.NotifyDescriptor; |
90 |
import org.openide.awt.MouseUtils; |
93 |
import org.openide.awt.MouseUtils; |
91 |
import org.openide.util.Exceptions; |
94 |
import org.openide.util.Exceptions; |
92 |
import org.openide.util.NbBundle; |
95 |
import org.openide.util.NbBundle; |
Lines 168-175
Link Here
|
168 |
public void valueChanged(ListSelectionEvent e) { |
171 |
public void valueChanged(ListSelectionEvent e) { |
169 |
if (sqlTableSelektion.isSelectionEmpty()) { |
172 |
if (sqlTableSelektion.isSelectionEmpty()) { |
170 |
insertSQLButton.setEnabled(false); |
173 |
insertSQLButton.setEnabled(false); |
|
|
174 |
deleteSQLButtton.setEnabled(false); |
171 |
} else { |
175 |
} else { |
172 |
insertSQLButton.setEnabled(true); |
176 |
insertSQLButton.setEnabled(true); |
|
|
177 |
deleteSQLButtton.setEnabled(true); |
173 |
} |
178 |
} |
174 |
} |
179 |
} |
175 |
}); |
180 |
}); |
Lines 188-194
Link Here
|
188 |
|
193 |
|
189 |
String url = (String) connectionUrlComboBox.getSelectedItem(); |
194 |
String url = (String) connectionUrlComboBox.getSelectedItem(); |
190 |
|
195 |
|
191 |
if ( url != null && !url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"))) { |
196 |
if (url != null && !url.equals(NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem"))) { |
192 |
rowFilter.add(new EqualsFilter(url, 0)); |
197 |
rowFilter.add(new EqualsFilter(url, 0)); |
193 |
} |
198 |
} |
194 |
|
199 |
|
Lines 208-214
Link Here
|
208 |
urls.add(0, NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem")); |
213 |
urls.add(0, NbBundle.getMessage(SQLHistoryPanel.class, "LBL_URLComboBoxAllConnectionsItem")); |
209 |
Object selected = connectionUrlComboBox.getSelectedItem(); |
214 |
Object selected = connectionUrlComboBox.getSelectedItem(); |
210 |
connectionUrlComboBox.setModel(new DefaultComboBoxModel(urls.toArray())); |
215 |
connectionUrlComboBox.setModel(new DefaultComboBoxModel(urls.toArray())); |
211 |
if(selected != null && urls.contains(selected)) { |
216 |
if (selected != null && urls.contains(selected)) { |
212 |
connectionUrlComboBox.setSelectedItem(selected); |
217 |
connectionUrlComboBox.setSelectedItem(selected); |
213 |
} else { |
218 |
} else { |
214 |
connectionUrlComboBox.setSelectedIndex(0); |
219 |
connectionUrlComboBox.setSelectedIndex(0); |
Lines 245-250
Link Here
|
245 |
sqlLimitTextField = new javax.swing.JTextField(); |
250 |
sqlLimitTextField = new javax.swing.JTextField(); |
246 |
sqlLimitButton = new javax.swing.JButton(); |
251 |
sqlLimitButton = new javax.swing.JButton(); |
247 |
inputWarningLabel = new javax.swing.JLabel(); |
252 |
inputWarningLabel = new javax.swing.JLabel(); |
|
|
253 |
deleteSQLButtton = new javax.swing.JButton(); |
254 |
deleteAllSQLButton = new javax.swing.JButton(); |
248 |
|
255 |
|
249 |
jLabel1.setText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Connection")); // NOI18N |
256 |
jLabel1.setText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Connection")); // NOI18N |
250 |
|
257 |
|
Lines 254-259
Link Here
|
254 |
searchTextField.setMinimumSize(new java.awt.Dimension(20, 22)); |
261 |
searchTextField.setMinimumSize(new java.awt.Dimension(20, 22)); |
255 |
|
262 |
|
256 |
org.openide.awt.Mnemonics.setLocalizedText(insertSQLButton, org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Insert")); // NOI18N |
263 |
org.openide.awt.Mnemonics.setLocalizedText(insertSQLButton, org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Insert")); // NOI18N |
|
|
264 |
insertSQLButton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_Insert")); // NOI18N |
257 |
insertSQLButton.setEnabled(false); |
265 |
insertSQLButton.setEnabled(false); |
258 |
insertSQLButton.addActionListener(new java.awt.event.ActionListener() { |
266 |
insertSQLButton.addActionListener(new java.awt.event.ActionListener() { |
259 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
267 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
Lines 313-318
Link Here
|
313 |
inputWarningLabel.setRequestFocusEnabled(false); |
321 |
inputWarningLabel.setRequestFocusEnabled(false); |
314 |
inputWarningLabel.setVerifyInputWhenFocusTarget(false); |
322 |
inputWarningLabel.setVerifyInputWhenFocusTarget(false); |
315 |
|
323 |
|
|
|
324 |
org.openide.awt.Mnemonics.setLocalizedText(deleteSQLButtton, org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_Delete")); // NOI18N |
325 |
deleteSQLButtton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_Delete")); // NOI18N |
326 |
deleteSQLButtton.setEnabled(false); |
327 |
deleteSQLButtton.addActionListener(new java.awt.event.ActionListener() { |
328 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
329 |
deleteSQLButttonActionPerformed(evt); |
330 |
} |
331 |
}); |
332 |
|
333 |
deleteAllSQLButton.setText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "LBL_DeleteAll")); // NOI18N |
334 |
deleteAllSQLButton.setToolTipText(org.openide.util.NbBundle.getMessage(SQLHistoryPanel.class, "ACSD_DeleteAll")); // NOI18N |
335 |
deleteAllSQLButton.addActionListener(new java.awt.event.ActionListener() { |
336 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
337 |
deleteAllSQLButtonActionPerformed(evt); |
338 |
} |
339 |
}); |
340 |
|
316 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
341 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
317 |
this.setLayout(layout); |
342 |
this.setLayout(layout); |
318 |
layout.setHorizontalGroup( |
343 |
layout.setHorizontalGroup( |
Lines 322-341
Link Here
|
322 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
347 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
323 |
.addGroup(layout.createSequentialGroup() |
348 |
.addGroup(layout.createSequentialGroup() |
324 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
349 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
325 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 645, Short.MAX_VALUE) |
350 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE) |
326 |
.addGroup(layout.createSequentialGroup() |
351 |
.addGroup(layout.createSequentialGroup() |
327 |
.addComponent(jLabel1) |
352 |
.addComponent(jLabel1) |
328 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
353 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
329 |
.addComponent(connectionUrlComboBox, 0, 301, Short.MAX_VALUE) |
354 |
.addComponent(connectionUrlComboBox, 0, 224, Short.MAX_VALUE) |
330 |
.addGap(18, 18, 18) |
355 |
.addGap(18, 18, 18) |
331 |
.addComponent(jLabel2) |
356 |
.addComponent(jLabel2) |
332 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
357 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
333 |
.addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))) |
358 |
.addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))) |
334 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
359 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
335 |
.addComponent(insertSQLButton) |
360 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
|
361 |
.addComponent(insertSQLButton, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE) |
362 |
.addComponent(deleteSQLButtton, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE) |
363 |
.addComponent(deleteAllSQLButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
336 |
.addContainerGap()) |
364 |
.addContainerGap()) |
337 |
.addGroup(layout.createSequentialGroup() |
365 |
.addGroup(layout.createSequentialGroup() |
338 |
.addComponent(inputWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE) |
366 |
.addComponent(inputWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE) |
339 |
.addGap(493, 493, 493)) |
367 |
.addGap(493, 493, 493)) |
340 |
.addGroup(layout.createSequentialGroup() |
368 |
.addGroup(layout.createSequentialGroup() |
341 |
.addComponent(sqlLimitLabel) |
369 |
.addComponent(sqlLimitLabel) |
Lines 355-370
Link Here
|
355 |
.addComponent(connectionUrlComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) |
383 |
.addComponent(connectionUrlComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) |
356 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
384 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
357 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
385 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
358 |
.addComponent(insertSQLButton) |
|
|
359 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
386 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
360 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE) |
387 |
.addComponent(insertSQLButton) |
|
|
388 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE) |
389 |
.addComponent(deleteAllSQLButton) |
390 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
391 |
.addComponent(deleteSQLButtton)) |
392 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)) |
361 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
393 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
362 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
394 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
363 |
.addComponent(sqlLimitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
395 |
.addComponent(sqlLimitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
364 |
.addComponent(sqlLimitButton) |
396 |
.addComponent(sqlLimitButton) |
365 |
.addComponent(sqlLimitLabel)) |
397 |
.addComponent(sqlLimitLabel)) |
366 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
398 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
367 |
.addComponent(inputWarningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))) |
399 |
.addComponent(inputWarningLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) |
368 |
.addContainerGap()) |
400 |
.addContainerGap()) |
369 |
); |
401 |
); |
370 |
|
402 |
|
Lines 395-400
Link Here
|
395 |
verifySQLLimit(); |
427 |
verifySQLLimit(); |
396 |
}//GEN-LAST:event_sqlLimitButtonActionPerformed |
428 |
}//GEN-LAST:event_sqlLimitButtonActionPerformed |
397 |
|
429 |
|
|
|
430 |
private void deleteSQLButttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSQLButttonActionPerformed |
431 |
deleteSQL(); |
432 |
}//GEN-LAST:event_deleteSQLButttonActionPerformed |
433 |
|
434 |
private void deleteAllSQLButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteAllSQLButtonActionPerformed |
435 |
deleteAllSQL(); |
436 |
}//GEN-LAST:event_deleteAllSQLButtonActionPerformed |
437 |
|
398 |
private void insertSQL() { |
438 |
private void insertSQL() { |
399 |
try { |
439 |
try { |
400 |
JEditorPane pane = (JEditorPane) EditorRegistry.lastFocusedComponent(); |
440 |
JEditorPane pane = (JEditorPane) EditorRegistry.lastFocusedComponent(); |
Lines 416-421
Link Here
|
416 |
} |
456 |
} |
417 |
} |
457 |
} |
418 |
|
458 |
|
|
|
459 |
private void deleteSQL() { |
460 |
SQLHistoryManager shm = SQLHistoryManager.getInstance(); |
461 |
SQLHistory history = shm.getSQLHistory(); |
462 |
int min = sqlTableSelektion.getMinSelectionIndex(); |
463 |
int max = sqlTableSelektion.getMaxSelectionIndex(); |
464 |
for (int i = min; i <= max; i++) { |
465 |
if (sqlHistoryTable.isRowSelected(i)) { |
466 |
int modelIndex = sqlHistoryTable.convertRowIndexToModel(i); |
467 |
SQLHistoryEntry sql = (SQLHistoryEntry) htm.getValueAt(modelIndex, 3); |
468 |
history.remove(sql); |
469 |
} |
470 |
} |
471 |
shm.save(); |
472 |
htm.refresh(); |
473 |
} |
474 |
|
475 |
private void deleteAllSQL() { |
476 |
NotifyDescriptor d = new NotifyDescriptor.Confirmation( |
477 |
NbBundle.getMessage(SQLHistoryPanel.class, "DESC_DeleteAll"), |
478 |
NbBundle.getMessage(SQLHistoryPanel.class, "LBL_DeleteAll"), |
479 |
NotifyDescriptor.YES_NO_OPTION); |
480 |
if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.YES_OPTION) { |
481 |
SQLHistoryManager shm = SQLHistoryManager.getInstance(); |
482 |
SQLHistory history = shm.getSQLHistory(); |
483 |
history.clear(); |
484 |
shm.save(); |
485 |
htm.refresh(); |
486 |
} |
487 |
} |
488 |
|
419 |
private void verifySQLLimit() { |
489 |
private void verifySQLLimit() { |
420 |
String enteredLimitString = sqlLimitTextField.getText(); |
490 |
String enteredLimitString = sqlLimitTextField.getText(); |
421 |
String currentLimit = Integer.toString(SQLHistoryManager.getInstance().getListSize()); |
491 |
String currentLimit = Integer.toString(SQLHistoryManager.getInstance().getListSize()); |
Lines 481-486
Link Here
|
481 |
} |
551 |
} |
482 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
552 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
483 |
private javax.swing.JComboBox connectionUrlComboBox; |
553 |
private javax.swing.JComboBox connectionUrlComboBox; |
|
|
554 |
private javax.swing.JButton deleteAllSQLButton; |
555 |
private javax.swing.JButton deleteSQLButtton; |
484 |
private javax.swing.JLabel inputWarningLabel; |
556 |
private javax.swing.JLabel inputWarningLabel; |
485 |
private javax.swing.JButton insertSQLButton; |
557 |
private javax.swing.JButton insertSQLButton; |
486 |
private javax.swing.JLabel jLabel1; |
558 |
private javax.swing.JLabel jLabel1; |