Source Code Cross Referenced for WhereUsedPanel.java in  » IDE-Netbeans » refactoring.api » org » netbeans » modules » refactoring » java » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » refactoring.api » org.netbeans.modules.refactoring.java.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.refactoring.java.ui;
042:
043:        import java.awt.BorderLayout;
044:        import java.awt.Component;
045:        import java.awt.Dimension;
046:        import java.awt.event.ItemEvent;
047:        import java.io.IOException;
048:        import java.text.MessageFormat;
049:        import java.util.Collection;
050:        import java.util.HashSet;
051:        import java.util.Set;
052:        import javax.lang.model.element.Element;
053:        import javax.lang.model.element.ElementKind;
054:        import javax.lang.model.element.ExecutableElement;
055:        import javax.swing.DefaultComboBoxModel;
056:        import javax.swing.JList;
057:        import javax.swing.JList;
058:        import javax.swing.ListCellRenderer;
059:        import javax.swing.SwingUtilities;
060:        import javax.swing.event.ChangeListener;
061:        import org.netbeans.api.java.source.CompilationInfo;
062:        import org.netbeans.api.java.source.TreePathHandle;
063:        import org.netbeans.api.java.source.UiUtils;
064:        import org.netbeans.api.project.FileOwnerQuery;
065:        import org.netbeans.api.project.ProjectInformation;
066:        import org.netbeans.api.project.ProjectUtils;
067:        import org.netbeans.modules.refactoring.java.RefactoringModule;
068:        import org.netbeans.modules.refactoring.java.RetoucheUtils;
069:        import org.netbeans.modules.refactoring.java.ui.WhereUsedPanel.Scope;
070:        import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
071:        import org.openide.awt.Mnemonics;
072:        import org.openide.util.NbBundle;
073:        import org.netbeans.modules.refactoring.java.RefactoringModule;
074:        import javax.lang.model.element.Modifier;
075:        import javax.swing.JLabel;
076:        import javax.swing.JPanel;
077:        import javax.swing.ListCellRenderer;
078:        import javax.swing.SwingConstants;
079:        import javax.swing.plaf.UIResource;
080:        import org.netbeans.api.java.source.CancellableTask;
081:        import org.netbeans.api.java.source.CompilationController;
082:        import org.netbeans.api.java.source.JavaSource;
083:        import org.netbeans.api.java.source.JavaSource.Phase;
084:        import org.netbeans.api.project.Project;
085:
086:        /**
087:         * @author  Jan Becicka
088:         */
089:        public class WhereUsedPanel extends JPanel implements 
090:                CustomRefactoringPanel {
091:
092:            private final transient TreePathHandle element;
093:            private TreePathHandle newElement;
094:            private final transient ChangeListener parent;
095:            private static final int MAX_NAME = 50;
096:
097:            /** Creates new form WhereUsedPanel */
098:            public WhereUsedPanel(String name, TreePathHandle e,
099:                    ChangeListener parent) {
100:                setName(NbBundle.getMessage(WhereUsedPanel.class,
101:                        "LBL_WhereUsed")); // NOI18N
102:                this .element = e;
103:                this .parent = parent;
104:                initComponents();
105:                //parent.setPreviewEnabled(false);
106:            }
107:
108:            public enum Scope {
109:                ALL, CURRENT
110:            }
111:
112:            public Scope getScope() {
113:                if (scope.getSelectedIndex() == 1)
114:                    return Scope.CURRENT;
115:                return Scope.ALL;
116:            }
117:
118:            private boolean initialized = false;
119:            private String methodDeclaringSuperClass = null;
120:            private String methodDeclaringClass = null;
121:
122:            String getMethodDeclaringClass() {
123:                return isMethodFromBaseClass() ? methodDeclaringSuperClass
124:                        : methodDeclaringClass;
125:            }
126:
127:            private Collection getOverriddenMethods(ExecutableElement m,
128:                    CompilationInfo info) {
129:                return RetoucheUtils.getOverridenMethods(m, info);
130:            }
131:
132:            public void initialize() {
133:                if (initialized)
134:                    return;
135:                JavaSource source = JavaSource.forFileObject(element
136:                        .getFileObject());
137:                Project p = FileOwnerQuery.getOwner(element.getFileObject());
138:                final JLabel currentProject;
139:                final JLabel allProjects;
140:                if (p != null) {
141:                    ProjectInformation pi = ProjectUtils
142:                            .getInformation(FileOwnerQuery.getOwner(element
143:                                    .getFileObject()));
144:                    currentProject = new JLabel(pi.getDisplayName(), pi
145:                            .getIcon(), SwingConstants.LEFT);
146:                    allProjects = new JLabel(NbBundle.getMessage(
147:                            WhereUsedPanel.class, "LBL_AllProjects"), pi
148:                            .getIcon(), SwingConstants.LEFT);
149:                } else {
150:                    currentProject = null;
151:                    allProjects = null;
152:                }
153:                CancellableTask<CompilationController> task = new CancellableTask<CompilationController>() {
154:                    public void cancel() {
155:                        throw new UnsupportedOperationException(
156:                                "Not supported yet."); // NOI18N
157:                    }
158:
159:                    public void run(CompilationController info)
160:                            throws Exception {
161:                        info.toPhase(Phase.RESOLVED);
162:                        String m_isBaseClassText = null;
163:                        final String labelText;
164:                        Set<Modifier> modif = new HashSet<Modifier>();
165:
166:                        final Element element = WhereUsedPanel.this .element
167:                                .resolveElement(info);
168:                        if (element.getKind() == ElementKind.METHOD) {
169:                            ExecutableElement method = (ExecutableElement) element;
170:                            modif = method.getModifiers();
171:                            labelText = NbBundle
172:                                    .getMessage(WhereUsedPanel.class,
173:                                            "DSC_MethodUsages", getHeader(
174:                                                    method, info),
175:                                            getSimpleName(method
176:                                                    .getEnclosingElement())); // NOI18N
177:
178:                            methodDeclaringClass = getSimpleName(method
179:                                    .getEnclosingElement());
180:                            Collection overridens = getOverriddenMethods(
181:                                    method, info);
182:                            if (!overridens.isEmpty()) {
183:                                ExecutableElement el = (ExecutableElement) overridens
184:                                        .iterator().next();
185:                                assert el != null;
186:                                m_isBaseClassText = new MessageFormat(NbBundle
187:                                        .getMessage(WhereUsedPanel.class,
188:                                                "LBL_UsagesOfBaseClass"))
189:                                        .format(new Object[] { methodDeclaringSuperClass = getSimpleName((el)
190:                                                .getEnclosingElement()) });
191:                                newElement = TreePathHandle.create(el, info);
192:
193:                            }
194:                        } else if (element.getKind().isClass()
195:                                || element.getKind().isInterface()) {
196:                            labelText = NbBundle.getMessage(
197:                                    WhereUsedPanel.class, "DSC_ClassUsages",
198:                                    element.getSimpleName()); // NOI18N
199:                        } else if (element.getKind() == ElementKind.CONSTRUCTOR) {
200:                            labelText = NbBundle.getMessage(
201:                                    WhereUsedPanel.class,
202:                                    "DSC_ConstructorUsages",
203:                                    getHeader(element), getSimpleName(element
204:                                            .getEnclosingElement())); // NOI18N
205:                        } else if (element.getKind().isField()) {
206:                            labelText = NbBundle
207:                                    .getMessage(WhereUsedPanel.class,
208:                                            "DSC_FieldUsages", element
209:                                                    .getSimpleName(),
210:                                            getSimpleName(element
211:                                                    .getEnclosingElement())); // NOI18N
212:                        } else if (element.getKind() == ElementKind.PACKAGE) {
213:                            labelText = NbBundle.getMessage(
214:                                    WhereUsedPanel.class, "DSC_PackageUsages",
215:                                    element.getSimpleName()); // NOI18N
216:                        } else {
217:                            labelText = NbBundle.getMessage(
218:                                    WhereUsedPanel.class, "DSC_VariableUsages",
219:                                    element.getSimpleName()); // NOI18N
220:                        }
221:
222:                        final Set<Modifier> modifiers = modif;
223:                        final String isBaseClassText = m_isBaseClassText;
224:
225:                        SwingUtilities.invokeLater(new Runnable() {
226:                            public void run() {
227:                                remove(classesPanel);
228:                                remove(methodsPanel);
229:                                label.setText(labelText);
230:                                if (element instanceof  ExecutableElement) {
231:                                    add(methodsPanel, BorderLayout.CENTER);
232:                                    methodsPanel.setVisible(true);
233:                                    m_usages.setVisible(!modifiers
234:                                            .contains(Modifier.STATIC));
235:                                    m_overriders
236:                                            .setVisible(!(element
237:                                                    .getEnclosingElement()
238:                                                    .getModifiers().contains(
239:                                                            Modifier.FINAL)
240:                                                    || modifiers
241:                                                            .contains(Modifier.FINAL)
242:                                                    || modifiers
243:                                                            .contains(Modifier.STATIC) || modifiers
244:                                                    .contains(Modifier.PRIVATE)));
245:                                    if (methodDeclaringSuperClass != null) {
246:                                        m_isBaseClass.setVisible(true);
247:                                        m_isBaseClass.setSelected(true);
248:                                        Mnemonics.setLocalizedText(
249:                                                m_isBaseClass, isBaseClassText);
250:                                    } else {
251:                                        m_isBaseClass.setVisible(false);
252:                                        m_isBaseClass.setSelected(false);
253:                                    }
254:                                } else if ((element.getKind() == ElementKind.CLASS)
255:                                        || (element.getKind() == ElementKind.INTERFACE)) {
256:                                    add(classesPanel, BorderLayout.CENTER);
257:                                    classesPanel.setVisible(true);
258:                                } else {
259:                                    remove(classesPanel);
260:                                    remove(methodsPanel);
261:                                    c_subclasses.setVisible(false);
262:                                    m_usages.setVisible(false);
263:                                    c_usages.setVisible(false);
264:                                    c_directOnly.setVisible(false);
265:                                }
266:                                if (currentProject != null) {
267:                                    scope.setModel(new DefaultComboBoxModel(
268:                                            new Object[] { allProjects,
269:                                                    currentProject }));
270:                                    int defaultItem = (Integer) RefactoringModule
271:                                            .getOption("whereUsed.scope", 0); // NOI18N
272:                                    scope.setSelectedIndex(defaultItem);
273:                                    scope.setRenderer(new JLabelRenderer());
274:                                } else {
275:                                    scopePanel.setVisible(false);
276:                                }
277:                                validate();
278:                            }
279:                        });
280:                    }
281:                };
282:                try {
283:                    source.runUserActionTask(task, true);
284:                } catch (IOException ioe) {
285:                    throw (RuntimeException) new RuntimeException()
286:                            .initCause(ioe);
287:                }
288:                initialized = true;
289:            }
290:
291:            private static class JLabelRenderer extends JLabel implements 
292:                    ListCellRenderer, UIResource {
293:                public JLabelRenderer() {
294:                    setOpaque(true);
295:                }
296:
297:                public Component getListCellRendererComponent(JList list,
298:                        Object value, int index, boolean isSelected,
299:                        boolean cellHasFocus) {
300:
301:                    // #89393: GTK needs name to render cell renderer "natively"
302:                    setName("ComboBox.listRenderer"); // NOI18N
303:
304:                    if (value != null) {
305:                        setText(((JLabel) value).getText());
306:                        setIcon(((JLabel) value).getIcon());
307:                    }
308:
309:                    if (isSelected) {
310:                        setBackground(list.getSelectionBackground());
311:                        setForeground(list.getSelectionForeground());
312:                    } else {
313:                        setBackground(list.getBackground());
314:                        setForeground(list.getForeground());
315:                    }
316:
317:                    return this ;
318:                }
319:
320:                // #89393: GTK needs name to render cell renderer "natively"
321:                @Override
322:                public String getName() {
323:                    String name = super .getName();
324:                    return name == null ? "ComboBox.renderer" : name; // NOI18N
325:                }
326:            }
327:
328:            private String getSimpleName(Element clazz) {
329:                return clazz.getSimpleName().toString();
330:                //return NbBundle.getMessage(WhereUsedPanel.class, "LBL_AnonymousClass"); // NOI18N
331:            }
332:
333:            private String getHeader(ExecutableElement call,
334:                    CompilationInfo info) {
335:                String result = UiUtils.getHeader(call, info,
336:                        UiUtils.PrintPart.NAME + UiUtils.PrintPart.PARAMETERS);
337:                if (result.length() > MAX_NAME) {
338:                    result = result.substring(0, MAX_NAME - 1) + "..."; // NOI18N
339:                }
340:                return RetoucheUtils.htmlize(result);
341:            }
342:
343:            public TreePathHandle getBaseMethod() {
344:                return newElement;
345:            }
346:
347:            public void requestFocus() {
348:                super .requestFocus();
349:            }
350:
351:            /** This method is called from within the constructor to
352:             * initialize the form.
353:             * WARNING: Do NOT modify this code. The content of this method is
354:             * always regenerated by the Form Editor.
355:             */
356:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
357:            private void initComponents() {
358:                java.awt.GridBagConstraints gridBagConstraints;
359:
360:                buttonGroup = new javax.swing.ButtonGroup();
361:                methodsPanel = new javax.swing.JPanel();
362:                m_isBaseClass = new javax.swing.JCheckBox();
363:                jPanel1 = new javax.swing.JPanel();
364:                m_overriders = new javax.swing.JCheckBox();
365:                m_usages = new javax.swing.JCheckBox();
366:                classesPanel = new javax.swing.JPanel();
367:                jPanel2 = new javax.swing.JPanel();
368:                c_subclasses = new javax.swing.JRadioButton();
369:                c_usages = new javax.swing.JRadioButton();
370:                c_directOnly = new javax.swing.JRadioButton();
371:                commentsPanel = new javax.swing.JPanel();
372:                label = new javax.swing.JLabel();
373:                searchInComments = new javax.swing.JCheckBox();
374:                scopePanel = new javax.swing.JPanel();
375:                scopeLabel = new javax.swing.JLabel();
376:                scope = new javax.swing.JComboBox();
377:
378:                setLayout(new java.awt.BorderLayout());
379:
380:                methodsPanel.setLayout(new java.awt.GridBagLayout());
381:
382:                m_isBaseClass.setSelected(true);
383:                m_isBaseClass
384:                        .addActionListener(new java.awt.event.ActionListener() {
385:                            public void actionPerformed(
386:                                    java.awt.event.ActionEvent evt) {
387:                                m_isBaseClassActionPerformed(evt);
388:                            }
389:                        });
390:                gridBagConstraints = new java.awt.GridBagConstraints();
391:                gridBagConstraints.gridx = 0;
392:                gridBagConstraints.gridy = 3;
393:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
394:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
395:                methodsPanel.add(m_isBaseClass, gridBagConstraints);
396:                java.util.ResourceBundle bundle = java.util.ResourceBundle
397:                        .getBundle("org/netbeans/modules/refactoring/java/ui/Bundle"); // NOI18N
398:                m_isBaseClass.getAccessibleContext().setAccessibleDescription(
399:                        bundle.getString("ACSD_isBaseClass")); // NOI18N
400:
401:                gridBagConstraints = new java.awt.GridBagConstraints();
402:                gridBagConstraints.gridx = 0;
403:                gridBagConstraints.gridy = 4;
404:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
405:                gridBagConstraints.weightx = 1.0;
406:                gridBagConstraints.weighty = 1.0;
407:                methodsPanel.add(jPanel1, gridBagConstraints);
408:
409:                org.openide.awt.Mnemonics.setLocalizedText(m_overriders,
410:                        org.openide.util.NbBundle.getMessage(
411:                                WhereUsedPanel.class,
412:                                "LBL_FindOverridingMethods")); // NOI18N
413:                m_overriders
414:                        .addActionListener(new java.awt.event.ActionListener() {
415:                            public void actionPerformed(
416:                                    java.awt.event.ActionEvent evt) {
417:                                m_overridersActionPerformed(evt);
418:                            }
419:                        });
420:                gridBagConstraints = new java.awt.GridBagConstraints();
421:                gridBagConstraints.gridx = 0;
422:                gridBagConstraints.gridy = 2;
423:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
424:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
425:                methodsPanel.add(m_overriders, gridBagConstraints);
426:                m_overriders.getAccessibleContext().setAccessibleDescription(
427:                        bundle.getString("ACSD_overriders")); // NOI18N
428:
429:                m_usages.setSelected(true);
430:                org.openide.awt.Mnemonics.setLocalizedText(m_usages,
431:                        org.openide.util.NbBundle.getMessage(
432:                                WhereUsedPanel.class, "LBL_FindUsages")); // NOI18N
433:                m_usages.setMargin(new java.awt.Insets(10, 2, 2, 2));
434:                m_usages.addActionListener(new java.awt.event.ActionListener() {
435:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
436:                        m_usagesActionPerformed(evt);
437:                    }
438:                });
439:                gridBagConstraints = new java.awt.GridBagConstraints();
440:                gridBagConstraints.gridx = 0;
441:                gridBagConstraints.gridy = 1;
442:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
443:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
444:                methodsPanel.add(m_usages, gridBagConstraints);
445:                m_usages.getAccessibleContext().setAccessibleDescription(
446:                        bundle.getString("ACSD_usages")); // NOI18N
447:
448:                add(methodsPanel, java.awt.BorderLayout.CENTER);
449:
450:                classesPanel.setLayout(new java.awt.GridBagLayout());
451:                gridBagConstraints = new java.awt.GridBagConstraints();
452:                gridBagConstraints.gridx = 0;
453:                gridBagConstraints.gridy = 4;
454:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
455:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
456:                gridBagConstraints.weightx = 1.0;
457:                gridBagConstraints.weighty = 1.0;
458:                classesPanel.add(jPanel2, gridBagConstraints);
459:
460:                buttonGroup.add(c_subclasses);
461:                org.openide.awt.Mnemonics.setLocalizedText(c_subclasses,
462:                        org.openide.util.NbBundle.getMessage(
463:                                WhereUsedPanel.class, "LBL_FindAllSubtypes")); // NOI18N
464:                gridBagConstraints = new java.awt.GridBagConstraints();
465:                gridBagConstraints.gridx = 0;
466:                gridBagConstraints.gridy = 2;
467:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
468:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
469:                classesPanel.add(c_subclasses, gridBagConstraints);
470:                c_subclasses.getAccessibleContext().setAccessibleDescription(
471:                        bundle.getString("ACSD_subclasses")); // NOI18N
472:
473:                buttonGroup.add(c_usages);
474:                c_usages.setSelected(true);
475:                org.openide.awt.Mnemonics.setLocalizedText(c_usages,
476:                        org.openide.util.NbBundle.getMessage(
477:                                WhereUsedPanel.class, "LBL_FindUsages")); // NOI18N
478:                c_usages.setMargin(new java.awt.Insets(4, 2, 2, 2));
479:                gridBagConstraints = new java.awt.GridBagConstraints();
480:                gridBagConstraints.gridx = 0;
481:                gridBagConstraints.gridy = 1;
482:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
483:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
484:                classesPanel.add(c_usages, gridBagConstraints);
485:                c_usages.getAccessibleContext().setAccessibleDescription(
486:                        bundle.getString("ACSD_usages")); // NOI18N
487:
488:                buttonGroup.add(c_directOnly);
489:                org.openide.awt.Mnemonics.setLocalizedText(c_directOnly,
490:                        org.openide.util.NbBundle.getMessage(
491:                                WhereUsedPanel.class,
492:                                "LBL_FindDirectSubtypesOnly")); // NOI18N
493:                gridBagConstraints = new java.awt.GridBagConstraints();
494:                gridBagConstraints.gridx = 0;
495:                gridBagConstraints.gridy = 3;
496:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
497:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
498:                classesPanel.add(c_directOnly, gridBagConstraints);
499:                c_directOnly.getAccessibleContext().setAccessibleDescription(
500:                        bundle.getString("ACSD_directOnly")); // NOI18N
501:
502:                add(classesPanel, java.awt.BorderLayout.CENTER);
503:
504:                commentsPanel.setLayout(new java.awt.BorderLayout());
505:                commentsPanel.add(label, java.awt.BorderLayout.NORTH);
506:
507:                searchInComments
508:                        .setSelected(((Boolean) RefactoringModule.getOption(
509:                                "searchInComments.whereUsed", Boolean.FALSE))
510:                                .booleanValue());
511:                org.openide.awt.Mnemonics.setLocalizedText(searchInComments,
512:                        org.openide.util.NbBundle.getBundle(
513:                                WhereUsedPanel.class).getString(
514:                                "LBL_SearchInComents")); // NOI18N
515:                searchInComments.setMargin(new java.awt.Insets(10, 14, 2, 2));
516:                searchInComments
517:                        .addItemListener(new java.awt.event.ItemListener() {
518:                            public void itemStateChanged(
519:                                    java.awt.event.ItemEvent evt) {
520:                                searchInCommentsItemStateChanged(evt);
521:                            }
522:                        });
523:                commentsPanel
524:                        .add(searchInComments, java.awt.BorderLayout.SOUTH);
525:                searchInComments.getAccessibleContext()
526:                        .setAccessibleDescription(searchInComments.getText());
527:
528:                add(commentsPanel, java.awt.BorderLayout.NORTH);
529:
530:                scopeLabel.setText(org.openide.util.NbBundle.getMessage(
531:                        WhereUsedPanel.class, "LBL_Scope")); // NOI18N
532:
533:                scope.addActionListener(new java.awt.event.ActionListener() {
534:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
535:                        scopeActionPerformed(evt);
536:                    }
537:                });
538:
539:                org.jdesktop.layout.GroupLayout scopePanelLayout = new org.jdesktop.layout.GroupLayout(
540:                        scopePanel);
541:                scopePanel.setLayout(scopePanelLayout);
542:                scopePanelLayout
543:                        .setHorizontalGroup(scopePanelLayout
544:                                .createParallelGroup(
545:                                        org.jdesktop.layout.GroupLayout.LEADING)
546:                                .add(
547:                                        scopePanelLayout
548:                                                .createSequentialGroup()
549:                                                .addContainerGap()
550:                                                .add(scopeLabel)
551:                                                .addPreferredGap(
552:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
553:                                                .add(scope, 0, 288,
554:                                                        Short.MAX_VALUE)
555:                                                .addContainerGap()));
556:                scopePanelLayout.setVerticalGroup(scopePanelLayout
557:                        .createParallelGroup(
558:                                org.jdesktop.layout.GroupLayout.BASELINE).add(
559:                                scopeLabel).add(scope,
560:                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
561:                                20, Short.MAX_VALUE));
562:
563:                add(scopePanel, java.awt.BorderLayout.PAGE_END);
564:            }// </editor-fold>//GEN-END:initComponents
565:
566:            private void scopeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scopeActionPerformed
567:                RefactoringModule.setOption("whereUsed.scope", scope
568:                        .getSelectedIndex()); // NOI18N
569:            }//GEN-LAST:event_scopeActionPerformed
570:
571:            private void searchInCommentsItemStateChanged(
572:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_searchInCommentsItemStateChanged
573:                // used for change default value for searchInComments check-box.
574:                // The value is persisted and then used as default in next IDE run.
575:                Boolean b = evt.getStateChange() == ItemEvent.SELECTED ? Boolean.TRUE
576:                        : Boolean.FALSE;
577:                RefactoringModule.setOption("searchInComments.whereUsed", b); // NOI18N
578:            }//GEN-LAST:event_searchInCommentsItemStateChanged
579:
580:            private void m_isBaseClassActionPerformed(
581:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_isBaseClassActionPerformed
582:                parent.stateChanged(null);
583:            }//GEN-LAST:event_m_isBaseClassActionPerformed
584:
585:            private void m_overridersActionPerformed(
586:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_overridersActionPerformed
587:                parent.stateChanged(null);
588:            }//GEN-LAST:event_m_overridersActionPerformed
589:
590:            private void m_usagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_usagesActionPerformed
591:                parent.stateChanged(null);
592:            }//GEN-LAST:event_m_usagesActionPerformed
593:
594:            // Variables declaration - do not modify//GEN-BEGIN:variables
595:            private javax.swing.ButtonGroup buttonGroup;
596:            private javax.swing.JRadioButton c_directOnly;
597:            private javax.swing.JRadioButton c_subclasses;
598:            private javax.swing.JRadioButton c_usages;
599:            private javax.swing.JPanel classesPanel;
600:            private javax.swing.JPanel commentsPanel;
601:            private javax.swing.JPanel jPanel1;
602:            private javax.swing.JPanel jPanel2;
603:            private javax.swing.JLabel label;
604:            private javax.swing.JCheckBox m_isBaseClass;
605:            private javax.swing.JCheckBox m_overriders;
606:            private javax.swing.JCheckBox m_usages;
607:            private javax.swing.JPanel methodsPanel;
608:            private javax.swing.JComboBox scope;
609:            private javax.swing.JLabel scopeLabel;
610:            private javax.swing.JPanel scopePanel;
611:            private javax.swing.JCheckBox searchInComments;
612:
613:            // End of variables declaration//GEN-END:variables
614:
615:            public boolean isMethodFromBaseClass() {
616:                return m_isBaseClass.isSelected();
617:            }
618:
619:            public boolean isMethodOverriders() {
620:                return m_overriders.isSelected();
621:            }
622:
623:            public boolean isClassSubTypes() {
624:                return c_subclasses.isSelected();
625:            }
626:
627:            public boolean isClassSubTypesDirectOnly() {
628:                return c_directOnly.isSelected();
629:            }
630:
631:            public boolean isMethodFindUsages() {
632:                return m_usages.isSelected();
633:            }
634:
635:            public boolean isClassFindUsages() {
636:                return c_usages.isSelected();
637:            }
638:
639:            public Dimension getPreferredSize() {
640:                Dimension orig = super .getPreferredSize();
641:                return new Dimension(orig.width + 30, orig.height + 30);
642:            }
643:
644:            public boolean isSearchInComments() {
645:                return searchInComments.isSelected();
646:            }
647:
648:            private Object getHeader(javax.lang.model.element.Element element) {
649:                return element.toString();
650:            }
651:
652:            public Component getComponent() {
653:                return this;
654:            }
655:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.