Source Code Cross Referenced for DependencyFinder.java in  » Code-Analyzer » DependencyFinder » com » jeantessier » dependencyfinder » gui » 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 » Code Analyzer » DependencyFinder » com.jeantessier.dependencyfinder.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Copyright (c) 2001-2007, Jean Tessier
0003:         *  All rights reserved.
0004:         *  
0005:         *  Redistribution and use in source and binary forms, with or without
0006:         *  modification, are permitted provided that the following conditions
0007:         *  are met:
0008:         *  
0009:         *      * Redistributions of source code must retain the above copyright
0010:         *        notice, this list of conditions and the following disclaimer.
0011:         *  
0012:         *      * Redistributions in binary form must reproduce the above copyright
0013:         *        notice, this list of conditions and the following disclaimer in the
0014:         *        documentation and/or other materials provided with the distribution.
0015:         *  
0016:         *      * Neither the name of Jean Tessier nor the names of his contributors
0017:         *        may be used to endorse or promote products derived from this software
0018:         *        without specific prior written permission.
0019:         *  
0020:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0021:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0022:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0023:         *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
0024:         *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0025:         *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0026:         *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0027:         *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0028:         *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0029:         *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0030:         *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0031:         */
0032:
0033:        package com.jeantessier.dependencyfinder.gui;
0034:
0035:        import java.awt.*;
0036:        import java.awt.event.*;
0037:        import java.io.*;
0038:        import java.util.*;
0039:        import javax.swing.*;
0040:        import javax.swing.border.*;
0041:
0042:        import org.apache.log4j.*;
0043:
0044:        import com.jeantessier.classreader.*;
0045:        import com.jeantessier.commandline.*;
0046:        import com.jeantessier.dependency.*;
0047:
0048:        public class DependencyFinder extends JFrame {
0049:            private boolean minimize;
0050:            private boolean maximize;
0051:
0052:            private boolean advancedMode;
0053:            private JPanel queryPanel = new JPanel();
0054:
0055:            private JMenuBar menuBar = new JMenuBar();
0056:            private JMenu fileMenu = new JMenu();
0057:            private JMenu viewMenu = new JMenu();
0058:            private JMenu helpMenu = new JMenu();
0059:            private JToolBar toolbar = new JToolBar();
0060:            private JTextArea dependenciesResultArea = new JTextArea();
0061:            private JTextArea closureResultArea = new JTextArea();
0062:            private JTextArea metricsResultArea = new JTextArea();
0063:            private MetricsTableModel metricsChartModel = new MetricsTableModel();
0064:            private StatusLine statusLine = new StatusLine(420);
0065:            private JProgressBar progressBar = new JProgressBar();
0066:
0067:            private Collection<String> inputFiles = null;
0068:            private ClassfileLoaderDispatcher dispatcher = null;
0069:            private NodeFactory nodeFactory = null;
0070:            private Monitor monitor = null;
0071:
0072:            private JCheckBox packageScope = new JCheckBox("packages");
0073:            private JCheckBox classScope = new JCheckBox("classes");
0074:            private JCheckBox featureScope = new JCheckBox("features");
0075:            private JTextField scopeIncludes = new JTextField();
0076:            private JTextField packageScopeIncludes = new JTextField();
0077:            private JTextField classScopeIncludes = new JTextField();
0078:            private JTextField featureScopeIncludes = new JTextField();
0079:            private JTextField scopeExcludes = new JTextField();
0080:            private JTextField packageScopeExcludes = new JTextField();
0081:            private JTextField classScopeExcludes = new JTextField();
0082:            private JTextField featureScopeExcludes = new JTextField();
0083:
0084:            private JCheckBox packageFilter = new JCheckBox("packages");
0085:            private JCheckBox classFilter = new JCheckBox("classes");
0086:            private JCheckBox featureFilter = new JCheckBox("features");
0087:            private JTextField filterIncludes = new JTextField();
0088:            private JTextField packageFilterIncludes = new JTextField();
0089:            private JTextField classFilterIncludes = new JTextField();
0090:            private JTextField featureFilterIncludes = new JTextField();
0091:            private JTextField filterExcludes = new JTextField();
0092:            private JTextField packageFilterExcludes = new JTextField();
0093:            private JTextField classFilterExcludes = new JTextField();
0094:            private JTextField featureFilterExcludes = new JTextField();
0095:
0096:            private JCheckBox showInbounds = new JCheckBox("<--");
0097:            private JCheckBox showOutbounds = new JCheckBox("-->");
0098:            private JCheckBox showEmptyNodes = new JCheckBox("empty elements");
0099:            private JCheckBox copyOnly = new JCheckBox("copy only");
0100:
0101:            private JTextField maximumInboundDepth = new JTextField("0", 2);
0102:            private JTextField maximumOutboundDepth = new JTextField(2);
0103:
0104:            private GraphCopier dependenciesQuery = null;
0105:
0106:            public DependencyFinder(CommandLine commandLine) {
0107:                this .setSize(new Dimension(800, 600));
0108:                this .setTitle("Dependency Finder");
0109:                this .setIconImage(new ImageIcon(getClass().getResource(
0110:                        "icons/logoicon.gif")).getImage());
0111:                this .setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
0112:                this .addWindowListener(new WindowKiller());
0113:
0114:                setNewDependencyGraph();
0115:
0116:                packageScope.setToolTipText("Select packages");
0117:                classScope
0118:                        .setToolTipText("Select classes (with their package)");
0119:                featureScope
0120:                        .setToolTipText("Select methods and fields (with their class and package)");
0121:                scopeIncludes
0122:                        .setToolTipText("Package, class, method, or field must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0123:                packageScopeIncludes
0124:                        .setToolTipText("Package must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0125:                classScopeIncludes
0126:                        .setToolTipText("Class must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0127:                featureScopeIncludes
0128:                        .setToolTipText("Method or field must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0129:                scopeExcludes
0130:                        .setToolTipText("Package, class, method, or field must NOT match any of these expressions. E.g., /Test/");
0131:                packageScopeExcludes
0132:                        .setToolTipText("Package must NOT match any of these expressions. E.g., /Test/");
0133:                classScopeExcludes
0134:                        .setToolTipText("Class must NOT match any of these expressions. E.g., /Test/");
0135:                featureScopeExcludes
0136:                        .setToolTipText("Method or field must NOT match any of these expressions. E.g., /Test/");
0137:
0138:                packageFilter
0139:                        .setToolTipText("Show dependencies to/from packages");
0140:                classFilter.setToolTipText("Show dependencies to/from classes");
0141:                featureFilter
0142:                        .setToolTipText("Show dependencies to/from methods and fields");
0143:                filterIncludes
0144:                        .setToolTipText("Package, class, method, or field at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0145:                packageFilterIncludes
0146:                        .setToolTipText("Package at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0147:                classFilterIncludes
0148:                        .setToolTipText("Class at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0149:                featureFilterIncludes
0150:                        .setToolTipText("Method or field at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
0151:                filterExcludes
0152:                        .setToolTipText("Package, class, method, or field at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
0153:                packageFilterExcludes
0154:                        .setToolTipText("Package at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
0155:                classFilterExcludes
0156:                        .setToolTipText("Class at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
0157:                featureFilterExcludes
0158:                        .setToolTipText("Method or field at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
0159:
0160:                showInbounds
0161:                        .setToolTipText("Show dependencies that point to the selected packages, classes, methods, or fields");
0162:                showOutbounds
0163:                        .setToolTipText("Show dependencies that originate from the selected packages, classes, methods, or fields");
0164:                showEmptyNodes
0165:                        .setToolTipText("Show selected packages, classes, methods, and fields even if they do not have dependencies");
0166:                copyOnly
0167:                        .setToolTipText("<html>Only copy explicit dependencies to the result graph.<br>Do not introduce implicit dependencies<br>where explicit dependencies match the regular expressions<br>but are otherwise out of scope</html>");
0168:
0169:                showInbounds.setFont(getCodeFont(Font.BOLD, 14));
0170:                showOutbounds.setFont(getCodeFont(Font.BOLD, 14));
0171:
0172:                maximumInboundDepth
0173:                        .setToolTipText("Maximum hops against the direction dependencies.  Empty field means no limit.");
0174:                maximumOutboundDepth
0175:                        .setToolTipText("Maximum hops in the direction of dependencies.  Empty field means no limit.");
0176:
0177:                setAdvancedMode(false);
0178:
0179:                buildMenus(commandLine);
0180:                buildUI();
0181:
0182:                try {
0183:                    UIManager
0184:                            .setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
0185:                    SwingUtilities.updateComponentTreeUI(this );
0186:                } catch (Exception ex) {
0187:                    Logger.getLogger(DependencyFinder.class).error(
0188:                            "Unable to set look and feel", ex);
0189:                }
0190:
0191:                statusLine.showInfo("Ready.");
0192:            }
0193:
0194:            private Font getCodeFont(int style, int size) {
0195:                String fontName = "Monospaced";
0196:
0197:                String[] fontNames = GraphicsEnvironment
0198:                        .getLocalGraphicsEnvironment()
0199:                        .getAvailableFontFamilyNames();
0200:                for (String fontName1 : fontNames) {
0201:                    if (fontName1.indexOf("Courier") != -1) {
0202:                        fontName = fontName1;
0203:                    }
0204:                }
0205:
0206:                return new Font(fontName, style, size);
0207:            }
0208:
0209:            private boolean isAdvancedMode() {
0210:                return advancedMode;
0211:            }
0212:
0213:            void setAdvancedMode(boolean advancedMode) {
0214:                this .advancedMode = advancedMode;
0215:
0216:                copyOnly.setVisible(advancedMode);
0217:            }
0218:
0219:            public boolean getMaximize() {
0220:                return maximize;
0221:            }
0222:
0223:            private void setMaximize(boolean maximize) {
0224:                this .maximize = maximize;
0225:            }
0226:
0227:            public boolean getMinimize() {
0228:                return minimize;
0229:            }
0230:
0231:            private void setMinimize(boolean minimize) {
0232:                this .minimize = minimize;
0233:            }
0234:
0235:            public ClassfileLoaderDispatcher getClassfileLoaderDispatcher() {
0236:                return dispatcher;
0237:            }
0238:
0239:            private void setClassfileLoaderDispatcher(
0240:                    ClassfileLoaderDispatcher dispatcher) {
0241:                this .dispatcher = dispatcher;
0242:            }
0243:
0244:            public Monitor getMonitor() {
0245:                return monitor;
0246:            }
0247:
0248:            private void setMonitor(Monitor monitor) {
0249:                this .monitor = monitor;
0250:            }
0251:
0252:            public Collection<String> getInputFiles() {
0253:                return inputFiles;
0254:            }
0255:
0256:            private void setInputFiles(Collection<String> inputFiles) {
0257:                this .inputFiles = inputFiles;
0258:            }
0259:
0260:            public void addInputFile(File file) {
0261:                inputFiles.add(file.toString());
0262:            }
0263:
0264:            public Collection<PackageNode> getPackages() {
0265:                return getNodeFactory().getPackages().values();
0266:            }
0267:
0268:            public NodeFactory getNodeFactory() {
0269:                return nodeFactory;
0270:            }
0271:
0272:            private void setNodeFactory(NodeFactory nodeFactory) {
0273:                this .nodeFactory = nodeFactory;
0274:            }
0275:
0276:            StatusLine getStatusLine() {
0277:                return statusLine;
0278:            }
0279:
0280:            JProgressBar getProgressBar() {
0281:                return progressBar;
0282:            }
0283:
0284:            private void buildMenus(CommandLine commandLine) {
0285:                buildFileMenu(commandLine);
0286:                buildViewMenu();
0287:                buildHelpMenu();
0288:
0289:                this .setJMenuBar(menuBar);
0290:            }
0291:
0292:            private void buildFileMenu(CommandLine commandLine) {
0293:                menuBar.add(fileMenu);
0294:
0295:                fileMenu.setText("File");
0296:
0297:                Action action;
0298:                JMenuItem menuItem;
0299:                JButton button;
0300:
0301:                action = new DependencyExtractAction(this );
0302:                menuItem = fileMenu.add(action);
0303:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
0304:                        Event.CTRL_MASK));
0305:                menuItem.setMnemonic('e');
0306:                button = toolbar.add(action);
0307:                button.setToolTipText((String) action
0308:                        .getValue(Action.LONG_DESCRIPTION));
0309:
0310:                action = new RefreshDependencyGraphAction(this );
0311:                menuItem = fileMenu.add(action);
0312:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
0313:                        Event.CTRL_MASK));
0314:                menuItem.setMnemonic('r');
0315:                button = toolbar.add(action);
0316:                button.setToolTipText((String) action
0317:                        .getValue(Action.LONG_DESCRIPTION));
0318:
0319:                toolbar.addSeparator();
0320:                fileMenu.addSeparator();
0321:
0322:                action = new OpenFileAction(this );
0323:                menuItem = fileMenu.add(action);
0324:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
0325:                        Event.CTRL_MASK));
0326:                menuItem.setMnemonic('o');
0327:                button = toolbar.add(action);
0328:                button.setToolTipText((String) action
0329:                        .getValue(Action.LONG_DESCRIPTION));
0330:
0331:                action = new SaveFileAction(this , commandLine
0332:                        .getSingleSwitch("encoding"), commandLine
0333:                        .getSingleSwitch("dtd-prefix"));
0334:                menuItem = fileMenu.add(action);
0335:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
0336:                        Event.CTRL_MASK));
0337:                menuItem.setMnemonic('s');
0338:                button = toolbar.add(action);
0339:                button.setToolTipText((String) action
0340:                        .getValue(Action.LONG_DESCRIPTION));
0341:
0342:                if (commandLine.isPresent("indent-text")) {
0343:                    ((SaveFileAction) action).setIndentText(commandLine
0344:                            .getSingleSwitch("indent-text"));
0345:                }
0346:
0347:                toolbar.addSeparator();
0348:                fileMenu.addSeparator();
0349:
0350:                action = new NewDependencyGraphAction(this );
0351:                menuItem = fileMenu.add(action);
0352:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
0353:                        Event.CTRL_MASK));
0354:                menuItem.setMnemonic('n');
0355:                button = toolbar.add(action);
0356:                button.setToolTipText((String) action
0357:                        .getValue(Action.LONG_DESCRIPTION));
0358:
0359:                toolbar.addSeparator();
0360:                fileMenu.addSeparator();
0361:
0362:                action = new DependencyQueryAction(this );
0363:                menuItem = fileMenu.add(action);
0364:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
0365:                        Event.CTRL_MASK));
0366:                menuItem.setMnemonic('d');
0367:                button = toolbar.add(action);
0368:                button.setToolTipText((String) action
0369:                        .getValue(Action.LONG_DESCRIPTION));
0370:
0371:                action = new ClosureQueryAction(this );
0372:                menuItem = fileMenu.add(action);
0373:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
0374:                        Event.CTRL_MASK));
0375:                menuItem.setMnemonic('c');
0376:                button = toolbar.add(action);
0377:                button.setToolTipText((String) action
0378:                        .getValue(Action.LONG_DESCRIPTION));
0379:
0380:                action = new MetricsQueryAction(this );
0381:                menuItem = fileMenu.add(action);
0382:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,
0383:                        Event.CTRL_MASK));
0384:                menuItem.setMnemonic('m');
0385:                button = toolbar.add(action);
0386:                button.setToolTipText((String) action
0387:                        .getValue(Action.LONG_DESCRIPTION));
0388:
0389:                action = new AllQueriesAction(this );
0390:                menuItem = fileMenu.add(action);
0391:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
0392:                        Event.CTRL_MASK));
0393:                menuItem.setMnemonic('a');
0394:                button = toolbar.add(action);
0395:                button.setToolTipText((String) action
0396:                        .getValue(Action.LONG_DESCRIPTION));
0397:
0398:                toolbar.addSeparator();
0399:                fileMenu.addSeparator();
0400:
0401:                action = new ExitAction(this );
0402:                menuItem = fileMenu.add(action);
0403:                menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
0404:                        Event.CTRL_MASK));
0405:                menuItem.setMnemonic('x');
0406:            }
0407:
0408:            private void buildViewMenu() {
0409:                menuBar.add(viewMenu);
0410:
0411:                viewMenu.setText("View");
0412:
0413:                ButtonGroup group = new ButtonGroup();
0414:                JMenuItem menuItem;
0415:
0416:                menuItem = new JRadioButtonMenuItem(new SimpleQueryPanelAction(
0417:                        this ));
0418:                menuItem.setSelected(true);
0419:                group.add(menuItem);
0420:                viewMenu.add(menuItem);
0421:
0422:                menuItem = new JRadioButtonMenuItem(
0423:                        new AdvancedQueryPanelAction(this ));
0424:                group.add(menuItem);
0425:                viewMenu.add(menuItem);
0426:            }
0427:
0428:            private void buildHelpMenu() {
0429:                menuBar.add(helpMenu);
0430:
0431:                helpMenu.setText("Help");
0432:
0433:                Action action;
0434:                JMenuItem menuItem;
0435:
0436:                action = new AboutAction(this );
0437:                menuItem = helpMenu.add(action);
0438:                menuItem.setMnemonic('a');
0439:            }
0440:
0441:            private void buildUI() {
0442:                this .getContentPane().setLayout(new BorderLayout());
0443:                this .getContentPane().add(buildControlPanel(),
0444:                        BorderLayout.NORTH);
0445:                this .getContentPane().add(buildResultPanel(),
0446:                        BorderLayout.CENTER);
0447:                this .getContentPane().add(buildStatusPanel(),
0448:                        BorderLayout.SOUTH);
0449:            }
0450:
0451:            private JComponent buildControlPanel() {
0452:                JPanel result = new JPanel();
0453:
0454:                result.setLayout(new BorderLayout());
0455:                result.add(toolbar, BorderLayout.NORTH);
0456:                result.add(buildQueryPanel(), BorderLayout.CENTER);
0457:
0458:                return result;
0459:            }
0460:
0461:            JComponent buildQueryPanel() {
0462:                if (isAdvancedMode()) {
0463:                    buildAdvancedQueryPanel();
0464:                } else {
0465:                    buildSimpleQueryPanel();
0466:                }
0467:
0468:                return queryPanel;
0469:            }
0470:
0471:            private void buildSimpleQueryPanel() {
0472:                queryPanel.removeAll();
0473:                queryPanel.setLayout(new GridLayout(1, 2));
0474:                queryPanel.add(buildSimpleScopePanel());
0475:                queryPanel.add(buildSimpleFilterPanel());
0476:                queryPanel.revalidate();
0477:            }
0478:
0479:            private void buildAdvancedQueryPanel() {
0480:                queryPanel.removeAll();
0481:                queryPanel.setLayout(new GridLayout(1, 2));
0482:                queryPanel.add(buildAdvancedScopePanel());
0483:                queryPanel.add(buildAdvancedFilterPanel());
0484:                queryPanel.revalidate();
0485:            }
0486:
0487:            private JComponent buildSimpleScopePanel() {
0488:                JPanel result = new JPanel();
0489:
0490:                result.setBorder(BorderFactory
0491:                        .createTitledBorder("Select programming elements"));
0492:
0493:                result.setLayout(new BorderLayout());
0494:
0495:                result.add(buildSimpleScopePanelCheckboxes(),
0496:                        BorderLayout.NORTH);
0497:                result.add(buildSimpleScopePanelTextFields(),
0498:                        BorderLayout.SOUTH);
0499:
0500:                return result;
0501:            }
0502:
0503:            private JComponent buildSimpleScopePanelTextFields() {
0504:                JPanel result = new JPanel();
0505:
0506:                GridBagLayout gbl = new GridBagLayout();
0507:                GridBagConstraints c = new GridBagConstraints();
0508:                c.insets = new Insets(0, 2, 0, 2);
0509:
0510:                result.setLayout(gbl);
0511:
0512:                JLabel scopeIncludesLabel = new JLabel("including:");
0513:                c.anchor = GridBagConstraints.WEST;
0514:                c.fill = GridBagConstraints.NONE;
0515:                c.gridx = 0;
0516:                c.gridy = 0;
0517:                c.weightx = 0;
0518:                c.weighty = 0;
0519:                result.add(scopeIncludesLabel);
0520:                gbl.setConstraints(scopeIncludesLabel, c);
0521:
0522:                JLabel scopeExcludesLabel = new JLabel("excluding:");
0523:                c.anchor = GridBagConstraints.WEST;
0524:                c.fill = GridBagConstraints.NONE;
0525:                c.gridx = 1;
0526:                c.gridy = 0;
0527:                c.weightx = 0;
0528:                c.weighty = 0;
0529:                result.add(scopeExcludesLabel);
0530:                gbl.setConstraints(scopeExcludesLabel, c);
0531:
0532:                // -scope-includes
0533:                c.anchor = GridBagConstraints.WEST;
0534:                c.fill = GridBagConstraints.HORIZONTAL;
0535:                c.gridx = 0;
0536:                c.gridy = 1;
0537:                c.weightx = 1;
0538:                c.weighty = 0;
0539:                result.add(scopeIncludes);
0540:                gbl.setConstraints(scopeIncludes, c);
0541:
0542:                // -scope-excludes
0543:                c.anchor = GridBagConstraints.WEST;
0544:                c.fill = GridBagConstraints.HORIZONTAL;
0545:                c.gridx = 1;
0546:                c.gridy = 1;
0547:                c.weightx = 1;
0548:                c.weighty = 0;
0549:                result.add(scopeExcludes);
0550:                gbl.setConstraints(scopeExcludes, c);
0551:
0552:                return result;
0553:            }
0554:
0555:            private JComponent buildSimpleScopePanelCheckboxes() {
0556:                JPanel result = new JPanel();
0557:
0558:                GridBagLayout gbl = new GridBagLayout();
0559:                GridBagConstraints c = new GridBagConstraints();
0560:                c.insets = new Insets(0, 2, 0, 2);
0561:
0562:                result.setLayout(gbl);
0563:
0564:                // -package-scope
0565:                c.anchor = GridBagConstraints.EAST;
0566:                c.fill = GridBagConstraints.NONE;
0567:                c.gridx = 0;
0568:                c.gridy = 0;
0569:                c.weightx = 1;
0570:                c.weighty = 0;
0571:                result.add(packageScope);
0572:                gbl.setConstraints(packageScope, c);
0573:
0574:                // -class-scope
0575:                c.anchor = GridBagConstraints.CENTER;
0576:                c.fill = GridBagConstraints.NONE;
0577:                c.gridx = 1;
0578:                c.gridy = 0;
0579:                c.weightx = 0;
0580:                c.weighty = 0;
0581:                result.add(classScope);
0582:                gbl.setConstraints(classScope, c);
0583:
0584:                // -feature-scope
0585:                c.anchor = GridBagConstraints.WEST;
0586:                c.fill = GridBagConstraints.NONE;
0587:                c.gridx = 2;
0588:                c.gridy = 0;
0589:                c.weightx = 1;
0590:                c.weighty = 0;
0591:                result.add(featureScope);
0592:                gbl.setConstraints(featureScope, c);
0593:
0594:                return result;
0595:            }
0596:
0597:            private JComponent buildSimpleFilterPanel() {
0598:                JPanel result = new JPanel();
0599:
0600:                result
0601:                        .setBorder(BorderFactory
0602:                                .createTitledBorder("Show dependencies (stop for closure)"));
0603:
0604:                result.setLayout(new BorderLayout());
0605:
0606:                result.add(buildSimpleFilterPanelCheckboxes(),
0607:                        BorderLayout.NORTH);
0608:                result.add(buildSimpleFilterPanelTextFields(),
0609:                        BorderLayout.SOUTH);
0610:
0611:                return result;
0612:            }
0613:
0614:            private JComponent buildSimpleFilterPanelTextFields() {
0615:                JPanel result = new JPanel();
0616:
0617:                GridBagLayout gbl = new GridBagLayout();
0618:                GridBagConstraints c = new GridBagConstraints();
0619:                c.insets = new Insets(0, 2, 0, 2);
0620:
0621:                result.setLayout(gbl);
0622:
0623:                JLabel filterIncludesLabel = new JLabel("including:");
0624:                c.anchor = GridBagConstraints.WEST;
0625:                c.fill = GridBagConstraints.NONE;
0626:                c.gridx = 0;
0627:                c.gridy = 0;
0628:                c.weightx = 0;
0629:                c.weighty = 0;
0630:                result.add(filterIncludesLabel);
0631:                gbl.setConstraints(filterIncludesLabel, c);
0632:
0633:                JLabel filterExcludesLabel = new JLabel("excluding:");
0634:                c.anchor = GridBagConstraints.WEST;
0635:                c.fill = GridBagConstraints.NONE;
0636:                c.gridx = 1;
0637:                c.gridy = 0;
0638:                c.weightx = 0;
0639:                c.weighty = 0;
0640:                result.add(filterExcludesLabel);
0641:                gbl.setConstraints(filterExcludesLabel, c);
0642:
0643:                // -filter-includes
0644:                c.anchor = GridBagConstraints.WEST;
0645:                c.fill = GridBagConstraints.HORIZONTAL;
0646:                c.gridx = 0;
0647:                c.gridy = 1;
0648:                c.weightx = 1;
0649:                c.weighty = 0;
0650:                result.add(filterIncludes);
0651:                gbl.setConstraints(filterIncludes, c);
0652:
0653:                // -filter-excludes
0654:                c.anchor = GridBagConstraints.WEST;
0655:                c.fill = GridBagConstraints.HORIZONTAL;
0656:                c.gridx = 1;
0657:                c.gridy = 1;
0658:                c.weightx = 1;
0659:                c.weighty = 0;
0660:                result.add(filterExcludes);
0661:                gbl.setConstraints(filterExcludes, c);
0662:
0663:                return result;
0664:            }
0665:
0666:            private JComponent buildSimpleFilterPanelCheckboxes() {
0667:                JPanel result = new JPanel();
0668:
0669:                GridBagLayout gbl = new GridBagLayout();
0670:                GridBagConstraints c = new GridBagConstraints();
0671:                c.insets = new Insets(0, 2, 0, 2);
0672:
0673:                result.setLayout(gbl);
0674:
0675:                // -package-filter
0676:                c.anchor = GridBagConstraints.EAST;
0677:                c.fill = GridBagConstraints.NONE;
0678:                c.gridx = 0;
0679:                c.gridy = 0;
0680:                c.weightx = 1;
0681:                c.weighty = 0;
0682:                result.add(packageFilter);
0683:                gbl.setConstraints(packageFilter, c);
0684:
0685:                // -class-filter
0686:                c.anchor = GridBagConstraints.CENTER;
0687:                c.fill = GridBagConstraints.NONE;
0688:                c.gridx = 1;
0689:                c.gridy = 0;
0690:                c.weightx = 0;
0691:                c.weighty = 0;
0692:                result.add(classFilter);
0693:                gbl.setConstraints(classFilter, c);
0694:
0695:                // -feature-filter
0696:                c.anchor = GridBagConstraints.WEST;
0697:                c.fill = GridBagConstraints.NONE;
0698:                c.gridx = 2;
0699:                c.gridy = 0;
0700:                c.weightx = 1;
0701:                c.weighty = 0;
0702:                result.add(featureFilter);
0703:                gbl.setConstraints(featureFilter, c);
0704:
0705:                return result;
0706:            }
0707:
0708:            private JComponent buildAdvancedScopePanel() {
0709:                JPanel result = new JPanel();
0710:
0711:                result.setBorder(BorderFactory
0712:                        .createTitledBorder("Select programming elements"));
0713:
0714:                GridBagLayout gbl = new GridBagLayout();
0715:                GridBagConstraints c = new GridBagConstraints();
0716:                c.insets = new Insets(2, 0, 2, 5);
0717:
0718:                result.setLayout(gbl);
0719:
0720:                // -package-scope
0721:                c.anchor = GridBagConstraints.WEST;
0722:                c.fill = GridBagConstraints.NONE;
0723:                c.gridx = 0;
0724:                c.gridy = 2;
0725:                c.weightx = 0;
0726:                c.weighty = 0;
0727:                result.add(packageScope);
0728:                gbl.setConstraints(packageScope, c);
0729:
0730:                // -class-scope
0731:                c.anchor = GridBagConstraints.WEST;
0732:                c.fill = GridBagConstraints.NONE;
0733:                c.gridx = 0;
0734:                c.gridy = 3;
0735:                c.weightx = 0;
0736:                c.weighty = 0;
0737:                result.add(classScope);
0738:                gbl.setConstraints(classScope, c);
0739:
0740:                // -feature-scope
0741:                c.anchor = GridBagConstraints.WEST;
0742:                c.fill = GridBagConstraints.NONE;
0743:                c.gridx = 0;
0744:                c.gridy = 4;
0745:                c.weightx = 0;
0746:                c.weighty = 0;
0747:                result.add(featureScope);
0748:                gbl.setConstraints(featureScope, c);
0749:
0750:                JLabel scopeIncludesLabel = new JLabel("including:");
0751:                c.anchor = GridBagConstraints.WEST;
0752:                c.fill = GridBagConstraints.NONE;
0753:                c.gridx = 1;
0754:                c.gridy = 0;
0755:                c.weightx = 0;
0756:                c.weighty = 0;
0757:                result.add(scopeIncludesLabel);
0758:                gbl.setConstraints(scopeIncludesLabel, c);
0759:
0760:                // -scope-includes
0761:                c.anchor = GridBagConstraints.WEST;
0762:                c.fill = GridBagConstraints.HORIZONTAL;
0763:                c.gridx = 1;
0764:                c.gridy = 1;
0765:                c.weightx = 1;
0766:                c.weighty = 0;
0767:                result.add(scopeIncludes);
0768:                gbl.setConstraints(scopeIncludes, c);
0769:
0770:                // -package-scope-includes
0771:                c.anchor = GridBagConstraints.WEST;
0772:                c.fill = GridBagConstraints.HORIZONTAL;
0773:                c.gridx = 1;
0774:                c.gridy = 2;
0775:                c.weightx = 1;
0776:                c.weighty = 0;
0777:                result.add(packageScopeIncludes);
0778:                gbl.setConstraints(packageScopeIncludes, c);
0779:
0780:                // -class-scope-includes
0781:                c.anchor = GridBagConstraints.WEST;
0782:                c.fill = GridBagConstraints.HORIZONTAL;
0783:                c.gridx = 1;
0784:                c.gridy = 3;
0785:                c.weightx = 1;
0786:                c.weighty = 0;
0787:                result.add(classScopeIncludes);
0788:                gbl.setConstraints(classScopeIncludes, c);
0789:
0790:                // -feature-scope-includes
0791:                c.anchor = GridBagConstraints.WEST;
0792:                c.fill = GridBagConstraints.HORIZONTAL;
0793:                c.gridx = 1;
0794:                c.gridy = 4;
0795:                c.weightx = 1;
0796:                c.weighty = 0;
0797:                result.add(featureScopeIncludes);
0798:                gbl.setConstraints(featureScopeIncludes, c);
0799:
0800:                JLabel scopeExcludesLabel = new JLabel("excluding:");
0801:                c.anchor = GridBagConstraints.WEST;
0802:                c.fill = GridBagConstraints.NONE;
0803:                c.gridx = 2;
0804:                c.gridy = 0;
0805:                c.weightx = 0;
0806:                c.weighty = 0;
0807:                result.add(scopeExcludesLabel);
0808:                gbl.setConstraints(scopeExcludesLabel, c);
0809:
0810:                // -scope-excludes
0811:                c.anchor = GridBagConstraints.WEST;
0812:                c.fill = GridBagConstraints.HORIZONTAL;
0813:                c.gridx = 2;
0814:                c.gridy = 1;
0815:                c.weightx = 1;
0816:                c.weighty = 0;
0817:                result.add(scopeExcludes);
0818:                gbl.setConstraints(scopeExcludes, c);
0819:
0820:                // -package-scope-excludes
0821:                c.anchor = GridBagConstraints.WEST;
0822:                c.fill = GridBagConstraints.HORIZONTAL;
0823:                c.gridx = 2;
0824:                c.gridy = 2;
0825:                c.weightx = 1;
0826:                c.weighty = 0;
0827:                result.add(packageScopeExcludes);
0828:                gbl.setConstraints(packageScopeExcludes, c);
0829:
0830:                // -class-scope-excludes
0831:                c.anchor = GridBagConstraints.WEST;
0832:                c.fill = GridBagConstraints.HORIZONTAL;
0833:                c.gridx = 2;
0834:                c.gridy = 3;
0835:                c.weightx = 1;
0836:                c.weighty = 0;
0837:                result.add(classScopeExcludes);
0838:                gbl.setConstraints(classScopeExcludes, c);
0839:
0840:                // -feature-scope-excludes
0841:                c.anchor = GridBagConstraints.WEST;
0842:                c.fill = GridBagConstraints.HORIZONTAL;
0843:                c.gridx = 2;
0844:                c.gridy = 4;
0845:                c.weightx = 1;
0846:                c.weighty = 0;
0847:                result.add(featureScopeExcludes);
0848:                gbl.setConstraints(featureScopeExcludes, c);
0849:
0850:                return result;
0851:            }
0852:
0853:            private JComponent buildAdvancedFilterPanel() {
0854:                JPanel result = new JPanel();
0855:
0856:                result
0857:                        .setBorder(BorderFactory
0858:                                .createTitledBorder("Show dependencies (stop for closure)"));
0859:
0860:                GridBagLayout gbl = new GridBagLayout();
0861:                GridBagConstraints c = new GridBagConstraints();
0862:                c.insets = new Insets(2, 0, 2, 5);
0863:
0864:                result.setLayout(gbl);
0865:
0866:                // -package-filter
0867:                c.anchor = GridBagConstraints.WEST;
0868:                c.fill = GridBagConstraints.NONE;
0869:                c.gridx = 0;
0870:                c.gridy = 2;
0871:                c.weightx = 0;
0872:                c.weighty = 0;
0873:                result.add(packageFilter);
0874:                gbl.setConstraints(packageFilter, c);
0875:
0876:                // -class-filter
0877:                c.anchor = GridBagConstraints.WEST;
0878:                c.fill = GridBagConstraints.NONE;
0879:                c.gridx = 0;
0880:                c.gridy = 3;
0881:                c.weightx = 0;
0882:                c.weighty = 0;
0883:                result.add(classFilter);
0884:                gbl.setConstraints(classFilter, c);
0885:
0886:                // -feature-filter
0887:                c.anchor = GridBagConstraints.WEST;
0888:                c.fill = GridBagConstraints.NONE;
0889:                c.gridx = 0;
0890:                c.gridy = 4;
0891:                c.weightx = 0;
0892:                c.weighty = 0;
0893:                result.add(featureFilter);
0894:                gbl.setConstraints(featureFilter, c);
0895:
0896:                JLabel filterIncludesLabel = new JLabel("including:");
0897:                c.anchor = GridBagConstraints.WEST;
0898:                c.fill = GridBagConstraints.NONE;
0899:                c.gridx = 1;
0900:                c.gridy = 0;
0901:                c.weightx = 0;
0902:                c.weighty = 0;
0903:                result.add(filterIncludesLabel);
0904:                gbl.setConstraints(filterIncludesLabel, c);
0905:
0906:                // -filter-includes
0907:                c.anchor = GridBagConstraints.WEST;
0908:                c.fill = GridBagConstraints.HORIZONTAL;
0909:                c.gridx = 1;
0910:                c.gridy = 1;
0911:                c.weightx = 1;
0912:                c.weighty = 0;
0913:                result.add(filterIncludes);
0914:                gbl.setConstraints(filterIncludes, c);
0915:
0916:                // -package-filter-includes
0917:                c.anchor = GridBagConstraints.WEST;
0918:                c.fill = GridBagConstraints.HORIZONTAL;
0919:                c.gridx = 1;
0920:                c.gridy = 2;
0921:                c.weightx = 1;
0922:                c.weighty = 0;
0923:                result.add(packageFilterIncludes);
0924:                gbl.setConstraints(packageFilterIncludes, c);
0925:
0926:                // -class-filter-includes
0927:                c.anchor = GridBagConstraints.WEST;
0928:                c.fill = GridBagConstraints.HORIZONTAL;
0929:                c.gridx = 1;
0930:                c.gridy = 3;
0931:                c.weightx = 1;
0932:                c.weighty = 0;
0933:                result.add(classFilterIncludes);
0934:                gbl.setConstraints(classFilterIncludes, c);
0935:
0936:                // -feature-filter-includes
0937:                c.anchor = GridBagConstraints.WEST;
0938:                c.fill = GridBagConstraints.HORIZONTAL;
0939:                c.gridx = 1;
0940:                c.gridy = 4;
0941:                c.weightx = 1;
0942:                c.weighty = 0;
0943:                result.add(featureFilterIncludes);
0944:                gbl.setConstraints(featureFilterIncludes, c);
0945:
0946:                JLabel filterExcludesLabel = new JLabel("excluding:");
0947:                c.anchor = GridBagConstraints.WEST;
0948:                c.fill = GridBagConstraints.NONE;
0949:                c.gridx = 2;
0950:                c.gridy = 0;
0951:                c.weightx = 0;
0952:                c.weighty = 0;
0953:                result.add(filterExcludesLabel);
0954:                gbl.setConstraints(filterExcludesLabel, c);
0955:
0956:                // -filter-excludes
0957:                c.anchor = GridBagConstraints.WEST;
0958:                c.fill = GridBagConstraints.HORIZONTAL;
0959:                c.gridx = 2;
0960:                c.gridy = 1;
0961:                c.weightx = 1;
0962:                c.weighty = 0;
0963:                result.add(filterExcludes);
0964:                gbl.setConstraints(filterExcludes, c);
0965:
0966:                // -package-filter-excludes
0967:                c.anchor = GridBagConstraints.WEST;
0968:                c.fill = GridBagConstraints.HORIZONTAL;
0969:                c.gridx = 2;
0970:                c.gridy = 2;
0971:                c.weightx = 1;
0972:                c.weighty = 0;
0973:                result.add(packageFilterExcludes);
0974:                gbl.setConstraints(packageFilterExcludes, c);
0975:
0976:                // -class-filter-excludes
0977:                c.anchor = GridBagConstraints.WEST;
0978:                c.fill = GridBagConstraints.HORIZONTAL;
0979:                c.gridx = 2;
0980:                c.gridy = 3;
0981:                c.weightx = 1;
0982:                c.weighty = 0;
0983:                result.add(classFilterExcludes);
0984:                gbl.setConstraints(classFilterExcludes, c);
0985:
0986:                // -feature-filter-excludes
0987:                c.anchor = GridBagConstraints.WEST;
0988:                c.fill = GridBagConstraints.HORIZONTAL;
0989:                c.gridx = 2;
0990:                c.gridy = 4;
0991:                c.weightx = 1;
0992:                c.weighty = 0;
0993:                result.add(featureFilterExcludes);
0994:                gbl.setConstraints(featureFilterExcludes, c);
0995:
0996:                return result;
0997:            }
0998:
0999:            private JComponent buildResultPanel() {
1000:                JTabbedPane result = new JTabbedPane();
1001:
1002:                result.setBorder(BorderFactory.createTitledBorder("Results"));
1003:                result.addTab("Dependencies", buildDependenciesPanel());
1004:                result.addTab("Closure", buildClosurePanel());
1005:                result.addTab("Metrics", buildMetricsPanel());
1006:
1007:                return result;
1008:            }
1009:
1010:            private JComponent buildDependenciesPanel() {
1011:                JPanel result = new JPanel();
1012:
1013:                result.setLayout(new BorderLayout());
1014:                result.add(buildPrinterControlPanel(), BorderLayout.NORTH);
1015:                result.add(buildDependenciesResultPanel(), BorderLayout.CENTER);
1016:
1017:                return result;
1018:            }
1019:
1020:            private JComponent buildPrinterControlPanel() {
1021:                JPanel result = new JPanel();
1022:
1023:                result.add(new JLabel("Show "));
1024:                result.add(showInbounds);
1025:                result.add(showOutbounds);
1026:                result.add(showEmptyNodes);
1027:                result.add(copyOnly);
1028:
1029:                PrinterControlAction action = new PrinterControlAction(this );
1030:                showInbounds.addActionListener(action);
1031:                showOutbounds.addActionListener(action);
1032:                showEmptyNodes.addActionListener(action);
1033:
1034:                return result;
1035:            }
1036:
1037:            private JComponent buildDependenciesResultPanel() {
1038:                JComponent result = new JScrollPane(dependenciesResultArea);
1039:
1040:                dependenciesResultArea.setEditable(false);
1041:                dependenciesResultArea.setFont(getCodeFont(Font.PLAIN, 12));
1042:
1043:                return result;
1044:            }
1045:
1046:            private JComponent buildClosurePanel() {
1047:                JPanel result = new JPanel();
1048:
1049:                result.setLayout(new BorderLayout());
1050:                result.add(buildClosureControlPanel(), BorderLayout.NORTH);
1051:                result.add(buildClosureResultPanel(), BorderLayout.CENTER);
1052:
1053:                return result;
1054:            }
1055:
1056:            private JComponent buildClosureControlPanel() {
1057:                JPanel result = new JPanel();
1058:
1059:                result.add(new JLabel("Follow inbounds: "));
1060:                result.add(maximumInboundDepth);
1061:                result.add(new JLabel("Follow outbounds: "));
1062:                result.add(maximumOutboundDepth);
1063:
1064:                return result;
1065:            }
1066:
1067:            private JComponent buildClosureResultPanel() {
1068:                JComponent result = new JScrollPane(closureResultArea);
1069:
1070:                closureResultArea.setEditable(false);
1071:                closureResultArea.setFont(getCodeFont(Font.PLAIN, 12));
1072:
1073:                return result;
1074:            }
1075:
1076:            private JComponent buildMetricsPanel() {
1077:                return new JSplitPane(JSplitPane.VERTICAL_SPLIT,
1078:                        buildMetricsResultPanel(), buildMetricsChartPanel());
1079:            }
1080:
1081:            private JComponent buildMetricsResultPanel() {
1082:                JComponent result = new JScrollPane(metricsResultArea);
1083:
1084:                metricsResultArea.setEditable(false);
1085:
1086:                return result;
1087:            }
1088:
1089:            private JComponent buildMetricsChartPanel() {
1090:                JComponent result;
1091:
1092:                JTable table = new JTable(metricsChartModel);
1093:
1094:                table.setCellSelectionEnabled(true);
1095:                table.setColumnSelectionAllowed(true);
1096:
1097:                result = new JScrollPane(table);
1098:
1099:                return result;
1100:            }
1101:
1102:            private JComponent buildStatusPanel() {
1103:                JPanel result = new JPanel();
1104:
1105:                Dimension size = getProgressBar().getPreferredSize();
1106:                size.width = 100;
1107:                getProgressBar().setPreferredSize(size);
1108:                getProgressBar().setBorder(
1109:                        BorderFactory.createBevelBorder(BevelBorder.LOWERED));
1110:
1111:                result.setLayout(new BorderLayout());
1112:                result.add(getStatusLine(), BorderLayout.CENTER);
1113:                result.add(getProgressBar(), BorderLayout.EAST);
1114:
1115:                return result;
1116:            }
1117:
1118:            public void resetQuery() {
1119:                packageScope.setSelected(true);
1120:                classScope.setSelected(false);
1121:                featureScope.setSelected(false);
1122:                scopeIncludes.setText("//");
1123:                packageScopeIncludes.setText("");
1124:                classScopeIncludes.setText("");
1125:                featureScopeIncludes.setText("");
1126:                scopeExcludes.setText("");
1127:                packageScopeExcludes.setText("");
1128:                classScopeExcludes.setText("");
1129:                featureScopeExcludes.setText("");
1130:
1131:                packageFilter.setSelected(true);
1132:                classFilter.setSelected(false);
1133:                featureFilter.setSelected(false);
1134:                filterIncludes.setText("//");
1135:                packageFilterIncludes.setText("");
1136:                classFilterIncludes.setText("");
1137:                featureFilterIncludes.setText("");
1138:                filterExcludes.setText("");
1139:                packageFilterExcludes.setText("");
1140:                classFilterExcludes.setText("");
1141:                featureFilterExcludes.setText("");
1142:
1143:                showInbounds.setSelected(true);
1144:                showOutbounds.setSelected(true);
1145:                showEmptyNodes.setSelected(true);
1146:                copyOnly.setSelected(false);
1147:            }
1148:
1149:            void clearDependencyResult() {
1150:                dependenciesQuery = null;
1151:                dependenciesResultArea.setText("");
1152:            }
1153:
1154:            void doDependencyQuery() {
1155:                RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1156:
1157:                scopeCriteria.setMatchingPackages(packageScope.isSelected());
1158:                scopeCriteria.setMatchingClasses(classScope.isSelected());
1159:                scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1160:                scopeCriteria.setGlobalIncludes(scopeIncludes.getText());
1161:                scopeCriteria.setGlobalExcludes(scopeExcludes.getText());
1162:
1163:                if (isAdvancedMode()) {
1164:                    scopeCriteria.setPackageIncludes(packageScopeIncludes
1165:                            .getText());
1166:                    scopeCriteria
1167:                            .setClassIncludes(classScopeIncludes.getText());
1168:                    scopeCriteria.setFeatureIncludes(featureScopeIncludes
1169:                            .getText());
1170:                    scopeCriteria.setPackageExcludes(packageScopeExcludes
1171:                            .getText());
1172:                    scopeCriteria
1173:                            .setClassExcludes(classScopeExcludes.getText());
1174:                    scopeCriteria.setFeatureExcludes(featureScopeExcludes
1175:                            .getText());
1176:                }
1177:
1178:                RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1179:
1180:                filterCriteria.setMatchingPackages(packageFilter.isSelected());
1181:                filterCriteria.setMatchingClasses(classFilter.isSelected());
1182:                filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1183:                filterCriteria.setGlobalIncludes(filterIncludes.getText());
1184:                filterCriteria.setGlobalExcludes(filterExcludes.getText());
1185:
1186:                if (isAdvancedMode()) {
1187:                    filterCriteria.setPackageIncludes(packageFilterIncludes
1188:                            .getText());
1189:                    filterCriteria.setClassIncludes(classFilterIncludes
1190:                            .getText());
1191:                    filterCriteria.setFeatureIncludes(featureFilterIncludes
1192:                            .getText());
1193:                    filterCriteria.setPackageExcludes(packageFilterExcludes
1194:                            .getText());
1195:                    filterCriteria.setClassExcludes(classFilterExcludes
1196:                            .getText());
1197:                    filterCriteria.setFeatureExcludes(featureFilterExcludes
1198:                            .getText());
1199:                }
1200:
1201:                if ((isAdvancedMode() && copyOnly.isSelected())
1202:                        || getMaximize()) {
1203:                    TraversalStrategy strategy = new SelectiveTraversalStrategy(
1204:                            scopeCriteria, filterCriteria);
1205:                    dependenciesQuery = new GraphCopier(strategy);
1206:                } else {
1207:                    dependenciesQuery = new GraphSummarizer(scopeCriteria,
1208:                            filterCriteria);
1209:                }
1210:
1211:                dependenciesQuery.traverseNodes(getPackages());
1212:
1213:                refreshDependenciesDisplay();
1214:            }
1215:
1216:            void refreshDependenciesDisplay() {
1217:                if (dependenciesQuery != null) {
1218:                    StringWriter out = new StringWriter();
1219:                    com.jeantessier.dependency.TextPrinter printer = new com.jeantessier.dependency.TextPrinter(
1220:                            new PrintWriter(out));
1221:
1222:                    printer.setShowInbounds(showInbounds.isSelected());
1223:                    printer.setShowOutbounds(showOutbounds.isSelected());
1224:                    printer.setShowEmptyNodes(showEmptyNodes.isSelected());
1225:
1226:                    printer.traverseNodes(dependenciesQuery.getScopeFactory()
1227:                            .getPackages().values());
1228:
1229:                    dependenciesResultArea.setText(out.toString());
1230:                }
1231:            }
1232:
1233:            void clearClosureResult() {
1234:                closureResultArea.setText("");
1235:            }
1236:
1237:            void doClosureQuery() {
1238:                RegularExpressionSelectionCriteria startCriteria = new RegularExpressionSelectionCriteria();
1239:
1240:                startCriteria.setGlobalIncludes(scopeIncludes.getText());
1241:                startCriteria.setGlobalExcludes(scopeExcludes.getText());
1242:
1243:                if (isAdvancedMode()) {
1244:                    startCriteria.setPackageIncludes(packageScopeIncludes
1245:                            .getText());
1246:                    startCriteria
1247:                            .setClassIncludes(classScopeIncludes.getText());
1248:                    startCriteria.setFeatureIncludes(featureScopeIncludes
1249:                            .getText());
1250:                    startCriteria.setPackageExcludes(packageScopeExcludes
1251:                            .getText());
1252:                    startCriteria
1253:                            .setClassExcludes(classScopeExcludes.getText());
1254:                    startCriteria.setFeatureExcludes(featureScopeExcludes
1255:                            .getText());
1256:                }
1257:
1258:                RegularExpressionSelectionCriteria stopCriteria = new RegularExpressionSelectionCriteria();
1259:
1260:                stopCriteria.setGlobalIncludes(filterIncludes.getText());
1261:                stopCriteria.setGlobalExcludes(filterExcludes.getText());
1262:
1263:                if (isAdvancedMode()) {
1264:                    stopCriteria.setPackageIncludes(packageFilterIncludes
1265:                            .getText());
1266:                    stopCriteria
1267:                            .setClassIncludes(classFilterIncludes.getText());
1268:                    stopCriteria.setFeatureIncludes(featureFilterIncludes
1269:                            .getText());
1270:                    stopCriteria.setPackageExcludes(packageFilterExcludes
1271:                            .getText());
1272:                    stopCriteria
1273:                            .setClassExcludes(classFilterExcludes.getText());
1274:                    stopCriteria.setFeatureExcludes(featureFilterExcludes
1275:                            .getText());
1276:                }
1277:
1278:                TransitiveClosure selector = new TransitiveClosure(
1279:                        startCriteria, stopCriteria);
1280:
1281:                try {
1282:                    selector.setMaximumInboundDepth(Long
1283:                            .parseLong(maximumInboundDepth.getText()));
1284:                } catch (NumberFormatException ex) {
1285:                    selector
1286:                            .setMaximumInboundDepth(TransitiveClosure.UNBOUNDED_DEPTH);
1287:                }
1288:
1289:                try {
1290:                    selector.setMaximumOutboundDepth(Long
1291:                            .parseLong(maximumOutboundDepth.getText()));
1292:                } catch (NumberFormatException ex) {
1293:                    selector
1294:                            .setMaximumOutboundDepth(TransitiveClosure.UNBOUNDED_DEPTH);
1295:                }
1296:
1297:                selector.traverseNodes(getPackages());
1298:
1299:                RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1300:
1301:                scopeCriteria.setMatchingPackages(packageScope.isSelected());
1302:                scopeCriteria.setMatchingClasses(classScope.isSelected());
1303:                scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1304:                scopeCriteria.setGlobalIncludes("//");
1305:
1306:                RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1307:
1308:                filterCriteria.setMatchingPackages(packageFilter.isSelected());
1309:                filterCriteria.setMatchingClasses(classFilter.isSelected());
1310:                filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1311:                filterCriteria.setGlobalIncludes("//");
1312:
1313:                GraphSummarizer summarizer = new GraphSummarizer(scopeCriteria,
1314:                        filterCriteria);
1315:                summarizer.traverseNodes(selector.getFactory().getPackages()
1316:                        .values());
1317:
1318:                StringWriter out = new StringWriter();
1319:                com.jeantessier.dependency.Printer printer = new com.jeantessier.dependency.TextPrinter(
1320:                        new PrintWriter(out));
1321:                printer.traverseNodes(summarizer.getScopeFactory()
1322:                        .getPackages().values());
1323:                closureResultArea.setText(out.toString());
1324:            }
1325:
1326:            void clearMetricsResult() {
1327:                metricsResultArea.setText("");
1328:            }
1329:
1330:            void doMetricsQuery() {
1331:                RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1332:
1333:                scopeCriteria.setMatchingPackages(packageScope.isSelected());
1334:                scopeCriteria.setMatchingClasses(classScope.isSelected());
1335:                scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1336:                scopeCriteria.setGlobalIncludes(scopeIncludes.getText());
1337:                scopeCriteria.setGlobalExcludes(scopeExcludes.getText());
1338:
1339:                if (isAdvancedMode()) {
1340:                    scopeCriteria.setPackageIncludes(packageScopeIncludes
1341:                            .getText());
1342:                    scopeCriteria
1343:                            .setClassIncludes(classScopeIncludes.getText());
1344:                    scopeCriteria.setFeatureIncludes(featureScopeIncludes
1345:                            .getText());
1346:                    scopeCriteria.setPackageExcludes(packageScopeExcludes
1347:                            .getText());
1348:                    scopeCriteria
1349:                            .setClassExcludes(classScopeExcludes.getText());
1350:                    scopeCriteria.setFeatureExcludes(featureScopeExcludes
1351:                            .getText());
1352:                }
1353:
1354:                RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1355:
1356:                filterCriteria.setMatchingPackages(packageFilter.isSelected());
1357:                filterCriteria.setMatchingClasses(classFilter.isSelected());
1358:                filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1359:                filterCriteria.setGlobalIncludes(filterIncludes.getText());
1360:                filterCriteria.setGlobalExcludes(filterExcludes.getText());
1361:
1362:                if (isAdvancedMode()) {
1363:                    filterCriteria.setPackageIncludes(packageFilterIncludes
1364:                            .getText());
1365:                    filterCriteria.setClassIncludes(classFilterIncludes
1366:                            .getText());
1367:                    filterCriteria.setFeatureIncludes(featureFilterIncludes
1368:                            .getText());
1369:                    filterCriteria.setPackageExcludes(packageFilterExcludes
1370:                            .getText());
1371:                    filterCriteria.setClassExcludes(classFilterExcludes
1372:                            .getText());
1373:                    filterCriteria.setFeatureExcludes(featureFilterExcludes
1374:                            .getText());
1375:                }
1376:
1377:                TraversalStrategy strategy = new SelectiveTraversalStrategy(
1378:                        scopeCriteria, filterCriteria);
1379:                com.jeantessier.dependency.MetricsGatherer metrics = new com.jeantessier.dependency.MetricsGatherer(
1380:                        strategy);
1381:
1382:                metrics.traverseNodes(getPackages());
1383:
1384:                StringWriter out = new StringWriter();
1385:                MetricsReport report = new MetricsReport(new PrintWriter(out));
1386:                report.process(metrics);
1387:
1388:                metricsResultArea.setText(out.toString());
1389:                metricsChartModel.setMetrics(metrics);
1390:            }
1391:
1392:            void setNewDependencyGraph() {
1393:                setInputFiles(new LinkedList<String>());
1394:                setClassfileLoaderDispatcher(new ModifiedOnlyDispatcher(
1395:                        ClassfileLoaderEventSource.DEFAULT_DISPATCHER));
1396:
1397:                NodeFactory factory = new NodeFactory();
1398:                setNodeFactory(factory);
1399:
1400:                CodeDependencyCollector collector = new CodeDependencyCollector(
1401:                        factory);
1402:                DeletingVisitor deletingVisitor = new DeletingVisitor(factory);
1403:                setMonitor(new Monitor(collector, deletingVisitor));
1404:
1405:                resetQuery();
1406:            }
1407:
1408:            public static void showError(CommandLineUsage clu, String msg) {
1409:                System.err.println(msg);
1410:                showError(clu);
1411:            }
1412:
1413:            public static void showError(CommandLineUsage clu) {
1414:                System.err.println(clu);
1415:            }
1416:
1417:            public static void main(String[] args) {
1418:                // Parsing the command line
1419:                CommandLine commandLine = new CommandLine(
1420:                        new NullParameterStrategy());
1421:                commandLine.addToggleSwitch("minimize");
1422:                commandLine.addToggleSwitch("maximize");
1423:                commandLine.addSingleValueSwitch("encoding",
1424:                        com.jeantessier.dependency.XMLPrinter.DEFAULT_ENCODING);
1425:                commandLine
1426:                        .addSingleValueSwitch(
1427:                                "dtd-prefix",
1428:                                com.jeantessier.dependency.XMLPrinter.DEFAULT_DTD_PREFIX);
1429:                commandLine.addSingleValueSwitch("indent-text");
1430:                commandLine.addToggleSwitch("help");
1431:
1432:                CommandLineUsage usage = new CommandLineUsage(
1433:                        "DependencyFinder");
1434:                commandLine.accept(usage);
1435:
1436:                try {
1437:                    commandLine.parse(args);
1438:                } catch (IllegalArgumentException ex) {
1439:                    showError(usage, ex.toString());
1440:                    System.exit(1);
1441:                }
1442:
1443:                if (commandLine.getToggleSwitch("help")) {
1444:                    showError(usage);
1445:                    System.exit(1);
1446:                }
1447:
1448:                if (commandLine.getToggleSwitch("maximize")
1449:                        && commandLine.getToggleSwitch("minimize")) {
1450:                    showError(usage,
1451:                            "Only one of -maximize or -minimize allowed");
1452:                }
1453:
1454:                /*
1455:                 *  Beginning of main processing
1456:                 */
1457:
1458:                try {
1459:                    UIManager.setLookAndFeel(UIManager
1460:                            .getSystemLookAndFeelClassName());
1461:                } catch (Exception ex) {
1462:                    // Ignore
1463:                }
1464:
1465:                DependencyFinder model = new DependencyFinder(commandLine);
1466:                model.setMaximize(commandLine.getToggleSwitch("maximize"));
1467:                model.setMinimize(commandLine.getToggleSwitch("minimize"));
1468:                model.setVisible(true);
1469:            }
1470:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.