01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package org.acm.seguin.tools.builder;
10:
11: import java.io.File;
12: import java.util.Iterator;
13: import javax.swing.JFileChooser;
14: import org.acm.seguin.ide.command.CommandLineSourceBrowser;
15: import org.acm.seguin.ide.common.SourceBrowser;
16: import org.acm.seguin.ide.common.PackageSelectorPanel;
17: import org.acm.seguin.io.AllFileFilter;
18: import org.acm.seguin.summary.*;
19: import org.acm.seguin.tools.RefactoryInstaller;
20: import net.sourceforge.jrefactory.uml.loader.ReloaderSingleton;
21: import org.acm.seguin.util.FileSettings;
22:
23: /**
24: * Draws a UML diagram for all the classes in a package
25: *
26: *@author Chris Seguin
27: */
28: public class Refactory {
29: /**
30: * The main program
31: *
32: *@param args the command line arguments
33: */
34: public static void main(String[] args) {
35: for (int ndx = 0; ndx < args.length; ndx++) {
36: if (args[ndx].equals("-config")) {
37: String dir = args[ndx + 1];
38: ndx++;
39: FileSettings.setSettingsRoot(dir);
40: }
41: }
42:
43: // Make sure everything is installed properly
44: (new RefactoryInstaller(true)).run();
45: SourceBrowser.set(new CommandLineSourceBrowser());
46:
47: if (args.length == 0) {
48: elixir();
49: } else {
50: selectionPanel(args[0]);
51: }
52: }
53:
54: /**
55: * Creates the selection panel
56: *
57: *@param directory Description of Parameter
58: */
59: public static void selectionPanel(String directory) {
60: PackageSelectorPanel panel = PackageSelectorPanel
61: .openMainFrame(directory);
62: ReloaderSingleton.register(panel);
63: }
64:
65: /**
66: * Insertion point for elixir
67: */
68: public static void elixir() {
69: if (PackageSelectorPanel.openMainFrame(null) != null) {
70: return;
71: }
72:
73: JFileChooser chooser = new JFileChooser();
74:
75: // Add other file filters - All
76: AllFileFilter allFilter = new AllFileFilter();
77: chooser.addChoosableFileFilter(allFilter);
78:
79: // Set it so that files and directories can be selected
80: chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
81:
82: // Set the directory to the current directory
83: chooser.setCurrentDirectory(new File(System
84: .getProperty("user.dir")));
85:
86: // Get the user's selection
87: int returnVal = chooser.showOpenDialog(null);
88: if (returnVal == JFileChooser.APPROVE_OPTION) {
89: selectionPanel(chooser.getSelectedFile().getAbsolutePath());
90: }
91: }
92: }
|