4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.138 $ |
* @version $Revision: 1.139 $ |
* |
* Last modification: $Date: 2003/07/28 15:26:39 $ |
* $Id: DocumentManager.java,v 1.138 2003/07/28 15:26:39 hjokusch Exp $ |
* Last modification: $Date: 2003/07/28 17:09:51 $ |
* $Id: DocumentManager.java,v 1.139 2003/07/28 17:09:51 smcsporr Exp $ |
*/ |
|
package src.control; |
52,7 → 52,7 |
* |
* @author Group 5 |
* |
* @version $Revision: 1.138 $ Last modification: $Date: 2003/07/28 15:26:39 $ |
* @version $Revision: 1.139 $ Last modification: $Date: 2003/07/28 17:09:51 $ |
*/ |
public class DocumentManager implements ActionListener, DocumentManagerInterface, |
ChangeListener { |
110,7 → 110,8 |
|
/** |
* The class constructor instantiates the document lists and file filters needed and |
* creates a new instance of <code>DocumentFactory</code>. |
* creates a new instance of <code>DocumentFactory</code>. A global <code>JFileChooser</code> |
* is created to remember the last directory where a document has been opened. |
* |
* author Group 5 |
* |
127,7 → 128,6 |
DTDFilter = new DTDExtensionFilter(); |
schemaFilter = new SchemaExtensionFilter(); |
|
|
/* Initialize the choosing dialog. */ |
fileChooserOpen = new JFileChooser(); |
|
184,6 → 184,8 |
* 'Validate document' |
* 'Set DTD' |
* 'Set XML schema' |
* 'Remove DTD' |
* 'Remove XML schema' |
* |
* @param event The <code>ActionEvent</code> that occured. |
* |
209,7 → 211,6 |
|
updateView.update(); |
} |
|
} |
|
/* Actions to perform if the user choosed the 'New document' option. */ |
826,6 → 827,17 |
* This method displays a <code>JFileChooser</code> and parses a file if the user |
* chooses one. |
* |
* The method checks, if the file to open is already available in the internal |
* document list. If not, a new empty <code>OurDocument</code> instance will be |
* created. If the specified file could've been parsed, the document object |
* created by the parser is copied into the new <code>OurDocument</code> instance |
* and a new tab will be added to the tabbed pane containing a reference to the |
* parsed document. |
* If the document is already available in the document list, the current |
* document object in memory will be replaced by a reparsed instance. |
* In both cases, the parsed file will be validated against an XML grammar, if |
* one is specified in the XML document. |
* |
* @return Returns <code>true</code>, if a file has been chosen, false otherwise. |
* |
* author Group 5 |
842,15 → 854,11 |
/* 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 ((fileChooserOpen.getSelectedFile().exists()) && |
(fileChooserOpen.getSelectedFile().canRead()) && |
(! alreadyOpened(fileChooserOpen.getSelectedFile().getName()))) { |
/* Check, if the chosen document is already available for editing. */ |
if (! alreadyOpened(fileChooserOpen.getSelectedFile().getName())) { |
|
/* Set the properties of the new opened document. */ |
OurDocument docu = new OurDocument(logInterfaceReference); |
|
docu.setFileName(fileChooserOpen.getSelectedFile().getAbsoluteFile()); |
docu.setTitle(docu.getFileName().getName()); |
|
859,15 → 867,25 |
/* Save the parsed document object in the active OurDocument instance. */ |
docu.setDomDoc((parser.getDocument())); |
actualDocument = docu; |
|
/* Create a new panel and add it to the tabbed pane together with the document. */ |
JPanel panel = new JPanel(); |
pluginTabbedPane.addTab(actualDocument.getTitle(),panel); |
openDocumentList.add(actualDocument); |
|
updateView.update(); |
|
if(validator.validateDocument(actualDocument.getDomDoc(), actualDocument.getFileName())== false) |
logInterfaceReference.log(LogInterface.TYPE_ERROR, "The document " + actualDocument.getTitle()+" does not fit to the specified grammar"); |
/* Validate the document after loading. */ |
if (! validator.validateDocument(actualDocument.getDomDoc(), |
actualDocument.getFileName())) { |
logInterfaceReference.log(LogInterface.TYPE_ERROR, |
"The document " + actualDocument.getTitle()+ |
" does not fit to the specified grammar !"); |
} |
|
actualDocument.setSaved(); |
pluginTabbedPane.setSelectedIndex(pluginTabbedPane.getComponentCount()-1); |
|
return true; |
} else { |
|
874,13 → 892,22 |
/* 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(fileChooserOpen.getSelectedFile().getName()) == true) { |
|
/* Change focus to the document opened. */ |
changeToDocument(fileChooserOpen.getSelectedFile().getName()); |
parser.parse(fileChooserOpen.getSelectedFile()); |
actualDocument.setDomDoc((parser.getDocument())); |
updateView.update(); |
if(validator.validateDocument(actualDocument.getDomDoc(), actualDocument.getFileName())== false) |
logInterfaceReference.log(LogInterface.TYPE_ERROR, "The document " + actualDocument.getTitle()+" does not fit to the specified grammar"); |
|
/* Validate the document after loading. */ |
if (! validator.validateDocument(actualDocument.getDomDoc(), |
actualDocument.getFileName())) { |
logInterfaceReference.log(LogInterface.TYPE_ERROR, |
"The document " + actualDocument.getTitle()+ |
" does not fit to the specified grammar !"); |
} |
actualDocument.setSaved(); |
|
return true; |
} else { |
return false; |