/* The contents of this file are subject to the THDL Open Community License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License on the THDL web site (http://www.thdl.org/). Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific terms governing rights and limitations under the License. The Initial Developer of this software is the Tibetan and Himalayan Digital Library (THDL). Portions created by the THDL are Copyright 2001-2003 THDL. All Rights Reserved. Contributor(s): ______________________________________. */ package org.thdl.tib.bibl; import java.io.*; import java.util.*; import javax.swing.*; import javax.swing.filechooser.*; import org.jdom.*; import org.jdom.input.*; import org.jdom.output.*; //import org.thdl.tib.bibl.shared.*; /** *
* TTFileView test to see if a file is an .xml file and if so, assumes it's a Tibbibl
* and searches for the first <title> element and sets the file's description to that.
* It then uses this description for the name of the text by overriding the {@link #getName} function.
* This is used in for the {@link javax.swing.JFileChooser} in FileAction
so that
* when the open-file window appears it lists the text names instead of the file names.
*
* Overrides the ancestor's--{@link javax.swing.JFileChooser.FileView}--getName() function * so that it returns the text title as the name, if it is an XML file. This has the * effect of presenting a list of text names in the open dialog rather than their less * comprehensible file names. *
* * @param flFile
whose name is requested.
* @return String
the description of the file which has been set to
* the text title if it is an XML file.
*
*/
public String getName(File fl) {
if(getDescription(fl) == null && fl.getName().indexOf(".xml")>-1)
putDescription(fl);
return getDescription(fl);
}
/**
*
* Adds a description to the file, if the file is an XML file and the docHandler
,
* that is an {@link XMLReader}, successfully processes the document and returns a {@link TibDoc}.
* Furthermore, it must find a <title> element (the first in the document) with some text.
* If all these conditions are met, the description of the file is set to the text of the title
* element. Otherwise, the description is set to null
.
*