User: rinkrank
Date: 02/04/21 18:45:19
Modified: src/java/xdocletgui/swing Main.java
Log:
-small update to match recent API change in xjavadoc
Revision Changes Path
1.10 +708 -525 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.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- Main.java 16 Apr 2002 14:44:44 -0000 1.9
+++ Main.java 22 Apr 2002 01:45:19 -0000 1.10
@@ -1,66 +1,51 @@
/*
- * Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
+ * Copyright (c) 2001,2002 The XDoclet team
* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * - Neither the name of BEKK Consulting nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-
-/*
- * Change log
- *
*/
package xdocletgui.swing;
import java.io.File;
+
import java.io.Reader;
+
import java.io.FileReader;
+
import java.io.IOException;
+
import java.awt.event.ActionEvent;
+
import java.awt.event.WindowListener;
+
import java.awt.event.WindowEvent;
+
import java.awt.event.WindowAdapter;
import xjavadoc.ant.XJavadocTask;
+
import xjavadoc.ant.XJavaDocMain;
+
import xjavadoc.XJavaDocRoot;
+
import xjavadoc.XJavaDoc;
+
import xjavadoc.XDoc;
+
import xjavadoc.XTag;
import xjavadoc.XJavaDocException;
+
import xjavadoc.XClass;
import org.apache.tools.ant.*;
+
import org.apache.tools.ant.types.*;
import xtags.ConditionFactory;
+
import xtags.TagFamilies;
import javax.swing.*;
+
import javax.swing.tree.*;
/**
@@ -70,74 +55,93 @@
* @created 21. desember 2001
* @todo-javadoc Write javadocs
*/
-public class Main extends XJavaDocMain {
- /**
- * array of parsed classes
- */
- private XClass[] _classes;
- /**
- * root of xjavadoc hierarchy
- */
- private XJavaDocRoot _xJavaDocRoot;
+public class Main extends XJavaDocMain
+{
/**
- * directory to save hierarchy
+ * Get static reference to Log4J Logger
*/
- private File _saveDir;
- /**
- * directory or file to load class hierarchy
- */
- private File _loadSource;
+ private static org.apache.log4j.Category _log =
org.apache.log4j.Category.getInstance( Main.class.getName() );
/**
* file chooser to choose directory
*/
+
private final JFileChooser _fileChooser = new JFileChooser();
/**
* action to provide save-as operation
*/
+
private final SaveAsAction _saveAsAction = new SaveAsAction();
+
/**
* action to provide save operation
*/
+
private final SaveAction _saveAction = new SaveAction();
/**
* action to provide loading of sources
*/
+
private final LoadAction _loadAction = new LoadAction();
/**
* action to provide exit
*/
+
private final ExitAction _exitAction = new ExitAction();
/**
* window listener for main window
*/
+
private final WindowListener _mainWindowListener = new MainWindowListener();
+
+ /**
+ * array of parsed classes
+ */
+
+ private XClass[] _classes;
+
+ /**
+ * root of xjavadoc hierarchy
+ */
+
+ private XJavaDocRoot _xJavaDocRoot;
+
+ /**
+ * directory to save hierarchy
+ */
+
+ private File _saveDir;
+
+ /**
+ * directory or file to load class hierarchy
+ */
+
+ private File _loadSource;
+
/**
* whether this fierarchy is modified ( save needed )
*/
+
private boolean _isModified;
/**
* frame object pointer
*/
+
private JFrame _frame;
/**
* main panel object
*/
- private MainPanel _mainPanel;
- /**
- * Get static reference to Log4J Logger
- */
- private static org.apache.log4j.Category _log =
org.apache.log4j.Category.getInstance(Main.class.getName());
+ private MainPanel _mainPanel;
/**
@@ -147,16 +151,24 @@
* @todo-javadoc Write javadocs for exception
* @todo-javadoc Write javadocs for constructor
*/
- public Main() throws XJavaDocException {
+
+ public Main() throws XJavaDocException
+ {
+
_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
createGUI();
+
}
/**
* @return exit action object
*/
- public ExitAction getExitAction() {
+
+ public ExitAction getExitAction()
+ {
+
return _exitAction;
}
@@ -166,7 +178,10 @@
*
* @return The LoadAction value
*/
- public LoadAction getLoadAction() {
+
+ public LoadAction getLoadAction()
+ {
+
return _loadAction;
}
@@ -176,7 +191,10 @@
*
* @return The MainWindowListener value
*/
- public WindowListener getMainWindowListener() {
+
+ public WindowListener getMainWindowListener()
+ {
+
return _mainWindowListener;
}
@@ -186,7 +204,10 @@
*
* @return The SaveAsAction value
*/
- public Action getSaveAsAction() {
+
+ public Action getSaveAsAction()
+ {
+
return _saveAsAction;
}
@@ -196,7 +217,10 @@
*
* @return The SaveAction value
*/
- public Action getSaveAction() {
+
+ public Action getSaveAction()
+ {
+
return _saveAction;
}
@@ -207,44 +231,73 @@
* @exception XJavaDocException Describe the exception
* @todo-javadoc Write javadocs for exception
*/
- public void createGUI() throws XJavaDocException {
- try {
+
+ public void createGUI() throws XJavaDocException
+ {
+
+ try
+ {
+
_mainPanel = new MainPanel();
_frame = new JFrame("XDoclet GUI");
+
_frame.addWindowListener(getMainWindowListener());
+
_frame.getContentPane().add(_mainPanel);
+
_frame.pack();
+
// make a menu
+
JMenuBar bar = new JMenuBar();
+
JMenu file = new JMenu("File");
+
bar.add(file);
+
file.add(getLoadAction());
+
file.addSeparator();
+
file.add(getSaveAction());
+
file.add(getSaveAsAction());
+
file.addSeparator();
+
file.add(getExitAction());
+
_frame.setJMenuBar(bar);
- } catch (Exception e) {
+ }
+ catch( Exception e )
+ {
+
_log.error("Fatal error", e);
+
throw new XJavaDocException(e);
}
+
}
/**
* exit application. maybe save...
*/
- public void exit() {
+
+ public void exit()
+ {
+
// check whether save needed
_frame.setVisible(false);
System.out.println("exiting");
+
System.exit(0);
+
}
@@ -254,41 +307,70 @@
* @todo-javadoc Write javadocs for exception
* @todo-javadoc Write javadocs for exception
*/
- public void load() {
+
+ public void load()
+ {
+
_log.debug("loading");
+
int result = _fileChooser.showDialog(null, "Select");
- if (result == JFileChooser.APPROVE_OPTION) {
+
+ if( result == JFileChooser.APPROVE_OPTION )
+ {
+
_loadSource = _fileChooser.getSelectedFile();
+
_log.debug("loading from " + _loadSource);
- if (_loadSource.isFile()) {
+ if( _loadSource.isFile() )
+ {
+
// load from file
+
}
- else {
+
+ else
+ {
+
// load from directory
- try {
+
+ try
+ {
+
_xJavaDocRoot = XJavaDoc.getInstance();
XJavaDoc.getInstance().reset();
+
// do whatever necessary to feed
+
// xjavadoc with files
+
// did not figured yet what exactly
- _classes = _xJavaDocRoot.sourceClasses();
+
+ _classes = _xJavaDocRoot.sourceClasses( true );
+
_mainPanel.loadClasses(_classes);
- } catch (XJavaDocException e) {
+
+ }
+ catch( XJavaDocException e )
+ {
+
_log.error("Fatal error", e);
+
}
+
}
}
+
}
/**
* invioked when xjavadoc is ready.
*
- * @param extraContextFileName Describe what the parameter does
+ * @param args
* @exception java.lang.Exception Describe the exception
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
@@ -297,19 +379,23 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected void start(String extraContextFileName) throws java.lang.Exception {
+
+ protected void start( String[] args ) throws java.lang.Exception
+ {
// make the tree to the left
+
_xJavaDocRoot = XJavaDoc.getInstance();
- _classes = _xJavaDocRoot.sourceClasses(true, true);
+
+ _classes = _xJavaDocRoot.sourceClasses( true );
_mainPanel.loadClasses(_classes);
+
_frame.setVisible(true);
}
-
/**
* Describe what the method does
*
@@ -317,12 +403,21 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- private void saveAs() throws IOException {
+
+ private void saveAs() throws IOException
+ {
+
int result = _fileChooser.showDialog(null, "Select");
- if (result == JFileChooser.APPROVE_OPTION) {
+
+ if( result == JFileChooser.APPROVE_OPTION )
+ {
+
_saveDir = _fileChooser.getSelectedFile();
+
save();
+
}
+
}
@@ -333,16 +428,31 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- private void save() throws IOException {
- if (_saveDir == null) {
+
+ private void save() throws IOException
+ {
+
+ if( _saveDir == null )
+ {
+
saveAs();
+
}
- else {
- for (int i = 0; i < _classes.length; i++) {
+
+ else
+ {
+
+ for( int i = 0; i < _classes.length; i++ )
+ {
+
XClass xClass = (XClass)_classes[i];
+
xClass.save(_saveDir);
+
}
+
}
+
}
@@ -353,14 +463,21 @@
* @created 14. januar 2002
* @todo-javadoc Write javadocs
*/
- private class SaveAction extends AbstractAction {
+
+ private class SaveAction extends AbstractAction
+ {
+
/**
* Describe what the SaveAction constructor does
*
* @todo-javadoc Write javadocs for constructor
*/
- public SaveAction() {
+
+ public SaveAction()
+ {
+
putValue(Action.NAME, "Save");
+
}
@@ -371,13 +488,25 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
- public void actionPerformed(ActionEvent evt) {
- try {
+
+ public void actionPerformed( ActionEvent evt )
+ {
+
+ try
+ {
+
save();
- } catch (IOException e) {
+
+ }
+ catch( IOException e )
+ {
+
JOptionPane.showMessageDialog(null, "Couldn't save to
" + _saveDir.getAbsolutePath(), "Save error", JOptionPane.ERROR_MESSAGE);
+
}
+
}
+
}
@@ -388,14 +517,21 @@
* @created 14. januar 2002
* @todo-javadoc Write javadocs
*/
- private class SaveAsAction extends AbstractAction {
+
+ private class SaveAsAction extends AbstractAction
+ {
+
/**
* Describe what the SaveAsAction constructor does
*
* @todo-javadoc Write javadocs for constructor
*/
- public SaveAsAction() {
+
+ public SaveAsAction()
+ {
+
putValue(Action.NAME, "Save As...");
+
}
@@ -406,13 +542,25 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
- public void actionPerformed(ActionEvent evt) {
- try {
+
+ public void actionPerformed( ActionEvent evt )
+ {
+
+ try
+ {
+
saveAs();
- } catch (IOException e) {
+
+ }
+ catch( IOException e )
+ {
+
JOptionPane.showMessageDialog(null, "Couldn't save to
" + _saveDir.getAbsolutePath(), "Save error", JOptionPane.ERROR_MESSAGE);
+
}
+
}
+
}
@@ -423,14 +571,21 @@
* @created February 8, 2002
* @todo-javadoc Write javadocs
*/
- private class ExitAction extends AbstractAction {
+
+ private class ExitAction extends AbstractAction
+ {
+
/**
* Describe what the SaveAsAction constructor does
*
* @todo-javadoc Write javadocs for constructor
*/
- public ExitAction() {
+
+ public ExitAction()
+ {
+
putValue(Action.NAME, "Exit");
+
}
@@ -441,11 +596,14 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
- public void actionPerformed(ActionEvent evt) {
+
+ public void actionPerformed( ActionEvent evt )
+ {
exit();
}
+
}
@@ -456,14 +614,21 @@
* @created February 8, 2002
* @todo-javadoc Write javadocs
*/
- private class LoadAction extends AbstractAction {
+
+ private class LoadAction extends AbstractAction
+ {
+
/**
* Describe what the SaveAsAction constructor does
*
* @todo-javadoc Write javadocs for constructor
*/
- public LoadAction() {
+
+ public LoadAction()
+ {
+
putValue(Action.NAME, "Load");
+
}
@@ -475,11 +640,14 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
- public void actionPerformed(ActionEvent evt) {
+
+ public void actionPerformed( ActionEvent evt )
+ {
load();
}
+
}
@@ -490,7 +658,9 @@
* @created February 15, 2002
* @todo-javadoc Write javadocs
*/
- private class MainWindowListener extends WindowAdapter {
+
+ private class MainWindowListener extends WindowAdapter
+ {
/**
* catch attempt to close window. ask for saving
@@ -498,12 +668,18 @@
* @param e Describe what the parameter does
* @todo-javadoc Write javadocs for method parameter
*/
- public void windowClosing(WindowEvent e) {
+
+ public void windowClosing( WindowEvent e )
+ {
+
_log.debug("windowClosing called");
+
System.out.println("windowClosing called");
+
// take care of saving stuff if necessary
exit();
+
}
@@ -514,12 +690,19 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
- public void windowClosed(WindowEvent e) {
+
+ public void windowClosed( WindowEvent e )
+ {
+
_log.debug("windowClosed called");
+
System.out.println("windowClosed called");
+
exit();
+
}
}
}
+
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel