Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 792 → Rev 793

/sun/xmleditor/trunk/src/control/DocumentManager.java
4,10 → 4,10
* Coded by: Group 5, software practice summer 2003
* University of Bielefeld, Germany
*
* @version $Revision: 1.116 $
* @version $Revision: 1.117 $
*
* Last modification: $Date: 2003/07/24 22:18:06 $
* $Id: DocumentManager.java,v 1.116 2003/07/24 22:18:06 ioklasse Exp $
* Last modification: $Date: 2003/07/25 11:19:55 $
* $Id: DocumentManager.java,v 1.117 2003/07/25 11:19:55 hjokusch Exp $
*/
 
package src.control;
50,7 → 50,7
*
* @author Group 5
*
* @version $Revision: 1.116 $ Last modification: $Date: 2003/07/24 22:18:06 $
* @version $Revision: 1.117 $ Last modification: $Date: 2003/07/25 11:19:55 $
*/
public class DocumentManager implements ActionListener,DocumentManagerInterface,ChangeListener {
 
89,6 → 89,9
/** An instance variable of the Validator class used to validate documents. */
private Validator validator;
/** Create new parser instance for parsing XML documents. */
private Parser parser = new Parser();
/** A parser, in this case used to parse a grammar (DTD or XML schema). */
private Parser grammarParser = new Parser();
175,10 → 178,12
if (event.getActionCommand() == "Open XML file") {
/* Check if the user really choosed a file. */
if (! loadDocument()) {
}
else {
} else {
/* Display data if a file has been loaded. */
pluginTabbedPane.setTitleAt(pluginTabbedPane.getComponentCount()-1,actualDocument.getFileName().getName());
pluginTabbedPane.setTitleAt(pluginTabbedPane.getComponentCount()-1,
actualDocument.getFileName().getName());
updateView.update();
}
 
309,9 → 314,21
changeToDocument(pluginTabbedPane.getTitleAt(pluginTabbedPane.getSelectedIndex()));
}
/* Sends messages to the log panel. */
private void log(int i, String text) {
logInterfaceReference.log(i,text);
/**
* Sends a text message of a specified type (info, error, warning) to the
* registered log panel.
* A reference to an implementation of a log panel can be set with the
* <code>setLogInterface</code> method.
*
* @param i The type of the message as defined in src.gui.LogInterface.
* 0 or src.gui.LogInterface.TYPE_INFO -> info message (black)
* 1 or src.gui.LogInterface.TYPE_WARNING -> warning message (orange)
* 2 or src.gui.LogInterface.TYPE_ERROR -> error message (red)
*
* @param message The text message to display in the log panel.
*/
private void log(int i, String message) {
logInterfaceReference.log(i,message);
}
/**
752,9 → 769,7
*/
public boolean loadDocument() {
/* Create new parser instance. */
Parser parser = new Parser();
/* Give a reference to the log panel to the parser. */
parser.setLogInterface(logInterfaceReference);
774,7 → 789,12
/* Case user has chosen a file. */
if (returnValue == JFileChooser.APPROVE_OPTION) {
if (alreadyOpened(fileChooser.getSelectedFile().getName()) == false) {
/* Check, if the chosen document is already available for editing
* and if the chosen file is access- and readable. */
if ((fileChooser.getSelectedFile().exists()) &&
(fileChooser.getSelectedFile().canRead()) &&
(! alreadyOpened(fileChooser.getSelectedFile().getName()))) {
/* Set the properties of the new opened document. */
OurDocument x = new OurDocument(logInterfaceReference);
781,6 → 801,7
actualDocument = x;
actualDocument.setFileName(fileChooser.getSelectedFile());
actualDocument.setTitle(actualDocument.getFileName().getName());
 
parser.parse(fileChooser.getSelectedFile());
/* Save the parsed document object in the active OurDocument instance. */
794,8 → 815,8
return true;
} else {
/* Checks if the document to be opened is already open and if so, replaces the
* already opened document with the now opened document. */
/* Checks if the document to be opened is already open and if so, replaces
* the already open document with the now opened document. */
if (alreadyOpened(fileChooser.getSelectedFile().getName()) == true) {
changeToDocument(fileChooser.getSelectedFile().getName());
parser.parse(fileChooser.getSelectedFile());
973,7 → 994,9
actualDocument.saveDocument(actualDocument.getDomDoc(),saveFile);
actualDocument.setTitle(fileChooser.getSelectedFile().getName());
actualDocument.setFileName(fileChooser.getSelectedFile());
pluginTabbedPane.setTitleAt(pluginTabbedPane.getSelectedIndex(),actualDocument.getTitle());
pluginTabbedPane.setTitleAt(pluginTabbedPane.getSelectedIndex(),
actualDocument.getTitle());
actualDocument.setSaved();
} else {
}
1061,6 → 1084,7
/* Get the selected file's path and name. */
File selectedFile = fileChooser.getSelectedFile();
/* Check, whether the selected file exists and is readable. */
if (selectedFile.exists() && selectedFile.canRead()) {
try {
1151,8 → 1175,10
/* Parse the selected grammar file. */
File grammarFile = fileChooser.getSelectedFile();
/* Checks, whether the selected file exists and is readable. */
if (grammarFile.exists() && grammarFile.canRead()) {
 
/* Try to get the names of the schema's top level elements. */
elementNames = grammarParser.parseSchemaGrammar(grammarFile);
/* If the PreParser was able to retrieve possible root elements, continue. */