4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.131 $ |
* @version $Revision: 1.132 $ |
* |
* Last modification: $Date: 2003/07/26 15:35:48 $ |
* $Id: DocumentManager.java,v 1.131 2003/07/26 15:35:48 smcsporr Exp $ |
* Last modification: $Date: 2003/07/26 15:56:11 $ |
* $Id: DocumentManager.java,v 1.132 2003/07/26 15:56:11 smcsporr Exp $ |
*/ |
|
package src.control; |
50,13 → 50,16 |
* |
* @author Group 5 |
* |
* @version $Revision: 1.131 $ Last modification: $Date: 2003/07/26 15:35:48 $ |
* @version $Revision: 1.132 $ Last modification: $Date: 2003/07/26 15:56:11 $ |
*/ |
public class DocumentManager implements ActionListener,DocumentManagerInterface,ChangeListener { |
|
/** A Vector used to store a list of open documents. */ |
private Vector openDocumentList; |
|
|
/** The global open dialog. Is made global to save last directory. */ |
private JFileChooser fileChooserOpen; |
|
/** A reference variable to the log panel. */ |
private LogInterface logInterfaceReference; |
|
123,6 → 126,19 |
xmlFilter = new XMLExtensionFilter(); |
DTDFilter = new DTDExtensionFilter(); |
schemaFilter = new SchemaExtensionFilter(); |
|
|
/* Initialize the choosing dialog. */ |
fileChooserOpen = new JFileChooser(); |
|
/* Adds a file filter that accepts only files with an *.xml- or *.XML-extension. */ |
fileChooserOpen.addChoosableFileFilter(xmlFilter); |
|
/* Add the ability to choose a 'view all files' filter. */ |
fileChooserOpen.setAcceptAllFileFilterUsed(true); |
|
/* Set the XML file filter as default. */ |
fileChooserOpen.setFileFilter(xmlFilter); |
} |
|
/** |
817,7 → 833,7 |
* |
* author Group 5 |
* |
* Last revision: 08-Jul-2003 |
* Last revision: 28-Jul-2003 by S. Walkenhorst |
*/ |
public boolean loadDocument() { |
|
824,36 → 840,25 |
/* Give a reference to the log panel to the parser. */ |
parser.setLogInterface(logInterfaceReference); |
|
/* Open a choosing dialog. */ |
JFileChooser fileChooser = new JFileChooser(); |
|
/* Adds a file filter that accepts only files with an *.xml- or *.XML-extension. */ |
fileChooser.addChoosableFileFilter(xmlFilter); |
|
/* Add the ability to choose a 'view all files' filter. */ |
fileChooser.setAcceptAllFileFilterUsed(true); |
int returnValue = fileChooserOpen.showOpenDialog(rootFrame); |
|
/* Set the XML file filter as default. */ |
fileChooser.setFileFilter(xmlFilter); |
|
int returnValue = fileChooser.showOpenDialog(rootFrame); |
|
/* Case user has chosen a file. */ |
if (returnValue == JFileChooser.APPROVE_OPTION) { |
|
/* 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()))) { |
if ((fileChooserOpen.getSelectedFile().exists()) && |
(fileChooserOpen.getSelectedFile().canRead()) && |
(! alreadyOpened(fileChooserOpen.getSelectedFile().getName()))) { |
|
/* Set the properties of the new opened document. */ |
OurDocument x = new OurDocument(logInterfaceReference); |
actualDocument = x; |
actualDocument.setFileName(fileChooser.getSelectedFile().getAbsoluteFile()); |
actualDocument.setFileName(fileChooserOpen.getSelectedFile().getAbsoluteFile()); |
actualDocument.setTitle(actualDocument.getFileName().getName()); |
|
parser.parse(fileChooser.getSelectedFile()); |
parser.parse(fileChooserOpen.getSelectedFile()); |
|
/* Save the parsed document object in the active OurDocument instance. */ |
actualDocument.setDomDoc((parser.getDocument())); |
871,9 → 876,9 |
|
/* 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()); |
if (alreadyOpened(fileChooserOpen.getSelectedFile().getName()) == true) { |
changeToDocument(fileChooserOpen.getSelectedFile().getName()); |
parser.parse(fileChooserOpen.getSelectedFile()); |
actualDocument.setDomDoc((parser.getDocument())); |
updateView.update(); |
if(validator.validateDocument(actualDocument.getDomDoc(), actualDocument.getFileName())== false) |