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 226286
Collapse All | Expand All

(-)a/api.search/apichanges.xml (+34 lines)
Lines 105-110 Link Here
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
106
107
    <changes>
107
    <changes>
108
109
        <change id="ComponentUtils_adjustPanelsForOptions">
110
            <api name="api.search"/>
111
            <summary>Added method ComponentUtils.adjustPanelsForOptions</summary>
112
            <version major="1" minor="12"/>
113
            <date day="6" month="2" year="2013"/>
114
            <author login="jhavlin"/>
115
            <compatibility addition="yes"/>
116
            <description>
117
                <p>
118
                    Controls for specifying search scope options can now be
119
                    split into two panels - one for scope options, and one for
120
                    file name options.
121
                </p>
122
                <p>
123
                    Class ComponentUtils has new method
124
                    adjustPanelsForOptions(JPanel, JPanel, boolean,
125
                    FileNameController), that takes the two panels. It can be
126
                    used instead of adjustPanelForOptions(JPanel, boolean,
127
                    FileNameController), that puts all controls into a single
128
                    panel.
129
                </p>
130
                <p>
131
                    Class ScopeOptionsController has new method
132
                    getFileNameComponent() to get the panel with controls
133
                    related to file name. (The panel related to search scope can
134
                    be get using getComponent()).
135
                </p>
136
            </description>
137
            <class package="org.netbeans.api.search.ui" name="ComponentUtils"/>
138
            <class package="org.netbeans.api.search.ui" name="ScopeOptionsController"/>
139
            <issue number="226286"/>
140
        </change>
141
108
        <change id="SearchPattern_MatchType">
142
        <change id="SearchPattern_MatchType">
109
            <api name="api.search"/>
143
            <api name="api.search"/>
110
            <summary>Search pattern supports three match types (literal, basic wildcards, regexp)</summary>
144
            <summary>Search pattern supports three match types (literal, basic wildcards, regexp)</summary>
(-)a/api.search/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.search
2
OpenIDE-Module: org.netbeans.api.search
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/search/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/search/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.11
4
OpenIDE-Module-Specification-Version: 1.12
5
5
(-)a/api.search/src/org/netbeans/api/search/ui/ComponentUtils.java (+35 lines)
Lines 138-143 Link Here
138
    }
138
    }
139
139
140
    /**
140
    /**
141
     * Adjust two empty panels for specifying search scope options. Several
142
     * checkboxes and other controls will be addded to them, and their layout
143
     * can be altered.
144
     *
145
     * Such ajdusted panels are useful if you want to let users customize
146
     * options for {@link SearchScopeOptions} that you want to pass to file
147
     * object iterator of a {@link SearchInfo}.
148
     *
149
     * @see ScopeOptionsController#getSearchScopeOptions()
150
     *
151
     * @param scopePanel Empty (with no child components) panel to adjust for
152
     * controls related to search scope (search in archives, search in generated
153
     * sources).
154
     * @param fileNamePanel Empty (with no child components) panel to adjust for
155
     * controls related to file name pattern (regular expression, ignore list).
156
     * @param searchAndReplace True if options for search-and-replace mode
157
     * should be shown, false to show options for search-only mode.
158
     * @param fileNameController File-name combo box that will be bound to this
159
     * settings panel.
160
     * @return Controller for adjusted {@code JPanel}s with controls for setting
161
     * search options (search in archives, search in generated sources, use
162
     * ignore list, treat file name pattern as regular expression matching file
163
     * path).
164
     *
165
     * @since api.search/1.12
166
     */
167
    public static @NonNull ScopeOptionsController adjustPanelsForOptions(
168
            @NonNull JPanel scopePanel, @NonNull JPanel fileNamePanel,
169
            boolean searchAndReplace,
170
            @NonNull FileNameController fileNameController) {
171
        return new ScopeOptionsController(scopePanel, fileNamePanel,
172
                fileNameController, searchAndReplace);
173
    }
174
175
    /**
141
     * Adjust a {@link JComboBox} to act as component for selecting search text
176
     * Adjust a {@link JComboBox} to act as component for selecting search text
142
     * pattern, and return a controller object for interacting with it.
177
     * pattern, and return a controller object for interacting with it.
143
     *
178
     *
(-)a/api.search/src/org/netbeans/api/search/ui/ScopeOptionsController.java (-19 / +63 lines)
Lines 49-54 Link Here
49
import javax.swing.JButton;
49
import javax.swing.JButton;
50
import javax.swing.JCheckBox;
50
import javax.swing.JCheckBox;
51
import javax.swing.JPanel;
51
import javax.swing.JPanel;
52
import org.netbeans.api.annotations.common.NullUnknown;
52
import org.netbeans.api.queries.SharabilityQuery;
53
import org.netbeans.api.queries.SharabilityQuery;
53
import org.netbeans.api.search.SearchScopeOptions;
54
import org.netbeans.api.search.SearchScopeOptions;
54
import org.netbeans.modules.search.BasicSearchProvider;
55
import org.netbeans.modules.search.BasicSearchProvider;
Lines 57-63 Link Here
57
import org.netbeans.modules.search.ui.CheckBoxWithButtonPanel;
58
import org.netbeans.modules.search.ui.CheckBoxWithButtonPanel;
58
import org.netbeans.modules.search.ui.FormLayoutHelper;
59
import org.netbeans.modules.search.ui.FormLayoutHelper;
59
import org.netbeans.modules.search.ui.UiUtils;
60
import org.netbeans.modules.search.ui.UiUtils;
60
import org.openide.util.NbBundle;
61
61
62
/**
62
/**
63
 * Component controller for setting search scope options.
63
 * Component controller for setting search scope options.
Lines 78-83 Link Here
78
    private JCheckBox chkArchives;
78
    private JCheckBox chkArchives;
79
    private JCheckBox chkGenerated;
79
    private JCheckBox chkGenerated;
80
    private ItemListener checkBoxListener;
80
    private ItemListener checkBoxListener;
81
    private JPanel fileNameComponent;
81
82
82
    /**
83
    /**
83
     * Create settings panel that can be used in search dialog.
84
     * Create settings panel that can be used in search dialog.
Lines 89-96 Link Here
89
     */
90
     */
90
    ScopeOptionsController(JPanel component,
91
    ScopeOptionsController(JPanel component,
91
            FileNameController fileNameComboBox, boolean replacing) {
92
            FileNameController fileNameComboBox, boolean replacing) {
92
        super(component);
93
        this(component, null, fileNameComboBox, replacing);
93
        this.fileNameComboBox = fileNameComboBox;
94
    }
95
96
    /**
97
     * Create two settings panels that can be used in search dialog. The first
98
     * panel will contain controls for setting search scope options, the second
99
     * panel controls for setting file name pattern options.
100
     *
101
     * @param scopeComponent Component to adjust for search scope setting.
102
     * @param fileNameComponent Component to adjust for file name settings.
103
     * @param fileNameController File name controller tath will be bound to the
104
     * regular-expression check box in the file name settings panel.
105
     * @param replacing Replace mode flag.
106
     * @since api.search/1.12
107
     */
108
    ScopeOptionsController(JPanel scopeComponent, JPanel fileNameComponent,
109
            FileNameController fileNameController, boolean replacing) {
110
        super(scopeComponent);
111
        this.fileNameComponent = fileNameComponent;
112
        this.fileNameComboBox = fileNameController;
94
        this.replacing = replacing;
113
        this.replacing = replacing;
95
        init();
114
        init();
96
    }
115
    }
Lines 149-172 Link Here
149
     */
168
     */
150
    private void initScopeOptionsRow(boolean searchAndReplace) {
169
    private void initScopeOptionsRow(boolean searchAndReplace) {
151
170
152
        JPanel jp = new JPanel();
171
        JPanel regexpPanel = new CheckBoxWithButtonPanel(
153
        if (searchAndReplace) {
172
                chkFileNameRegex, btnTestFileNamePattern);
154
            jp.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
173
        if (fileNameComponent != null) {
155
            jp.add(ignoreListOptionPanel);
174
            fileNameComponent.setLayout(
156
            jp.add(new CheckBoxWithButtonPanel(
175
                    new FlowLayout(FlowLayout.LEADING, 0, 0));
157
                    chkFileNameRegex, btnTestFileNamePattern));
176
            fileNameComponent.add(ignoreListOptionPanel);
158
            jp.setMaximumSize(jp.getMinimumSize());
177
            fileNameComponent.add(regexpPanel);
178
            if (!searchAndReplace) {
179
                component.add(chkArchives);
180
                component.add(chkGenerated);
181
            }
159
        } else {
182
        } else {
160
            FormLayoutHelper flh = new FormLayoutHelper(jp,
183
            JPanel jp = new JPanel();
161
                    FormLayoutHelper.DEFAULT_COLUMN,
184
            if (searchAndReplace) {
162
                    FormLayoutHelper.DEFAULT_COLUMN);
185
                jp.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
163
            flh.addRow(chkArchives, chkGenerated);
186
                jp.add(ignoreListOptionPanel);
164
            flh.addRow(ignoreListOptionPanel,
187
                jp.add(regexpPanel);
165
                    new CheckBoxWithButtonPanel(
188
                jp.setMaximumSize(jp.getMinimumSize());
166
                    chkFileNameRegex, btnTestFileNamePattern));
189
            } else {
167
            jp.setMaximumSize(jp.getMinimumSize());
190
                FormLayoutHelper flh = new FormLayoutHelper(jp,
191
                        FormLayoutHelper.DEFAULT_COLUMN,
192
                        FormLayoutHelper.DEFAULT_COLUMN);
193
                flh.addRow(chkArchives, chkGenerated);
194
                flh.addRow(ignoreListOptionPanel,
195
                        new CheckBoxWithButtonPanel(
196
                        chkFileNameRegex, btnTestFileNamePattern));
197
                jp.setMaximumSize(jp.getMinimumSize());
198
            }
199
            component.add(jp);
168
        }
200
        }
169
        component.add(jp);
170
    }
201
    }
171
202
172
    private void initInteraction() {
203
    private void initInteraction() {
Lines 340-345 Link Here
340
    }
371
    }
341
372
342
    /**
373
    /**
374
     * Get the panel containing controls related to file name pattern settings.
375
     * This is only applicable if the controller was created using
376
     * {@link ComponentUtils#adjustPanelsForOptions(JPanel, JPanel, boolean, FileNameController)}.
377
     *
378
     * @return Panel containing controls related to file name pattern settings,
379
     * or null if there is a single panel for all settings.
380
     * @since api.search/1.12
381
     */
382
    public @NullUnknown JPanel getFileNameComponent() {
383
        return fileNameComponent;
384
    }
385
386
    /**
343
     * Checkbox listener.
387
     * Checkbox listener.
344
     */
388
     */
345
    private final class CheckBoxListener implements ItemListener {
389
    private final class CheckBoxListener implements ItemListener {
(-)a/api.search/src/org/netbeans/modules/search/BasicSearchForm.java (-3 / +6 lines)
Lines 292-302 Link Here
292
        }
292
        }
293
        formPanel.addSeparator();
293
        formPanel.addSeparator();
294
        formPanel.addRow(lblScope, cboxScope.getComponent());
294
        formPanel.addRow(lblScope, cboxScope.getComponent());
295
        initScopeOptionsRow(searchAndReplace);
295
        formPanel.addSeparator();
296
        formPanel.addSeparator();
296
        formPanel.addRow(lblFileNamePattern,
297
        formPanel.addRow(lblFileNamePattern,
297
                cboxFileNamePattern.getComponent());
298
                cboxFileNamePattern.getComponent());
298
        formPanel.addRow(new JLabel(), lblFileNameHint);
299
        formPanel.addRow(new JLabel(), lblFileNameHint);
299
        initScopeOptionsRow(searchAndReplace);
300
        formPanel.addRow(new JLabel(),
301
                scopeSettingsPanel.getFileNameComponent());
300
        formPanel.addEmptyLine();
302
        formPanel.addEmptyLine();
301
    }
303
    }
302
304
Lines 335-342 Link Here
335
    }
337
    }
336
338
337
    private void initScopeOptionsRow(boolean searchAndReplace) {
339
    private void initScopeOptionsRow(boolean searchAndReplace) {
338
        this.scopeSettingsPanel = ComponentUtils.adjustPanelForOptions(
340
        this.scopeSettingsPanel = ComponentUtils.adjustPanelsForOptions(
339
                new JPanel(), searchAndReplace, cboxFileNamePattern);
341
                new JPanel(), new JPanel(), searchAndReplace,
342
                cboxFileNamePattern);
340
        formPanel.addRow(new JLabel(), scopeSettingsPanel.getComponent());
343
        formPanel.addRow(new JLabel(), scopeSettingsPanel.getComponent());
341
    }
344
    }
342
345

Return to bug 226286