Source Code Cross Referenced for SelectRootMethodsForClassPanel.java in  » IDE-Netbeans » profiler » org » netbeans » modules » profiler » ui » panels » 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 » profiler » org.netbeans.modules.profiler.ui.panels 
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:         * The Original Software is NetBeans. The Initial Developer of the Original
026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027:         * Microsystems, Inc. All Rights Reserved.
028:         *
029:         * If you wish your version of this file to be governed by only the CDDL
030:         * or only the GPL Version 2, indicate your decision by adding
031:         * "[Contributor] elects to include this software in this distribution
032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
033:         * single choice of license, a recipient has the option to distribute
034:         * your version of this file under either the CDDL, the GPL Version 2 or
035:         * to extend the choice of license to its licensees as provided above.
036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
037:         * Version 2 license, then the option applies only if the new code is
038:         * made subject to such option by the copyright holder.
039:         */
040:
041:        package org.netbeans.modules.profiler.ui.panels;
042:
043:        import org.netbeans.api.progress.ProgressHandle;
044:        import org.netbeans.api.project.Project;
045:        import org.netbeans.lib.profiler.client.ClientUtils;
046:        import org.netbeans.lib.profiler.ui.UIUtils;
047:        import org.netbeans.lib.profiler.ui.components.HTMLTextArea;
048:        import org.netbeans.modules.profiler.ui.ProfilerDialogs;
049:        import org.netbeans.modules.profiler.utils.IDEUtils;
050:        import org.openide.DialogDescriptor;
051:        import org.openide.util.NbBundle;
052:        import java.awt.Color;
053:        import java.awt.Container;
054:        import java.awt.Dialog;
055:        import java.awt.Dimension;
056:        import java.awt.GridBagConstraints;
057:        import java.awt.GridBagLayout;
058:        import java.awt.Insets;
059:        import javax.swing.BorderFactory;
060:        import javax.swing.JButton;
061:        import javax.swing.JPanel;
062:        import javax.swing.JScrollPane;
063:        import javax.swing.UIManager;
064:        import org.netbeans.modules.profiler.selector.ui.ProgressDisplayer;
065:        import org.netbeans.modules.profiler.selector.ui.RootSelectorNode;
066:        import org.netbeans.modules.profiler.selector.ui.RootSelectorTree;
067:        import org.netbeans.modules.profiler.utilities.trees.TreeDecimator;
068:
069:        /**
070:         *
071:         * @author Jaroslav Bachorik
072:         */
073:        public class SelectRootMethodsForClassPanel extends JPanel {
074:            //~ Static fields/initializers -----------------------------------------------------------------------------------------------
075:
076:            protected static final Dimension PREFERRED_TOPTREE_DIMENSION = new Dimension(
077:                    500, 250);
078:            private static SelectRootMethodsForClassPanel instance;
079:
080:            //~ Instance fields ----------------------------------------------------------------------------------------------------------
081:
082:            //  private JComboBox treeBuilderList;
083:            private HTMLTextArea hintArea;
084:            private JButton okButton;
085:            private Project currentProject;
086:            private RootSelectorTree advancedLogicalPackageTree;
087:            private String assignedClassName;
088:
089:            //~ Constructors -------------------------------------------------------------------------------------------------------------
090:
091:            /** Creates a new instance of SelectRootMethodsForClassPanel */
092:            public SelectRootMethodsForClassPanel() {
093:                initComponents(this );
094:            }
095:
096:            //~ Methods ------------------------------------------------------------------------------------------------------------------
097:
098:            public static synchronized SelectRootMethodsForClassPanel getDefault() {
099:                if (instance == null) {
100:                    instance = new SelectRootMethodsForClassPanel();
101:                }
102:
103:                return instance;
104:            }
105:
106:            public ClientUtils.SourceCodeSelection[] getRootMethods(
107:                    final Project project, final String className,
108:                    final ClientUtils.SourceCodeSelection[] currentSelection) {
109:                this .assignedClassName = demaskInnerClass(className);
110:                this .currentProject = project;
111:
112:                updateSelector(new Runnable() {
113:                    public void run() {
114:                        advancedLogicalPackageTree.setup(
115:                                new Project[] { currentProject },
116:                                currentSelection);
117:                    }
118:                });
119:
120:                final DialogDescriptor dd = new DialogDescriptor(this ,
121:                        NbBundle.getMessage(this .getClass(),
122:                                "SelectRootMethodsPanel_Title"), // NOI18N
123:                        true, new Object[] { okButton,
124:                                DialogDescriptor.CANCEL_OPTION }, okButton,
125:                        DialogDescriptor.BOTTOM_ALIGN, null, null);
126:
127:                Object[] additionalOptions = getAdditionalOptions();
128:
129:                if ((additionalOptions != null)
130:                        && (additionalOptions.length > 0)) {
131:                    dd.setAdditionalOptions(additionalOptions);
132:                }
133:
134:                final Dialog d = ProfilerDialogs.createDialog(dd);
135:                d.pack(); // To properly layout HTML hint area
136:                d.setVisible(true);
137:
138:                this .currentProject = null;
139:
140:                return advancedLogicalPackageTree.getSelection();
141:            }
142:
143:            protected void initComponents(final Container container) {
144:                GridBagConstraints gridBagConstraints;
145:
146:                okButton = new JButton("OK");
147:
148:                advancedLogicalPackageTree = new RootSelectorTree(
149:                        new ProgressDisplayer() {
150:                            ProfilerProgressDisplayer pd = null;
151:
152:                            public synchronized void showProgress(String message) {
153:                                pd = ProfilerProgressDisplayer
154:                                        .showProgress(message);
155:                            }
156:
157:                            public synchronized void showProgress(
158:                                    String message,
159:                                    ProgressController controller) {
160:                                pd = ProfilerProgressDisplayer.showProgress(
161:                                        message, controller);
162:                            }
163:
164:                            public synchronized void showProgress(
165:                                    String caption, String message,
166:                                    ProgressController controller) {
167:                                pd = ProfilerProgressDisplayer.showProgress(
168:                                        caption, message, controller);
169:                            }
170:
171:                            public synchronized boolean isOpened() {
172:                                return pd != null;
173:                            }
174:
175:                            public synchronized void close() {
176:                                if (pd != null) {
177:                                    pd.close();
178:                                    pd = null;
179:                                }
180:                            }
181:                        });
182:
183:                advancedLogicalPackageTree
184:                        .setNodeFilter(new TreeDecimator.NodeFilter<RootSelectorNode>() {
185:                            public boolean match(RootSelectorNode node) {
186:                                return node.getSignature().toFlattened()
187:                                        .equals(assignedClassName);
188:                            }
189:
190:                            public boolean maymatch(RootSelectorNode node) {
191:                                return assignedClassName.startsWith(node
192:                                        .getSignature().toFlattened());
193:                            }
194:                        });
195:
196:                container.setLayout(new GridBagLayout());
197:
198:                hintArea = new HTMLTextArea() {
199:                    public Dimension getPreferredSize() { // Workaround to force the text area not to consume horizontal space to fit the contents to just one line
200:
201:                        return new Dimension(1, super .getPreferredSize().height);
202:                    }
203:                };
204:
205:                advancedLogicalPackageTree.setRowHeight(UIUtils
206:                        .getDefaultRowHeight() + 2);
207:
208:                JScrollPane advancedLogicalPackageTreeScrollPane = new JScrollPane(
209:                        advancedLogicalPackageTree);
210:                advancedLogicalPackageTreeScrollPane
211:                        .setPreferredSize(PREFERRED_TOPTREE_DIMENSION);
212:
213:                gridBagConstraints = new GridBagConstraints();
214:                gridBagConstraints.gridx = 0;
215:                gridBagConstraints.gridy = 0;
216:                gridBagConstraints.weightx = 1;
217:                gridBagConstraints.weighty = 1;
218:                gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
219:                gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
220:                gridBagConstraints.fill = GridBagConstraints.BOTH;
221:                gridBagConstraints.insets = new Insets(10, 10, 0, 10);
222:                container.add(advancedLogicalPackageTreeScrollPane,
223:                        gridBagConstraints);
224:
225:                gridBagConstraints = new GridBagConstraints();
226:                gridBagConstraints.gridx = 1;
227:                gridBagConstraints.gridy = 1;
228:                gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
229:                gridBagConstraints.insets = new Insets(10, 10, 5, 10);
230:
231:                // hintArea
232:                String hintString = getHintString();
233:
234:                if ((hintString != null) && (hintString.length() > 0)) {
235:                    Color panelBackground = UIManager
236:                            .getColor("Panel.background"); //NOI18N
237:                    Color hintBackground = UIUtils.getSafeColor(panelBackground
238:                            .getRed() - 10, panelBackground.getGreen() - 10,
239:                            panelBackground.getBlue() - 10);
240:                    hintArea.setText(hintString);
241:                    hintArea.setEnabled(false);
242:                    hintArea.setDisabledTextColor(Color.darkGray);
243:                    hintArea.setBackground(hintBackground);
244:                    hintArea.setBorder(BorderFactory.createMatteBorder(10, 10,
245:                            10, 10, hintBackground));
246:                    gridBagConstraints = new GridBagConstraints();
247:                    gridBagConstraints.gridx = 0;
248:                    gridBagConstraints.gridy = 3;
249:                    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
250:                    gridBagConstraints.insets = new Insets(5, 10, 5, 10);
251:                    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
252:                    gridBagConstraints.fill = GridBagConstraints.BOTH;
253:                    container.add(hintArea, gridBagConstraints);
254:                }
255:            }
256:
257:            private Object[] getAdditionalOptions() {
258:                return null;
259:            }
260:
261:            private String getHintString() {
262:                return null;
263:            }
264:
265:            private String demaskInnerClass(String className) {
266:                return className;
267:                //        return className.replace('$', '.'); // NOI18N
268:            }
269:
270:            //    private SelectorNode[] findElligibleNodes(SelectorNode currentRoot) {
271:            //        ClientUtils.SourceCodeSelection signature = currentRoot.getSignature();
272:            //
273:            //        if ((signature != null) && signature.getClassName().equals(assignedClassName)) {
274:            //            return new SelectorNode[] { currentRoot };
275:            //        }
276:            //
277:            //        Set<SelectorNode> foundNodes = new HashSet<SelectorNode>();
278:            //
279:            //        if ((signature == null) || assignedClassName.startsWith(signature.toFlattened())) {
280:            //            Enumeration chldrn = currentRoot.children();
281:            //
282:            //            while (chldrn.hasMoreElements()) {
283:            //                SelectorNode[] nodes = findElligibleNodes((SelectorNode) chldrn.nextElement());
284:            //                foundNodes.addAll(Arrays.asList(nodes));
285:            //            }
286:            //        }
287:            //
288:            //        return foundNodes.toArray(new SelectorNode[foundNodes.size()]);
289:            //    }
290:            //
291:            //    private void refreshDefaultBuilder() {
292:            //        Collection<?extends SelectionTreeBuilder> allBuilders = Lookup.getDefault().lookupAll(SelectionTreeBuilder.class);
293:            //
294:            //        for (SelectionTreeBuilder builder : allBuilders) {
295:            //            if (builder.supports(currentProject)) {
296:            //                if (builder.isDefault()) {
297:            //                    defaultBuilder = builder;
298:            //
299:            //                    break;
300:            //                }
301:            //            }
302:            //        }
303:            //    }
304:
305:            private void updateSelector(Runnable updater) {
306:                ProgressHandle ph = IDEUtils
307:                        .indeterminateProgress(
308:                                NbBundle
309:                                        .getMessage(this .getClass(),
310:                                                "SelectRootMethodsPanel_ParsingProjectStructureMessage"),
311:                                500); // NOI18N
312:
313:                try {
314:                    advancedLogicalPackageTree.setEnabled(false);
315:                    okButton.setEnabled(false);
316:                    updater.run();
317:                } finally {
318:                    ph.finish();
319:                    okButton.setEnabled(true);
320:                    advancedLogicalPackageTree.setEnabled(true);
321:                }
322:            }
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.