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

(-)a/refactoring.api/apichanges.xml (+21 lines)
Lines 49-54 Link Here
49
    <apidef name="refactoring">Refactoring API</apidef>
49
    <apidef name="refactoring">Refactoring API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="RefactoringResultsFilters">
53
        <api name="refactoring"/>
54
        <summary>Added an API to support filters of the Find Usages results.</summary>
55
        <version major="1" minor="29"/>
56
        <date day="10" month="7" year="2012"/>
57
        <author login="ralphbenjamin"/>
58
        <compatibility addition="yes"/>
59
        <description>
60
            <p>
61
                This API allows refactoring plugins to add/enable filters to the
62
                results window and refactoring elements to specify if they should
63
                be included in the results.
64
            </p>
65
        </description>
66
        <class package="org.netbeans.modules.refactoring.api" name="AbstractRefactoring"/>
67
        <class package="org.netbeans.modules.refactoring.api" name="RefactoringElement"/>
68
        <class package="org.netbeans.modules.refactoring.api" name="RefactoringSession"/>
69
        <class package="org.netbeans.modules.refactoring.spi" name="FiltersManager"/>
70
        <class package="org.netbeans.modules.refactoring.spi.ui" name="FiltersDescription"/>
71
        <issue number="215361"/>
72
    </change>
52
    <change id="FinishSession">
73
    <change id="FinishSession">
53
        <api name="refactoring"/>
74
        <api name="refactoring"/>
54
        <summary>Changed access level of #finish() to public.</summary>
75
        <summary>Changed access level of #finish() to public.</summary>
(-)a/refactoring.api/nbproject/project.properties (-1 / +1 lines)
Lines 4-8 Link Here
4
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.apichanges=${basedir}/apichanges.xml
5
javadoc.title=Refactoring API
5
javadoc.title=Refactoring API
6
6
7
spec.version.base=1.28.0
7
spec.version.base=1.29.0
8
test.config.stableBTD.includes=**/*Test.class
8
test.config.stableBTD.includes=**/*Test.class
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/api/AbstractRefactoring.java (-5 / +28 lines)
Lines 57-80 Link Here
57
import org.netbeans.modules.refactoring.api.impl.APIAccessor;
57
import org.netbeans.modules.refactoring.api.impl.APIAccessor;
58
import org.netbeans.modules.refactoring.api.impl.ProgressSupport;
58
import org.netbeans.modules.refactoring.api.impl.ProgressSupport;
59
import org.netbeans.modules.refactoring.api.impl.SPIAccessor;
59
import org.netbeans.modules.refactoring.api.impl.SPIAccessor;
60
import org.netbeans.modules.refactoring.spi.FiltersManager;
60
import org.netbeans.modules.refactoring.spi.GuardedBlockHandler;
61
import org.netbeans.modules.refactoring.spi.GuardedBlockHandler;
61
import org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory;
62
import org.netbeans.modules.refactoring.spi.GuardedBlockHandlerFactory;
62
import org.netbeans.modules.refactoring.spi.ProgressProvider;
63
import org.netbeans.modules.refactoring.spi.ProgressProvider;
63
import org.netbeans.modules.refactoring.spi.ReadOnlyFilesHandler;
64
import org.netbeans.modules.refactoring.spi.ReadOnlyFilesHandler;
65
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
64
import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
66
import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
65
import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
67
import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
68
import org.netbeans.modules.refactoring.spi.impl.RefactoringPanel;
66
import org.netbeans.modules.refactoring.spi.impl.Util;
69
import org.netbeans.modules.refactoring.spi.impl.Util;
70
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription;
71
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription.Provider;
67
import org.openide.ErrorManager;
72
import org.openide.ErrorManager;
68
import org.openide.filesystems.FileObject;
73
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileUtil;
70
import org.openide.loaders.DataObject;
74
import org.openide.loaders.DataObject;
71
import org.openide.loaders.DataObjectNotFoundException;
75
import org.openide.loaders.DataObjectNotFoundException;
72
import org.openide.modules.ModuleInfo;
76
import org.openide.modules.ModuleInfo;
73
import org.openide.util.Lookup;
74
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
75
import org.netbeans.modules.refactoring.spi.impl.RefactoringPanel;
76
import org.openide.modules.Modules;
77
import org.openide.modules.Modules;
77
import org.openide.util.Exceptions;
78
import org.openide.util.Exceptions;
79
import org.openide.util.Lookup;
78
import org.openide.util.NbBundle;
80
import org.openide.util.NbBundle;
79
import org.openide.util.Parameters;
81
import org.openide.util.Parameters;
80
import org.openide.util.lookup.InstanceContent;
82
import org.openide.util.lookup.InstanceContent;
Lines 116-121 Link Here
116
    private static final int PLUGIN_STEPS = 30;
118
    private static final int PLUGIN_STEPS = 30;
117
    
119
    
118
    private ArrayList plugins;
120
    private ArrayList plugins;
121
    private FiltersDescription filtersDescription;
119
    
122
    
120
    ArrayList pluginsWithProgress;
123
    ArrayList pluginsWithProgress;
121
    
124
    
Lines 136-141 Link Here
136
        if (plugins == null) {
139
        if (plugins == null) {
137
            plugins = new ArrayList();
140
            plugins = new ArrayList();
138
            // get plugins from the lookup
141
            // get plugins from the lookup
142
            filtersDescription = new FiltersDescription();
139
            Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(RefactoringPluginFactory.class));
143
            Lookup.Result result = Lookup.getDefault().lookup(new Lookup.Template(RefactoringPluginFactory.class));
140
            for (Iterator it = result.allInstances().iterator(); it.hasNext();) {
144
            for (Iterator it = result.allInstances().iterator(); it.hasNext();) {
141
                RefactoringPluginFactory factory = (RefactoringPluginFactory) it.next();
145
                RefactoringPluginFactory factory = (RefactoringPluginFactory) it.next();
Lines 155-166 Link Here
155
                        //  SafeDeleteRefactoringPlugin.
159
                        //  SafeDeleteRefactoringPlugin.
156
                        //  #65980
160
                        //  #65980
157
                        plugins.add(plugin);
161
                        plugins.add(plugin);
162
                        if(plugin instanceof FiltersDescription.Provider) {
163
                            FiltersDescription.Provider prov = (FiltersDescription.Provider) plugin;
164
                            prov.addFilters(filtersDescription);
165
                        }
158
                    }
166
                    }
159
                }
167
                }
160
            }
168
            }
161
        }
169
        }
162
        return plugins;
170
        return plugins;
163
    }
171
    }
172
173
    /**
174
     * The FiltersDescription used for this refactoring.
175
     *
176
     * @return the FiltersDescription
177
     * @since 1.29
178
     * @see FiltersManager
179
     */
180
    public @CheckForNull FiltersDescription getFiltersDescription() {
181
        return filtersDescription;
182
    }
164
    
183
    
165
    Collection getGBHandlers() {
184
    Collection getGBHandlers() {
166
        if (gbHandlers == null) {
185
        if (gbHandlers == null) {
Lines 427-434 Link Here
427
            } catch (Throwable t) {
446
            } catch (Throwable t) {
428
                problem =createProblemAndLog(problem, t, plugin.getClass());
447
                problem =createProblemAndLog(problem, t, plugin.getClass());
429
            }
448
            }
430
            if (problem!=null && problem.isFatal())
449
            if (problem!=null && problem.isFatal()) {
431
                return problem;
450
                return problem;
451
            } else if(plugin instanceof FiltersDescription.Provider) {
452
                Provider provider = (Provider) plugin;
453
                provider.enableFilters(filtersDescription);
454
            }
432
        }
455
        }
433
        
456
        
434
        //TODO: 
457
        //TODO: 
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/api/RefactoringElement.java (-2 / +15 lines)
Lines 44-52 Link Here
44
package org.netbeans.modules.refactoring.api;
44
package org.netbeans.modules.refactoring.api;
45
45
46
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.modules.refactoring.spi.FiltersManager;
48
import org.netbeans.modules.refactoring.spi.FiltersManager.Filterable;
47
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
49
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
48
import org.netbeans.modules.refactoring.spi.ui.TreeElement;
50
import org.netbeans.modules.refactoring.spi.ui.TreeElement;
49
import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory;
50
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileObject;
51
import org.openide.text.PositionBounds;
52
import org.openide.text.PositionBounds;
52
import org.openide.util.Lookup;
53
import org.openide.util.Lookup;
Lines 180-184 Link Here
180
        return hash;
181
        return hash;
181
    }
182
    }
182
183
183
184
    /**
185
     * Indicates if this element should be included in the results.
186
     * @param filtersManager the FiltersManager to use
187
     * @return true if this element should be included
188
     * @since 1.29
189
     */
190
    public boolean include(FiltersManager filtersManager) {
191
        if(impl instanceof FiltersManager.Filterable) {
192
            Filterable filterable = (Filterable) impl;
193
            return filterable.filter(filtersManager);
194
        }
195
        return true;
196
    }
184
}
197
}
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/api/RefactoringSession.java (+10 lines)
Lines 255-260 Link Here
255
    }
255
    }
256
    
256
    
257
    /**
257
    /**
258
     * Indicates if this session is finished.
259
     * @return true if this session is finished, false otherwise
260
     * @see #finished()
261
     * @since 1.29
262
     */
263
    public boolean isFinished() {
264
        return finished.get();
265
    }
266
    
267
    /**
258
     *  Adds progress listener to this RefactoringSession
268
     *  Adds progress listener to this RefactoringSession
259
     * @param listener to add
269
     * @param listener to add
260
     */
270
     */
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/spi/FiltersManager.java (+80 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.refactoring.spi;
43
44
import org.netbeans.modules.refactoring.api.RefactoringElement;
45
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription;
46
47
/**
48
 * Handles creation and manipulation with boolean state filters.
49
 *
50
 * @author Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
51
 * @see FiltersDescription
52
 * @since 1.29
53
 */
54
public abstract class FiltersManager {
55
56
    /**
57
     * Indicates if a filter is selected.
58
     *
59
     * @param filterName the name of the filter to check
60
     * @return Returns true when given filter is selected, false otherwise.
61
     */
62
    public abstract boolean isSelected(String filterName);
63
64
    /**
65
     * {@code RefactoringElement}s should implement this interface if they
66
     * should be filterable in the results.
67
     *
68
     * @see RefactoringElement#include
69
     */
70
    public static interface Filterable {
71
72
        /**
73
         * Indicates if this element should be included in the results.
74
         *
75
         * @param manager the FiltersManager to use
76
         * @return true if this element should be included
77
         */
78
        boolean filter(FiltersManager manager);
79
    }
80
}
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/base/FiltersManager.java (-157 / +153 lines)
Lines 41-48 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
package org.netbeans.modules.refactoring.spi.impl;
45
package org.netbeans.modules.java.navigation.base;
46
45
47
import java.awt.Dimension;
46
import java.awt.Dimension;
48
import java.awt.Insets;
47
import java.awt.Insets;
Lines 52-157 Link Here
52
import java.util.HashMap;
51
import java.util.HashMap;
53
import java.util.List;
52
import java.util.List;
54
import java.util.Map;
53
import java.util.Map;
55
import java.util.prefs.Preferences;
56
import javax.swing.BorderFactory;
57
import javax.swing.Box;
58
import javax.swing.BoxLayout;
59
import javax.swing.Icon;
54
import javax.swing.Icon;
60
import javax.swing.JComponent;
61
import javax.swing.JToggleButton;
55
import javax.swing.JToggleButton;
62
import javax.swing.JToolBar;
56
import javax.swing.JToolBar;
63
import javax.swing.SwingUtilities;
57
import javax.swing.SwingUtilities;
64
import javax.swing.border.EmptyBorder;
65
import javax.swing.event.ChangeEvent;
58
import javax.swing.event.ChangeEvent;
66
import org.netbeans.modules.java.navigation.NoBorderToolBar;
59
import org.netbeans.modules.refactoring.spi.FiltersManager;
60
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription;
67
import org.openide.util.Mutex;
61
import org.openide.util.Mutex;
68
import org.openide.util.NbPreferences;
69
62
70
/** Handles creation and manipulation with boolean state filters. 
63
/**
64
 * Handles creation and manipulation with boolean state filters.
71
 *
65
 *
72
 * @author Dafe Simomek
66
 * @author Dafe Simomek
73
 */
67
 */
74
public final class FiltersManager {
68
public final class FiltersManagerImpl extends FiltersManager {
75
    
69
76
    private FiltersComponent comp;
70
    private FiltersComponent comp;
77
    
71
78
    static FiltersManager create (FiltersDescription descr) {
72
    static FiltersManagerImpl create(FiltersDescription descr) {
79
        return new FiltersManager(descr);
73
        return new FiltersManagerImpl(descr);
80
    }
74
    }
81
    
75
82
    /** Returns true when given filter is selected, false otherwise.
76
    /**
83
     * Note that this method is thread safe, can be called from any thread
77
     * Indicates if a filter is selected.
84
     * (and usually will, as clients will call this from loadContent naturally)
78
     *
79
     * @param filterName the name of the filter to check
80
     * @return Returns true when given filter is selected, false otherwise.
85
     */
81
     */
86
    public boolean isSelected (String filterName) {
82
    @Override
83
    public boolean isSelected(String filterName) {
87
        return comp.isSelected(filterName);
84
        return comp.isSelected(filterName);
88
    }
85
    }
89
    
86
90
    /** Sets boolean value of filter with given name. True means filter is
87
    /**
91
     * selected (enabled), false otherwise. Note, must be called from AWT thread.
88
     * Sets boolean value of filter with given name. True means filter is
89
     * selected (enabled), false otherwise. Note, must be called from AWT
90
     * thread.
92
     */
91
     */
93
    public void setSelected (String filterName, boolean value) {
92
    public void setSelected(String filterName, boolean value) {
94
        comp.setFilterSelected(filterName, value);
93
        comp.setFilterSelected(filterName, value);
95
    }
94
    }
96
95
97
    /** @return component instance visually representing filters */ 
96
    /**
98
    public JComponent getComponent ( JToggleButton[] sortButtons ) {
97
     * @return component instance visually representing filters
99
        comp.addSortButtons( sortButtons );
98
     */
100
        return comp;
99
    public JToolBar getComponent(JToggleButton... additionalButtons) {
100
        if(additionalButtons != null && additionalButtons.length > 0) {
101
            comp.addAdditionalButtons(additionalButtons);
102
        }
103
        return comp.toolbar;
101
    }
104
    }
102
    
105
103
    /** @return Filters description */
106
    /**
104
    public FiltersDescription getDescription () {
107
     * @return Filters description
108
     */
109
    public FiltersDescription getDescription() {
105
        return comp.getDescription();
110
        return comp.getDescription();
106
    }
111
    }
107
112
108
    /** Assigns listener for listening to filter changes */ 
113
    /**
109
    public void hookChangeListener (FilterChangeListener l) {
114
     * Assigns listener for listening to filter changes
115
     */
116
    public void hookChangeListener(FilterChangeListener l) {
110
        comp.hookFilterChangeListener(l);
117
        comp.hookFilterChangeListener(l);
111
    }
118
    }
112
    
119
113
    /** Interface for listening to changes of filter states contained in FIltersPanel
120
    /**
121
     * Interface for listening to changes of filter states contained in
122
     * FIltersPanel
114
     */
123
     */
115
    public interface FilterChangeListener {
124
    public interface FilterChangeListener {
116
        /** Called whenever some changes in state of filters contained in
125
117
         * filters panel is triggered
126
        /**
127
         * Called whenever some changes in state of filters contained in filters
128
         * panel is triggered
118
         */
129
         */
119
        public void filterStateChanged(ChangeEvent e);
130
        public void filterStateChanged(ChangeEvent e);
120
        
121
    } // end of FilterChangeListener
131
    } // end of FilterChangeListener
122
    
123
132
124
    /** Private, creation managed by factory method 'create' */
133
    /**
125
    private FiltersManager (FiltersDescription descr) {
134
     * Private, creation managed by factory method 'create'
135
     */
136
    private FiltersManagerImpl(FiltersDescription descr) {
126
        comp = new FiltersComponent(descr);
137
        comp = new FiltersComponent(descr);
127
    }
138
    }
128
    
139
129
    /** Swing component representing filters in panel filled with toggle buttons.
140
    /**
141
     * Swing component representing filters in panel filled with toggle buttons.
130
     * Provides thread safe access to the states of filters by copying states
142
     * Provides thread safe access to the states of filters by copying states
131
     * into private map, properly sync'ed.
143
     * into private map, properly sync'ed.
132
     */
144
     */
133
    private class FiltersComponent extends Box implements ActionListener {
145
    private class FiltersComponent implements ActionListener {
134
        
146
135
        /** list of <JToggleButton> visually representing filters */
147
        /**
148
         * list of <JToggleButton> visually representing filters
149
         */
136
        private List<JToggleButton> toggles;
150
        private List<JToggleButton> toggles;
137
        /** description of filters */
151
        /**
152
         * description of filters
153
         */
138
        private final FiltersDescription filtersDesc;
154
        private final FiltersDescription filtersDesc;
139
 
155
        /**
140
        /** lock for listener */
156
         * lock for listener
141
        private Object L_LOCK = new Object();
157
         */
142
        /** listener */
158
        private final Object L_LOCK = new Object();
159
        /**
160
         * listener
161
         */
143
        private FilterChangeListener clientL;
162
        private FilterChangeListener clientL;
144
163
        /**
145
        /** lock for map of filter states */
164
         * lock for map of filter states
146
        private Object STATES_LOCK = new Object();
165
         */
147
        /** copy of filter states for accessing outside AWT */
166
        private final Object STATES_LOCK = new Object();
148
        private Map<String,Boolean> filterStates;
167
        /**
149
        
168
         * copy of filter states for accessing outside AWT
169
         */
170
        private Map<String, Boolean> filterStates;
150
        private JToolBar toolbar;
171
        private JToolBar toolbar;
151
172
152
        /** Returns selected state of given filter, thread safe.
173
        /**
174
         * Returns selected state of given filter, thread safe.
153
         */
175
         */
154
        public boolean isSelected (String filterName) {
176
        public boolean isSelected(String filterName) {
155
            Boolean result;
177
            Boolean result;
156
            synchronized (STATES_LOCK) {
178
            synchronized (STATES_LOCK) {
157
                if (filterStates == null) {
179
                if (filterStates == null) {
Lines 165-181 Link Here
165
                }
187
                }
166
                result = filterStates.get(filterName);
188
                result = filterStates.get(filterName);
167
            }
189
            }
168
            
190
169
            if (result == null) {
191
            if (result == null) {
170
                throw new IllegalArgumentException("Filter " + filterName + " not found.");
192
                throw new IllegalArgumentException("Filter " + filterName + " not found.");
171
            }
193
            }
172
            return result.booleanValue();
194
            return result.booleanValue();
173
        }
195
        }
174
        
196
175
        /** Sets filter value, AWT only */
197
        /**
176
        public void setFilterSelected (String filterName, boolean value) {
198
         * Sets filter value, AWT only
199
         */
200
        public void setFilterSelected(String filterName, boolean value) {
177
            assert SwingUtilities.isEventDispatchThread();
201
            assert SwingUtilities.isEventDispatchThread();
178
            
202
179
            int index = filterIndexForName(filterName);
203
            int index = filterIndexForName(filterName);
180
            if (index < 0) {
204
            if (index < 0) {
181
                throw new IllegalArgumentException("Filter " + filterName + " not found.");
205
                throw new IllegalArgumentException("Filter " + filterName + " not found.");
Lines 188-299 Link Here
188
            // notify
212
            // notify
189
            fireChange();
213
            fireChange();
190
        }
214
        }
191
        
215
192
        public void hookFilterChangeListener (FilterChangeListener l) {
216
        public void hookFilterChangeListener(FilterChangeListener l) {
193
            synchronized (L_LOCK) {
217
            synchronized (L_LOCK) {
194
                clientL = l;
218
                clientL = l;
195
            }
219
            }
196
        }
220
        }
197
        
221
198
        public FiltersDescription getDescription () {
222
        public FiltersDescription getDescription() {
199
            return filtersDesc;
223
            return filtersDesc;
200
        }
224
        }
201
    
225
202
        /** Not public, instances created using factory method createPanel */
226
        /**
227
         * Not public, instances created using factory method createPanel
228
         */
203
        FiltersComponent(FiltersDescription descr) {
229
        FiltersComponent(FiltersDescription descr) {
204
            super(BoxLayout.X_AXIS);
205
            this.filtersDesc = descr;
230
            this.filtersDesc = descr;
206
            // always create swing content in AWT thread
231
            // always create swing content in AWT thread
207
            Mutex.EVENT.readAccess(new Runnable () {
232
            Mutex.EVENT.readAccess(new Runnable() {
208
                public void run () {
233
                @Override
209
                    initPanel();                        
234
                public void run() {
235
                    initPanel();
210
                }
236
                }
211
            });
237
            });
212
        }
238
        }
213
239
214
        /** Called only from AWT */
240
        /**
215
        private void initPanel () {
241
         * Called only from AWT
216
            setBorder(new EmptyBorder(1, 2, 3, 5));
242
         */
217
243
        private void initPanel() {
218
            // configure toolbar
244
            // configure toolbar
219
            toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
245
            toolbar = new JToolBar(JToolBar.VERTICAL);
220
            toolbar.setFloatable(false);
246
            toolbar.setFloatable(false);
221
            toolbar.setRollover(true);
247
            toolbar.setRollover(true);
222
            toolbar.setBorderPainted(false);
248
            toolbar.setBorderPainted(true);
223
            toolbar.setBorder(BorderFactory.createEmptyBorder());
249
            toolbar.setBorder(
250
                    javax.swing.BorderFactory.createCompoundBorder(
251
                    javax.swing.BorderFactory.createMatteBorder(0, 1, 0, 0,
252
                    javax.swing.UIManager.getDefaults().getColor("Separator.foreground")), //NOI18N
253
                    javax.swing.BorderFactory.createEmptyBorder(0, 1, 0, 0)));
224
            toolbar.setOpaque(false);
254
            toolbar.setOpaque(false);
225
            toolbar.setFocusable(false);
255
            toolbar.setFocusable(false);
226
            // create toggle buttons
256
            // create toggle buttons
227
            int filterCount = filtersDesc.getFilterCount();
257
            int filterCount = filtersDesc.getFilterCount();
228
            toggles = new ArrayList<JToggleButton>(filterCount);
258
            toggles = new ArrayList<JToggleButton>(filterCount);
229
            JToggleButton toggleButton = null;
259
            JToggleButton toggleButton;
230
            
260
231
            Map<String,Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);
261
            Map<String, Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);
232
262
233
            for (int i = 0; i < filterCount; i++) {
263
            for (int i = 0; i < filterCount; i++) {
234
                toggleButton = createToggle(fStates, i);
264
                toggleButton = createToggle(fStates, i);
235
                toggles.add(toggleButton);
265
                toggles.add(toggleButton);
236
            }
266
            }
237
            
267
238
            // add toggle buttons
268
            // add toggle buttons
239
            JToggleButton curToggle;
269
            JToggleButton curToggle;
240
            for (int i = 0; i < toggles.size(); i++) {
270
            for (int i = 0; i < toggles.size(); i++) {
241
                curToggle = toggles.get(i);
271
                curToggle = toggles.get(i);
242
                curToggle.addActionListener(this);
272
                curToggle.addActionListener(this);
243
                toolbar.add(curToggle);
273
                toolbar.add(curToggle);
244
                if (i != toggles.size() - 1) {
245
                    toolbar.add(new Space());
246
                }
247
            }
274
            }
248
            
275
249
            add(toolbar);
250
            
251
            // initialize member states map
276
            // initialize member states map
252
            synchronized (STATES_LOCK) {
277
            synchronized (STATES_LOCK) {
253
                filterStates = fStates;
278
                filterStates = fStates;
254
            }
279
            }
255
        }
280
        }
256
        
281
257
        private void addSortButtons( JToggleButton[] sortButtons ) {
282
        private void addAdditionalButtons(JToggleButton[] sortButtons) {
258
            Dimension space = new Dimension(3, 0);
283
            Dimension space = new Dimension(3, 0);
259
            for( JToggleButton button : sortButtons ) {
284
            for (JToggleButton button : sortButtons) {
260
                Icon icon = button.getIcon();
285
                Dimension size = new Dimension(21, 21); // 3 less than other buttons
261
                Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
286
                button.setMaximumSize(size);
287
                button.setMinimumSize(size);
262
                button.setPreferredSize(size);
288
                button.setPreferredSize(size);
263
                button.setMargin(new Insets(2,3,2,3));
289
//                button.setMargin(new Insets(2, 3, 2, 3));
264
                toolbar.addSeparator(space);
290
                toolbar.addSeparator(space);
265
                toolbar.add( button );
291
                toolbar.add(button);
266
            }
292
            }
267
        }
293
        }
268
        
294
269
        private Preferences getPreferences() {
295
        private JToggleButton createToggle(Map<String, Boolean> fStates, int index) {
270
            return NbPreferences.forModule( FiltersManager.class );
296
            boolean isSelected = filtersDesc.isSelected(index);
271
        }
297
            Icon icon = filtersDesc.getIcon(index);
272
        
273
        private JToggleButton createToggle (Map<String,Boolean> fStates, int index) {
274
            boolean isSelected = getPreferences().getBoolean( filtersDesc.getName(index), filtersDesc.isSelected(index) );
275
            Icon icon = filtersDesc.getSelectedIcon(index);
276
            // ensure small size, just for the icon
298
            // ensure small size, just for the icon
277
            JToggleButton result = new JToggleButton(icon, isSelected);
299
            JToggleButton result = new JToggleButton(icon, isSelected);
278
            Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
300
            Dimension size = new Dimension(21, 21); // 3 less than other buttons
301
            result.setMaximumSize(size);
302
            result.setMinimumSize(size);
279
            result.setPreferredSize(size);
303
            result.setPreferredSize(size);
280
            result.setMargin(new Insets(2,3,2,3));
304
            result.setBorderPainted(false);
305
//            result.setMargin(new Insets(2, 3, 2, 3));
281
            result.setToolTipText(filtersDesc.getTooltip(index));
306
            result.setToolTipText(filtersDesc.getTooltip(index));
282
            result.setFocusable(false);
307
            result.setEnabled(filtersDesc.isEnabled(index));
283
            
308
            fStates.put(filtersDesc.getKey(index), Boolean.valueOf(isSelected));
284
            fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected));
309
285
            
286
            return result;
310
            return result;
287
        }
311
        }
288
312
289
        /** Finds and returns index of filter with given name or -1 if no
313
        /**
290
         * such filter exists.
314
         * Finds and returns index of filter with given name or -1 if no such
315
         * filter exists.
291
         */
316
         */
292
        private int filterIndexForName (String filterName) {
317
        private int filterIndexForName(String filterName) {
293
            int filterCount = filtersDesc.getFilterCount();
318
            int filterCount = filtersDesc.getFilterCount();
294
            String curName;
319
            String curName;
295
            for (int i = 0; i < filterCount; i++) {
320
            for (int i = 0; i < filterCount; i++) {
296
                curName = filtersDesc.getName(i);
321
                curName = filtersDesc.getKey(i);
297
                if (filterName.equals(curName)) {
322
                if (filterName.equals(curName)) {
298
                    return i;
323
                    return i;
299
                }
324
                }
Lines 301-320 Link Here
301
            return -1;
326
            return -1;
302
        }
327
        }
303
328
304
        /** Reactions to toggle button click,  */
329
        /**
330
         * Reactions to toggle button click,
331
         */
332
        @Override
305
        public void actionPerformed(ActionEvent e) {
333
        public void actionPerformed(ActionEvent e) {
306
            // copy changed state first
334
            // copy changed state first
307
            JToggleButton toggle = (JToggleButton)e.getSource();
335
            JToggleButton toggle = (JToggleButton) e.getSource();
308
            int index = toggles.indexOf(e.getSource());
336
            int index = toggles.indexOf(e.getSource());
309
            synchronized (STATES_LOCK) {
337
            synchronized (STATES_LOCK) {
310
                filterStates.put(filtersDesc.getName(index),
338
                filterStates.put(filtersDesc.getKey(index),
311
                                Boolean.valueOf(toggle.isSelected()));
339
                        Boolean.valueOf(toggle.isSelected()));
312
            }
340
            }
313
            // notify
341
            // notify
314
            fireChange();
342
            fireChange();
315
        }
343
        }
316
        
344
317
        private void fireChange () {
345
        private void fireChange() {
318
            FilterChangeListener lCopy;
346
            FilterChangeListener lCopy;
319
            synchronized (L_LOCK) {
347
            synchronized (L_LOCK) {
320
                // no listener = no notification
348
                // no listener = no notification
Lines 323-363 Link Here
323
                }
351
                }
324
                lCopy = clientL;
352
                lCopy = clientL;
325
            }
353
            }
326
            
354
327
            // notify listener
355
            // notify listener
328
            lCopy.filterStateChanged(new ChangeEvent(FiltersManager.this));
356
            lCopy.filterStateChanged(new ChangeEvent(FiltersManagerImpl.this));
329
        }
357
        }
330
331
        @Override
332
        public void removeNotify() {
333
            //remember filter settings
334
            if( null != filterStates ) {
335
                Preferences prefs = getPreferences();
336
                for( String filterName : filterStates.keySet() ) {
337
                    prefs.putBoolean( filterName, filterStates.get( filterName ) );
338
                }
339
            }
340
            super.removeNotify();
341
        }
342
    
343
    } // end of FiltersComponent
358
    } // end of FiltersComponent
344
345
    private static class Space extends JComponent {
346
347
        private static final Dimension SPACE = new Dimension(3, 3);
348
349
        @Override
350
        public Dimension getPreferredSize() {
351
            return getMinimumSize();
352
        }
353
        @Override
354
        public Dimension getMaximumSize() {
355
            return getMinimumSize();
356
        }
357
        @Override
358
        public Dimension getMinimumSize() {
359
            return SPACE;
360
        }
361
    }
362
    
363
}
359
}
(-)a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringPanel.java (-102 / +159 lines)
Lines 57-68 Link Here
57
import java.lang.ref.WeakReference;
57
import java.lang.ref.WeakReference;
58
import java.lang.reflect.InvocationTargetException;
58
import java.lang.reflect.InvocationTargetException;
59
import java.util.*;
59
import java.util.*;
60
import java.util.Collection;
60
import java.util.Map.Entry;
61
import java.util.concurrent.atomic.AtomicBoolean;
61
import java.util.concurrent.atomic.AtomicBoolean;
62
import java.util.Map.Entry;
63
import java.util.prefs.Preferences;
62
import java.util.prefs.Preferences;
64
import javax.swing.*;
63
import javax.swing.*;
65
import javax.swing.border.EmptyBorder;
64
import javax.swing.border.EmptyBorder;
65
import javax.swing.event.ChangeEvent;
66
import javax.swing.text.html.HTMLEditorKit;
66
import javax.swing.text.html.HTMLEditorKit;
67
import javax.swing.text.html.parser.ParserDelegator;
67
import javax.swing.text.html.parser.ParserDelegator;
68
import javax.swing.tree.DefaultTreeModel;
68
import javax.swing.tree.DefaultTreeModel;
Lines 73-78 Link Here
73
import org.netbeans.api.project.*;
73
import org.netbeans.api.project.*;
74
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
74
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
75
import org.netbeans.modules.refactoring.api.*;
75
import org.netbeans.modules.refactoring.api.*;
76
import org.netbeans.modules.refactoring.spi.ui.FiltersDescription;
76
import org.netbeans.modules.refactoring.spi.ui.RefactoringCustomUI;
77
import org.netbeans.modules.refactoring.spi.ui.RefactoringCustomUI;
77
import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
78
import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
78
import org.netbeans.modules.refactoring.spi.ui.TreeElement;
79
import org.netbeans.modules.refactoring.spi.ui.TreeElement;
Lines 85-92 Link Here
85
import org.openide.awt.Mnemonics;
86
import org.openide.awt.Mnemonics;
86
import org.openide.filesystems.FileObject;
87
import org.openide.filesystems.FileObject;
87
import org.openide.loaders.DataObject;
88
import org.openide.loaders.DataObject;
88
import org.openide.text.CloneableEditorSupport;
89
import org.openide.text.PositionBounds;
90
import org.openide.util.*;
89
import org.openide.util.*;
91
import org.openide.windows.TopComponent;
90
import org.openide.windows.TopComponent;
92
91
Lines 95-101 Link Here
95
 *
94
 *
96
 * @author  Pavel Flaska, Martin Matula
95
 * @author  Pavel Flaska, Martin Matula
97
 */
96
 */
98
public class RefactoringPanel extends JPanel {
97
public class RefactoringPanel extends JPanel implements FiltersManagerImpl.FilterChangeListener {
99
    private static final RequestProcessor RP = new RequestProcessor(RefactoringPanel.class.getName(), 1, false, false);
98
    private static final RequestProcessor RP = new RequestProcessor(RefactoringPanel.class.getName(), 1, false, false);
100
    
99
    
101
    // PRIVATE FIELDS
100
    // PRIVATE FIELDS
Lines 105-111 Link Here
105
    private transient JButton refreshButton = null;
104
    private transient JButton refreshButton = null;
106
    /* button lying in the toolbar allows expansion of all nodes in a tree */
105
    /* button lying in the toolbar allows expansion of all nodes in a tree */
107
    private transient JToggleButton expandButton = null;
106
    private transient JToggleButton expandButton = null;
108
    private JToolBar toolBar = null;
109
107
110
    private transient JButton refactorButton = null;
108
    private transient JButton refactorButton = null;
111
    private transient JButton cancelButton = null;
109
    private transient JButton cancelButton = null;
Lines 118-124 Link Here
118
    private transient boolean isVisible = false;
116
    private transient boolean isVisible = false;
119
    private transient RefactoringSession session = null;
117
    private transient RefactoringSession session = null;
120
    private transient ParametersPanel parametersPanel = null;
118
    private transient ParametersPanel parametersPanel = null;
121
    private transient JScrollPane scrollPane = null; 
119
    private transient JScrollPane scrollPane = null;
122
    private transient JPanel southPanel;
120
    private transient JPanel southPanel;
123
    public JSplitPane splitPane;
121
    public JSplitPane splitPane;
124
    private JPanel left;
122
    private JPanel left;
Lines 141-158 Link Here
141
    private Component customComponent;
139
    private Component customComponent;
142
    private AtomicBoolean cancelRequest = new AtomicBoolean();
140
    private AtomicBoolean cancelRequest = new AtomicBoolean();
143
    private int size = 0;
141
    private int size = 0;
144
145
146
    
142
    
147
    static Image PACKAGE_BADGE = ImageUtilities.loadImage( "org/netbeans/spi/java/project/support/ui/packageBadge.gif" ); // NOI18N
143
    static Image PACKAGE_BADGE = ImageUtilities.loadImage( "org/netbeans/spi/java/project/support/ui/packageBadge.gif" ); // NOI18N
144
    private FiltersManagerImpl filtersManager;
145
    private JComponent filterBar;
146
    private JPanel toolbars;
148
    
147
    
149
    public RefactoringPanel(RefactoringUI ui) {
148
    public RefactoringPanel(RefactoringUI ui) {
150
        this(ui,null);
149
        this(ui,null);
151
    }
150
    }
152
    
151
    
153
    public RefactoringPanel(RefactoringUI ui, TopComponent caller) {
152
    public RefactoringPanel(RefactoringUI ui, TopComponent caller) {
154
        if (caller!=null)
153
        if (caller!=null) {
155
            refCallerTC = new WeakReference<TopComponent>(caller);
154
            refCallerTC = new WeakReference<TopComponent>(caller);
155
        }
156
        this.ui = ui;
156
        this.ui = ui;
157
        this.isQuery = ui.isQuery();
157
        this.isQuery = ui.isQuery();
158
        if (isQuery) {
158
        if (isQuery) {
Lines 170-175 Link Here
170
            ui.getRefactoring().addProgressListener(fuListener = new FUListener());
170
            ui.getRefactoring().addProgressListener(fuListener = new FUListener());
171
        }
171
        }
172
        initialize();
172
        initialize();
173
        updateFilters();
173
        refresh(false);
174
        refresh(false);
174
    }
175
    }
175
    
176
    
Lines 181-188 Link Here
181
    
182
    
182
    /* initializes all the ui */
183
    /* initializes all the ui */
183
    private void initialize() {
184
    private void initialize() {
184
        if (inited)
185
        if (inited) {
185
            return ;
186
            return ;
187
        }
186
        checkEventThread();
188
        checkEventThread();
187
        setFocusCycleRoot(true);
189
        setFocusCycleRoot(true);
188
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
190
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
Lines 197-232 Link Here
197
        splitPane.setBorder(null);
199
        splitPane.setBorder(null);
198
        // add panel with buttons
200
        // add panel with buttons
199
        JButton[] buttons = getButtons();
201
        JButton[] buttons = getButtons();
200
        //if (buttons.length != 0) {
202
        // there will be at least one button on panel
201
            // there will be at least one button on panel
203
        southPanel = new JPanel(new GridBagLayout());
202
            southPanel = new JPanel(new GridBagLayout());
204
        for (int i = 0; i < buttons.length; i++) {
203
            for (int i = 0; i < buttons.length; i++) {
204
                GridBagConstraints c = new GridBagConstraints();
205
                c.gridy = 0;
206
                c.insets = new Insets(5, 5, 5, 0);
207
                southPanel.add(buttons[i], c);
208
            }
209
            JPanel pp = new JPanel(new BorderLayout());
210
            GridBagConstraints c = new GridBagConstraints();
205
            GridBagConstraints c = new GridBagConstraints();
211
            c.gridy = 0;
206
            c.gridy = 0;
212
            c.insets = new Insets(5, 5, 5, 5);
207
            c.insets = new Insets(5, 5, 5, 0);
213
            c.weightx = 1;
208
            southPanel.add(buttons[i], c);
214
            c.fill = GridBagConstraints.HORIZONTAL;
209
        }
215
            southPanel.add(pp, c);
210
        JPanel pp = new JPanel(new BorderLayout());
216
            
211
        GridBagConstraints c = new GridBagConstraints();
217
            if (!isQuery|| callback != null) {
212
        c.gridy = 0;
218
                left.add(southPanel, BorderLayout.SOUTH);
213
        c.insets = new Insets(5, 5, 5, 5);
219
            }
214
        c.weightx = 1;
220
        //}
215
        c.fill = GridBagConstraints.HORIZONTAL;
216
        southPanel.add(pp, c);
217
218
        if (!isQuery|| callback != null) {
219
            left.add(southPanel, BorderLayout.SOUTH);
220
        }
221
        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
222
            southPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
223
        }
221
        // put the toolbar to the panel. If the getToolBar() returns null,
224
        // put the toolbar to the panel. If the getToolBar() returns null,
222
        // suppose the toolbar does not exist.
225
        // suppose the toolbar does not exist.
223
        JToolBar toolBar = getToolBar();
226
        JToolBar toolbar = getToolBar();
224
        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
227
        if (toolbar != null) {
225
            toolBar.setBackground(UIManager.getColor("NbExplorerView.background"));
228
            if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
226
            southPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
229
                toolbar.setBackground(UIManager.getColor("NbExplorerView.background"));
230
            }
231
            toolbars = new JPanel(new BorderLayout());
232
            toolbars.add(toolbar, BorderLayout.WEST);
233
            left.add(toolbars, BorderLayout.WEST);
227
        }
234
        }
228
        if (toolBar != null)
229
            left.add(toolBar, BorderLayout.WEST);
230
        validate();
235
        validate();
231
        inited=true;
236
        inited=true;
232
    }
237
    }
Lines 267-275 Link Here
267
        );
272
        );
268
        expandButton.setBorderPainted(false);
273
        expandButton.setBorderPainted(false);
269
        expandButton.addActionListener(getButtonListener());
274
        expandButton.addActionListener(getButtonListener());
270
        // create toolbar
271
        toolBar = new JToolBar(JToolBar.VERTICAL);
272
        toolBar.setFloatable(false); 
273
        
275
        
274
        logicalViewButton = new JToggleButton(
276
        logicalViewButton = new JToggleButton(
275
            ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/logical_view.png", false));
277
            ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/logical_view.png", false));
Lines 360-378 Link Here
360
        stopButton.setBorderPainted(false);
362
        stopButton.setBorderPainted(false);
361
        stopButton.addActionListener(getButtonListener());
363
        stopButton.addActionListener(getButtonListener());
362
        
364
        
363
        
365
        // create toolbar
364
        toolBar.add(refreshButton);
366
        JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);
365
        toolBar.add(prevMatch);
367
        toolbar.setFloatable(false);
366
        toolBar.add(nextMatch);
368
367
        toolBar.add(logicalViewButton);
369
        toolbar.add(refreshButton);
368
        toolBar.add(physicalViewButton);
370
        toolbar.add(stopButton);
369
        toolBar.add(expandButton);
371
        toolbar.add(prevMatch);
372
        toolbar.add(nextMatch);
373
        toolbar.add(logicalViewButton);
374
        toolbar.add(physicalViewButton);
375
        toolbar.add(expandButton);
370
        if (ui instanceof RefactoringCustomUI) {
376
        if (ui instanceof RefactoringCustomUI) {
371
            toolBar.add(customViewButton);
377
            toolbar.add(customViewButton);
372
        }
378
        }
373
        toolBar.add(stopButton);
379
        return toolbar;
374
        
375
        return toolBar;
376
    }
380
    }
377
    
381
    
378
    /**
382
    /**
Lines 381-387 Link Here
381
     * if you want to provide any other buttons with different action to be 
385
     * if you want to provide any other buttons with different action to be 
382
     * performed.
386
     * performed.
383
     *
387
     *
384
     * @return  array of avasilable buttons.
388
     * @return  array of available buttons.
385
     */
389
     */
386
    private JButton[] getButtons() {
390
    private JButton[] getButtons() {
387
        checkEventThread();
391
        checkEventThread();
Lines 416-423 Link Here
416
420
417
    void switchToLogicalView() {
421
    void switchToLogicalView() {
418
        logicalViewButton.setSelected(true);
422
        logicalViewButton.setSelected(true);
419
        if (currentView == LOGICAL)
423
        if (currentView == LOGICAL) {
420
            return ;
424
            return ;
425
        }
421
        currentView = LOGICAL;
426
        currentView = LOGICAL;
422
        physicalViewButton.setSelected(false);
427
        physicalViewButton.setSelected(false);
423
        if (customViewButton!=null) {
428
        if (customViewButton!=null) {
Lines 432-439 Link Here
432
    
437
    
433
    void switchToPhysicalView() {
438
    void switchToPhysicalView() {
434
        physicalViewButton.setSelected(true);
439
        physicalViewButton.setSelected(true);
435
        if (currentView == PHYSICAL)
440
        if (currentView == PHYSICAL) {
436
            return ;
441
            return ;
442
        }
437
        currentView = PHYSICAL;
443
        currentView = PHYSICAL;
438
        logicalViewButton.setSelected(false);
444
        logicalViewButton.setSelected(false);
439
        if (customViewButton!=null) {
445
        if (customViewButton!=null) {
Lines 448-455 Link Here
448
454
449
    void switchToCustomView() {
455
    void switchToCustomView() {
450
        customViewButton.setSelected(true);
456
        customViewButton.setSelected(true);
451
        if (currentView == GRAPHICAL)
457
        if (currentView == GRAPHICAL) {
452
            return ;
458
            return ;
459
        }
453
        currentView = GRAPHICAL;
460
        currentView = GRAPHICAL;
454
        logicalViewButton.setSelected(false);
461
        logicalViewButton.setSelected(false);
455
        physicalViewButton.setSelected(false);
462
        physicalViewButton.setSelected(false);
Lines 512-527 Link Here
512
        return node;
519
        return node;
513
    }
520
    }
514
    
521
    
515
    private static final String getString(String key) {
516
        return NbBundle.getMessage(RefactoringPanel.class, key);
517
    }
518
    
519
    /**
520
     * Overrides default ExplorerPanel behaviour. Does nothing now.
521
     */
522
    protected void updateTitle() {
523
    }
524
    
525
    /**
522
    /**
526
     * Method is responsible for making changes in sources.
523
     * Method is responsible for making changes in sources.
527
     */
524
     */
Lines 590-597 Link Here
590
     * This is the reason of lazy initialization.
587
     * This is the reason of lazy initialization.
591
     */
588
     */
592
    private ButtonL getButtonListener() {
589
    private ButtonL getButtonListener() {
593
        if (buttonListener == null)
590
        if (buttonListener == null) {
594
            buttonListener = new ButtonL();
591
            buttonListener = new ButtonL();
592
        }
595
        
593
        
596
        return buttonListener;
594
        return buttonListener;
597
    }
595
    }
Lines 698-714 Link Here
698
        final RefactoringPanelContainer cont = isQuery ? RefactoringPanelContainer.getUsagesComponent() : RefactoringPanelContainer.getRefactoringComponent();
696
        final RefactoringPanelContainer cont = isQuery ? RefactoringPanelContainer.getUsagesComponent() : RefactoringPanelContainer.getRefactoringComponent();
699
        cont.makeBusy(true);
697
        cont.makeBusy(true);
700
        initialize();
698
        initialize();
699
        if(showParametersPanel) {
700
            updateFilters();
701
        }
701
702
702
        cancelRequest.set(false);
703
        cancelRequest.set(false);
703
        stopButton.setVisible(isQuery);
704
        stopButton.setVisible(isQuery && showParametersPanel);
705
        refreshButton.setVisible(!isQuery || !showParametersPanel);
704
        stopButton.setEnabled(showParametersPanel);
706
        stopButton.setEnabled(showParametersPanel);
705
        final String description = ui.getDescription();
707
        final String description = ui.getDescription();
706
        setToolTipText("<html>" + description + "</html>"); // NOI18N
708
        setToolTipText("<html>" + description + "</html>"); // NOI18N
707
        final Collection<RefactoringElement> elements = session.getRefactoringElements();
709
        final Collection<RefactoringElement> elements = session.getRefactoringElements();
708
        setName(ui.getName());
710
        setName(ui.getName());
709
        if (ui instanceof RefactoringCustomUI) {
711
        if (ui instanceof RefactoringCustomUI) {
710
            if (customComponent==null)
712
            if (customComponent==null) {
711
                customComponent = ((RefactoringCustomUI) ui).getCustomComponent(elements);
713
                customComponent = ((RefactoringCustomUI) ui).getCustomComponent(elements);
714
            }
712
            this.left.remove(customComponent);
715
            this.left.remove(customComponent);
713
        }
716
        }
714
        final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(RefactoringPanel.class, isQuery ? "LBL_PreparingUsagesTree":"LBL_PreparingRefactoringTree"));
717
        final ProgressHandle progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(RefactoringPanel.class, isQuery ? "LBL_PreparingUsagesTree":"LBL_PreparingRefactoringTree"));
Lines 726-732 Link Here
726
            RP.post(new Runnable() {
729
            RP.post(new Runnable() {
727
                @Override
730
                @Override
728
                public void run() {
731
                public void run() {
729
                    setTreeControlsEnabled(false);
732
                    SwingUtilities.invokeLater(new Runnable() {
733
                        @Override
734
                        public void run() {
735
                            setTreeControlsEnabled(false);
736
                        }
737
                    });
730
                    Set<FileObject> fileObjects = new HashSet<FileObject>();
738
                    Set<FileObject> fileObjects = new HashSet<FileObject>();
731
                    int errorsNum = 0;
739
                    int errorsNum = 0;
732
                    if (!isQuery) {
740
                    if (!isQuery) {
Lines 737-743 Link Here
737
                            }
745
                            }
738
                        }
746
                        }
739
                    }
747
                    }
740
                    StringBuffer errorsDesc = getErrorDesc(errorsNum, isQuery?size:elements.size());
748
                    StringBuffer errorsDesc = getErrorDesc(errorsNum, isQuery?size:elements.size(), 0);
741
                    final CheckNode root = new CheckNode(ui, description + errorsDesc.toString() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/" + (isQuery ? "findusages.png" : "refactoring.gif"), false), isQuery);
749
                    final CheckNode root = new CheckNode(ui, description + errorsDesc.toString() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/api/resources/" + (isQuery ? "findusages.png" : "refactoring.gif"), false), isQuery);
742
                    final Map<Object, CheckNode> nodes = new HashMap<Object, CheckNode>();
750
                    final Map<Object, CheckNode> nodes = new HashMap<Object, CheckNode>();
743
                    
751
                    
Lines 754-767 Link Here
754
                    }
762
                    }
755
763
756
                    int i=0;
764
                    int i=0;
765
                    int hidden = 0;
757
                    try {
766
                    try {
758
                        //[retouche]                    JavaModel.getJavaRepository().beginTrans(false);
767
                        //[retouche]                    JavaModel.getJavaRepository().beginTrans(false);
759
                        try {
768
                        try {
760
                            // ui.getRefactoring().setClassPath();
769
                            // ui.getRefactoring().setClassPath();
761
                            for (Iterator it = elements.iterator(); it.hasNext();i++) {
770
                            for (Iterator it = elements.iterator(); it.hasNext();i++) {
762
                                final RefactoringElement e = (RefactoringElement) it.next();
771
                                final RefactoringElement e = (RefactoringElement) it.next();
763
                                createNode(TreeElementFactory.getTreeElement(e), nodes, root);
772
                                if(e.include(filtersManager)) {
764
                                
773
                                    createNode(TreeElementFactory.getTreeElement(e), nodes, root);
774
                                } else {
775
                                    hidden++;
776
                                }
765
                                if (isQuery && showParametersPanel) {
777
                                if (isQuery && showParametersPanel) {
766
                                    if (cancelRequest.get()) {
778
                                    if (cancelRequest.get()) {
767
                                        break;
779
                                        break;
Lines 769-781 Link Here
769
781
770
                                    final boolean last = !it.hasNext();
782
                                    final boolean last = !it.hasNext();
771
                                    final int occurrences = i + 1;
783
                                    final int occurrences = i + 1;
784
                                    final int hiddenOccurrences = hidden;
772
                                    size = occurrences;
785
                                    size = occurrences;
773
                                    if (occurrences % 10 == 0 || last) {
786
                                    if ((occurrences % 10 == 0 && !session.isFinished()) || last) {
774
                                        SwingUtilities.invokeLater(new Runnable() {
787
                                        SwingUtilities.invokeLater(new Runnable() {
775
788
776
                                            @Override
789
                                            @Override
777
                                            public void run() {
790
                                            public void run() {
778
                                                root.setNodeLabel(description + getErrorDesc(0, occurrences));
791
                                                root.setNodeLabel(description + getErrorDesc(0, occurrences, hiddenOccurrences));
779
                                                if (last) {
792
                                                if (last) {
780
                                                    tree.repaint();
793
                                                    tree.repaint();
781
                                                }
794
                                                }
Lines 783-789 Link Here
783
                                        });
796
                                        });
784
                                    }
797
                                    }
785
                                }
798
                                }
786
                                PositionBounds pb = e.getPosition();
799
//                                PositionBounds pb = e.getPosition();
787
                                fileObjects.add(e.getParentFile());
800
                                fileObjects.add(e.getParentFile());
788
                                
801
                                
789
                                if (!isQuery) {
802
                                if (!isQuery) {
Lines 807-828 Link Here
807
                    } finally {
820
                    } finally {
808
                        progressHandle.finish();
821
                        progressHandle.finish();
809
                        cont.makeBusy(false);
822
                        cont.makeBusy(false);
810
                        setTreeControlsEnabled(true);
811
                        SwingUtilities.invokeLater(new Runnable() {
823
                        SwingUtilities.invokeLater(new Runnable() {
812
                            @Override
824
                            @Override
813
                            public void run() {
825
                            public void run() {
826
                                setTreeControlsEnabled(true);
814
                                stopButton.setEnabled(false);
827
                                stopButton.setEnabled(false);
828
                                stopButton.setVisible(false);
829
                                refreshButton.setVisible(true);
830
                                if(showParametersPanel) {
831
                                    updateFilters();
832
                                }
815
                            }
833
                            }
816
                        });
834
                        });
817
                    }
835
                    }
818
                    
836
                    
819
                    if (!(isQuery && showParametersPanel)) {
837
                    if (!(isQuery && showParametersPanel)) {
838
                        root.setNodeLabel(description + getErrorDesc(errorsNum, isQuery?size:elements.size(), hidden).toString());
820
                        setupTree(root, showParametersPanel, elements.size());
839
                        setupTree(root, showParametersPanel, elements.size());
821
                    }
840
                    }
822
                    
841
                    
823
                }
842
                }
824
843
825
                private StringBuffer getErrorDesc(int errorsNum, int occurencesNum) throws MissingResourceException {
844
                private StringBuffer getErrorDesc(int errorsNum, int occurencesNum, int hiddenNum) throws MissingResourceException {
826
                    StringBuffer errorsDesc = new StringBuffer();
845
                    StringBuffer errorsDesc = new StringBuffer();
827
                    errorsDesc.append(" [").append(occurencesNum); // NOI18N
846
                    errorsDesc.append(" [").append(occurencesNum); // NOI18N
828
                    errorsDesc.append(' ');
847
                    errorsDesc.append(' ');
Lines 841-846 Link Here
841
                            );
860
                            );
842
                        errorsDesc.append("</font>"); // NOI18N
861
                        errorsDesc.append("</font>"); // NOI18N
843
                    }
862
                    }
863
                    if (hiddenNum > 0) {
864
                        errorsDesc.append(',');
865
                        errorsDesc.append(' ');
866
                        errorsDesc.append("<font color=#CC0000>").append(hiddenNum); // NOI18N
867
                        errorsDesc.append(' ');
868
                        errorsDesc.append(NbBundle.getMessage(RefactoringPanel.class, "LBL_Hidden"));
869
                        errorsDesc.append("</font>"); // NOI18N
870
                    }
844
                    errorsDesc.append(']');
871
                    errorsDesc.append(']');
845
                    return errorsDesc;
872
                    return errorsDesc;
846
                }
873
                }
Lines 857-878 Link Here
857
            cont.addPanel(this);
884
            cont.addPanel(this);
858
            isVisible = true;
885
            isVisible = true;
859
        }
886
        }
860
        if (!isQuery)
887
        if (!isQuery) {
861
            setRefactoringEnabled(false, true);
888
            setRefactoringEnabled(false, true);
889
        }
862
    }
890
    }
863
    
891
    
864
    private void setTreeControlsEnabled(final boolean b) {
892
    private void setTreeControlsEnabled(final boolean b) {
865
        SwingUtilities.invokeLater(new Runnable() {
893
        expandButton.setEnabled(b);
866
894
        logicalViewButton.setEnabled(b);
867
            @Override
895
        physicalViewButton.setEnabled(b);
868
            public void run() {
896
        if (customViewButton != null) {
869
                expandButton.setEnabled(b);
897
            customViewButton.setEnabled(b);
870
                logicalViewButton.setEnabled(b);
898
        }
871
                physicalViewButton.setEnabled(b);
872
                if (customViewButton != null)
873
                    customViewButton.setEnabled(b);
874
            }
875
        });
876
    }
899
    }
877
    
900
    
878
    
901
    
Lines 923-943 Link Here
923
         }
946
         }
924
     }
947
     }
925
     
948
     
926
     /**
949
    /**
927
      * @return true if timestamps are OK
950
     * @return true if timestamps are OK
928
      */
951
     */
929
     private boolean checkTimeStamps() {
952
    private boolean checkTimeStamps() {
930
         Set<FileObject> modified = getModifiedFileObjects();
953
        Set<FileObject> modified = getModifiedFileObjects();
931
         for (Entry<FileObject, Long> entry: timeStamps.entrySet()) {
954
         for (Entry<FileObject, Long> entry: timeStamps.entrySet()) {
932
             if (modified.contains(entry.getKey()))
955
             if (modified.contains(entry.getKey()))
933
                 return false;
956
                return false;
934
             if (!entry.getKey().isValid())
957
             if (!entry.getKey().isValid())
935
                 return false;
958
                 return false;
936
             if (entry.getKey().lastModified().getTime() != entry.getValue())
959
             if (entry.getKey().lastModified().getTime() != entry.getValue())
937
                 return false;
960
                 return false;
938
         }
961
            }
939
         return true;
962
        return true;
940
     }
963
    }
941
     
964
     
942
     private Set<FileObject> getModifiedFileObjects() {
965
     private Set<FileObject> getModifiedFileObjects() {
943
         Set<FileObject> result = new HashSet();
966
         Set<FileObject> result = new HashSet();
Lines 997-1004 Link Here
997
        if (refactorButton != null) {
1020
        if (refactorButton != null) {
998
            refactorButton.requestFocus();
1021
            refactorButton.requestFocus();
999
        } else {
1022
        } else {
1000
            if (tree!=null)
1023
            if (tree!=null) {
1001
                tree.requestFocus();
1024
                tree.requestFocus();
1025
            }
1002
        }
1026
        }
1003
    }
1027
    }
1004
    
1028
    
Lines 1046-1058 Link Here
1046
    
1070
    
1047
    private int location;
1071
    private int location;
1048
    public void storeDividerLocation() {
1072
    public void storeDividerLocation() {
1049
        if (splitPane.getRightComponent()!=null)
1073
        if (splitPane.getRightComponent()!=null) {
1050
            location = splitPane.getDividerLocation();
1074
            location = splitPane.getDividerLocation();
1075
        }
1051
    }
1076
    }
1052
    
1077
    
1053
    public void restoreDeviderLocation() {
1078
    public void restoreDeviderLocation() {
1054
        if (splitPane.getRightComponent()!=null)
1079
        if (splitPane.getRightComponent()!=null) {
1055
            splitPane.setDividerLocation(location);
1080
            splitPane.setDividerLocation(location);
1081
        }
1056
    }
1082
    }
1057
1083
1058
    private byte getPrefViewType() {
1084
    private byte getPrefViewType() {
Lines 1066-1071 Link Here
1066
        prefs.putInt(PREF_VIEW_TYPE, currentView);
1092
        prefs.putInt(PREF_VIEW_TYPE, currentView);
1067
    }
1093
    }
1068
1094
1095
    private void updateFilters() {
1096
        if(!ui.isQuery()) {
1097
            if(filterBar != null) {
1098
                toolbars.remove(filterBar);
1099
                filterBar = null;
1100
                filtersManager = null;
1101
            }
1102
            return;
1103
        }
1104
1105
        if(filtersManager != null) {
1106
            toolbars.remove(filterBar);
1107
            filterBar = null;
1108
            filtersManager = null;
1109
        }
1110
        final FiltersDescription desc = ui.getRefactoring().getFiltersDescription();
1111
        filtersManager = FiltersManagerImpl.create(desc == null? new FiltersDescription() : desc);
1112
        filterBar = filtersManager.getComponent();
1113
        toolbars.add(filterBar, BorderLayout.EAST);
1114
        filtersManager.hookChangeListener(this);
1115
        toolbars.validate();
1116
    }
1117
1118
    @Override
1119
    public void filterStateChanged(ChangeEvent e) {
1120
        refresh(false);
1121
    }
1122
1069
    ////////////////////////////////////////////////////////////////////////////
1123
    ////////////////////////////////////////////////////////////////////////////
1070
    // INNER CLASSES
1124
    // INNER CLASSES
1071
    ////////////////////////////////////////////////////////////////////////////
1125
    ////////////////////////////////////////////////////////////////////////////
Lines 1085-1094 Link Here
1085
            }
1139
            }
1086
            // expandAll button selected/deselected
1140
            // expandAll button selected/deselected
1087
            else if (o == expandButton && tree != null) {
1141
            else if (o == expandButton && tree != null) {
1088
                if (expandButton.isSelected())
1142
                if (expandButton.isSelected()) {
1089
                    expandAll();
1143
                    expandAll();
1090
                else
1144
                } else {
1091
                    collapseAll();
1145
                    collapseAll();
1146
                }
1092
            } else if (o == refreshButton) {
1147
            } else if (o == refreshButton) {
1093
                if (callback!=null) {
1148
                if (callback!=null) {
1094
                    close();
1149
                    close();
Lines 1116-1121 Link Here
1116
1171
1117
    private void stopSearch() {
1172
    private void stopSearch() {
1118
        stopButton.setEnabled(false);
1173
        stopButton.setEnabled(false);
1174
        stopButton.setVisible(false);
1175
        refreshButton.setVisible(true);
1119
        cancelRequest.set(true);
1176
        cancelRequest.set(true);
1120
        ui.getRefactoring().cancelRequest();
1177
        ui.getRefactoring().cancelRequest();
1121
    }
1178
    }
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/base/FiltersDescription.java (-51 / +154 lines)
Lines 41-123 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
package org.netbeans.modules.refactoring.spi.ui;
45
package org.netbeans.modules.java.navigation.base;
46
45
47
import java.util.ArrayList;
46
import java.util.ArrayList;
48
import java.util.List;
47
import java.util.List;
49
import javax.swing.Icon;
48
import javax.swing.Icon;
49
import org.netbeans.api.annotations.common.NonNull;
50
50
51
/**
51
/**
52
 * @author Dafe Simonek
52
 * @author Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
53
 * @since 1.29
53
 */
54
 */
54
public final class FiltersDescription {
55
public final class FiltersDescription {
55
56
56
    public static FiltersManager createManager (FiltersDescription descr) {
57
    /**
57
        return FiltersManager.create(descr);
58
     * List of {@code FilterItem}s describing filters properties
58
    }
59
     */
59
60
    /** List of <FilterItem> describing filters properties */
61
    private List<FilterItem> filters;
60
    private List<FilterItem> filters;
62
61
63
    /** Creates a new instance of FiltersDescription */
62
    /**
63
     * Creates a new instance of FiltersDescription
64
     */
64
    public FiltersDescription() {
65
    public FiltersDescription() {
65
        filters = new ArrayList<FilterItem>();
66
        filters = new ArrayList<FilterItem>();
66
    }
67
    }
67
    
68
68
    public void addFilter (String name, String displayName, String tooltip,
69
    /**
69
            boolean isSelected, Icon selectedIcon, Icon unselectedIcon) {
70
     * Add a new filter to the FiltersDescription. Filters are by default
70
        FilterItem newItem = new FilterItem(name, displayName, tooltip, 
71
     * disabled. {@code FiltersDescription.Provider}s should enable them when
71
                isSelected, selectedIcon, unselectedIcon);
72
     * used.
73
     *
74
     * @param key identifier for the filter
75
     * @param tooltip text to display in the tooltip of the filter button
76
     * @param selected true if the filter should be selected
77
     * @param icon icon to use for the filter button
78
     */
79
    public void addFilter(@NonNull String key, @NonNull String tooltip,
80
            boolean selected, @NonNull Icon icon) {
81
        FilterItem newItem = new FilterItem(key, tooltip, selected, icon);
72
        filters.add(newItem);
82
        filters.add(newItem);
73
    }
83
    }
74
    
84
75
    public int getFilterCount () {
85
    /**
86
     * Returns the number of filters in this description.
87
     *
88
     * @return the number of filters in this description
89
     */
90
    public int getFilterCount() {
76
        return filters.size();
91
        return filters.size();
77
    }
92
    }
78
    
93
79
    public String getName (int index) {
94
    /**
80
        return filters.get(index).name;
95
     * Returns the key of the filter at the supplied index.
96
     *
97
     * @param index the index of the filter
98
     * @return the key
99
     * @throws IndexOutOfBoundsException if the index is out of range
100
     * ({@code index < 0 || index >= size()})
101
     */
102
    public @NonNull
103
    String getKey(int index) {
104
        return filters.get(index).key;
81
    }
105
    }
82
    
106
83
    public String getDisplayName (int index) {
107
    /**
84
        return filters.get(index).displayName;
108
     * Returns the tooltip of the filter at the supplied index.
85
    }
109
     *
86
    
110
     * @param index the index of the filter
87
    public String getTooltip (int index) {
111
     * @return the tooltip
112
     * @throws IndexOutOfBoundsException if the index is out of range
113
     * ({@code index < 0 || index >= size()})
114
     */
115
    public @NonNull
116
    String getTooltip(int index) {
88
        return filters.get(index).tooltip;
117
        return filters.get(index).tooltip;
89
    }
118
    }
90
    
119
91
    public Icon getSelectedIcon (int index) {
120
    /**
92
        return filters.get(index).selectedIcon;
121
     * Returns the icon of the filter at the supplied index.
122
     *
123
     * @param index the index of the filter
124
     * @return the icon
125
     * @throws IndexOutOfBoundsException if the index is out of range
126
     * ({@code index < 0 || index >= size()})
127
     */
128
    public @NonNull
129
    Icon getIcon(int index) {
130
        return filters.get(index).icon;
93
    }
131
    }
94
    
132
95
    public Icon getUnselectedIcon (int index) {
133
    /**
96
        return filters.get(index).unselectedIcon;
134
     * Returns true if the filter at the supplied index is selected.
135
     *
136
     * @param index the index of the filter
137
     * @return true if the filter is selected.
138
     * @throws IndexOutOfBoundsException if the index is out of range
139
     * ({@code index < 0 || index >= size()})
140
     */
141
    public boolean isSelected(int index) {
142
        return filters.get(index).selected;
97
    }
143
    }
98
    
144
99
    public boolean isSelected (int index) {
145
    /**
100
        return filters.get(index).isSelected;
146
     * Enable the filter at the supplied index.
147
     *
148
     * @param index the index of the filter
149
     * @throws IndexOutOfBoundsException if the index is out of range
150
     * ({@code index < 0 || index >= size()})
151
     */
152
    public void enable(int index) {
153
        filters.get(index).enabled = true;
101
    }
154
    }
102
    
155
103
    static class FilterItem {
156
    /**
104
        String name;
157
     * Enable the filter with the supplied key. If there is no filter with the
105
        String displayName;
158
     * supplied key, nothing will change.
159
     *
160
     * @param key the key of a filter
161
     */
162
    public void enable(@NonNull String key) {
163
        for (FilterItem filterItem : filters) {
164
            if (filterItem.key.contentEquals(key)) {
165
                filterItem.enabled = true;
166
                break;
167
            }
168
        }
169
    }
170
171
    /**
172
     * Returns true if the filter at the supplied index is enabled.
173
     *
174
     * @param index the index of the filter
175
     * @return true if the filter is enabled.
176
     * @throws IndexOutOfBoundsException if the index is out of range
177
     * ({@code index < 0 || index >= size()})
178
     */
179
    public boolean isEnabled(int index) {
180
        return filters.get(index).enabled;
181
    }
182
183
    private static class FilterItem {
184
185
        String key;
106
        String tooltip;
186
        String tooltip;
107
        Icon selectedIcon;
187
        Icon icon;
108
        Icon unselectedIcon;
188
        boolean selected;
109
        boolean isSelected;
189
        boolean enabled;
110
        
190
111
        FilterItem (String name, String displayName, String tooltip,
191
        FilterItem(String key, String tooltip,
112
                boolean isSelected, Icon selectedIcon, Icon unselectedIcon) {
192
                boolean selected, Icon icon) {
113
            this.name = name;
193
            this.key = key;
114
            this.displayName = displayName;
115
            this.tooltip = tooltip;
194
            this.tooltip = tooltip;
116
            this.selectedIcon = selectedIcon;
195
            this.icon = icon;
117
            this.unselectedIcon = unselectedIcon;
196
            this.selected = selected;
118
            this.isSelected = isSelected;
197
            this.enabled = false;
119
        }
198
        }
120
        
121
    }
199
    }
122
    
200
201
    /**
202
     * {@code RefactoringPlugin}s can implement this interface if they want to
203
     * supply new filters, or enable existing filters.
204
     */
205
    public static interface Provider {
206
207
        /**
208
         * Add filters to the supplied {@code FiltersDescription}. This method
209
         * will be called after the plugin is received from the
210
         * {@code RefactoringPluginFactory}.
211
         *
212
         * @param filtersDescription the {@code FiltersDescription} to add filters to
213
         * @see FiltersDescription#addFilter
214
         */
215
        void addFilters(FiltersDescription filtersDescription);
216
217
        /**
218
         * Enable filters in the supplied {@code FiltersDescription}. This method
219
         * will be called after the plugins {@code RefactoringPlugin#prepare} method is called.
220
         *
221
         * @param filtersDescription the {@code FiltersDescription} to enable filters from
222
         * @see FiltersDescription#enable
223
         */
224
        void enableFilters(FiltersDescription filtersDescription);
225
    }
123
}
226
}

Return to bug 215361