|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.thdl.tib.bibl.TiblEdit
TiblEdit is a editor for the master catalog records of the rNying ma rgyud 'bum. These XML records are displayed in an editor window so that the user can enter certain information into them. It is primarily geared toward allowing the user to critically edit and translate titles. Hence, the name. However, it also at the same time provides the option to assign doxographical genres and other critical information that are then stored in the XML file with valid mark-up.
Field Summary | |
protected static Thread |
t
This is the Thread used to run the splash screen while the program
loads. |
static XMLOutputter |
xop
This static instanciation of an XMLOutputter is used by
the static method outputString(org.jdom.Element) , to print XML mark-up for debugging
purposes. |
Constructor Summary | |
TiblEdit()
The only constructor takes no arguments and simply calls the init() method. |
Method Summary | |
void |
addToRecent(File newFile)
This method takes a file and checks the recent file list to see if it is not already there. |
boolean |
checkCaretPosition(String type)
This method checks the position of the caret to see if it is an appropriate place to perform certain actions depending on the Type parameter supplied. |
void |
closeFile()
Checks to make sure the file has first been saved. |
void |
deleteEdition(Element edToDie)
|
void |
doAppSubmission(Hashtable args)
This method is called from the TibTable which is observed by this
controller. |
int |
doConfirm(String[] specs)
This is a generic method to display a JOptionPane confirm
dialog it takes a String array with three specs. |
int |
doConfirm(String[] specs,
String append)
|
void |
doMessage(String[] specs)
This is a generic method to display a JOptionPane message
dialog it takes a String array with three specs. |
void |
doMessage(String[] specs,
String append)
|
void |
editTranslation()
This method is invoked from the Edit menu and allows the user to edit an already existing translation for a title by inserting the Enter translation prompt prior to the text of the translation and allowing the TextPane to be editable. |
void |
enterDox(org.thdl.tib.bibl.DoxWindow dw)
This method is invoked when the DoxWindow is submitted. |
void |
enterTranslation()
This method is called when one either double clicks on a title or chooses enter a translation from the menu. |
void |
exit()
Writes the preference data. |
File |
getCurrentDirectory()
Returns the path for the current working directory. |
File |
getCurrentFile()
Returns the file that is currently being worked on. |
String |
getDate()
This method returns the value of the today's date variable. |
void |
getEditorInfo()
This method is called if there is no editor information in the preference file. |
String |
getEditorsInitials()
Returns the editors initials. |
String |
getEditorsName()
Returns the editors name. |
org.thdl.tib.bibl.TibFrame |
getFrame()
Returns the view or TibFrame that is the GUI of this program. |
int |
getMode()
This returns the current display mode for the program. |
File |
getNewFile(File outDirectory,
String masterName)
This method returns the new File created from renaming a file according to its master doxographical classification. |
Vector |
getRecent()
Recturns the vector containing the recent files opened. |
Element |
getSelectedElement()
Returns the presently selected element. |
org.thdl.tib.bibl.TibDoc |
getTibDoc()
This returns the TibDoc presently being worked on. |
void |
init()
The init method sets the #dataDirectory , #currentDirectory ,
and the #tibFrame variables. |
void |
insertApp()
This method is called when a selection of title text is made and the insert variant reading choice is taken from the Insert menu. |
void |
insertCritTitle()
This method inserts a title to be critically edited that is based on a particular edition title. |
void |
insertDiscussion()
This method inserts a particular type of discussion depending on the setting of the type parameter. |
void |
insertEdTitle()
This method is for inserting a new edition title. |
void |
insertNewEdAndTitle(org.thdl.tib.bibl.TibDialog tdia)
This enters the information from the TibDialog called by insertNewEdTitle(org.thdl.tib.bibl.TibDialog)
into the TibidDecl of the Tibbibl and then calls TibFrame.showTitles(org.thdl.tib.bibl.TitleFactory) with
the TitleFactory of the Tibbibl and a #mode set to TibConstants.NEW_TITLE . |
void |
insertNewEdition()
|
void |
insertNewEdTitle(org.thdl.tib.bibl.TibDialog tdia)
This is called when a TibDialog is submitted with new edition title information. |
void |
keyPressed(KeyEvent ke)
This implementation of the KeyListener interface is used when information is being added directly to the TextPane being displayed. |
void |
keyReleased(KeyEvent ke)
|
void |
keyTyped(KeyEvent ke)
|
static Element |
locateDisc(Element parent)
This method takes a TitleDecl or any grouping element that might contain a discussion element and checks to see if it has a prose discussion within it. |
static void |
main(String[] args)
|
void |
mouseClicked(MouseEvent me)
This implementation of the mouse listener checks to make sure the source is the TextPane . |
void |
mouseEntered(MouseEvent me)
|
void |
mouseExited(MouseEvent me)
|
void |
mousePressed(MouseEvent me)
|
void |
mouseReleased(MouseEvent me)
|
void |
openFile()
This method uses a JFileChooser to get the user to choose a file and then calls openFile(File) to open the selected file. |
void |
openFile(File file)
With the File sent to it, this method uses
an instance of an XMLReader to read the file. |
static String |
outputString(Element e)
A method for debugging, it takes an Element and converts it to a
string, the way it would be viewed in a plain text editor, angle brackets, attributes, and all. |
static String |
promptInput(String[] specs)
This is a static method to display a JOptionPane input
dialog it takes a String array with three specs. |
void |
readPrefData()
This reads in the preferences from the preference file that is located in TibConstants.DEFAULT_DIRECTORY + TibConstants.BIN +
TibConstants.PREFS . |
void |
removeApp()
|
void |
removeFromRecent(File badFile)
This method removes a file from the recent list if the controller (TiblEdit) cannot open it. |
void |
removePageRefs(Element parentEl,
String corrsp)
|
void |
removeTitle()
|
void |
save(File outFile)
This method actually writes the given file to disk. |
boolean |
saveAs(File outFile)
This method displays a Save As window through a JFileChooser. |
protected boolean |
saveTibbibl()
This method saves the edited TibDoc which is #tibbibl as a new
document to the TibConstants.OUT_DIRECTORY , checking first to make sure
it does not already exist. |
void |
setCaretPosition()
This method sets the caret position to just after the enter information prompt depending on the #mode at the time it is called. |
void |
setCurrentDirectory(File cd)
Sets the current directory to the given path. |
void |
setDate()
This sets the #todaysDate variable to the current date in the form:
YYYY-MM-DD. |
void |
setEditor()
This method is called when the TibDialog for getting editor information
closes. |
void |
setFileChooser()
This sets the #fc variable to a JFileChooser and modifies
it by adding an XMLFilter and a TTFileView . |
void |
setFileName(String masterID)
This method sets the name of the file to be saved for a certain Tibbibl. |
void |
setMode(int m)
This sets the current display mode of the program. |
void |
setSelectedElement(Element e)
Sets the #selected_element variable to the presently selected element. |
void |
showApp()
This method causes the TibFrame to display a table with the
information on variant readings at the bottom of its text pane. |
void |
showMasterDox()
|
static void |
showSplash()
|
void |
showTitles()
This method is used to display a text's variant titles. |
static void |
stopSplash()
This static method stops the splash screen from displaying by interrupting the thread it is on t and setting it to null. |
void |
submitNewEditionInfo(org.thdl.tib.bibl.TibDialog tdia)
|
static String[] |
toStringArray(Object[] objs)
A public static method that converts an Object array into an array of Strings . |
static String[] |
toStringArray(Vector v)
A public static method that converts a Vector into an array of Strings . |
void |
update(Observable obs,
Object arg)
The implementation of the Observer interface is used for listening
to the TibTable that displays variant reading information. |
void |
updateTranslation()
This method is invoked after a translation has been edited and the Enter key has been pressed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static Thread t
This is the Thread
used to run the splash screen while the program
loads.
public static XMLOutputter xop
This static instanciation of an XMLOutputter
is used by
the static method outputString(org.jdom.Element)
, to print XML mark-up for debugging
purposes.
Constructor Detail |
public TiblEdit()
The only constructor takes no arguments and simply calls the init()
method.
Method Detail |
public void init()
The init method sets the #dataDirectory
, #currentDirectory
,
and the #tibFrame
variables. It reads in preferences from readPrefData()
,
performs setDate()
and setFileChooser()
, and sets the #mode
to TibConstants.NORM
.
public void readPrefData()
TibConstants.DEFAULT_DIRECTORY
+ TibConstants.BIN
+
TibConstants.PREFS
. The main preferences that are stored in this file
are: the #editorsInitials
and #editorsName
.
public void getEditorInfo()
TibDialog
with TibConstants.EDITORS_INFO
title and
TibConstants.EDITORS_INFO_SPECS
. When the TibDialog
closes,
it calls setEditor()
.
public void setEditor()
This method is called when the TibDialog
for getting editor information
closes. The information is extracted from the TibDialog
and
the variables #editorsName
and #editorsInitials
are set.
public void setDate()
This sets the #todaysDate
variable to the current date in the form:
YYYY-MM-DD.
public String getDate()
This method returns the value of the today's date variable.
public void exit()
Writes the preference data. This is read in and stored upon initialization of TiblEdit, when the program is restarted.
public void setCurrentDirectory(File cd)
Sets the current directory to the given path.
public File getCurrentDirectory()
Returns the path for the current working directory.
File
- The current working directory as a File object.public File getCurrentFile()
Returns the file that is currently being worked on.
File
- The currently open File object.public void setMode(int m)
This sets the current display mode of the program. The values are:
TibConstants.NORM
- normal
TibConstants.ENTER_TRANS
- for entering translations
TibConstants.NEW_TITLE
- for entering new versions of a title
TibConstants.NEW_AP
- for entering variant readings within a title.
public int getMode()
This returns the current display mode for the program.
setMode(int)
public org.thdl.tib.bibl.TibFrame getFrame()
Returns the view or TibFrame
that is the GUI of this program.
TibFrame
- The frame which displays the text information.public org.thdl.tib.bibl.TibDoc getTibDoc()
This returns the TibDoc
presently being worked on.
TibDoc
that is open.public void setSelectedElement(Element e)
Sets the #selected_element
variable to the presently selected element.
public Element getSelectedElement()
Returns the presently selected element.
public String getEditorsInitials()
Returns the editors initials.
public String getEditorsName()
Returns the editors name.
public Vector getRecent()
Recturns the vector containing the recent files opened.
public void setFileChooser()
This sets the #fc
variable to a JFileChooser
and modifies
it by adding an XMLFilter
and a TTFileView
. The latter serves
to change the getName
function in the file chooser so that it
displays the Tibbibl's text name rather than the actual file name. The file name
is still used when the text is saved.
public void setFileName(String masterID)
This method sets the name of the file to be saved for a certain Tibbibl. It is invoked when the Master ID is set so that the name of the file reflects the master ID.
public File getNewFile(File outDirectory, String masterName)
This method returns the new File created from renaming a file according to its master doxographical
classification. It is called once an entry has been made through the DoxWindow
and the ID and
Sysid have been changed. It takes the folder that new files are written to and the master ID name and
returns the new file. It first checks to make sure the name is unique since it is build from the doxographical
classification number and the first 3 words of the title. If there is a conflict, it begins to add numbers to
the end of the name until a unique name is arrived at.
public void openFile()
This method uses a JFileChooser to get the user to choose a file and then
calls openFile(File)
to open the selected file.
public void openFile(File file)
With the File
sent to it, this method uses
an instance of an XMLReader
to read the file. It sets the tibbibl
variable to the TibDoc extracted by the reader. It then creates a TextPane
, and
sends it to the internal method showTitles()
, which displays titles from the TibDoc
in the TextPane. The text pane is then put in a JScrollPane
and this is sent
to the TibFrame
using its TibFrame.fileOpened()
method.
public void addToRecent(File newFile)
This method takes a file and checks the recent file list to see if it is not already there. If it is not, then it adds it to the list.
public void removeFromRecent(File badFile)
public void closeFile()
Checks to make sure the file has first been saved. If not, then it prompts to save.
If it has then, it calls TibFrame.fileClosed()
and sets #currentFile
to null.
protected boolean saveTibbibl()
This method saves the edited TibDoc
which is #tibbibl
as a new
document to the TibConstants.OUT_DIRECTORY
, checking first to make sure
it does not already exist. If it does, it prompts to overwrite.
public void save(File outFile)
This method actually writes the given file to disk. It is called from the saveTibbibl()
method and
from the saveAs(java.io.File)
method.
public boolean saveAs(File outFile)
This method displays a Save As window through a JFileChooser. It is invoked from saveTibbibl()
when
the user attempts to save a file that exists but choses not to write over it. If the save option is chosen,
it then calls saveTibbibl()
which returns the success, creating a loop until either a unique file name is given,
the overwrite option is chosen, or it is cancelled.
public void showApp()
This method causes the TibFrame
to display a table with the
information on variant readings at the bottom of its text pane. It is
invoked by double clicking on section of the TextPane
that displays
in yellow background, indicating there is an app element there. The clicking
sets the selected element to that app element. If the area is not associated with
an app, nothing happens. If it is, this method first locates the associated
pagination and then calls the TibFrame.showTable(org.thdl.tib.bibl.TibTable)
method that takes
a TibTable
. The TibTable is constructed using the selected element or app,
the IDFactory
of the Tibbibl, and the pagination element.
public void insertNewEdition()
public void submitNewEditionInfo(org.thdl.tib.bibl.TibDialog tdia)
public void insertCritTitle()
This method inserts a title to be critically edited that is based on a particular
edition title. It is called when an edition title is double clicked or when
the corresponding insert command is chosen from the menu. It first locates the
element at the caret, makes sure it is a title and then calls enterTranslation()
.
(Should it check for the title's type here?)
public void insertEdTitle()
This method is for inserting a new edition title. Edition titles cannot be
critically edited. They represent titles as they appear in particular editions.
One choses a particular edition title as the basis for a critical title which
then can have app elements collating the various readings. This method uses
a TibDialog
with TibConstants.NEW_ED_TITLE_INFO
and
TibConstants.NEW_ED_TITLE_INFO_SPECS
to get the title and its pagination.
When the TibDialog
is submitted, the insertNewEdTitle(org.thdl.tib.bibl.TibDialog)
method
is called with that TibDialog
.
public void insertNewEdTitle(org.thdl.tib.bibl.TibDialog tdia)
This is called when a TibDialog
is submitted with new edition title information.
It checks to see if the sigla of the new title (i.e., the edition it is from) already
exists in the texts TibidDecl, using the tibbibl's IDFactory
. If it does not,
exist, another TibDialog
is called with TibConstants.NEW_ED_INFO
and
TibConstants.NEW_ED_INFO_SPECS
to get all the relevant information. When that
second TibDialog
is closed, the insertNewEdAndTitle(org.thdl.tib.bibl.TibDialog)
method
is invoked. Otherwise, if the edition is known, it calls TibFrame.showTitles(org.thdl.tib.bibl.TitleFactory)
with an TitleFactory
and a #mode
equal to TibConstants.NEW_TITLE
to display a place to enter the new title.
public void insertNewEdAndTitle(org.thdl.tib.bibl.TibDialog tdia)
This enters the information from the TibDialog
called by insertNewEdTitle(org.thdl.tib.bibl.TibDialog)
into the TibidDecl of the Tibbibl and then calls TibFrame.showTitles(org.thdl.tib.bibl.TitleFactory)
with
the TitleFactory
of the Tibbibl and a #mode
set to TibConstants.NEW_TITLE
.
This displays an entry place for the new title in the TextPane
.
public void enterTranslation()
This method is called when one either double clicks on a title or chooses enter a translation
from the menu. It first determines if the selected element is the normalized title, in which case
it sets the #mode
to ENTER_NORMALIZED
and redisplays with the appropriate prompts.
Otherwise, it makes sure there is a Tibetan title there and not "No title given" or "Not specified" and
if it's a valid title, asks the user if they want to create a critical title with the selected title
as its base. If so, it redisplays with the appropriate prompts.
public void insertApp()
This method is called when a selection of title text is made and the insert
variant reading choice is taken from the Insert menu. It first checks to make
sure the caret is in the appropriate place using checkCaretPosition(java.lang.String)
with
the param TibConstants.AP
. If it is a viable insertion point, it calculates
the offset of the selection from the previous paragraph mark and calls
TibDoc.insertApp(org.jdom.Element, java.lang.String, int)
using the #selected_element
, the selected text,
and this offset from the last paragraph integer. The #mode
is then set
to TibConstants.NEW_AP
and the showApp()
method is called.
public void insertDiscussion()
This method inserts a particular type of discussion depending on the setting of the
type parameter. When type equals TITLE
, a discussion will be inserted
for the title at the cursor position of the TextPane
. When type equals GEN
the user will be prompted with a list of options to choose from.
public static Element locateDisc(Element parent)
DiscDialog
and so needs to be static.
public void showTitles()
This method is used to display a text's variant titles. It first calls
TibFrame.hideEditions()
to hide any table displaying at the bottom.
It then sets the mode to TibConstants.NORM
and calls TibFrame.showTitles(org.thdl.tib.bibl.TitleFactory)
public void doAppSubmission(Hashtable args)
This method is called from the TibTable
which is observed by this
controller. When it is submitted, it notifies this observer and this method is run.
It takes a hashtable of arguments, as follows:
TibConstants.AP
-- the App that is being modified
TibConstants.TABLE
-- the TibTable.TibTableModel
that contains the data.
TibConstants.PAGIN
-- the hashtable of paginations keyed on edition sigla, used to create table
TibConstants.LM
or lemma element.
Then, it correlates the reading witnesses already in the app element with the siglas
for the lines of data in the table and replaces the information in existing reading elements
or adds new ones where necessary.
public void editTranslation()
This method is invoked from the Edit menu and allows the user to edit an already
existing translation for a title by inserting the Enter translation prompt prior to
the text of the translation and allowing the TextPane
to be editable.
public void updateTranslation()
This method is invoked after a translation has been edited and the Enter key has been pressed. It replaces the text of the Foreign element containing the translation with the next text between the Enter translation prompt and the subsequent paragraph return.
- the implementation of the KeyListener that invokes this method.
public void removeApp()
public void removeTitle()
public void removePageRefs(Element parentEl, String corrsp)
public void deleteEdition(Element edToDie)
public void showMasterDox()
public void enterDox(org.thdl.tib.bibl.DoxWindow dw)
This method is invoked when the DoxWindow
is submitted. It calls upon the
TibDoc
to setDoxography
and then
to setMasterID
.
public void doMessage(String[] specs)
This is a generic method to display a JOptionPane
message
dialog it takes a String
array with three specs.
JOptionPane
.
public void doMessage(String[] specs, String append)
public int doConfirm(String[] specs)
This is a generic method to display a JOptionPane
confirm
dialog it takes a String
array with three specs.
JOptionPane
.
public int doConfirm(String[] specs, String append)
public void setCaretPosition()
This method sets the caret position to just after the enter information prompt
depending on the #mode
at the time it is called. The mode gives an indication
which prompt is being used and should be searched for to determine the corresponding index
at which to set the caret. This is not working correctly. 11 needs to be added to the index
for it to come out even approximately correct. Why is this?
public boolean checkCaretPosition(String type)
This method checks the position of the caret to see if it is an appropriate place to perform certain actions depending on the Type parameter supplied. The types available are:
ED_TITLE
- for adding an edition title.
AP
- for adding variant readings (apparatus).
TRANS_EDIT
- for editing the translation of a title.
public static String promptInput(String[] specs)
This is a static method to display a JOptionPane
input
dialog it takes a String
array with three specs.
JOptionPane
.
String
that was inputed.
public static String[] toStringArray(Vector v)
A public static method that converts a Vector
into an array of Strings
.
String[]
The resulting array of Strings
.public static String[] toStringArray(Object[] objs)
A public static method that converts an Object
array into an array of Strings
.
String[]
The resulting array of Strings
.public static String outputString(Element e)
A method for debugging, it takes an Element
and converts it to a
string, the way it would be viewed in a plain text editor, angle brackets, attributes, and all.
This is a public, static method that can be called from anywhere with this classes prefix.
String
The resulting string version of the element.public static void showSplash()
public static void stopSplash()
This static method stops the splash screen from displaying by interrupting
the thread it is on t
and setting it to null.
public static void main(String[] args)
public void mouseClicked(MouseEvent me)
This implementation of the mouse listener checks to make sure the source is
the TextPane
. Then, it makes sure the #mode
is TibConstants.NORM
to make sure action is viable. Thus, it only responds when the TextPane
is click when nothing else is being inserted etc. It makes sure its a double click
and there is an ElementList
defined to check. It checks the #elemList
for the selected element, if it is a TibConstants.TITLE
, then it calls
enterTranslation()
. If it is an TibConstants.AP
, then it calls
showApp()
.
mouseClicked
in interface MouseListener
public void mousePressed(MouseEvent me)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent me)
mouseReleased
in interface MouseListener
public void mouseEntered(MouseEvent me)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent me)
mouseExited
in interface MouseListener
public void keyPressed(KeyEvent ke)
This implementation of the KeyListener interface is used when information
is being added directly to the TextPane
being displayed. If the
Enter key is pressed, the it checks the #mode
. If the mode is
TibConstants.ENTER_TRANS
, then it calls #insertTranslation
.
If the mode is TibConstants.NEW_TITLE
, it calls #insertNewTitleAndTranslation
.
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent ke)
keyReleased
in interface KeyListener
public void keyTyped(KeyEvent ke)
keyTyped
in interface KeyListener
public void update(Observable obs, Object arg)
The implementation of the Observer
interface is used for listening
to the TibTable
that displays variant reading information. That table
is displayed along with a button panel for submitting and canceling. When either
of those buttons are pressed. The TibTable notifies its observers (the TiblEdit
controller) with an argument of a Hashtable
with keyed specs.
If the type key equals TibConstants.APP_SUBMIT
then the doAppSubmission(java.util.Hashtable)
is called with the arguments. If it is TibConstants.CANCEL
, then
it calls the showTitles()
method with mode TibConstants.CANCEL_NEW_APP
.
update
in interface Observer
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |