This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 218030
Collapse All | Expand All

(-)a/api.search/src/org/netbeans/modules/search/IgnoreListPanel.form (-1 / +1 lines)
Lines 37-43 Link Here
37
              <EmptySpace max="-2" attributes="0"/>
37
              <EmptySpace max="-2" attributes="0"/>
38
              <Group type="103" groupAlignment="0" attributes="0">
38
              <Group type="103" groupAlignment="0" attributes="0">
39
                  <Group type="102" attributes="0">
39
                  <Group type="102" attributes="0">
40
                      <Component id="btnBrowse" min="-2" pref="23" max="-2" attributes="0"/>
40
                      <Component id="btnBrowse" min="-2" max="-2" attributes="0"/>
41
                      <EmptySpace max="-2" attributes="0"/>
41
                      <EmptySpace max="-2" attributes="0"/>
42
                      <Component id="btnPattern" min="-2" max="-2" attributes="0"/>
42
                      <Component id="btnPattern" min="-2" max="-2" attributes="0"/>
43
                      <EmptySpace max="-2" attributes="0"/>
43
                      <EmptySpace max="-2" attributes="0"/>
(-)a/api.search/src/org/netbeans/modules/search/IgnoreListPanel.java (-5 / +82 lines)
Lines 5-10 Link Here
5
package org.netbeans.modules.search;
5
package org.netbeans.modules.search;
6
6
7
import java.awt.Window;
7
import java.awt.Window;
8
import java.awt.event.ActionEvent;
9
import java.awt.event.KeyEvent;
10
import java.awt.event.MouseAdapter;
11
import java.awt.event.MouseEvent;
8
import java.io.File;
12
import java.io.File;
9
import java.util.ArrayList;
13
import java.util.ArrayList;
10
import java.util.LinkedList;
14
import java.util.LinkedList;
Lines 46-51 Link Here
46
                        updateEnabledButtons();
50
                        updateEnabledButtons();
47
                    }
51
                    }
48
                });
52
                });
53
        // double click invokes edit action
54
        table.addMouseListener(new MouseAdapter() {
55
            @Override
56
            public void mouseClicked (MouseEvent e) {
57
                if (e.getClickCount() == 2) {
58
                    btnEdit.doClick();
59
                }
60
            }
61
        });
62
        
63
        //select first item
64
        selectAndScrollToRow(table, 0);
65
    }
66
67
    /**
68
     * Selects the row in a table. It will be assured that 
69
     * the row is visible.
70
     * 
71
     * @param aTable
72
     * @param row 
73
     */
74
    public void selectAndScrollToRow (JTable aTable, int row) {
75
        int rowcount = aTable.getModel().getRowCount();
76
        boolean rowsAvailable = rowcount > 0;
77
        boolean isValidRow = row < rowcount;
78
        if (rowsAvailable && isValidRow) {
79
            //select and scroll to item
80
            aTable.getSelectionModel().setSelectionInterval(row, row);
81
            aTable.scrollRectToVisible(aTable.getCellRect(row, 0, false));
82
        }
49
    }
83
    }
50
84
51
    private void updateEnabledButtons() {
85
    private void updateEnabledButtons() {
Lines 139-145 Link Here
139
                .addContainerGap()
173
                .addContainerGap()
140
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
141
                    .addGroup(layout.createSequentialGroup()
175
                    .addGroup(layout.createSequentialGroup()
142
                        .addComponent(btnBrowse, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
176
                        .addComponent(btnBrowse)
143
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
177
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144
                        .addComponent(btnPattern)
178
                        .addComponent(btnPattern)
145
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
179
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
Lines 154-163 Link Here
154
    }// </editor-fold>//GEN-END:initComponents
188
    }// </editor-fold>//GEN-END:initComponents
155
189
156
    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
190
    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
191
        int firstSelectedRow=table.getSelectedRow();
192
        List<IgnoreListItem> itemsToDelete = new ArrayList<IgnoreListItem>();
193
        //get all selected objects
194
        //NOTE: remove the item from model later, so that the selected index 
195
        //always points to the correct object
157
        for (int i : table.getSelectedRows()) {
196
        for (int i : table.getSelectedRows()) {
158
            IgnoreListItem ili = ignoreListModel.list.get(i);
197
            itemsToDelete.add(ignoreListModel.list.get(i));
159
            ignoreListModel.remove(ili);
160
        }
198
        }
199
        //remove the selected objects
200
        for (IgnoreListItem item : itemsToDelete) {
201
            ignoreListModel.remove(item);
202
        }
203
        //select the next available row
204
        int row=Math.min(Math.max(0, firstSelectedRow),table.getModel().getRowCount()-1);
205
        selectAndScrollToRow(table, row);
161
    }//GEN-LAST:event_btnDeleteActionPerformed
206
    }//GEN-LAST:event_btnDeleteActionPerformed
162
207
163
    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
208
    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
Lines 195-201 Link Here
195
            protected void onApply(String pattern, boolean regexp) {
240
            protected void onApply(String pattern, boolean regexp) {
196
                ignoreListModel.addPattern(pattern, regexp);
241
                ignoreListModel.addPattern(pattern, regexp);
197
            }
242
            }
198
        }, btnPattern);
243
        }, this);
199
    }//GEN-LAST:event_btnPatternActionPerformed
244
    }//GEN-LAST:event_btnPatternActionPerformed
200
245
201
    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
246
    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
Lines 439-449 Link Here
439
                (JDialog) SwingUtilities.getAncestorOfClass(
484
                (JDialog) SwingUtilities.getAncestorOfClass(
440
                JDialog.class, baseComponent));
485
                JDialog.class, baseComponent));
441
486
442
        IgnoreListPanel ilp = new IgnoreListPanel();
487
        final IgnoreListPanel ilp = new IgnoreListPanel();
443
        jd.add(ilp);
488
        jd.add(ilp);
444
        jd.setModal(true);
489
        jd.setModal(true);
445
        jd.setLocationRelativeTo(baseComponent);
490
        jd.setLocationRelativeTo(baseComponent);
446
        jd.getRootPane().setDefaultButton(ilp.btnClose);
491
        jd.getRootPane().setDefaultButton(ilp.btnClose);
492
493
        // register ESC key to close the dialog
494
        {
495
            Object actionKey = "cancel"; // NOI18N
496
            jd.getRootPane().getInputMap(
497
                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
498
                    KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionKey);
499
500
            Action cancelAction = new AbstractAction() {
501
                @Override
502
                public void actionPerformed (ActionEvent ev) {
503
                    ilp.btnClose.doClick();
504
                }
505
            };
506
            jd.getRootPane().getActionMap().put(actionKey, cancelAction);
507
        }
508
        // register DEL key to remove the current selected items
509
        {
510
            Object actionKey = "delete"; // NOI18N
511
            jd.getRootPane().getInputMap(
512
                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
513
                    KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), actionKey);
514
515
            Action deleteAction = new AbstractAction() {
516
                @Override
517
                public void actionPerformed (ActionEvent ev) {
518
                    ilp.btnDelete.doClick();
519
                }
520
            };
521
            jd.getRootPane().getActionMap().put(actionKey, deleteAction);
522
        }    
523
447
        jd.pack();
524
        jd.pack();
448
        jd.setTitle(getText("IgnoreListPanel.title"));                  //NOI18N
525
        jd.setTitle(getText("IgnoreListPanel.title"));                  //NOI18N
449
        jd.setVisible(true);
526
        jd.setVisible(true);
(-)a/api.search/src/org/netbeans/modules/search/PatternSandbox.java (-1 / +3 lines)
Lines 814-820 Link Here
814
        jd.add(sandbox);
814
        jd.add(sandbox);
815
        jd.setTitle(sandbox.getTitle());
815
        jd.setTitle(sandbox.getTitle());
816
        jd.setModal(true);
816
        jd.setModal(true);
817
        jd.setLocationRelativeTo(baseComponent);
817
        // try to reuse location of basecomponent 
818
        // else 3 cascades of subdialogs does not fit to the screen
819
        jd.setLocation(baseComponent.getLocationOnScreen());
818
        jd.pack();
820
        jd.pack();
819
        jd.setVisible(true);
821
        jd.setVisible(true);
820
    }
822
    }

Return to bug 218030