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