EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.dependencyfinder.gui]

COVERAGE SUMMARY FOR SOURCE FILE [DependencyFinder.java]

nameclass, %method, %block, %line, %
DependencyFinder.java0%   (0/1)0%   (0/60)0%   (0/3506)0%   (0/881)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DependencyFinder0%   (0/1)0%   (0/60)0%   (0/3506)0%   (0/881)
DependencyFinder (CommandLine): void 0%   (0/1)0%   (0/411)0%   (0/92)
addInputFile (File): void 0%   (0/1)0%   (0/7)0%   (0/2)
buildAdvancedFilterPanel (): JComponent 0%   (0/1)0%   (0/400)0%   (0/113)
buildAdvancedQueryPanel (): void 0%   (0/1)0%   (0/27)0%   (0/6)
buildAdvancedScopePanel (): JComponent 0%   (0/1)0%   (0/400)0%   (0/113)
buildClosureControlPanel (): JComponent 0%   (0/1)0%   (0/30)0%   (0/6)
buildClosurePanel (): JComponent 0%   (0/1)0%   (0/21)0%   (0/5)
buildClosureResultPanel (): JComponent 0%   (0/1)0%   (0/19)0%   (0/4)
buildControlPanel (): JComponent 0%   (0/1)0%   (0/21)0%   (0/5)
buildDependenciesPanel (): JComponent 0%   (0/1)0%   (0/21)0%   (0/5)
buildDependenciesResultPanel (): JComponent 0%   (0/1)0%   (0/19)0%   (0/4)
buildFileMenu (CommandLine): void 0%   (0/1)0%   (0/330)0%   (0/71)
buildHelpMenu (): void 0%   (0/1)0%   (0/24)0%   (0/6)
buildMenus (CommandLine): void 0%   (0/1)0%   (0/12)0%   (0/5)
buildMetricsChartPanel (): JComponent 0%   (0/1)0%   (0/19)0%   (0/5)
buildMetricsPanel (): JComponent 0%   (0/1)0%   (0/9)0%   (0/1)
buildMetricsResultPanel (): JComponent 0%   (0/1)0%   (0/12)0%   (0/3)
buildPrinterControlPanel (): JComponent 0%   (0/1)0%   (0/50)0%   (0/11)
buildQueryPanel (): JComponent 0%   (0/1)0%   (0/11)0%   (0/4)
buildResultPanel (): JComponent 0%   (0/1)0%   (0/25)0%   (0/6)
buildSimpleFilterPanel (): JComponent 0%   (0/1)0%   (0/25)0%   (0/6)
buildSimpleFilterPanelCheckboxes (): JComponent 0%   (0/1)0%   (0/110)0%   (0/30)
buildSimpleFilterPanelTextFields (): JComponent 0%   (0/1)0%   (0/144)0%   (0/40)
buildSimpleQueryPanel (): void 0%   (0/1)0%   (0/27)0%   (0/6)
buildSimpleScopePanel (): JComponent 0%   (0/1)0%   (0/25)0%   (0/6)
buildSimpleScopePanelCheckboxes (): JComponent 0%   (0/1)0%   (0/110)0%   (0/30)
buildSimpleScopePanelTextFields (): JComponent 0%   (0/1)0%   (0/144)0%   (0/40)
buildStatusPanel (): JComponent 0%   (0/1)0%   (0/37)0%   (0/9)
buildUI (): void 0%   (0/1)0%   (0/25)0%   (0/5)
buildViewMenu (): void 0%   (0/1)0%   (0/50)0%   (0/11)
clearClosureResult (): void 0%   (0/1)0%   (0/5)0%   (0/2)
clearDependencyResult (): void 0%   (0/1)0%   (0/8)0%   (0/3)
clearMetricsResult (): void 0%   (0/1)0%   (0/5)0%   (0/2)
doClosureQuery (): void 0%   (0/1)0%   (0/206)0%   (0/47)
doDependencyQuery (): void 0%   (0/1)0%   (0/162)0%   (0/34)
doMetricsQuery (): void 0%   (0/1)0%   (0/164)0%   (0/35)
getClassfileLoaderDispatcher (): ClassfileLoaderDispatcher 0%   (0/1)0%   (0/3)0%   (0/1)
getCodeFont (int, int): Font 0%   (0/1)0%   (0/35)0%   (0/6)
getInputFiles (): Collection 0%   (0/1)0%   (0/3)0%   (0/1)
getMaximize (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
getMinimize (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
getMonitor (): Monitor 0%   (0/1)0%   (0/3)0%   (0/1)
getNodeFactory (): NodeFactory 0%   (0/1)0%   (0/3)0%   (0/1)
getPackages (): Collection 0%   (0/1)0%   (0/5)0%   (0/1)
getProgressBar (): JProgressBar 0%   (0/1)0%   (0/3)0%   (0/1)
getStatusLine (): StatusLine 0%   (0/1)0%   (0/3)0%   (0/1)
isAdvancedMode (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
main (String []): void 0%   (0/1)0%   (0/96)0%   (0/27)
refreshDependenciesDisplay (): void 0%   (0/1)0%   (0/43)0%   (0/9)
resetQuery (): void 0%   (0/1)0%   (0/105)0%   (0/27)
setAdvancedMode (boolean): void 0%   (0/1)0%   (0/8)0%   (0/3)
setClassfileLoaderDispatcher (ClassfileLoaderDispatcher): void 0%   (0/1)0%   (0/4)0%   (0/2)
setInputFiles (Collection): void 0%   (0/1)0%   (0/4)0%   (0/2)
setMaximize (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setMinimize (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setMonitor (Monitor): void 0%   (0/1)0%   (0/4)0%   (0/2)
setNewDependencyGraph (): void 0%   (0/1)0%   (0/38)0%   (0/9)
setNodeFactory (NodeFactory): void 0%   (0/1)0%   (0/4)0%   (0/2)
showError (CommandLineUsage): void 0%   (0/1)0%   (0/4)0%   (0/2)
showError (CommandLineUsage, String): void 0%   (0/1)0%   (0/6)0%   (0/3)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.dependencyfinder.gui;
34 
35import java.awt.*;
36import java.awt.event.*;
37import java.io.*;
38import java.util.*;
39import javax.swing.*;
40import javax.swing.border.*;
41 
42import org.apache.log4j.*;
43 
44import com.jeantessier.classreader.*;
45import com.jeantessier.commandline.*;
46import com.jeantessier.dependency.*;
47 
48public class DependencyFinder extends JFrame {
49    private boolean minimize;
50    private boolean maximize;
51 
52    private boolean advancedMode;
53    private JPanel  queryPanel   = new JPanel();
54    
55    private JMenuBar          menuBar                = new JMenuBar();
56    private JMenu             fileMenu               = new JMenu();
57    private JMenu             viewMenu               = new JMenu();
58    private JMenu             helpMenu               = new JMenu();
59    private JToolBar          toolbar                = new JToolBar();
60    private JTextArea         dependenciesResultArea = new JTextArea();
61    private JTextArea         closureResultArea      = new JTextArea();
62    private JTextArea         metricsResultArea      = new JTextArea();
63    private MetricsTableModel metricsChartModel      = new MetricsTableModel();
64    private StatusLine        statusLine             = new StatusLine(420);
65    private JProgressBar      progressBar            = new JProgressBar();
66 
67    private Collection<String>        inputFiles  = null;
68    private ClassfileLoaderDispatcher dispatcher  = null;
69    private NodeFactory               nodeFactory = null;
70    private Monitor                   monitor     = null;
71 
72    private JCheckBox  packageScope          = new JCheckBox("packages");
73    private JCheckBox  classScope            = new JCheckBox("classes");
74    private JCheckBox  featureScope          = new JCheckBox("features");
75    private JTextField scopeIncludes         = new JTextField();
76    private JTextField packageScopeIncludes  = new JTextField();
77    private JTextField classScopeIncludes    = new JTextField();
78    private JTextField featureScopeIncludes  = new JTextField();
79    private JTextField scopeExcludes         = new JTextField();
80    private JTextField packageScopeExcludes  = new JTextField();
81    private JTextField classScopeExcludes    = new JTextField();
82    private JTextField featureScopeExcludes  = new JTextField();
83    
84    private JCheckBox  packageFilter         = new JCheckBox("packages");
85    private JCheckBox  classFilter           = new JCheckBox("classes");
86    private JCheckBox  featureFilter         = new JCheckBox("features");
87    private JTextField filterIncludes        = new JTextField();
88    private JTextField packageFilterIncludes = new JTextField();
89    private JTextField classFilterIncludes   = new JTextField();
90    private JTextField featureFilterIncludes = new JTextField();
91    private JTextField filterExcludes        = new JTextField();
92    private JTextField packageFilterExcludes = new JTextField();
93    private JTextField classFilterExcludes   = new JTextField();
94    private JTextField featureFilterExcludes = new JTextField();
95 
96    private JCheckBox  showInbounds          = new JCheckBox("<--");
97    private JCheckBox  showOutbounds         = new JCheckBox("-->");
98    private JCheckBox  showEmptyNodes        = new JCheckBox("empty elements");
99    private JCheckBox  copyOnly              = new JCheckBox("copy only");
100    
101    private JTextField maximumInboundDepth   = new JTextField("0", 2);
102    private JTextField maximumOutboundDepth  = new JTextField(2);
103 
104    private GraphCopier dependenciesQuery    = null;
105    
106    public DependencyFinder(CommandLine commandLine) {
107        this.setSize(new Dimension(800, 600));
108        this.setTitle("Dependency Finder");
109        this.setIconImage(new ImageIcon(getClass().getResource("icons/logoicon.gif")).getImage());
110        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
111        this.addWindowListener(new WindowKiller());
112 
113        setNewDependencyGraph();
114        
115        packageScope.setToolTipText("Select packages");
116        classScope.setToolTipText("Select classes (with their package)");
117        featureScope.setToolTipText("Select methods and fields (with their class and package)");
118        scopeIncludes.setToolTipText("Package, class, method, or field must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
119        packageScopeIncludes.setToolTipText("Package must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
120        classScopeIncludes.setToolTipText("Class must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
121        featureScopeIncludes.setToolTipText("Method or field must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
122        scopeExcludes.setToolTipText("Package, class, method, or field must NOT match any of these expressions. E.g., /Test/");
123        packageScopeExcludes.setToolTipText("Package must NOT match any of these expressions. E.g., /Test/");
124        classScopeExcludes.setToolTipText("Class must NOT match any of these expressions. E.g., /Test/");
125        featureScopeExcludes.setToolTipText("Method or field must NOT match any of these expressions. E.g., /Test/");
126        
127        packageFilter.setToolTipText("Show dependencies to/from packages");
128        classFilter.setToolTipText("Show dependencies to/from classes");
129        featureFilter.setToolTipText("Show dependencies to/from methods and fields");
130        filterIncludes.setToolTipText("Package, class, method, or field at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
131        packageFilterIncludes.setToolTipText("Package at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
132        classFilterIncludes.setToolTipText("Class at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
133        featureFilterIncludes.setToolTipText("Method or field at the other end of the dependency must match any these expressions. E.g., /^com.mycompany/, /\\.get\\w+\\(/");
134        filterExcludes.setToolTipText("Package, class, method, or field at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
135        packageFilterExcludes.setToolTipText("Package at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
136        classFilterExcludes.setToolTipText("Class at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
137        featureFilterExcludes.setToolTipText("Method or field at the other end of the dependency must NOT match any of these expressions. E.g., /Test/");
138        
139        showInbounds.setToolTipText("Show dependencies that point to the selected packages, classes, methods, or fields");
140        showOutbounds.setToolTipText("Show dependencies that originate from the selected packages, classes, methods, or fields");
141        showEmptyNodes.setToolTipText("Show selected packages, classes, methods, and fields even if they do not have dependencies");
142        copyOnly.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>");
143 
144        showInbounds.setFont(getCodeFont(Font.BOLD, 14));
145        showOutbounds.setFont(getCodeFont(Font.BOLD, 14));
146        
147        maximumInboundDepth.setToolTipText("Maximum hops against the direction dependencies.  Empty field means no limit.");
148        maximumOutboundDepth.setToolTipText("Maximum hops in the direction of dependencies.  Empty field means no limit.");
149 
150        setAdvancedMode(false);
151        
152        buildMenus(commandLine);
153        buildUI();
154 
155        try {
156            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
157            SwingUtilities.updateComponentTreeUI(this);
158        } catch (Exception ex) {
159            Logger.getLogger(DependencyFinder.class).error("Unable to set look and feel", ex);
160        }
161        
162        statusLine.showInfo("Ready.");
163    }
164 
165    private Font getCodeFont(int style, int size) {
166        String fontName = "Monospaced";
167        
168        String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
169        for (String fontName1 : fontNames) {
170            if (fontName1.indexOf("Courier") != -1) {
171                fontName = fontName1;
172            }
173        }
174 
175        return new Font(fontName, style, size);
176    }
177 
178    private boolean isAdvancedMode() {
179        return advancedMode;
180    }
181 
182    void setAdvancedMode(boolean advancedMode) {
183        this.advancedMode = advancedMode;
184 
185        copyOnly.setVisible(advancedMode);
186    }
187    
188    public boolean getMaximize() {
189        return maximize;
190    }
191 
192    private void setMaximize(boolean maximize) {
193        this.maximize = maximize;
194    }
195 
196    public boolean getMinimize() {
197        return minimize;
198    }
199 
200    private void setMinimize(boolean minimize) {
201        this.minimize = minimize;
202    }
203    
204    public ClassfileLoaderDispatcher getClassfileLoaderDispatcher() {
205        return dispatcher;
206    }
207 
208    private void setClassfileLoaderDispatcher(ClassfileLoaderDispatcher dispatcher) {
209        this.dispatcher = dispatcher;
210    }
211 
212    public Monitor getMonitor() {
213        return monitor;
214    }
215 
216    private void setMonitor(Monitor monitor) {
217        this.monitor = monitor;
218    }
219    
220    public Collection<String> getInputFiles() {
221        return inputFiles;
222    }
223 
224    private void setInputFiles(Collection<String> inputFiles) {
225        this.inputFiles = inputFiles;
226    }
227    
228    public void addInputFile(File file) {
229        inputFiles.add(file.toString());
230    }
231 
232    public Collection<PackageNode> getPackages() {
233        return getNodeFactory().getPackages().values();
234    }
235 
236    public NodeFactory getNodeFactory() {
237        return nodeFactory;
238    }
239 
240    private void setNodeFactory(NodeFactory nodeFactory) {
241        this.nodeFactory = nodeFactory;
242    }
243    
244    StatusLine getStatusLine() {
245        return statusLine;
246    }
247        
248    JProgressBar getProgressBar() {
249        return progressBar;
250    }
251 
252    private void buildMenus(CommandLine commandLine) {
253        buildFileMenu(commandLine);
254        buildViewMenu();
255        buildHelpMenu();
256 
257        this.setJMenuBar(menuBar);
258    }
259    
260    private void buildFileMenu(CommandLine commandLine) {
261        menuBar.add(fileMenu);
262 
263        fileMenu.setText("File");
264 
265        Action    action;
266        JMenuItem menuItem;
267        JButton   button;
268 
269        action = new DependencyExtractAction(this);
270        menuItem = fileMenu.add(action);
271        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK));
272        menuItem.setMnemonic('e');
273        button = toolbar.add(action);
274        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
275 
276        action = new RefreshDependencyGraphAction(this);
277        menuItem = fileMenu.add(action);
278        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK));
279        menuItem.setMnemonic('r');
280        button = toolbar.add(action);
281        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
282 
283        toolbar.addSeparator();
284        fileMenu.addSeparator();
285        
286        action = new OpenFileAction(this);
287        menuItem = fileMenu.add(action);
288        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));
289        menuItem.setMnemonic('o');
290        button = toolbar.add(action);
291        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
292        
293        action = new SaveFileAction(this, commandLine.getSingleSwitch("encoding"), commandLine.getSingleSwitch("dtd-prefix"));
294        menuItem = fileMenu.add(action);
295        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
296        menuItem.setMnemonic('s');
297        button = toolbar.add(action);
298        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
299 
300        if (commandLine.isPresent("indent-text")) {
301            ((SaveFileAction) action).setIndentText(commandLine.getSingleSwitch("indent-text"));
302        }
303        
304        toolbar.addSeparator();
305        fileMenu.addSeparator();
306        
307        action = new NewDependencyGraphAction(this);
308        menuItem = fileMenu.add(action);
309        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK));
310        menuItem.setMnemonic('n');
311        button = toolbar.add(action);
312        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
313 
314        toolbar.addSeparator();
315        fileMenu.addSeparator();
316        
317        action = new DependencyQueryAction(this);
318        menuItem = fileMenu.add(action);
319        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK));
320        menuItem.setMnemonic('d');
321        button = toolbar.add(action);
322        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
323 
324        action = new ClosureQueryAction(this);
325        menuItem = fileMenu.add(action);
326        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
327        menuItem.setMnemonic('c');
328        button = toolbar.add(action);
329        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
330 
331        action = new MetricsQueryAction(this);
332        menuItem = fileMenu.add(action);
333        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK));
334        menuItem.setMnemonic('m');
335        button = toolbar.add(action);
336        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
337 
338        action = new AllQueriesAction(this);
339        menuItem = fileMenu.add(action);
340        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK));
341        menuItem.setMnemonic('a');
342        button = toolbar.add(action);
343        button.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
344 
345        toolbar.addSeparator();
346        fileMenu.addSeparator();
347 
348        action = new ExitAction(this);
349        menuItem = fileMenu.add(action);
350        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
351        menuItem.setMnemonic('x');
352    }
353    
354    private void buildViewMenu() {
355        menuBar.add(viewMenu);
356 
357        viewMenu.setText("View");
358 
359        ButtonGroup group = new ButtonGroup();
360        JMenuItem menuItem;
361        
362        menuItem = new JRadioButtonMenuItem(new SimpleQueryPanelAction(this));
363        menuItem.setSelected(true);
364        group.add(menuItem);
365        viewMenu.add(menuItem);
366        
367        menuItem = new JRadioButtonMenuItem(new AdvancedQueryPanelAction(this));
368        group.add(menuItem);
369        viewMenu.add(menuItem);
370    }
371 
372    private void buildHelpMenu() {
373        menuBar.add(helpMenu);
374 
375        helpMenu.setText("Help");
376 
377        Action action;
378        JMenuItem menuItem;
379 
380        action = new AboutAction(this);
381        menuItem = helpMenu.add(action);
382        menuItem.setMnemonic('a');
383    }
384 
385    private void buildUI() {
386        this.getContentPane().setLayout(new BorderLayout());
387        this.getContentPane().add(buildControlPanel(), BorderLayout.NORTH);
388        this.getContentPane().add(buildResultPanel(), BorderLayout.CENTER);
389        this.getContentPane().add(buildStatusPanel(), BorderLayout.SOUTH);
390    }
391 
392    private JComponent buildControlPanel() {
393        JPanel result = new JPanel();
394 
395        result.setLayout(new BorderLayout());
396        result.add(toolbar, BorderLayout.NORTH);
397        result.add(buildQueryPanel(), BorderLayout.CENTER);
398        
399        return result;
400    }
401    
402    JComponent buildQueryPanel() {
403        if (isAdvancedMode()) {
404            buildAdvancedQueryPanel();
405        } else {
406            buildSimpleQueryPanel();
407        }
408        
409        return queryPanel;
410    }
411    
412    private void buildSimpleQueryPanel() {
413        queryPanel.removeAll();
414        queryPanel.setLayout(new GridLayout(1, 2));
415        queryPanel.add(buildSimpleScopePanel());
416        queryPanel.add(buildSimpleFilterPanel());
417        queryPanel.revalidate();
418    }
419    
420    private void buildAdvancedQueryPanel() {
421        queryPanel.removeAll();
422        queryPanel.setLayout(new GridLayout(1, 2));
423        queryPanel.add(buildAdvancedScopePanel());
424        queryPanel.add(buildAdvancedFilterPanel());
425        queryPanel.revalidate();
426    }
427 
428    private JComponent buildSimpleScopePanel() {
429        JPanel result = new JPanel();
430 
431        result.setBorder(BorderFactory.createTitledBorder("Select programming elements"));
432 
433        result.setLayout(new BorderLayout());
434 
435        result.add(buildSimpleScopePanelCheckboxes(), BorderLayout.NORTH);
436        result.add(buildSimpleScopePanelTextFields(), BorderLayout.SOUTH);
437 
438        return result;
439    }
440    
441    private JComponent buildSimpleScopePanelTextFields() {
442        JPanel result = new JPanel();
443 
444        GridBagLayout      gbl = new GridBagLayout();
445        GridBagConstraints c   = new GridBagConstraints();
446        c.insets = new Insets(0, 2, 0, 2);
447        
448        result.setLayout(gbl);
449 
450        JLabel scopeIncludesLabel = new JLabel("including:");
451        c.anchor = GridBagConstraints.WEST;
452        c.fill = GridBagConstraints.NONE;
453        c.gridx = 0;
454        c.gridy = 0;
455        c.weightx = 0;
456        c.weighty = 0;
457        result.add(scopeIncludesLabel);
458        gbl.setConstraints(scopeIncludesLabel, c);
459 
460        JLabel scopeExcludesLabel = new JLabel("excluding:");
461        c.anchor = GridBagConstraints.WEST;
462        c.fill = GridBagConstraints.NONE;
463        c.gridx = 1;
464        c.gridy = 0;
465        c.weightx = 0;
466        c.weighty = 0;
467        result.add(scopeExcludesLabel);
468        gbl.setConstraints(scopeExcludesLabel, c);
469 
470        // -scope-includes
471        c.anchor = GridBagConstraints.WEST;
472        c.fill = GridBagConstraints.HORIZONTAL;
473        c.gridx = 0;
474        c.gridy = 1;
475        c.weightx = 1;
476        c.weighty = 0;
477        result.add(scopeIncludes);
478        gbl.setConstraints(scopeIncludes, c);
479        
480        // -scope-excludes
481        c.anchor = GridBagConstraints.WEST;
482        c.fill = GridBagConstraints.HORIZONTAL;
483        c.gridx = 1;
484        c.gridy = 1;
485        c.weightx = 1;
486        c.weighty = 0;
487        result.add(scopeExcludes);
488        gbl.setConstraints(scopeExcludes, c);
489 
490        return result;
491    }
492 
493    private JComponent buildSimpleScopePanelCheckboxes() {
494        JPanel result = new JPanel();
495 
496        GridBagLayout      gbl = new GridBagLayout();
497        GridBagConstraints c   = new GridBagConstraints();
498        c.insets = new Insets(0, 2, 0, 2);
499        
500        result.setLayout(gbl);
501 
502        // -package-scope
503        c.anchor = GridBagConstraints.EAST;
504        c.fill = GridBagConstraints.NONE;
505        c.gridx = 0;
506        c.gridy = 0;
507        c.weightx = 1;
508        c.weighty = 0;
509        result.add(packageScope);
510        gbl.setConstraints(packageScope, c);
511 
512        // -class-scope
513        c.anchor = GridBagConstraints.CENTER;
514        c.fill = GridBagConstraints.NONE;
515        c.gridx = 1;
516        c.gridy = 0;
517        c.weightx = 0;
518        c.weighty = 0;
519        result.add(classScope);
520        gbl.setConstraints(classScope, c);
521 
522        // -feature-scope
523        c.anchor = GridBagConstraints.WEST;
524        c.fill = GridBagConstraints.NONE;
525        c.gridx = 2;
526        c.gridy = 0;
527        c.weightx = 1;
528        c.weighty = 0;
529        result.add(featureScope);
530        gbl.setConstraints(featureScope, c);
531 
532        return result;
533    }
534    
535    private JComponent buildSimpleFilterPanel() {
536        JPanel result = new JPanel();
537 
538        result.setBorder(BorderFactory.createTitledBorder("Show dependencies (stop for closure)"));
539 
540        result.setLayout(new BorderLayout());
541 
542        result.add(buildSimpleFilterPanelCheckboxes(), BorderLayout.NORTH);
543        result.add(buildSimpleFilterPanelTextFields(), BorderLayout.SOUTH);
544 
545        return result;
546    }
547    
548    private JComponent buildSimpleFilterPanelTextFields() {
549        JPanel result = new JPanel();
550 
551        GridBagLayout      gbl = new GridBagLayout();
552        GridBagConstraints c   = new GridBagConstraints();
553        c.insets = new Insets(0, 2, 0, 2);
554        
555        result.setLayout(gbl);
556 
557        JLabel filterIncludesLabel = new JLabel("including:");
558        c.anchor = GridBagConstraints.WEST;
559        c.fill = GridBagConstraints.NONE;
560        c.gridx = 0;
561        c.gridy = 0;
562        c.weightx = 0;
563        c.weighty = 0;
564        result.add(filterIncludesLabel);
565        gbl.setConstraints(filterIncludesLabel, c);
566 
567        JLabel filterExcludesLabel = new JLabel("excluding:");
568        c.anchor = GridBagConstraints.WEST;
569        c.fill = GridBagConstraints.NONE;
570        c.gridx = 1;
571        c.gridy = 0;
572        c.weightx = 0;
573        c.weighty = 0;
574        result.add(filterExcludesLabel);
575        gbl.setConstraints(filterExcludesLabel, c);
576 
577        // -filter-includes
578        c.anchor = GridBagConstraints.WEST;
579        c.fill = GridBagConstraints.HORIZONTAL;
580        c.gridx = 0;
581        c.gridy = 1;
582        c.weightx = 1;
583        c.weighty = 0;
584        result.add(filterIncludes);
585        gbl.setConstraints(filterIncludes, c);
586 
587        // -filter-excludes
588        c.anchor = GridBagConstraints.WEST;
589        c.fill = GridBagConstraints.HORIZONTAL;
590        c.gridx = 1;
591        c.gridy = 1;
592        c.weightx = 1;
593        c.weighty = 0;
594        result.add(filterExcludes);
595        gbl.setConstraints(filterExcludes, c);
596 
597        return result;
598    }
599    
600    private JComponent buildSimpleFilterPanelCheckboxes() {
601        JPanel result = new JPanel();
602 
603        GridBagLayout      gbl = new GridBagLayout();
604        GridBagConstraints c   = new GridBagConstraints();
605        c.insets = new Insets(0, 2, 0, 2);
606        
607        result.setLayout(gbl);
608 
609        // -package-filter
610        c.anchor = GridBagConstraints.EAST;
611        c.fill = GridBagConstraints.NONE;
612        c.gridx = 0;
613        c.gridy = 0;
614        c.weightx = 1;
615        c.weighty = 0;
616        result.add(packageFilter);
617        gbl.setConstraints(packageFilter, c);
618 
619        // -class-filter
620        c.anchor = GridBagConstraints.CENTER;
621        c.fill = GridBagConstraints.NONE;
622        c.gridx = 1;
623        c.gridy = 0;
624        c.weightx = 0;
625        c.weighty = 0;
626        result.add(classFilter);
627        gbl.setConstraints(classFilter, c);
628 
629        // -feature-filter
630        c.anchor = GridBagConstraints.WEST;
631        c.fill = GridBagConstraints.NONE;
632        c.gridx = 2;
633        c.gridy = 0;
634        c.weightx = 1;
635        c.weighty = 0;
636        result.add(featureFilter);
637        gbl.setConstraints(featureFilter, c);
638 
639        return result;
640    }
641 
642    private JComponent buildAdvancedScopePanel() {
643        JPanel result = new JPanel();
644 
645        result.setBorder(BorderFactory.createTitledBorder("Select programming elements"));
646 
647        GridBagLayout      gbl = new GridBagLayout();
648        GridBagConstraints c   = new GridBagConstraints();
649        c.insets = new Insets(2, 0, 2, 5);
650        
651        result.setLayout(gbl);
652 
653        // -package-scope
654        c.anchor = GridBagConstraints.WEST;
655        c.fill = GridBagConstraints.NONE;
656        c.gridx = 0;
657        c.gridy = 2;
658        c.weightx = 0;
659        c.weighty = 0;
660        result.add(packageScope);
661        gbl.setConstraints(packageScope, c);
662 
663        // -class-scope
664        c.anchor = GridBagConstraints.WEST;
665        c.fill = GridBagConstraints.NONE;
666        c.gridx = 0;
667        c.gridy = 3;
668        c.weightx = 0;
669        c.weighty = 0;
670        result.add(classScope);
671        gbl.setConstraints(classScope, c);
672 
673        // -feature-scope
674        c.anchor = GridBagConstraints.WEST;
675        c.fill = GridBagConstraints.NONE;
676        c.gridx = 0;
677        c.gridy = 4;
678        c.weightx = 0;
679        c.weighty = 0;
680        result.add(featureScope);
681        gbl.setConstraints(featureScope, c);
682 
683        JLabel scopeIncludesLabel = new JLabel("including:");
684        c.anchor = GridBagConstraints.WEST;
685        c.fill = GridBagConstraints.NONE;
686        c.gridx = 1;
687        c.gridy = 0;
688        c.weightx = 0;
689        c.weighty = 0;
690        result.add(scopeIncludesLabel);
691        gbl.setConstraints(scopeIncludesLabel, c);
692 
693        // -scope-includes
694        c.anchor = GridBagConstraints.WEST;
695        c.fill = GridBagConstraints.HORIZONTAL;
696        c.gridx = 1;
697        c.gridy = 1;
698        c.weightx = 1;
699        c.weighty = 0;
700        result.add(scopeIncludes);
701        gbl.setConstraints(scopeIncludes, c);
702 
703        // -package-scope-includes
704        c.anchor = GridBagConstraints.WEST;
705        c.fill = GridBagConstraints.HORIZONTAL;
706        c.gridx = 1;
707        c.gridy = 2;
708        c.weightx = 1;
709        c.weighty = 0;
710        result.add(packageScopeIncludes);
711        gbl.setConstraints(packageScopeIncludes, c);
712 
713        // -class-scope-includes
714        c.anchor = GridBagConstraints.WEST;
715        c.fill = GridBagConstraints.HORIZONTAL;
716        c.gridx = 1;
717        c.gridy = 3;
718        c.weightx = 1;
719        c.weighty = 0;
720        result.add(classScopeIncludes);
721        gbl.setConstraints(classScopeIncludes, c);
722 
723        // -feature-scope-includes
724        c.anchor = GridBagConstraints.WEST;
725        c.fill = GridBagConstraints.HORIZONTAL;
726        c.gridx = 1;
727        c.gridy = 4;
728        c.weightx = 1;
729        c.weighty = 0;
730        result.add(featureScopeIncludes);
731        gbl.setConstraints(featureScopeIncludes, c);
732 
733        JLabel scopeExcludesLabel = new JLabel("excluding:");
734        c.anchor = GridBagConstraints.WEST;
735        c.fill = GridBagConstraints.NONE;
736        c.gridx = 2;
737        c.gridy = 0;
738        c.weightx = 0;
739        c.weighty = 0;
740        result.add(scopeExcludesLabel);
741        gbl.setConstraints(scopeExcludesLabel, c);
742 
743        // -scope-excludes
744        c.anchor = GridBagConstraints.WEST;
745        c.fill = GridBagConstraints.HORIZONTAL;
746        c.gridx = 2;
747        c.gridy = 1;
748        c.weightx = 1;
749        c.weighty = 0;
750        result.add(scopeExcludes);
751        gbl.setConstraints(scopeExcludes, c);
752 
753        // -package-scope-excludes
754        c.anchor = GridBagConstraints.WEST;
755        c.fill = GridBagConstraints.HORIZONTAL;
756        c.gridx = 2;
757        c.gridy = 2;
758        c.weightx = 1;
759        c.weighty = 0;
760        result.add(packageScopeExcludes);
761        gbl.setConstraints(packageScopeExcludes, c);
762 
763        // -class-scope-excludes
764        c.anchor = GridBagConstraints.WEST;
765        c.fill = GridBagConstraints.HORIZONTAL;
766        c.gridx = 2;
767        c.gridy = 3;
768        c.weightx = 1;
769        c.weighty = 0;
770        result.add(classScopeExcludes);
771        gbl.setConstraints(classScopeExcludes, c);
772 
773        // -feature-scope-excludes
774        c.anchor = GridBagConstraints.WEST;
775        c.fill = GridBagConstraints.HORIZONTAL;
776        c.gridx = 2;
777        c.gridy = 4;
778        c.weightx = 1;
779        c.weighty = 0;
780        result.add(featureScopeExcludes);
781        gbl.setConstraints(featureScopeExcludes, c);
782 
783        return result;
784    }
785    
786    private JComponent buildAdvancedFilterPanel() {
787        JPanel result = new JPanel();
788 
789        result.setBorder(BorderFactory.createTitledBorder("Show dependencies (stop for closure)"));
790 
791        GridBagLayout      gbl = new GridBagLayout();
792        GridBagConstraints c   = new GridBagConstraints();
793        c.insets = new Insets(2, 0, 2, 5);
794        
795        result.setLayout(gbl);
796 
797        // -package-filter
798        c.anchor = GridBagConstraints.WEST;
799        c.fill = GridBagConstraints.NONE;
800        c.gridx = 0;
801        c.gridy = 2;
802        c.weightx = 0;
803        c.weighty = 0;
804        result.add(packageFilter);
805        gbl.setConstraints(packageFilter, c);
806 
807        // -class-filter
808        c.anchor = GridBagConstraints.WEST;
809        c.fill = GridBagConstraints.NONE;
810        c.gridx = 0;
811        c.gridy = 3;
812        c.weightx = 0;
813        c.weighty = 0;
814        result.add(classFilter);
815        gbl.setConstraints(classFilter, c);
816 
817        // -feature-filter
818        c.anchor = GridBagConstraints.WEST;
819        c.fill = GridBagConstraints.NONE;
820        c.gridx = 0;
821        c.gridy = 4;
822        c.weightx = 0;
823        c.weighty = 0;
824        result.add(featureFilter);
825        gbl.setConstraints(featureFilter, c);
826 
827        JLabel filterIncludesLabel = new JLabel("including:");
828        c.anchor = GridBagConstraints.WEST;
829        c.fill = GridBagConstraints.NONE;
830        c.gridx = 1;
831        c.gridy = 0;
832        c.weightx = 0;
833        c.weighty = 0;
834        result.add(filterIncludesLabel);
835        gbl.setConstraints(filterIncludesLabel, c);
836 
837        // -filter-includes
838        c.anchor = GridBagConstraints.WEST;
839        c.fill = GridBagConstraints.HORIZONTAL;
840        c.gridx = 1;
841        c.gridy = 1;
842        c.weightx = 1;
843        c.weighty = 0;
844        result.add(filterIncludes);
845        gbl.setConstraints(filterIncludes, c);
846 
847        // -package-filter-includes
848        c.anchor = GridBagConstraints.WEST;
849        c.fill = GridBagConstraints.HORIZONTAL;
850        c.gridx = 1;
851        c.gridy = 2;
852        c.weightx = 1;
853        c.weighty = 0;
854        result.add(packageFilterIncludes);
855        gbl.setConstraints(packageFilterIncludes, c);
856 
857        // -class-filter-includes
858        c.anchor = GridBagConstraints.WEST;
859        c.fill = GridBagConstraints.HORIZONTAL;
860        c.gridx = 1;
861        c.gridy = 3;
862        c.weightx = 1;
863        c.weighty = 0;
864        result.add(classFilterIncludes);
865        gbl.setConstraints(classFilterIncludes, c);
866 
867        // -feature-filter-includes
868        c.anchor = GridBagConstraints.WEST;
869        c.fill = GridBagConstraints.HORIZONTAL;
870        c.gridx = 1;
871        c.gridy = 4;
872        c.weightx = 1;
873        c.weighty = 0;
874        result.add(featureFilterIncludes);
875        gbl.setConstraints(featureFilterIncludes, c);
876 
877        JLabel filterExcludesLabel = new JLabel("excluding:");
878        c.anchor = GridBagConstraints.WEST;
879        c.fill = GridBagConstraints.NONE;
880        c.gridx = 2;
881        c.gridy = 0;
882        c.weightx = 0;
883        c.weighty = 0;
884        result.add(filterExcludesLabel);
885        gbl.setConstraints(filterExcludesLabel, c);
886 
887        // -filter-excludes
888        c.anchor = GridBagConstraints.WEST;
889        c.fill = GridBagConstraints.HORIZONTAL;
890        c.gridx = 2;
891        c.gridy = 1;
892        c.weightx = 1;
893        c.weighty = 0;
894        result.add(filterExcludes);
895        gbl.setConstraints(filterExcludes, c);
896 
897        // -package-filter-excludes
898        c.anchor = GridBagConstraints.WEST;
899        c.fill = GridBagConstraints.HORIZONTAL;
900        c.gridx = 2;
901        c.gridy = 2;
902        c.weightx = 1;
903        c.weighty = 0;
904        result.add(packageFilterExcludes);
905        gbl.setConstraints(packageFilterExcludes, c);
906 
907        // -class-filter-excludes
908        c.anchor = GridBagConstraints.WEST;
909        c.fill = GridBagConstraints.HORIZONTAL;
910        c.gridx = 2;
911        c.gridy = 3;
912        c.weightx = 1;
913        c.weighty = 0;
914        result.add(classFilterExcludes);
915        gbl.setConstraints(classFilterExcludes, c);
916 
917        // -feature-filter-excludes
918        c.anchor = GridBagConstraints.WEST;
919        c.fill = GridBagConstraints.HORIZONTAL;
920        c.gridx = 2;
921        c.gridy = 4;
922        c.weightx = 1;
923        c.weighty = 0;
924        result.add(featureFilterExcludes);
925        gbl.setConstraints(featureFilterExcludes, c);
926 
927        return result;
928    }
929    
930    private JComponent buildResultPanel() {
931        JTabbedPane result = new JTabbedPane();
932 
933        result.setBorder(BorderFactory.createTitledBorder("Results"));
934        result.addTab("Dependencies", buildDependenciesPanel());
935        result.addTab("Closure",      buildClosurePanel());
936        result.addTab("Metrics",      buildMetricsPanel());
937        
938        return result;
939    }
940 
941    private JComponent buildDependenciesPanel() {
942        JPanel result = new JPanel();
943 
944        result.setLayout(new BorderLayout());
945        result.add(buildPrinterControlPanel(),     BorderLayout.NORTH);
946        result.add(buildDependenciesResultPanel(), BorderLayout.CENTER);
947        
948        return result;
949    }
950    
951    private JComponent buildPrinterControlPanel() {
952        JPanel result = new JPanel();
953 
954        result.add(new JLabel("Show "));
955        result.add(showInbounds);
956        result.add(showOutbounds);
957        result.add(showEmptyNodes);
958        result.add(copyOnly);
959 
960        PrinterControlAction action = new PrinterControlAction(this);
961        showInbounds.addActionListener(action);
962        showOutbounds.addActionListener(action);
963        showEmptyNodes.addActionListener(action);
964 
965        return result;
966    }
967    
968    private JComponent buildDependenciesResultPanel() {
969        JComponent result = new JScrollPane(dependenciesResultArea);
970        
971        dependenciesResultArea.setEditable(false);
972        dependenciesResultArea.setFont(getCodeFont(Font.PLAIN, 12));
973        
974        return result;
975    }
976    
977    private JComponent buildClosurePanel() {
978        JPanel result = new JPanel();
979        
980        result.setLayout(new BorderLayout());
981        result.add(buildClosureControlPanel(), BorderLayout.NORTH);
982        result.add(buildClosureResultPanel(),  BorderLayout.CENTER);
983        
984        return result;
985    }
986    
987    private JComponent buildClosureControlPanel() {
988        JPanel result = new JPanel();
989        
990        result.add(new JLabel("Follow inbounds: "));
991        result.add(maximumInboundDepth);
992        result.add(new JLabel("Follow outbounds: "));
993        result.add(maximumOutboundDepth);
994        
995        return result;
996    }
997 
998    private JComponent buildClosureResultPanel() {
999        JComponent result = new JScrollPane(closureResultArea);
1000        
1001        closureResultArea.setEditable(false);
1002        closureResultArea.setFont(getCodeFont(Font.PLAIN, 12));
1003        
1004        return result;
1005    }
1006    
1007    private JComponent buildMetricsPanel() {
1008        return new JSplitPane(JSplitPane.VERTICAL_SPLIT, buildMetricsResultPanel(), buildMetricsChartPanel());
1009    }
1010 
1011    private JComponent buildMetricsResultPanel() {
1012        JComponent result = new JScrollPane(metricsResultArea);
1013 
1014        metricsResultArea.setEditable(false);
1015        
1016        return result;
1017    }
1018 
1019    private JComponent buildMetricsChartPanel() {
1020        JComponent result;
1021 
1022        JTable table = new JTable(metricsChartModel);
1023 
1024        table.setCellSelectionEnabled(true);
1025        table.setColumnSelectionAllowed(true);
1026        
1027        result = new JScrollPane(table);
1028 
1029        return result;
1030    }
1031    
1032    private JComponent buildStatusPanel() {
1033        JPanel result = new JPanel();
1034 
1035        Dimension size = getProgressBar().getPreferredSize();
1036        size.width = 100;
1037        getProgressBar().setPreferredSize(size);
1038        getProgressBar().setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
1039        
1040        result.setLayout(new BorderLayout());
1041        result.add(getStatusLine(),  BorderLayout.CENTER);
1042        result.add(getProgressBar(), BorderLayout.EAST);
1043        
1044        return result;
1045    }
1046    
1047    public void resetQuery() {
1048        packageScope.setSelected(true);
1049        classScope.setSelected(false);
1050        featureScope.setSelected(false);
1051        scopeIncludes.setText("//");
1052        packageScopeIncludes.setText("");
1053        classScopeIncludes.setText("");
1054        featureScopeIncludes.setText("");
1055        scopeExcludes.setText("");
1056        packageScopeExcludes.setText("");
1057        classScopeExcludes.setText("");
1058        featureScopeExcludes.setText("");
1059    
1060        packageFilter.setSelected(true);
1061        classFilter.setSelected(false);
1062        featureFilter.setSelected(false);
1063        filterIncludes.setText("//");
1064        packageFilterIncludes.setText("");
1065        classFilterIncludes.setText("");
1066        featureFilterIncludes.setText("");
1067        filterExcludes.setText("");
1068        packageFilterExcludes.setText("");
1069        classFilterExcludes.setText("");
1070        featureFilterExcludes.setText("");
1071 
1072        showInbounds.setSelected(true);
1073        showOutbounds.setSelected(true);
1074        showEmptyNodes.setSelected(true);
1075        copyOnly.setSelected(false);
1076    }
1077    
1078    void clearDependencyResult() {
1079        dependenciesQuery = null;
1080        dependenciesResultArea.setText("");
1081    }
1082    
1083    void doDependencyQuery() {
1084        RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1085        
1086        scopeCriteria.setMatchingPackages(packageScope.isSelected());
1087        scopeCriteria.setMatchingClasses(classScope.isSelected());
1088        scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1089        scopeCriteria.setGlobalIncludes(scopeIncludes.getText());
1090        scopeCriteria.setGlobalExcludes(scopeExcludes.getText());
1091 
1092        if (isAdvancedMode()) {
1093            scopeCriteria.setPackageIncludes(packageScopeIncludes.getText());
1094            scopeCriteria.setClassIncludes(classScopeIncludes.getText());
1095            scopeCriteria.setFeatureIncludes(featureScopeIncludes.getText());
1096            scopeCriteria.setPackageExcludes(packageScopeExcludes.getText());
1097            scopeCriteria.setClassExcludes(classScopeExcludes.getText());
1098            scopeCriteria.setFeatureExcludes(featureScopeExcludes.getText());
1099        }
1100    
1101        RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1102        
1103        filterCriteria.setMatchingPackages(packageFilter.isSelected());
1104        filterCriteria.setMatchingClasses(classFilter.isSelected());
1105        filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1106        filterCriteria.setGlobalIncludes(filterIncludes.getText());
1107        filterCriteria.setGlobalExcludes(filterExcludes.getText());
1108 
1109        if (isAdvancedMode()) {
1110            filterCriteria.setPackageIncludes(packageFilterIncludes.getText());
1111            filterCriteria.setClassIncludes(classFilterIncludes.getText());
1112            filterCriteria.setFeatureIncludes(featureFilterIncludes.getText());
1113            filterCriteria.setPackageExcludes(packageFilterExcludes.getText());
1114            filterCriteria.setClassExcludes(classFilterExcludes.getText());
1115            filterCriteria.setFeatureExcludes(featureFilterExcludes.getText());
1116        }
1117 
1118        if ((isAdvancedMode() && copyOnly.isSelected()) || getMaximize()) {
1119            TraversalStrategy strategy = new SelectiveTraversalStrategy(scopeCriteria, filterCriteria);
1120            dependenciesQuery = new GraphCopier(strategy);
1121        } else {
1122            dependenciesQuery = new GraphSummarizer(scopeCriteria, filterCriteria);
1123        }
1124        
1125        dependenciesQuery.traverseNodes(getPackages());
1126 
1127        refreshDependenciesDisplay();
1128    }
1129 
1130    void refreshDependenciesDisplay() {
1131        if (dependenciesQuery != null) {
1132            StringWriter out = new StringWriter();
1133            com.jeantessier.dependency.TextPrinter printer = new com.jeantessier.dependency.TextPrinter(new PrintWriter(out));
1134 
1135            printer.setShowInbounds(showInbounds.isSelected());
1136            printer.setShowOutbounds(showOutbounds.isSelected());
1137            printer.setShowEmptyNodes(showEmptyNodes.isSelected());
1138            
1139            printer.traverseNodes(dependenciesQuery.getScopeFactory().getPackages().values());
1140            
1141            dependenciesResultArea.setText(out.toString());
1142        }
1143    }
1144    
1145    void clearClosureResult() {
1146        closureResultArea.setText("");
1147    }
1148    
1149    void doClosureQuery() {
1150        RegularExpressionSelectionCriteria startCriteria = new RegularExpressionSelectionCriteria();
1151        
1152        startCriteria.setGlobalIncludes(scopeIncludes.getText());
1153        startCriteria.setGlobalExcludes(scopeExcludes.getText());
1154 
1155        if (isAdvancedMode()) {
1156            startCriteria.setPackageIncludes(packageScopeIncludes.getText());
1157            startCriteria.setClassIncludes(classScopeIncludes.getText());
1158            startCriteria.setFeatureIncludes(featureScopeIncludes.getText());
1159            startCriteria.setPackageExcludes(packageScopeExcludes.getText());
1160            startCriteria.setClassExcludes(classScopeExcludes.getText());
1161            startCriteria.setFeatureExcludes(featureScopeExcludes.getText());
1162        }
1163    
1164        RegularExpressionSelectionCriteria stopCriteria = new RegularExpressionSelectionCriteria();
1165        
1166        stopCriteria.setGlobalIncludes(filterIncludes.getText());
1167        stopCriteria.setGlobalExcludes(filterExcludes.getText());
1168 
1169        if (isAdvancedMode()) {
1170            stopCriteria.setPackageIncludes(packageFilterIncludes.getText());
1171            stopCriteria.setClassIncludes(classFilterIncludes.getText());
1172            stopCriteria.setFeatureIncludes(featureFilterIncludes.getText());
1173            stopCriteria.setPackageExcludes(packageFilterExcludes.getText());
1174            stopCriteria.setClassExcludes(classFilterExcludes.getText());
1175            stopCriteria.setFeatureExcludes(featureFilterExcludes.getText());
1176        }
1177 
1178        TransitiveClosure selector = new TransitiveClosure(startCriteria, stopCriteria);
1179 
1180        try {
1181            selector.setMaximumInboundDepth(Long.parseLong(maximumInboundDepth.getText()));
1182        } catch (NumberFormatException ex) {
1183            selector.setMaximumInboundDepth(TransitiveClosure.UNBOUNDED_DEPTH);
1184        }
1185 
1186        try {
1187            selector.setMaximumOutboundDepth(Long.parseLong(maximumOutboundDepth.getText()));
1188        } catch (NumberFormatException ex) {
1189            selector.setMaximumOutboundDepth(TransitiveClosure.UNBOUNDED_DEPTH);
1190        }
1191        
1192        selector.traverseNodes(getPackages());
1193 
1194        RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1195        
1196        scopeCriteria.setMatchingPackages(packageScope.isSelected());
1197        scopeCriteria.setMatchingClasses(classScope.isSelected());
1198        scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1199        scopeCriteria.setGlobalIncludes("//");
1200 
1201        RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1202        
1203        filterCriteria.setMatchingPackages(packageFilter.isSelected());
1204        filterCriteria.setMatchingClasses(classFilter.isSelected());
1205        filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1206        filterCriteria.setGlobalIncludes("//");
1207 
1208        GraphSummarizer summarizer = new GraphSummarizer(scopeCriteria, filterCriteria);
1209        summarizer.traverseNodes(selector.getFactory().getPackages().values());
1210        
1211        StringWriter out = new StringWriter();
1212        com.jeantessier.dependency.Printer printer = new com.jeantessier.dependency.TextPrinter(new PrintWriter(out));
1213        printer.traverseNodes(summarizer.getScopeFactory().getPackages().values());
1214        closureResultArea.setText(out.toString());
1215    }
1216    
1217    void clearMetricsResult() {
1218        metricsResultArea.setText("");
1219    }
1220    
1221    void doMetricsQuery() {
1222        RegularExpressionSelectionCriteria scopeCriteria = new RegularExpressionSelectionCriteria();
1223        
1224        scopeCriteria.setMatchingPackages(packageScope.isSelected());
1225        scopeCriteria.setMatchingClasses(classScope.isSelected());
1226        scopeCriteria.setMatchingFeatures(featureScope.isSelected());
1227        scopeCriteria.setGlobalIncludes(scopeIncludes.getText());
1228        scopeCriteria.setGlobalExcludes(scopeExcludes.getText());
1229 
1230        if (isAdvancedMode()) {
1231            scopeCriteria.setPackageIncludes(packageScopeIncludes.getText());
1232            scopeCriteria.setClassIncludes(classScopeIncludes.getText());
1233            scopeCriteria.setFeatureIncludes(featureScopeIncludes.getText());
1234            scopeCriteria.setPackageExcludes(packageScopeExcludes.getText());
1235            scopeCriteria.setClassExcludes(classScopeExcludes.getText());
1236            scopeCriteria.setFeatureExcludes(featureScopeExcludes.getText());
1237        }
1238    
1239        RegularExpressionSelectionCriteria filterCriteria = new RegularExpressionSelectionCriteria();
1240        
1241        filterCriteria.setMatchingPackages(packageFilter.isSelected());
1242        filterCriteria.setMatchingClasses(classFilter.isSelected());
1243        filterCriteria.setMatchingFeatures(featureFilter.isSelected());
1244        filterCriteria.setGlobalIncludes(filterIncludes.getText());
1245        filterCriteria.setGlobalExcludes(filterExcludes.getText());
1246 
1247        if (isAdvancedMode()) {
1248            filterCriteria.setPackageIncludes(packageFilterIncludes.getText());
1249            filterCriteria.setClassIncludes(classFilterIncludes.getText());
1250            filterCriteria.setFeatureIncludes(featureFilterIncludes.getText());
1251            filterCriteria.setPackageExcludes(packageFilterExcludes.getText());
1252            filterCriteria.setClassExcludes(classFilterExcludes.getText());
1253            filterCriteria.setFeatureExcludes(featureFilterExcludes.getText());
1254        }
1255 
1256        TraversalStrategy                          strategy = new SelectiveTraversalStrategy(scopeCriteria, filterCriteria);
1257        com.jeantessier.dependency.MetricsGatherer metrics  = new com.jeantessier.dependency.MetricsGatherer(strategy);
1258        
1259        metrics.traverseNodes(getPackages());
1260 
1261        StringWriter out = new StringWriter();
1262        MetricsReport report = new MetricsReport(new PrintWriter(out));
1263        report.process(metrics);
1264        
1265        metricsResultArea.setText(out.toString());
1266        metricsChartModel.setMetrics(metrics);
1267    }
1268 
1269    void setNewDependencyGraph() {
1270        setInputFiles(new LinkedList<String>());
1271        setClassfileLoaderDispatcher(new ModifiedOnlyDispatcher(ClassfileLoaderEventSource.DEFAULT_DISPATCHER));
1272 
1273        NodeFactory factory = new NodeFactory();
1274        setNodeFactory(factory);
1275 
1276        CodeDependencyCollector collector       = new CodeDependencyCollector(factory);
1277        DeletingVisitor         deletingVisitor = new DeletingVisitor(factory);
1278        setMonitor(new Monitor(collector, deletingVisitor));
1279 
1280        resetQuery();
1281    }
1282 
1283    public static void showError(CommandLineUsage clu, String msg) {
1284        System.err.println(msg);
1285        showError(clu);
1286    }
1287 
1288    public static void showError(CommandLineUsage clu) {
1289        System.err.println(clu);
1290    }
1291 
1292    public static void main(String[] args) {
1293        // Parsing the command line
1294        CommandLine commandLine = new CommandLine(new NullParameterStrategy());
1295        commandLine.addToggleSwitch("minimize");
1296        commandLine.addToggleSwitch("maximize");
1297        commandLine.addSingleValueSwitch("encoding", com.jeantessier.dependency.XMLPrinter.DEFAULT_ENCODING);
1298        commandLine.addSingleValueSwitch("dtd-prefix", com.jeantessier.dependency.XMLPrinter.DEFAULT_DTD_PREFIX);
1299        commandLine.addSingleValueSwitch("indent-text", com.jeantessier.dependency.XMLPrinter.DEFAULT_INDENT_TEXT);
1300        commandLine.addToggleSwitch("help");
1301 
1302        CommandLineUsage usage = new CommandLineUsage("DependencyFinder");
1303        commandLine.accept(usage);
1304 
1305        try {
1306            commandLine.parse(args);
1307        } catch (IllegalArgumentException ex) {
1308            showError(usage, ex.toString());
1309            System.exit(1);
1310        }
1311 
1312        if (commandLine.getToggleSwitch("help")) {
1313            showError(usage);
1314            System.exit(1);
1315        }
1316 
1317        if (commandLine.getToggleSwitch("maximize") && commandLine.getToggleSwitch("minimize")) {
1318            showError(usage, "Only one of -maximize or -minimize allowed");
1319        }
1320 
1321        /*
1322         *  Beginning of main processing
1323         */
1324 
1325        try {
1326            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
1327        } catch (Exception ex) {
1328            // Ignore
1329        }
1330 
1331        DependencyFinder model = new DependencyFinder(commandLine);
1332        model.setMaximize(commandLine.getToggleSwitch("maximize"));
1333        model.setMinimize(commandLine.getToggleSwitch("minimize"));
1334        model.setVisible(true);
1335    }
1336}

[all classes][com.jeantessier.dependencyfinder.gui]
EMMA 2.0.5312 (C) Vladimir Roubtsov