org.thdl.tib.bibl
Class TiblEdit

java.lang.Object
  |
  +--org.thdl.tib.bibl.TiblEdit
All Implemented Interfaces:
EventListener, KeyListener, MouseListener, Observer, TibConstants

public class TiblEdit
extends Object
implements MouseListener, KeyListener, Observer, TibConstants

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.

Author:
Than Garson, Tibetan and Himalayan Digital Library

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.
 
Fields inherited from interface org.thdl.tib.bibl.TibConstants
ABBR, ABOUT, ADD_DOX, ALT, ANUYOGA, AP, AP_CHECK, APP_SUBMIT, ATIYOGA, BACK, BAD_PARA, BASE_FONT_NAME, BASE_FONT_SIZE, BG, BIN, BIN_LOGIN, BODY, BOLD, BOLD_FONT, BRIEF, BUT_MARGINS, BUTT_PANEL_SIZE, BUTTON_SIZE, CANC, CANCEL, CANCEL_NEW_APP, CATEG, CHANGE, CHAP_TITLES_HEAD, CHAPS, CHAPTER, CIT, CLASS, CLOSE_TITLE_HEAD, CLOSEFILE, CLOSING, CONTROL, CONTROL_SOURCE, CONTROLLER, CORRESP, CORRESP_NG, CREATE_FILE_LIST, CREATE_FILE_LIST_SPECS, CREATE_FILE_LIST_TITLE, CREATOR, CRIT_ED_DESC, CRIT_ED_LABEL, CRIT_TITLE, CROSSREF, CURR_DIR, DATA_DIRECTORY, DATE, DATE_DELIM, DATE_MESSAGE, DATE_TITLE, DEFAULT_BGCOLOR, DEFAULT_BUTTON_COLOR, DEFAULT_DIRECTORY, DEFAULT_FONT, DEFAULT_HEADER, DEFAULT_INSETS, DEFAULT_PANEL_SIZE, DEL_EDS_MESS, DEL_EDS_TITLE, DESIG, DG, DIA_DATA, DIAC, DISC, DISC_DIA_TITLE, DIV, DO_ALL_TITLES, DO_TRANS, DOX, DOX_CAT_DELIM, DOX_DELIM, DOX_WINDOW_TITLE, DOXTYPE, ED, ED_EXISTS, ED_EXISTS_MESSAGE, ED_EXISTS_SPECS, ED_EXISTS_TITLE, ED_ID_MESS, ED_ID_REQUIRED, ED_ID_TITLE, ED_INFO, ED_NAME, ED_SCROLL_SIZE, ED_SIG, ED_SIGLA, ED_STRING, ED_TEXT_NUM, ED_TITLE, ED_TITLE_REM, ED_VOL_LET, ED_VOL_NUM, EDCON, EDCONS, EDIT, EDITOR_NAME_MESSAGE, EDITOR_NAME_TITLE, EDITORS_INFO, EDITORS_INFO_SPECS, EDITORS_INITIALS, EDITORS_NAME, EDNAMES, EDS_CORR, ENG, ENTER, ENTER_NORM_TRANS_PHRASE, ENTER_NORMALIZED, ENTER_NORMALIZED_PHRASE, ENTER_PLACE, ENTER_TITLE_PHRASE, ENTER_TRANS, ENTER_TRANS_PHRASE, EOC, EOC_TITLES_HEAD, EX1, EX2, EXIT, EXPAN, EXPORT, FILE, FILE_EXISTS, FILE_EXISTS_SPECS, FILE_EXISTS_TITLE, FOREIGN, FRAME, FRONT, FULL, FULL_TEXT_PAGE, GEN, GET_DESIG, GET_DESIG_QUESTION, GET_DESIG_SPECS, HEAD, HEAD_FONT, HEAD_FONT_SIZE, HI, ID, INFO, INPUT_DATE_MESSAGE, INPUT_DATE_TITLE, INSERT, INSERT_APP, INTDECL, INV_TRANS, INV_TRANS_TITLE, INVALID_TRANS_SPECS, IS_FILE_LIST, ITALIC, ITEM, JOP_ERROR, JOP_INFO, JOP_QUEST, JOP_WARN, JOP_YESNOCANCEL, KG, LABEL_SIZE, LABEL_SPACE, LANG, LANG_ENG, LANG_TIB, LET, LIST, LIST_COLOR, LIST_INSETS, LM, LVL, MAHAYOGA, MAIN_MARGINS, MASTER_ID_VIEW, MASTER_SIGLA, MENU_FONT, MISC, N, NAME, NEW_AP, NEW_ED_INFO, NEW_ED_INFO_SPECS, NEW_ED_TITLE_INFO, NEW_ED_TITLE_INFO_SPECS, NEW_TITLE, NG, NGDIVS, NGSIGS, NO, NO_ELEM, NO_SELECT_TITLE, NO_SELECTION, NO_SELECTION_SPECS, NO_TITLE, NO_TITLE_MESSAGE, NO_TITLE_SPECS, NO_TITLE_TITLE, NON_TIB_HEAD, NON_TIB_TITLE_HEAD, NONTIB, NONTIBET, NORM, NORM_AP_ERROR, NORM_AP_MESS, NORM_AP_TITLE, NORM_EDIT, NORM_ENG_LABEL, NORM_TIB_LABEL, NORM_TITLE, NORM_TITLE_HEAD, NOT_SAVED_MESSAGE, NOT_SAVED_TITLE, NOT_SPEC, NOT_SPEC_MESSAGE, NOT_SPEC_SPECS, NOT_SPEC_TITLE, NOTE, NOTFOUND, NUM, NUMB, OPEN_ERROR, OPEN_TITLE, OPENFILE, ORIG_LANG, OTHER, OTHER_EDS, OUT_DIRECTORY, P, PAGE_RANGE, PAGIN, PERSNAME, PHYSDEC, PREFS, PREFS_DELIM, PROG_NAME, QUOTE, RDG, RECENT, RECENT_FILE_SIZE, REDISPLAY, RELAT, REMOVE_APP, REMOVE_APP_MESS, REMOVE_APP_SPECS, REMOVE_APP_TITLE, REMOVE_ED_ERROR_MESS, REMOVE_ED_ERROR_TITLE, REMOVE_ED_TITLE_ERROR, REMOVE_ED_TITLE_MESS, REMOVE_ED_TITLE_SPECS, REMOVE_ED_TITLE_TITLE, REMOVE_EDITION, REMOVE_TITLE, RENAME_FILE, RENAME_FILE_TITLE, RENAMING_FILE_SPECS, REND, RESP, RESPDECL, RESPSTM, REVDESC, RS, RUNTIME_ERROR, SAVE, SAVE_SPECS, SAVEAS, SAVED_FILE, SAVED_FILE_SPECS, SAVED_FILE_TITLE, SECTIONS, SELDIV, SEPARATOR, SHORT_LABEL_SIZE, SHOW_AP, SID, SIG, SIGLA_DELIM, SPACE, SRC, SRCS_LABEL, SUBMIT, SUBTYPE, SUMMARY, SYS, SYS_LET, SYS_NUM, SYS_SIG, TABLE, TB, TDECL, TDIV, TEMP_DIR, TEXT, TEXT_COLOR, TEXT_FIELD_SIZE, TEXT_HEAD, TEXT_HEAD_SIZE, TEXT_LIST_HEAD, TEXT_NUM, TIB, TIBANAL, TIBBIBL, TIBL, TIBPANEL_SIZE, TID, TIDDECL, TINFO, TITEM, TITLE, TITLE_DISC, TITLE_FONT, TITLE_LINE_HEAD, TITLE_PAGE, TITLEGRP, TITLELINE, TITLELN, TITLEOPENFILE, TITLES_VIEW, TK, TLIST, TLIST_ADD_ERROR, TLIST_ADD_MESS, TLIST_ADD_TITLE, TLIST_WARN, TLIST_WARN_TITLE, TLIST_WARNING, TRANS, TRANS_EDIT, TRANS_JOB, TTFCOLS, TTITLE_TITLE, TXT, TXTHEAD, TYPE, TYPE_CLASS, TYPE_DOX, TYPE_ED, TYPE_TEXT, TYPE_VOL, UNCLASSED, UNTITLED, USER_ID_VIEW, VIEW, VOL, VOL_LET, VOL_NUM, VOL_TEXT, VOL_TEXT_NUM, WIT, YES
 
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

t

protected static Thread t

This is the Thread used to run the splash screen while the program loads.


xop

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

TiblEdit

public TiblEdit()

The only constructor takes no arguments and simply calls the init() method.

Method Detail

init

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.


readPrefData

public void readPrefData()
This reads in the preferences from the preference file that is located in TibConstants.DEFAULT_DIRECTORY + TibConstants.BIN + TibConstants.PREFS. The main preferences that are stored in this file are: the #editorsInitials and #editorsName.


getEditorInfo

public void getEditorInfo()
This method is called if there is no editor information in the preference file. It uses a TibDialog with TibConstants.EDITORS_INFO title and TibConstants.EDITORS_INFO_SPECS. When the TibDialog closes, it calls setEditor().


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.


setDate

public void setDate()

This sets the #todaysDate variable to the current date in the form: YYYY-MM-DD.


getDate

public String getDate()

This method returns the value of the today's date variable.

Returns:
String the present day's date in the form yyyy-mm-dd

exit

public void exit()

Writes the preference data. This is read in and stored upon initialization of TiblEdit, when the program is restarted.


setCurrentDirectory

public void setCurrentDirectory(File cd)

Sets the current directory to the given path.


getCurrentDirectory

public File getCurrentDirectory()

Returns the path for the current working directory.

Returns:
File - The current working directory as a File object.

getCurrentFile

public File getCurrentFile()

Returns the file that is currently being worked on.

Returns:
File - The currently open File object.

setMode

public void setMode(int m)

This sets the current display mode of the program. The values are:

  1. TibConstants.NORM - normal
  2. TibConstants.ENTER_TRANS - for entering translations
  3. TibConstants.NEW_TITLE - for entering new versions of a title
  4. TibConstants.NEW_AP - for entering variant readings within a title.


getMode

public int getMode()

This returns the current display mode for the program.

Returns:
int - the current display mode
See Also:
setMode(int)

getFrame

public org.thdl.tib.bibl.TibFrame getFrame()

Returns the view or TibFrame that is the GUI of this program.

Returns:
TibFrame - The frame which displays the text information.

getTibDoc

public org.thdl.tib.bibl.TibDoc getTibDoc()

This returns the TibDoc presently being worked on.

Returns:
The TibDoc that is open.

setSelectedElement

public void setSelectedElement(Element e)

Sets the #selected_element variable to the presently selected element.


getSelectedElement

public Element getSelectedElement()

Returns the presently selected element.

Returns:
org.jdom.Element - the selected element.

getEditorsInitials

public String getEditorsInitials()

Returns the editors initials.

Returns:
String - the initials.

getEditorsName

public String getEditorsName()

Returns the editors name.

Returns:
String - the editor's name.

getRecent

public Vector getRecent()

Recturns the vector containing the recent files opened.

Returns:
Vector the list of recent files

setFileChooser

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.


setFileName

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.


getNewFile

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.

Returns:
File - the uniquely named file created by combining the two above and checking for conflicts.

openFile

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.


openFile

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.


addToRecent

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.


removeFromRecent

public void removeFromRecent(File badFile)
This method removes a file from the recent list if the controller (TiblEdit) cannot open it.


closeFile

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.


saveTibbibl

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.


save

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.


saveAs

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.

Returns:
boolean - whether the save operation was successful.

showApp

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.


insertNewEdition

public void insertNewEdition()

submitNewEditionInfo

public void submitNewEditionInfo(org.thdl.tib.bibl.TibDialog tdia)

insertCritTitle

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?)


insertEdTitle

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.


insertNewEdTitle

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.


insertNewEdAndTitle

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.


enterTranslation

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.


insertApp

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.


insertDiscussion

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.


locateDisc

public 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. If so, this prose discussion element (i.e., one that has type=brief or type=full) is returned. Otherwise, null is return. It is used also by DiscDialog and so needs to be static.


showTitles

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)


doAppSubmission

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:

First, it sets the information for the main reading found in the 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.


editTranslation

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.


updateTranslation

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.

See Also:
- the implementation of the KeyListener that invokes this method.

removeApp

public void removeApp()

removeTitle

public void removeTitle()

removePageRefs

public void removePageRefs(Element parentEl,
                           String corrsp)

deleteEdition

public void deleteEdition(Element edToDie)

showMasterDox

public void showMasterDox()

enterDox

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.


doMessage

public void doMessage(String[] specs)

This is a generic method to display a JOptionPane message dialog it takes a String array with three specs.

  1. the message
  2. the title
  3. the message type as defined in JOptionPane.
The latter spec is converted to an integer.


doMessage

public void doMessage(String[] specs,
                      String append)

doConfirm

public int doConfirm(String[] specs)

This is a generic method to display a JOptionPane confirm dialog it takes a String array with three specs.

  1. the message
  2. the title
  3. the message type as defined in JOptionPane.
The latter spec is converted to an integer.

Returns:
int - the response


doConfirm

public int doConfirm(String[] specs,
                     String append)

setCaretPosition

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?


checkCaretPosition

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:


promptInput

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.

  1. the message
  2. the title
  3. the message type as defined in JOptionPane.
The latter spec is converted to an integer. It returns the String that was inputed.

Returns:
String - the string entered by the user.

toStringArray

public static String[] toStringArray(Vector v)

A public static method that converts a Vector into an array of Strings.

Returns:
String[] The resulting array of Strings.

toStringArray

public static String[] toStringArray(Object[] objs)

A public static method that converts an Object array into an array of Strings.

Returns:
String[] The resulting array of Strings.

outputString

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.

Returns:
String The resulting string version of the element.

showSplash

public static void showSplash()

stopSplash

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.


main

public static void main(String[] args)

mouseClicked

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().

Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent me)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent me)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent me)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent me)
Specified by:
mouseExited in interface MouseListener

keyPressed

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.

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ke)
Specified by:
keyTyped in interface KeyListener

update

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.

Specified by:
update in interface Observer


These API docs were created 02/02/2003 08:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo