User: ko5tik Date: 02/02/17 11:44:18 Modified: src/java/xdocletgui/swing Main.java MainPanel.java TreeFactoryScratch.java Log: added loading of source directories. way free for standalone app Revision Changes Path 1.3 +66 -16 xdocletgui/src/java/xdocletgui/swing/Main.java Index: Main.java =================================================================== RCS file: /cvsroot/xdoclet/xdocletgui/src/java/xdocletgui/swing/Main.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- Main.java 15 Feb 2002 13:55:12 -0000 1.2 +++ Main.java 17 Feb 2002 19:44:18 -0000 1.3 @@ -47,6 +47,7 @@ import xjavadoc.ant.XJavadocTask; import xjavadoc.XJavaDoclet; import xjavadoc.XJavaDocRoot; +import xjavadoc.XJavaDoc; import xjavadoc.XJavaDocException; import xjavadoc.XClass; import xjavadoc.parser.SourceClass; @@ -83,6 +84,11 @@ private File _saveDir; /** + * directory or file to load class hierarchy + */ + private File _loadSource; + + /** * file chooser to choose directory */ private final JFileChooser _fileChooser = new JFileChooser(); @@ -119,6 +125,11 @@ * frame object pointer */ private JFrame _frame; + + /** + * main panel object + */ + private MainPanel _mainPanel; /** * Get static reference to Log4J Logger */ @@ -127,12 +138,15 @@ /** - * Describe what the Main constructor does + * rig up interface * + * @exception XJavaDocException Describe the exception + * @todo-javadoc Write javadocs for exception * @todo-javadoc Write javadocs for constructor */ - public Main() { + public Main() throws XJavaDocException { _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + createGUI(); } @@ -185,26 +199,18 @@ /** - * Describe what the method does + * rig up user interface * - * @param xjavadoc Describe what the parameter does * @exception XJavaDocException Describe the exception - * @todo-javadoc Write javadocs for method - * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void start(XJavaDocRoot xjavadoc) throws XJavaDocException { - _xJavaDocRoot = xjavadoc; - + public void createGUI() throws XJavaDocException { try { - // make the tree to the left - _classes = xjavadoc.classes(); - - MainPanel mainPanel = new MainPanel(_classes); + _mainPanel = new MainPanel(); _frame = new JFrame("XDoclet GUI"); _frame.addWindowListener(getMainWindowListener()); - _frame.getContentPane().add(mainPanel); + _frame.getContentPane().add(_mainPanel); _frame.pack(); // make a menu @@ -219,8 +225,6 @@ file.add(getExitAction()); _frame.setJMenuBar(bar); - _frame.setVisible(true); - } catch (Exception e) { _log.error("Fatal error", e); throw new XJavaDocException(e); @@ -229,6 +233,26 @@ /** + * Describe what the method does + * + * @param xjavadoc Describe what the parameter does + * @exception XJavaDocException Describe the exception + * @todo-javadoc Write javadocs for method + * @todo-javadoc Write javadocs for method parameter + * @todo-javadoc Write javadocs for exception + */ + public void start(XJavaDocRoot xjavadoc) throws XJavaDocException { + _xJavaDocRoot = xjavadoc; + + // make the tree to the left + _classes = xjavadoc.classes(); + _mainPanel.loadClasses(_classes); + _frame.setVisible(true); + + } + + + /** * exit application. maybe save... */ public void exit() { @@ -245,8 +269,33 @@ * load sources * * @todo-javadoc Write javadocs for exception + * @todo-javadoc Write javadocs for exception */ public void load() { + System.out.println("loading"); + + int result = _fileChooser.showDialog(null, "Select"); + if (result == JFileChooser.APPROVE_OPTION) { + _loadSource = _fileChooser.getSelectedFile(); + System.out.println("loading from " + _loadSource); + + if (_loadSource.isFile()) { + // load from file + } + else { + // load from directory + try { + XJavaDoc xjd = new XJavaDoc(_loadSource, null); + xjd.scan(); + _xJavaDocRoot = xjd; + _classes = _xJavaDocRoot.classes(); + _mainPanel.loadClasses(_classes); + } catch (XJavaDocException e) { + _log.error("Fatal error", e); + } + } + + } } @@ -412,6 +461,7 @@ * Describe what the method does * * @param evt Describe what the parameter does + * @todo-javadoc Write javadocs for exception * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for method parameter */ 1.2 +152 -113 xdocletgui/src/java/xdocletgui/swing/MainPanel.java Index: MainPanel.java =================================================================== RCS file: /cvsroot/xdoclet/xdocletgui/src/java/xdocletgui/swing/MainPanel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- MainPanel.java 25 Jan 2002 00:50:15 -0000 1.1 +++ MainPanel.java 17 Feb 2002 19:44:18 -0000 1.2 @@ -64,6 +64,11 @@ public class MainPanel extends JPanel { /** + * @todo-javadoc Describe the field + */ + JTree _tree; + + /** * Get static reference to Log4J Logger */ private static org.apache.log4j.Category _log = org.apache.log4j.Category.getInstance(MainPanel.class.getName()); @@ -80,6 +85,26 @@ */ public MainPanel(XClass[] classes) { super(new BorderLayout()); + createGUI(); + loadClasses(classes); + } + + + /** + * Describe what the MainPanel constructor does + * + * @todo-javadoc Write javadocs for constructor + */ + public MainPanel() { + super(new BorderLayout()); + createGUI(); + } + + + /** + * create GUI stuff + */ + public void createGUI() { try { // Set multiline tooltip which shows for a while String multiLineToolTipUIClassName = "xdocletgui.swing.MultiLineToolTipUI"; @@ -88,9 +113,13 @@ ToolTipManager.sharedInstance().setDismissDelay(30000); // make the tree to the left - TreeModel tm = TreeFactoryScratch.createDefault(classes); - JTree t = new JTree(tm); - JScrollPane s = new JScrollPane(t); + _tree = new JTree( + /* + * new DefaultTreeModel(new DefaultMutableTreeNode()) + */ + ); + _tree.setModel(null); + JScrollPane s = new JScrollPane(_tree); // make the config panel to the right ConditionFactory configurationFactory = new ConditionFactory(); @@ -99,15 +128,25 @@ // hook them together via a listener RenderDocumentedTreeListener renderDocumentedTreeListener = new RenderDocumentedTreeListener(tagFamiliesPanel); - t.addTreeSelectionListener(renderDocumentedTreeListener); + _tree.addTreeSelectionListener(renderDocumentedTreeListener); // show them both in a split pane JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, s, tagFamiliesPanel); add(splitPane, BorderLayout.CENTER); - } catch (Exception e) { _log.error("", e); } + } + + /** + * load class hierarchy + * + * @param classes Describe what the parameter does + * @todo-javadoc Write javadocs for method parameter + */ + public void loadClasses(XClass[] classes) { + _tree.setModel(TreeFactoryScratch.createDefault(classes)); + } } 1.2 +107 -102 xdocletgui/src/java/xdocletgui/swing/TreeFactoryScratch.java Index: TreeFactoryScratch.java =================================================================== RCS file: /cvsroot/xdoclet/xdocletgui/src/java/xdocletgui/swing/TreeFactoryScratch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- TreeFactoryScratch.java 25 Jan 2002 00:50:18 -0000 1.1 +++ TreeFactoryScratch.java 17 Feb 2002 19:44:18 -0000 1.2 @@ -87,6 +87,11 @@ private static void addClasses(XClass[] classes, DefaultMutableTreeNode root, String visualName, String className) { DefaultMutableTreeNode classType = new DefaultMutableTreeNode(visualName); root.add(classType); + + //allow creation of empty tree model + if (classes == null) { + return; + } for (int i = 0; i < classes.length; i++) { if (classes[i].isA(className)) { DefaultMutableTreeNode clazz = new DefaultMutableTreeNode(classes[i]);
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel