Added Javadoc files overview.html and several package.html files.

Added a "Quit" option to Savant's File menu.  Factored out the Close
option in doing so.

Exceptions in many action listeners are now handled by
org.thdl.util.ThdlActionListener or org.thdl.util.ThdlAbstractAction.

Many exceptions that we used to just log now optionally cause aborts.
This option is on by default for developers using 'ant savant-run'-style
targets, but it is off for users.

An erroneous CLASSPATH now causes a useful error message in almost
all situations.

Fixed some typos and bad links in Javadoc comments.

Added a simple assertion facility, but the overhead is suffered even in
release builds.

Factored out the code that sets up log files like savant.log and jskad.log.
This commit is contained in:
dchandler 2002-10-06 18:23:27 +00:00
parent 14adf0d607
commit 403f21c8db
47 changed files with 2439 additions and 1567 deletions

View file

@ -41,8 +41,16 @@ import org.jdom.transform.JDOMSource;
import javax.xml.transform.stream.*; import javax.xml.transform.stream.*;
import javax.xml.transform.*; import javax.xml.transform.*;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
import org.thdl.util.ThdlAbstractAction;
public class QD extends JDesktopPane { public class QD extends JDesktopPane {
/** When opening a file, this is the only extension QuillDriver
cares about. This is case-insensitive. */
protected final static String dotQuillDriver = ".xml";
//project related data //project related data
protected Project project; protected Project project;
@ -97,16 +105,16 @@ public QD(ResourceBundle messages) {
fileChooser = new JFileChooser(); fileChooser = new JFileChooser();
fileChooser.addChoosableFileFilter(new XMLFilter()); fileChooser.addChoosableFileFilter(new XMLFilter());
Action insert1TimeAction = new AbstractAction("insert1Time", null) { Action insert1TimeAction = new ThdlAbstractAction("insert1Time", null) {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
new TimePoint(pane, clockIcon, tcp.getOutTime()); new TimePoint(pane, clockIcon, tcp.getOutTime());
tcp.setInTime(tcp.getOutTime().intValue()); tcp.setInTime(tcp.getOutTime().intValue());
tcp.setOutTime(player.getLastTime()); tcp.setOutTime(player.getLastTime());
} }
}; };
Action insert2TimesAction = new AbstractAction("insert2Times", null) { Action insert2TimesAction = new ThdlAbstractAction("insert2Times", null) {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
int p1 = pane.getSelectionStart(); int p1 = pane.getSelectionStart();
int p2 = pane.getSelectionEnd(); int p2 = pane.getSelectionEnd();
pane.setCaretPosition(p1); pane.setCaretPosition(p1);
@ -120,8 +128,8 @@ public QD(ResourceBundle messages) {
} }
}; };
Action saveAction = new AbstractAction("saveTranscript", null) { Action saveAction = new ThdlAbstractAction("saveTranscript", null) {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
getSave(); getSave();
} }
}; };
@ -282,6 +290,7 @@ class TimePoint extends JLabel implements DragGestureListener, DragSourceListene
pos = doc.createPosition(tp.getCaretPosition()-1); pos = doc.createPosition(tp.getCaretPosition()-1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
public void setTime(Integer t) { public void setTime(Integer t) {
@ -315,6 +324,7 @@ class TimePoint extends JLabel implements DragGestureListener, DragSourceListene
dge.startDrag(null, transferable, this); dge.startDrag(null, transferable, this);
} catch (InvalidDnDOperationException idoe) { } catch (InvalidDnDOperationException idoe) {
idoe.printStackTrace(); idoe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
public void dragEnter(DragSourceDragEvent dsde) { public void dragEnter(DragSourceDragEvent dsde) {
@ -332,6 +342,7 @@ class TimePoint extends JLabel implements DragGestureListener, DragSourceListene
doc.remove(pos.getOffset(), 1); doc.remove(pos.getOffset(), 1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} }
@ -400,9 +411,11 @@ public class TimePointDropTarget implements DropTargetListener {
new TimePoint(pane, clockIcon, time); new TimePoint(pane, clockIcon, time);
} catch (UnsupportedFlavorException ufe) { } catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace(); ufe.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} }
return true; return true;
@ -423,8 +436,8 @@ class TimeCodeManager extends JPanel {
inPanel.add(inButton); inPanel.add(inButton);
inPanel.add(inSpinner); inPanel.add(inSpinner);
inButton.addActionListener(new ActionListener() { inButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
int k = player.when(); int k = player.when();
if (k != -1) if (k != -1)
setInTime(k); setInTime(k);
@ -441,8 +454,8 @@ class TimeCodeManager extends JPanel {
outPanel.add(outButton); outPanel.add(outButton);
outPanel.add(outSpinner); outPanel.add(outSpinner);
outButton.addActionListener(new ActionListener() { outButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
int k = player.when(); int k = player.when();
if (k != -1) { if (k != -1) {
setOutTime(k); setOutTime(k);
@ -453,8 +466,8 @@ class TimeCodeManager extends JPanel {
JButton playSegButton = new JButton(messages.getString("PlaySegment")); JButton playSegButton = new JButton(messages.getString("PlaySegment"));
playSegButton.addActionListener(new ActionListener() { playSegButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
Integer in = getInTime(); Integer in = getInTime();
Integer out = getOutTime(); Integer out = getOutTime();
if (out.intValue() > in.intValue()) if (out.intValue() > in.intValue())
@ -468,14 +481,14 @@ class TimeCodeManager extends JPanel {
JButton playButton = new JButton(messages.getString("Play")); JButton playButton = new JButton(messages.getString("Play"));
JButton pauseButton = new JButton(messages.getString("Pause")); JButton pauseButton = new JButton(messages.getString("Pause"));
playButton.addActionListener(new ActionListener() { playButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (player != null) if (player != null)
player.cmd_play(); player.cmd_play();
} }
}); });
pauseButton.addActionListener(new ActionListener() { pauseButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (player != null) if (player != null)
player.cmd_stop(); player.cmd_stop();
} }
@ -593,6 +606,7 @@ public void setMedia(File f) {
startTimer(); startTimer();
} catch (MalformedURLException murle) { } catch (MalformedURLException murle) {
murle.printStackTrace(); murle.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} }
@ -696,7 +710,7 @@ public boolean getSave() {
fileChooser.setSelectedFile(null); fileChooser.setSelectedFile(null);
else { else {
String path = project.getMedia().getPath(); String path = project.getMedia().getPath();
path = path.substring(0, path.lastIndexOf('.')) + ".xml"; path = path.substring(0, path.lastIndexOf('.')) + QD.dotQuillDriver;
fileChooser.setSelectedFile(new File(path)); fileChooser.setSelectedFile(new File(path));
} }
if (fileChooser.showSaveDialog(QD.this) == JFileChooser.APPROVE_OPTION) { if (fileChooser.showSaveDialog(QD.this) == JFileChooser.APPROVE_OPTION) {
@ -838,12 +852,15 @@ if (keyboard_url != null) {
return true; return true;
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
fnfe.printStackTrace(); fnfe.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} catch (TransformerException e) { } catch (TransformerException e) {
e.printStackTrace(); e.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} }
} }
@ -950,6 +967,7 @@ if (keyboard_url != null) {
tDoc.insertString(tDoc.getLength(), "\n", null); tDoc.insertString(tDoc.getLength(), "\n", null);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
*/ */
new TimePoint(dp, clockIcon, Integer.valueOf(e.getAttributeValue("t"))); new TimePoint(dp, clockIcon, Integer.valueOf(e.getAttributeValue("t")));
@ -961,6 +979,7 @@ if (keyboard_url != null) {
tDoc.insertString(tDoc.getLength(), "\n", null); tDoc.insertString(tDoc.getLength(), "\n", null);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
*/ */
dp.insertComponent(new JLabel(" ", icons[Integer.parseInt(e.getAttributeValue("id"))], SwingConstants.LEFT)); dp.insertComponent(new JLabel(" ", icons[Integer.parseInt(e.getAttributeValue("id"))], SwingConstants.LEFT));
@ -984,6 +1003,7 @@ project.setTranscript(t);
return true; return true;
} catch (JDOMException jdome) { } catch (JDOMException jdome) {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
return false; return false;
} }
} }
@ -999,8 +1019,8 @@ SpeakerManager(final SpeakerTable sTable) {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
JButton addButton = new JButton(messages.getString("Add")); JButton addButton = new JButton(messages.getString("Add"));
addButton.addActionListener(new ActionListener() { addButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
SpeakerData sd = (SpeakerData)sTable.getModel(); SpeakerData sd = (SpeakerData)sTable.getModel();
JPanel p0 = new JPanel(new GridLayout(0,1)); JPanel p0 = new JPanel(new GridLayout(0,1));
JPanel p1 = new JPanel(); JPanel p1 = new JPanel();
@ -1021,8 +1041,8 @@ SpeakerManager(final SpeakerTable sTable) {
} }
}); });
JButton editButton = new JButton(messages.getString("Edit")); JButton editButton = new JButton(messages.getString("Edit"));
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
int row = sTable.getSelectedRow(); int row = sTable.getSelectedRow();
if (row == -1) if (row == -1)
return; return;
@ -1062,6 +1082,7 @@ SpeakerManager(final SpeakerTable sTable) {
doc2.remove(i,1); doc2.remove(i,1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
pane.setCaretPosition(i); pane.setCaretPosition(i);
pane.insertComponent(new JLabel(" ", icons[combo.getSelectedIndex()], SwingConstants.LEFT)); pane.insertComponent(new JLabel(" ", icons[combo.getSelectedIndex()], SwingConstants.LEFT));
@ -1075,8 +1096,8 @@ SpeakerManager(final SpeakerTable sTable) {
} }
}); });
JButton deleteButton = new JButton(messages.getString("Remove")); JButton deleteButton = new JButton(messages.getString("Remove"));
deleteButton.addActionListener(new ActionListener() { deleteButton.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
int row = sTable.getSelectedRow(); int row = sTable.getSelectedRow();
if (row > -1 && JOptionPane.showConfirmDialog(SpeakerManager.this, messages.getString("SureDeleteSpeaker"), messages.getString("Warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { if (row > -1 && JOptionPane.showConfirmDialog(SpeakerManager.this, messages.getString("SureDeleteSpeaker"), messages.getString("Warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
SpeakerData sd = (SpeakerData)sTable.getModel(); SpeakerData sd = (SpeakerData)sTable.getModel();
@ -1096,6 +1117,7 @@ SpeakerManager(final SpeakerTable sTable) {
k2--; k2--;
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} }
@ -1187,8 +1209,8 @@ class SpeakerData extends AbstractTableModel
for (int k=0; k<speaker.length; k++) for (int k=0; k<speaker.length; k++)
addSpeaker(speaker[k]); addSpeaker(speaker[k]);
Action insertSpeakerAction = new AbstractAction("insertSpeaker", null) { Action insertSpeakerAction = new ThdlAbstractAction("insertSpeaker", null) {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (speakers.size() == 0) if (speakers.size() == 0)
return; return;
JTextPane tp = (JTextPane)e.getSource(); JTextPane tp = (JTextPane)e.getSource();
@ -1213,6 +1235,7 @@ class SpeakerData extends AbstractTableModel
return; return;
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} }
@ -1286,6 +1309,7 @@ class SpeakerData extends AbstractTableModel
return TibetanDocument.getTibetanMachineWeb(sp.getName().trim()); return TibetanDocument.getTibetanMachineWeb(sp.getName().trim());
} catch (InvalidWylieException iwe) { } catch (InvalidWylieException iwe) {
iwe.printStackTrace(); iwe.printStackTrace();
ThdlDebug.noteIffyCode();
return null; return null;
} }
} }
@ -1367,15 +1391,15 @@ public JMenuBar getTextMenuBar() {
JMenu searchMenu = new JMenu(messages.getString("Search")); JMenu searchMenu = new JMenu(messages.getString("Search"));
JMenuItem findTextItem = new JMenuItem(messages.getString("FindText")); JMenuItem findTextItem = new JMenuItem(messages.getString("FindText"));
findTextItem.addActionListener(new ActionListener() { findTextItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
findText(); findText();
} }
}); });
JMenuItem replaceTextItem = new JMenuItem(messages.getString("ReplaceText")); JMenuItem replaceTextItem = new JMenuItem(messages.getString("ReplaceText"));
replaceTextItem.addActionListener(new ActionListener() { replaceTextItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
replaceText(); replaceText();
} }
}); });
@ -1446,6 +1470,7 @@ try {
} }
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
return -1; //not found return -1; //not found
@ -1495,6 +1520,7 @@ public void findText() {
} }
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -1582,13 +1608,14 @@ public void replaceText() {
} }
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} }
class RadioListener implements ActionListener { class RadioListener extends ThdlActionListener {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("edit")) { if (e.getActionCommand().equals("edit")) {
//make the text pane editable //make the text pane editable
pane.setEditable(true); pane.setEditable(true);
@ -1644,26 +1671,12 @@ class RadioListener implements ActionListener {
if (f.isDirectory()) { if (f.isDirectory()) {
return true; return true;
} }
return f.getName().toLowerCase().endsWith(QD.dotQuillDriver);
String fName = f.getName();
int i = fName.lastIndexOf('.');
if (i < 0)
return false;
else {
String ext = fName.substring(i+1).toLowerCase();
if (ext.equals("xml"))
return true;
else
return false;
}
} }
//the description of this filter //the description of this filter
public String getDescription() { public String getDescription() {
return "Extensible Markup Language (.xml)"; return "Extensible Markup Language (" + QD.dotQuillDriver + ")";
} }
} }
} }

View file

@ -25,6 +25,8 @@ import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import org.thdl.util.ThdlDebug;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
public class QDPlayer extends Panel implements ControllerListener public class QDPlayer extends Panel implements ControllerListener
{ {
@ -205,10 +207,12 @@ public class QDPlayer extends Panel implements ControllerListener
} catch (javax.media.NoPlayerException e) { } catch (javax.media.NoPlayerException e) {
System.err.println("noplayer exception"); System.err.println("noplayer exception");
e.printStackTrace(); e.printStackTrace();
ThdlDebug.noteIffyCode();
return; return;
} catch (java.io.IOException ex) { } catch (java.io.IOException ex) {
System.err.println("IO exception"); System.err.println("IO exception");
ex.printStackTrace(); ex.printStackTrace();
ThdlDebug.noteIffyCode();
return; return;
} }
if (player != null) if (player != null)

View file

@ -27,7 +27,8 @@ import java.awt.event.*;
import javax.swing.text.*; import javax.swing.text.*;
import javax.swing.text.rtf.*; import javax.swing.text.rtf.*;
import org.thdl.util.TeeStream; import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
public class QDShell extends JFrame { public class QDShell extends JFrame {
ResourceBundle messages = null; ResourceBundle messages = null;
@ -35,17 +36,7 @@ public class QDShell extends JFrame {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
PrintStream psOut ThdlDebug.attemptToSetUpLogFile("qd.log");
= new TeeStream(System.out,
new PrintStream(new FileOutputStream("qd.log")));
PrintStream psErr
= new TeeStream(System.err,
new PrintStream(new FileOutputStream("qd.log")));
System.setErr(psErr);
System.setOut(psOut);
}
catch (Exception e) {
}
Locale locale; Locale locale;
@ -69,6 +60,9 @@ public static void main(String[] args) {
QDShell qdsh = new QDShell(locale); QDShell qdsh = new QDShell(locale);
qdsh.setVisible(true); qdsh.setVisible(true);
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("QuillDriver's CLASSPATH", err);
}
} }
public QDShell(Locale locale) { public QDShell(Locale locale) {
@ -109,21 +103,21 @@ public static void main(String[] args) {
JMenu projectMenu = new JMenu(messages.getString("Project")); JMenu projectMenu = new JMenu(messages.getString("Project"));
JMenuItem newItem = new JMenuItem(messages.getString("New")); JMenuItem newItem = new JMenuItem(messages.getString("New"));
JMenuItem openItem = new JMenuItem(messages.getString("Open")); JMenuItem openItem = new JMenuItem(messages.getString("Open"));
openItem.addActionListener(new ActionListener() { openItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
qd.getOpen(); qd.getOpen();
} }
}); });
JMenuItem closeItem = new JMenuItem(messages.getString("Close")); JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
JMenuItem saveItem = new JMenuItem(messages.getString("Save")); JMenuItem saveItem = new JMenuItem(messages.getString("Save"));
saveItem.addActionListener(new ActionListener() { saveItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
qd.getSave(); qd.getSave();
} }
}); });
JMenuItem quitItem = new JMenuItem(messages.getString("Quit")); JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
quitItem.addActionListener(new ActionListener() { quitItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
qd.getSave(); qd.getSave();
//should only system exit if no cancel!! //should only system exit if no cancel!!
System.exit(0); System.exit(0);
@ -175,8 +169,8 @@ public static void main(String[] args) {
return bar; return bar;
} }
class RadioListener implements ActionListener { class RadioListener extends ThdlActionListener {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
qd.changeKeyboard(e); qd.changeKeyboard(e);
} }
} }

View file

@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides facilitates for authoring content to be used by Savant.
<p>
In the future, this may be combined with Savant, in which case this
will be the edit mode. For now, QuillDriver is a stand-alone
application.
<p>
<h2>Related Documentation</h2>
@see <a href="../savant/package-summary.html">org.thdl.savant</a>
</body>
</html>

View file

@ -22,6 +22,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.awt.Dimension;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Toolkit; import java.awt.Toolkit;
@ -49,7 +50,7 @@ import org.thdl.util.ThdlLazyException;
* deconstruct the mechanism. * deconstruct the mechanism.
* *
* This class is not instantiable. */ * This class is not instantiable. */
final class JdkVersionHacks { public final class JdkVersionHacks {
/** Don't instantiate this class. */ /** Don't instantiate this class. */
private JdkVersionHacks() { } private JdkVersionHacks() { }
@ -182,6 +183,25 @@ final class JdkVersionHacks {
} }
} }
public static Object getJSpinner(Dimension dim,
Object spinnerValue,
int value, int minimum,
int maximum, int stepSize) {
/* In Java 1.4, do the following:
SpinnerNumberModel snm1
= new SpinnerNumberModel(value, minimum, maximum, stepSize);
JSpinner spinner = new JSpinner(snm1);
spinner.setPreferredSize(dim);
spinner.setValue(spinnerValue);
return spinner;
*/
/* FIXME; */
return null;
}
/** Coming soon: Does what the user desires (via the options he or /** Coming soon: Does what the user desires (via the options he or
she has set) with this SecurityException, one encountered she has set) with this SecurityException, one encountered
@ -229,3 +249,4 @@ final class JdkVersionHacks {
} }
} }
}; };

View file

@ -59,6 +59,9 @@ import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import javax.swing.text.rtf.RTFEditorKit; import javax.swing.text.rtf.RTFEditorKit;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
public class Savant extends JDesktopPane public class Savant extends JDesktopPane
{ {
protected SoundPanel sp = null; protected SoundPanel sp = null;
@ -142,6 +145,7 @@ public class Savant extends JDesktopPane
open(views, new URL(video), new URL(vocabulary)); open(views, new URL(video), new URL(vocabulary));
} catch (MalformedURLException murle) { } catch (MalformedURLException murle) {
murle.printStackTrace(); murle.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -159,8 +163,8 @@ public class Savant extends JDesktopPane
viewNames[i] = new String(views[i].getTitle()); viewNames[i] = new String(views[i].getTitle());
JComboBox viewOptions = new JComboBox(viewNames); JComboBox viewOptions = new JComboBox(viewNames);
viewOptions.addActionListener(new ActionListener() { viewOptions.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) public void theRealActionPerformed(ActionEvent e)
{ {
JComboBox jcb = (JComboBox)e.getSource(); JComboBox jcb = (JComboBox)e.getSource();
setTranscriptView(views[jcb.getSelectedIndex()]); setTranscriptView(views[jcb.getSelectedIndex()]);
@ -201,8 +205,10 @@ public class Savant extends JDesktopPane
vocabPane.getCaret().setDot(0); vocabPane.getCaret().setDot(0);
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
vocabFrame = new JInternalFrame("About the Video", false, false, false, true); vocabFrame = new JInternalFrame("About the Video", false, false, false, true);
vocabFrame.setContentPane(vocabPanel); vocabFrame.setContentPane(vocabPanel);

View file

@ -23,30 +23,85 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.*; import javax.swing.filechooser.*;
import org.thdl.util.ThdlDebug;
/**
* The SavantFileView "sees through" a <code>*.savant</code> file and
* returns the title associated with it. A <code>*.savant</code> file
* is a properties file like the following:
* <pre>
* #Tue May 14 16:07:15 EDT 2002
* TRANSCRIPT=MST4.xml
* PROJECT=THDL
* MEDIA=MST4.mpg
* TITLE=MST Chapter 4 (video)
* </pre>
* @author Edward Garrett */
public class SavantFileView extends FileView { public class SavantFileView extends FileView {
/** When opening a file, this is the only extension Savant cares
about. This is case-insensitive. */
public final static String dotSavant = ".savant";
/** This loads <code>*.savant</code> files as properties files and
returns an associated TITLE attribute. For any other type of
file, or for a properties file that does not specify a
non-empty-string TITLE attribute, this returns null. */
public String getName(File f) { public String getName(File f) {
if (f.isDirectory()) if (f.isDirectory())
return null; return null;
/* Unless a developer has chosen to do otherwise, examine only
*.savant files. If you don't do this, you waste a lot of
time, making any file chooser that uses this class
unresponsive. In addition, you'll cause the floppy drive
to spin up every time you refresh or cd in the file
chooser. */
if (!Boolean.getBoolean("THDL_TREAT_ALL_FILES_AS_DOT_SAVANT_FILES_REGARDLESS_OF_EXTENSION")) { /* FIXME */
if (!f.getName().toLowerCase().endsWith(dotSavant))
return null;
}
Properties p = new Properties(); Properties p = new Properties();
try { try {
p.load(new FileInputStream(f)); p.load(new FileInputStream(f));
return p.getProperty("TITLE"); String ttl = p.getProperty("TITLE");
if (ttl.equals(""))
return null; /* We never want the user to see nothing
at all, so let the L&F file view
handle this. */
else
return ttl;
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
fnfe.printStackTrace(); fnfe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
return null; return null;
} }
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public String getDescription(File f) { public String getDescription(File f) {
return null; return null; // let the L&F FileView figure this out
} }
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public Boolean isTraversable(File f) { public Boolean isTraversable(File f) {
return null; // let the L&F FileView figure this out return null; // let the L&F FileView figure this out
} }
/** Returns null always, which lets the default look-and-feel's
* FileView take over.
* @return null */
public String getTypeDescription(File f) { public String getTypeDescription(File f) {
return null; return null; // let the L&F FileView figure this out
} }
/* FIXME: why not same as above? */
/* /*
public Icon getIcon(File f) { public Icon getIcon(File f) {
} }

View file

@ -30,6 +30,8 @@ import javax.swing.text.rtf.*;
import org.thdl.savant.ucuchi.*; import org.thdl.savant.ucuchi.*;
import org.thdl.savant.tib.*; import org.thdl.savant.tib.*;
import org.thdl.util.TeeStream; import org.thdl.util.TeeStream;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
public class SavantShell extends JFrame public class SavantShell extends JFrame
{ {
@ -44,17 +46,7 @@ public class SavantShell extends JFrame
public static void main(String[] args) { public static void main(String[] args) {
try { try {
PrintStream psOut ThdlDebug.attemptToSetUpLogFile("savant.log");
= new TeeStream(System.out,
new PrintStream(new FileOutputStream("savant.log")));
PrintStream psErr
= new TeeStream(System.err,
new PrintStream(new FileOutputStream("savant.log")));
System.setErr(psErr);
System.setOut(psOut);
}
catch (Exception e) {
}
try { try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
@ -94,6 +86,9 @@ public class SavantShell extends JFrame
SavantShell ssh = new SavantShell(); SavantShell ssh = new SavantShell();
ssh.setVisible(true); ssh.setVisible(true);
ssh.initFileChooser(); ssh.initFileChooser();
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("Savant's CLASSPATH", err);
}
} }
public void initFileChooser() { public void initFileChooser() {
@ -114,21 +109,7 @@ public class SavantShell extends JFrame
if (f.isDirectory()) { if (f.isDirectory()) {
return true; return true;
} }
return f.getName().toLowerCase().endsWith(SavantFileView.dotSavant);
String fName = f.getName();
int i = fName.lastIndexOf('.');
if (i < 0)
return false;
else {
String ext = fName.substring(i+1).toLowerCase();
if (ext.equals("savant"))
return true;
else
return false;
}
} }
//the description of this filter //the description of this filter
@ -137,45 +118,13 @@ public class SavantShell extends JFrame
} }
} }
public SavantShell() /** Closes one open title, if there is one open. Returns true if
{ one was closed, or false if no titles are open. */
setTitle("Savant"); private boolean closeOneSavantTitle() {
if (savant != null) {
JMenuBar menuBar = new JMenuBar(); ThdlDebug.verify("There should be one or more Savant titles open: ",
JMenu fileMenu = new JMenu("File"); numberOfSavantsOpen >= 1);
if (numberOfSavantsOpen < 2) {
JMenuItem openItem = new JMenuItem("Open");
openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2));
openItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (fileChooser.showOpenDialog(SavantShell.this) != JFileChooser.APPROVE_OPTION)
return;
Properties p = new Properties();
try {
File fileChosen = fileChooser.getSelectedFile();
p.load(new FileInputStream(fileChosen));
String path = "file:" + fileChosen.getParent() + File.separatorChar;
newSavantWindow(p.getProperty("PROJECT"), p.getProperty("TITLE"), new URL(path + p.getProperty("TRANSCRIPT")), new URL(path + p.getProperty("MEDIA")), null);
} catch (MalformedURLException murle) {
murle.printStackTrace();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
});
JMenuItem closeItem = new JMenuItem("Close");
closeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2));
closeItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (savant != null)
{
if (numberOfSavantsOpen < 2)
{
savant.close(); savant.close();
savant = null; savant = null;
getContentPane().removeAll(); getContentPane().removeAll();
@ -188,18 +137,95 @@ public class SavantShell extends JFrame
dispose(); dispose();
} }
numberOfSavantsOpen--; numberOfSavantsOpen--;
return true;
} else {
ThdlDebug.verify("There should be zero Savant titles open: ",
numberOfSavantsOpen == 0);
return false;
}
}
public SavantShell()
{
setTitle("Savant");
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2));
openItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
if (fileChooser.showOpenDialog(SavantShell.this) != JFileChooser.APPROVE_OPTION)
return;
Properties p = new Properties();
try {
File fileChosen = fileChooser.getSelectedFile();
p.load(new FileInputStream(fileChosen));
String path = "file:" + fileChosen.getParent() + File.separatorChar;
newSavantWindow(p.getProperty("PROJECT"), p.getProperty("TITLE"), new URL(path + p.getProperty("TRANSCRIPT")), new URL(path + p.getProperty("MEDIA")), null);
} catch (MalformedURLException murle) {
murle.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) {
ioe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
}); });
JMenuItem closeItem = new JMenuItem("Close");
closeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2));
closeItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
// Return value doesn't matter:
closeOneSavantTitle();
}
});
JMenuItem quitItem = new JMenuItem("Quit");
quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,2));
quitItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
// Close all Savant titles:
while (closeOneSavantTitle())
;
// Exit normally:
System.exit(0);
}
});
/* Hey developers: To test ThdlActionListener, use this:
JMenuItem errorThrowerItem = new JMenuItem("ErrorThrower");
errorThrowerItem.addActionListener(new ThdlActionListener()
{
public void theRealActionPerformed(ActionEvent e)
{
throw new Error("Testing ThdlActionListener");
}
});
fileMenu.add(errorThrowerItem);
*/
fileMenu.add(openItem); fileMenu.add(openItem);
fileMenu.add(closeItem); fileMenu.add(closeItem);
fileMenu.addSeparator();
fileMenu.add(quitItem);
JMenu infoMenu = new JMenu("Information"); JMenu infoMenu = new JMenu("Information");
JMenuItem helpItem = new JMenuItem("Help"); JMenuItem helpItem = new JMenuItem("Help");
helpItem.addActionListener(new ActionListener() helpItem.addActionListener(new ThdlActionListener()
{ {
public void actionPerformed(ActionEvent e) public void theRealActionPerformed(ActionEvent e)
{ {
JFrame h = new JFrame("Help"); JFrame h = new JFrame("Help");
h.setSize(500,400); h.setSize(500,400);
@ -218,9 +244,9 @@ public class SavantShell extends JFrame
} }
}); });
JMenuItem aboutItem = new JMenuItem("About"); JMenuItem aboutItem = new JMenuItem("About");
aboutItem.addActionListener(new ActionListener() aboutItem.addActionListener(new ThdlActionListener()
{ {
public void actionPerformed(ActionEvent e) public void theRealActionPerformed(ActionEvent e)
{ {
JFrame h = new JFrame("About"); JFrame h = new JFrame("About");
h.setSize(500,400); h.setSize(500,400);
@ -286,6 +312,7 @@ public class SavantShell extends JFrame
public void newSavantWindow(String project, String titleName, URL trn, URL vid, URL abt) public void newSavantWindow(String project, String titleName, URL trn, URL vid, URL abt)
{ {
try {
if (numberOfSavantsOpen == 0) if (numberOfSavantsOpen == 0)
openSavant(project, titleName, trn, vid, abt); openSavant(project, titleName, trn, vid, abt);
else { else {
@ -295,6 +322,9 @@ public class SavantShell extends JFrame
scp.setFileChooser(fileChooser); scp.setFileChooser(fileChooser);
} }
numberOfSavantsOpen++; numberOfSavantsOpen++;
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("Savant's CLASSPATH", err);
}
} }
public void openSavant(String project, String titleName, URL trn, URL vid, URL abt) public void openSavant(String project, String titleName, URL trn, URL vid, URL abt)

View file

@ -26,6 +26,8 @@ import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import org.thdl.util.ThdlDebug;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
public class SoundPanel extends Panel implements ControllerListener public class SoundPanel extends Panel implements ControllerListener
{ {
@ -346,10 +348,12 @@ System.out.println("soundpanel - "+sound.toString());
} catch (javax.media.NoPlayerException e) { } catch (javax.media.NoPlayerException e) {
System.err.println("noplayer exception"); System.err.println("noplayer exception");
e.printStackTrace(); e.printStackTrace();
ThdlDebug.noteIffyCode();
return; return;
} catch (java.io.IOException ex) { } catch (java.io.IOException ex) {
System.err.println("IO exception"); System.err.println("IO exception");
ex.printStackTrace(); ex.printStackTrace();
ThdlDebug.noteIffyCode();
return; return;
} }
if (player != null) if (player != null)

View file

@ -24,6 +24,8 @@ import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import org.thdl.util.ThdlDebug;
public class TextHighlightPlayer extends JPanel implements AnnotationPlayer public class TextHighlightPlayer extends JPanel implements AnnotationPlayer
{ {
protected JTextComponent text; protected JTextComponent text;
@ -108,6 +110,7 @@ public class TextHighlightPlayer extends JPanel implements AnnotationPlayer
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -23,6 +23,8 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import org.thdl.util.ThdlDebug;
public class TextPlayer extends JPanel implements AnnotationPlayer public class TextPlayer extends JPanel implements AnnotationPlayer
{ {
private JTextComponent text; private JTextComponent text;
@ -97,6 +99,7 @@ public class TextPlayer extends JPanel implements AnnotationPlayer
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -30,6 +30,8 @@ import java.util.Enumeration;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import org.thdl.util.ThdlDebug;
public class TwoWayTextPlayer extends TextHighlightPlayer public class TwoWayTextPlayer extends TextHighlightPlayer
{ {
protected TreeMap orderedOffsets = null; protected TreeMap orderedOffsets = null;
@ -106,6 +108,7 @@ public class TwoWayTextPlayer extends TextHighlightPlayer
catch (NoSuchElementException nsee) catch (NoSuchElementException nsee)
{ {
nsee.printStackTrace(); nsee.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
}); });

View file

@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides classes and methods for displaying foreign-language text,
audio, and video side-by-side.
<p>
Savant works for only a couple of languages right now, but can
be extended to work with many more.
</body>
</html>

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class English implements TranscriptView public class English implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class English implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -174,6 +177,7 @@ public class English implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Tibetan implements TranscriptView public class Tibetan implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class Tibetan implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -179,10 +182,12 @@ public class Tibetan implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
catch (InvalidWylieException iwe) catch (InvalidWylieException iwe)
{ {
iwe.printStackTrace(); iwe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanEnglish implements TranscriptView public class TibetanEnglish implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class TibetanEnglish implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -187,10 +190,12 @@ public class TibetanEnglish implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
catch (InvalidWylieException iwe) catch (InvalidWylieException iwe)
{ {
iwe.printStackTrace(); iwe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanWylie implements TranscriptView public class TibetanWylie implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class TibetanWylie implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -190,10 +193,12 @@ public class TibetanWylie implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
catch (InvalidWylieException iwe) catch (InvalidWylieException iwe)
{ {
iwe.printStackTrace(); iwe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class TibetanWylieEnglish implements TranscriptView public class TibetanWylieEnglish implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class TibetanWylieEnglish implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -192,10 +195,12 @@ public class TibetanWylieEnglish implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
catch (InvalidWylieException iwe) catch (InvalidWylieException iwe)
{ {
iwe.printStackTrace(); iwe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Wylie implements TranscriptView public class Wylie implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class Wylie implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -174,6 +177,7 @@ public class Wylie implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import org.thdl.tib.input.*; import org.thdl.tib.input.*;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class WylieEnglish implements TranscriptView public class WylieEnglish implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -60,6 +62,7 @@ public class WylieEnglish implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -187,6 +190,7 @@ public class WylieEnglish implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides Savant with the power to display Tibetan language
text beside video or audio of Tibetan speakers.
<p>
Supports Wylie, English, and Tibetan.
</body>
</html>

View file

@ -29,6 +29,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class All implements TranscriptView public class All implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -57,6 +59,7 @@ public class All implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -203,6 +206,7 @@ public class All implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -29,6 +29,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class English implements TranscriptView public class English implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -57,6 +59,7 @@ public class English implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -174,6 +177,7 @@ public class English implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -29,6 +29,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class Quechua implements TranscriptView public class Quechua implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -57,6 +59,7 @@ public class Quechua implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -173,6 +176,7 @@ public class Quechua implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -29,6 +29,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class QuechuaEnglish implements TranscriptView public class QuechuaEnglish implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -57,6 +59,7 @@ public class QuechuaEnglish implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -195,6 +198,7 @@ public class QuechuaEnglish implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -30,6 +30,8 @@ import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.thdl.savant.*; import org.thdl.savant.*;
import org.thdl.util.ThdlDebug;
public class SegmentedQuechua implements TranscriptView public class SegmentedQuechua implements TranscriptView
{ {
private JTextPane text = null; private JTextPane text = null;
@ -58,6 +60,7 @@ public class SegmentedQuechua implements TranscriptView
catch (JDOMException jdome) catch (JDOMException jdome)
{ {
jdome.printStackTrace(); jdome.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -195,6 +198,7 @@ public class SegmentedQuechua implements TranscriptView
catch (BadLocationException ble) catch (BadLocationException ble)
{ {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides Savant with the power to display Quechua language
text beside video or audio of Quechua speakers.
<p>
Supports Quechua and English.
</body>
</html>

View file

@ -32,6 +32,8 @@ import org.thdl.tib.text.*;
import java.io.*; import java.io.*;
import javax.swing.text.rtf.*; import javax.swing.text.rtf.*;
import org.thdl.util.ThdlDebug;
/** /**
* Enables input of Tibetan text * Enables input of Tibetan text
* using Tibetan Computer Company's free cross-platform TibetanMachineWeb fonts. * using Tibetan Computer Company's free cross-platform TibetanMachineWeb fonts.
@ -764,6 +766,7 @@ class RTFSelection implements ClipboardOwner, Transferable {
newDoc.insertString(i-offset, s, as); newDoc.insertString(i-offset, s, as);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
rtfOut = new ByteArrayOutputStream(); rtfOut = new ByteArrayOutputStream();
@ -771,8 +774,10 @@ class RTFSelection implements ClipboardOwner, Transferable {
plainText = getText(offset, length); plainText = getText(offset, length);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
public void lostOwnership(Clipboard clipboard, Transferable contents) { public void lostOwnership(Clipboard clipboard, Transferable contents) {
@ -816,6 +821,7 @@ class RTFSelection implements ClipboardOwner, Transferable {
rtfBoard.setContents(rtfSelection, rtfSelection); rtfBoard.setContents(rtfSelection, rtfSelection);
} catch (IllegalStateException ise) { } catch (IllegalStateException ise) {
ise.printStackTrace(); ise.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
if (remove) if (remove)
@ -823,6 +829,7 @@ class RTFSelection implements ClipboardOwner, Transferable {
getDocument().remove(p1, p2-p1); getDocument().remove(p1, p2-p1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -853,6 +860,7 @@ public void paste(int offset) {
doc.insertString(p1+i, s, as); doc.insertString(p1+i, s, as);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
} else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) { } else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
@ -861,12 +869,16 @@ public void paste(int offset) {
} }
} catch (UnsupportedFlavorException ufe) { } catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace(); ufe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (IllegalStateException ise) { } catch (IllegalStateException ise) {
ise.printStackTrace(); ise.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -1347,6 +1359,7 @@ public void paste(int offset) {
} }
catch (BadLocationException ble) { catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }
@ -1368,6 +1381,7 @@ public void paste(int offset) {
offset++; offset++;
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} else { } else {
TibetanDocument.DuffData[] dd = TibetanDocument.getTibetanMachineWeb(next); TibetanDocument.DuffData[] dd = TibetanDocument.getTibetanMachineWeb(next);
@ -1444,6 +1458,7 @@ public void paste(int offset) {
} }
catch (BadLocationException ble) { catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }

View file

@ -32,7 +32,9 @@ import javax.swing.text.*;
import javax.swing.text.rtf.*; import javax.swing.text.rtf.*;
import org.thdl.tib.text.*; import org.thdl.tib.text.*;
import org.thdl.util.TeeStream; import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
/** /**
* A simple Tibetan text editor. Jskad editors lack most of the * A simple Tibetan text editor. Jskad editors lack most of the
@ -97,8 +99,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem newItem = new JMenuItem("New"); JMenuItem newItem = new JMenuItem("New");
// newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,2)); //Ctrl-n // newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,2)); //Ctrl-n
newItem.addActionListener(new ActionListener() { newItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
newFile(); newFile();
} }
}); });
@ -106,8 +108,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem openItem = new JMenuItem("Open"); JMenuItem openItem = new JMenuItem("Open");
// openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2)); //Ctrl-o // openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,2)); //Ctrl-o
openItem.addActionListener(new ActionListener() { openItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
openFile(); openFile();
} }
}); });
@ -115,8 +117,8 @@ public class Jskad extends JPanel implements DocumentListener {
if (parentObject instanceof JFrame) { if (parentObject instanceof JFrame) {
JMenuItem closeItem = new JMenuItem("Close"); JMenuItem closeItem = new JMenuItem("Close");
closeItem.addActionListener(new ActionListener() { closeItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (!hasChanged || hasChanged && checkSave()) { if (!hasChanged || hasChanged && checkSave()) {
numberOfTibsRTFOpen--; numberOfTibsRTFOpen--;
@ -134,8 +136,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem saveItem = new JMenuItem("Save"); JMenuItem saveItem = new JMenuItem("Save");
// saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,2)); //Ctrl-s // saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,2)); //Ctrl-s
saveItem.addActionListener(new ActionListener() { saveItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
if (fileName == null) if (fileName == null)
saveAsFile(); saveAsFile();
else else
@ -147,8 +149,8 @@ public class Jskad extends JPanel implements DocumentListener {
fileMenu.add(saveItem); fileMenu.add(saveItem);
JMenuItem saveAsItem = new JMenuItem("Save as"); JMenuItem saveAsItem = new JMenuItem("Save as");
saveAsItem.addActionListener(new ActionListener() { saveAsItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
saveAsFile(); saveAsFile();
} }
}); });
@ -162,8 +164,8 @@ public class Jskad extends JPanel implements DocumentListener {
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) { if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
JMenuItem cutItem = new JMenuItem("Cut"); JMenuItem cutItem = new JMenuItem("Cut");
cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,2)); //Ctrl-x cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,2)); //Ctrl-x
cutItem.addActionListener(new ActionListener() { cutItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
cutSelection(); cutSelection();
} }
}); });
@ -171,8 +173,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem copyItem = new JMenuItem("Copy"); JMenuItem copyItem = new JMenuItem("Copy");
copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2)); //Ctrl-c copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,2)); //Ctrl-c
copyItem.addActionListener(new ActionListener() { copyItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
copySelection(); copySelection();
} }
}); });
@ -180,8 +182,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem pasteItem = new JMenuItem("Paste"); JMenuItem pasteItem = new JMenuItem("Paste");
pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,2)); //Ctrl-v pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,2)); //Ctrl-v
pasteItem.addActionListener(new ActionListener() { pasteItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
pasteSelection(); pasteSelection();
} }
}); });
@ -190,8 +192,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenuItem selectallItem = new JMenuItem("Select All"); JMenuItem selectallItem = new JMenuItem("Select All");
selectallItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,2)); //Ctrl-a selectallItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,2)); //Ctrl-a
selectallItem.addActionListener(new ActionListener() { selectallItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
dp.setSelectionStart(0); dp.setSelectionStart(0);
dp.setSelectionEnd(dp.getDocument().getLength()); dp.setSelectionEnd(dp.getDocument().getLength());
} }
@ -200,8 +202,8 @@ public class Jskad extends JPanel implements DocumentListener {
} }
JMenuItem preferencesItem = new JMenuItem("Preferences"); JMenuItem preferencesItem = new JMenuItem("Preferences");
preferencesItem.addActionListener(new ActionListener() { preferencesItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
getPreferences(); getPreferences();
} }
}); });
@ -213,16 +215,16 @@ public class Jskad extends JPanel implements DocumentListener {
JMenu toolsMenu = new JMenu("Tools"); JMenu toolsMenu = new JMenu("Tools");
JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie"); JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie");
TMWWylieItem.addActionListener(new ActionListener() { TMWWylieItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
toWylie(); toWylie();
} }
}); });
toolsMenu.add(TMWWylieItem); toolsMenu.add(TMWWylieItem);
JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan"); JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan");
wylieTMWItem.addActionListener(new ActionListener() { wylieTMWItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
toTibetan(); toTibetan();
} }
}); });
@ -230,8 +232,8 @@ public class Jskad extends JPanel implements DocumentListener {
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) { if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
JMenuItem importItem = new JMenuItem("Import Wylie as Tibetan"); JMenuItem importItem = new JMenuItem("Import Wylie as Tibetan");
importItem.addActionListener(new ActionListener() { importItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
importWylie(); importWylie();
} }
}); });
@ -244,8 +246,8 @@ public class Jskad extends JPanel implements DocumentListener {
JMenu infoMenu = new JMenu("Info"); JMenu infoMenu = new JMenu("Info");
JMenuItem aboutItem = new JMenuItem("About"); JMenuItem aboutItem = new JMenuItem("About");
aboutItem.addActionListener(new ActionListener() { aboutItem.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
"Copyright 2001 Tibetan and Himalayan Digital Library\n"+ "Copyright 2001 Tibetan and Himalayan Digital Library\n"+
"Programmed by Edward Garrett\n\n"+ "Programmed by Edward Garrett\n\n"+
@ -275,8 +277,8 @@ public class Jskad extends JPanel implements DocumentListener {
String[] input_modes = {"Tibetan","Roman"}; String[] input_modes = {"Tibetan","Roman"};
final JComboBox inputmethods = new JComboBox(input_modes); final JComboBox inputmethods = new JComboBox(input_modes);
inputmethods.addActionListener(new ActionListener() { inputmethods.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
switch (inputmethods.getSelectedIndex()) { switch (inputmethods.getSelectedIndex()) {
case 0: //Tibetan case 0: //Tibetan
if (dp.isRomanMode()) if (dp.isRomanMode())
@ -300,8 +302,8 @@ public class Jskad extends JPanel implements DocumentListener {
String[] keyboard_options = {"Extended Wylie","TCC Keyboard #1","TCC Keyboard #2","Sambhota Keymap One"}; String[] keyboard_options = {"Extended Wylie","TCC Keyboard #1","TCC Keyboard #2","Sambhota Keymap One"};
final JComboBox keyboards = new JComboBox(keyboard_options); final JComboBox keyboards = new JComboBox(keyboard_options);
keyboards.addActionListener(new ActionListener() { keyboards.addActionListener(new ThdlActionListener() {
public void actionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
switch (keyboards.getSelectedIndex()) { switch (keyboards.getSelectedIndex()) {
case 0: //Extended Wylie case 0: //Extended Wylie
installKeyboard("wylie"); installKeyboard("wylie");
@ -599,9 +601,11 @@ public class Jskad extends JPanel implements DocumentListener {
hasChanged = false; hasChanged = false;
} catch (IOException exception) { } catch (IOException exception) {
exception.printStackTrace(); exception.printStackTrace();
ThdlDebug.noteIffyCode();
return null; return null;
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
return f_name; return f_name;
} }
@ -899,26 +903,12 @@ public class Jskad extends JPanel implements DocumentListener {
} }
/** /**
* Runs Jskad. * Runs Jskad. System output, including errors, is redirected to
* System output, including errors, is redirected to jskad.log. * jskad.log in addition to appearing on the console as per usual. If
* If you discover a bug, please send us an email, making sure * you discover a bug, please send us an email, making sure to include
* to include the jskad.log file as an attachment. * the jskad.log file as an attachment. */
*/
public static void main(String[] args) { public static void main(String[] args) {
ThdlDebug.attemptToSetUpLogFile("jskad.log");
try {
PrintStream psOut
= new TeeStream(System.out,
new PrintStream(new FileOutputStream("jskad.log")));
PrintStream psErr
= new TeeStream(System.err,
new PrintStream(new FileOutputStream("jskad.log")));
System.setErr(psErr);
System.setOut(psOut);
}
catch (Exception e) {
}
try { try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

View file

@ -22,9 +22,11 @@ import java.applet.Applet;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import org.thdl.tib.text.*;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import org.thdl.tib.text.*;
import org.thdl.util.ThdlActionListener;
/** /**
* A version of Jskad which can be embedded into * A version of Jskad which can be embedded into
* a web page as an applet. It includes all of the functionality * a web page as an applet. It includes all of the functionality
@ -54,9 +56,9 @@ public class Jskad2JavaScript extends JApplet {
jskad = new Jskad(this); jskad = new Jskad(this);
panel.add("Center", jskad); panel.add("Center", jskad);
JButton submit = new JButton("Submit"); JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() submit.addActionListener(new ThdlActionListener()
{ {
public void actionPerformed(ActionEvent e) public void theRealActionPerformed(ActionEvent e)
{ {
try { try {
TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument(); TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument();

View file

@ -22,9 +22,11 @@ import java.applet.Applet;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import org.thdl.tib.text.*;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import org.thdl.tib.text.*;
import org.thdl.util.ThdlActionListener;
/** /**
* A version of Jskad which can be embedded into * A version of Jskad which can be embedded into
* a web page as an applet. It includes all of the functionality * a web page as an applet. It includes all of the functionality
@ -54,9 +56,9 @@ public class JskadConversionTool extends JApplet {
jskad = new Jskad(this); jskad = new Jskad(this);
panel.add("Center", jskad); panel.add("Center", jskad);
JButton submit = new JButton("Submit"); JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() submit.addActionListener(new ThdlActionListener()
{ {
public void actionPerformed(ActionEvent e) public void theRealActionPerformed(ActionEvent e)
{ {
try { try {
TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument(); TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument();

View file

@ -5,7 +5,7 @@
@(#)package.html @(#)package.html
Copyright 2001 Tibetan and Himalayan Digital Library Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such the Tibetan and Himalayan Digital Library. You shall use such
@ -30,6 +30,6 @@ conversion back and forth between TibetanMachineWeb and
Extended Wylie. Extended Wylie.
<p> <p>
<h2>Related Documentation</h2> <h2>Related Documentation</h2>
@see org.thdl.tib.text @see <a href="../text/package-summary.html">org.thdl.tib.text</a>
</body> </body>
</html> </html>

View file

@ -36,6 +36,9 @@ class AboutDialog extends Dialog implements ActionListener, WindowListener
setSize(240,300); // the size ipaq's window. setSize(240,300); // the size ipaq's window.
} }
/* FIXME: what happens if this throws an exception? We'll just
see it on the console--it won't terminate the program. And the
user may not see the console! See ThdlActionListener. -DC */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
hide(); hide();

View file

@ -42,7 +42,7 @@ import org.thdl.tib.text.TibetanDocument;
@author Andr&eacute;s Montano Pellegrini @author Andr&eacute;s Montano Pellegrini
@see RemoteScannerFilter @see RemoteScannerFilter
@see ScannerPannel @see ScannerPanel
*/ */
public class AppletScannerFilter extends JApplet implements ActionListener, FocusListener, ItemListener public class AppletScannerFilter extends JApplet implements ActionListener, FocusListener, ItemListener
{ {
@ -154,6 +154,9 @@ public class AppletScannerFilter extends JApplet implements ActionListener, Focu
/* mnuEdit.setEnabled(false); /* mnuEdit.setEnabled(false);
objModified=null;*/ objModified=null;*/
} }
/* FIXME: what happens if this throws an exception? We'll just
see it on the console--it won't terminate the program. And the
user may not see the console! See ThdlActionListener. -DC */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Object clicked = e.getSource(); Object clicked = e.getSource();

View file

@ -28,7 +28,7 @@ public class DictionarySource
{ {
private int dicts; private int dicts;
/** Last bit of word. 1 if there are more brothers.*/ /** Last bit of word; 1 if there are more brothers.*/
private static final int lastBit=32768; private static final int lastBit=32768;
private static final int allDicts=lastBit-1; private static final int allDicts=lastBit-1;

View file

@ -19,16 +19,16 @@ package org.thdl.tib.scanner;
import java.io.*; import java.io.*;
/** Searches the words directly in a file; not the prefered /** Searches the words directly in a file; not the preferred
implementation. The search is too slow! implementation. The search is too slow!
The prefered implementation is the CachedSyllableList. The preferred implementation is the CachedSyllableListTree.
<p>The words must be stored in a binary file tree structure format. <p>The words must be stored in a binary file tree structure format.
This can be done using the BinaryFileGenerator.</p> This can be done using the BinaryFileGenerator.</p>
@author Andr&eacute;s Montano Pellegrini @author Andr&eacute;s Montano Pellegrini
@see TibetanScanner @see TibetanScanner
@see CachedSyllableList @see CachedSyllableListTree
@see BinaryFileGenerator @see BinaryFileGenerator
*/ */

View file

@ -167,6 +167,9 @@ public abstract class ScannerPanel extends Panel implements ActionListener
} }
} }
/* FIXME: what happens if this throws an exception? We'll just
see it on the console--it won't terminate the program. And the
user may not see the console! See ThdlActionListener. -DC */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
translate(); translate();

View file

@ -247,6 +247,9 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
mnuSelectAll.setEnabled(false); mnuSelectAll.setEnabled(false);
} }
/* FIXME: what happens if this throws an exception? We'll just
see it on the console--it won't terminate the program. And the
user may not see the console! See ThdlActionListener. -DC */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Object clicked = e.getSource(); Object clicked = e.getSource();

View file

@ -0,0 +1,21 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
-->
</head>
<body bgcolor="white">
Provides classes and methods for translating Tibetan text to English.
<p>
Right now, this package scans Tibetan text, but we aim to make it parse Tibetan text.
<p>
Author: Andr&eacute;s Montano Pellegrini
<p>
<h2>Related Documentation</h2>
@see <a href="../text/package-summary.html">org.thdl.tib.text</a>
@see <a href="../input/package-summary.html">org.thdl.tib.input</a>
</body>
</html>

View file

@ -24,6 +24,8 @@ import javax.swing.text.*;
import javax.swing.text.rtf.RTFEditorKit; import javax.swing.text.rtf.RTFEditorKit;
import java.io.*; import java.io.*;
import org.thdl.util.ThdlDebug;
/** /**
* Provides methods for converting back and forth between * Provides methods for converting back and forth between
* Extended Wylie and TibetanMachineWeb, and for inserting Tibetan * Extended Wylie and TibetanMachineWeb, and for inserting Tibetan
@ -105,9 +107,9 @@ public class TibetanDocument extends DefaultStyledDocument {
* @param glyphs the array of Tibetan data you want to insert * @param glyphs the array of Tibetan data you want to insert
* @param pos the position at which you want to insert text * @param pos the position at which you want to insert text
*/ */
public void insertDuff(int pos, DuffData[] glyphs) { public int insertDuff(int pos, DuffData[] glyphs) {
if (glyphs == null) if (glyphs == null)
return; return pos;
MutableAttributeSet mas; MutableAttributeSet mas;
for (int i=0; i<glyphs.length; i++) { for (int i=0; i<glyphs.length; i++) {
@ -115,6 +117,7 @@ public class TibetanDocument extends DefaultStyledDocument {
appendDuff(pos, glyphs[i].text, mas); appendDuff(pos, glyphs[i].text, mas);
pos += glyphs[i].text.length(); pos += glyphs[i].text.length();
} }
return pos;
} }
/** /**
@ -426,7 +429,10 @@ public class TibetanDocument extends DefaultStyledDocument {
isSanskrit = false; isSanskrit = false;
} }
else { //could not convert - throw exception else { //could not convert - throw exception
if (start+5 < wylie.length())
System.out.println("Bad wylie: "+wylie.substring(start,5)); System.out.println("Bad wylie: "+wylie.substring(start,5));
else
System.out.println("Bad wylie: "+wylie.substring(start));
throw new InvalidWylieException(wylie, start); throw new InvalidWylieException(wylie, start);
} }
} }
@ -779,6 +785,7 @@ public class TibetanDocument extends DefaultStyledDocument {
vowels.add(halfHeight); vowels.add(halfHeight);
if (null != dc_v) if (null != dc_v)
vowels.add(dc_v); vowels.add(dc_v);
return vowels; return vowels;
@ -1033,6 +1040,7 @@ public class TibetanDocument extends DefaultStyledDocument {
*/ */
public String getWylie() { public String getWylie() {
return getWylie(0, getLength()); return getWylie(0, getLength());
} }
/** /**
@ -1051,35 +1059,58 @@ public class TibetanDocument extends DefaultStyledDocument {
DuffCode dc; DuffCode dc;
char ch; char ch;
if (begin == end) if (begin >= end)
return ""; return "";
java.util.List dcs = new ArrayList(); java.util.List dcs = new ArrayList();
int i = begin; int i = begin;
StringBuffer wylieBuffer = new StringBuffer();
try { try {
while (i < end) { while (i < end) {
attr = getCharacterElement(i).getAttributes(); attr = getCharacterElement(i).getAttributes();
fontName = StyleConstants.getFontFamily(attr); fontName = StyleConstants.getFontFamily(attr);
if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName)))) { ch = getText(i,1).charAt(0);
//current character is formatting
if (ch == '\n' || ch == '\t') {
if (dcs.size() > 0) {
DuffCode[] dc_array = new DuffCode[0]; DuffCode[] dc_array = new DuffCode[0];
dc_array = (DuffCode[])dcs.toArray(dc_array); dc_array = (DuffCode[])dcs.toArray(dc_array);
return TibetanDocument.getWylie(dc_array); wylieBuffer.append(TibetanDocument.getWylie(dc_array));
dcs.clear();
} }
wylieBuffer.append(ch);
}
//current character isn't TMW
else if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName)))) {
if (dcs.size() > 0) {
DuffCode[] dc_array = new DuffCode[0];
dc_array = (DuffCode[])dcs.toArray(dc_array);
wylieBuffer.append(TibetanDocument.getWylie(dc_array));
dcs.clear();
}
}
//current character is convertable
else { else {
ch = getText(i,1).charAt(0);
dc = new DuffCode(fontNum, ch); dc = new DuffCode(fontNum, ch);
dcs.add(dc); dcs.add(dc);
} }
i++; i++;
} }
if (dcs.size() > 0) {
DuffCode[] dc_array = new DuffCode[0]; DuffCode[] dc_array = new DuffCode[0];
dc_array = (DuffCode[])dcs.toArray(dc_array); dc_array = (DuffCode[])dcs.toArray(dc_array);
return TibetanDocument.getWylie(dc_array); wylieBuffer.append(TibetanDocument.getWylie(dc_array));
}
return wylieBuffer.toString();
} }
catch (BadLocationException ble) { catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
return ""; return "";

View file

@ -5,7 +5,7 @@
@(#)package.html @(#)package.html
Copyright 2001 Tibetan and Himalayan Digital Library Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such the Tibetan and Himalayan Digital Library. You shall use such
@ -33,6 +33,6 @@ Here, you can also find methods for installing and managing Tibetan
keyboards. Four keyboards have been provided in this release, keyboards. Four keyboards have been provided in this release,
but users may also create their own keyboards. but users may also create their own keyboards.
<h2>Related Documentation</h2> <h2>Related Documentation</h2>
@see org.thdl.tib.input @see <a href="../input/package-summary.html">org.thdl.tib.input</a>
</body> </body>
</html> </html>

View file

@ -22,7 +22,9 @@ import java.io.PrintStream;
/** /**
* All writes to this print stream are copied to two print streams of * All writes to this print stream are copied to two print streams of
* your choice. */ * your choice.
* @author David Chandler
*/
public class TeeStream extends PrintStream { public class TeeStream extends PrintStream {
private PrintStream out; private PrintStream out;
public TeeStream(PrintStream out1, PrintStream out2) { public TeeStream(PrintStream out1, PrintStream out2) {

View file

@ -0,0 +1,85 @@
/*
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 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.util;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
import org.thdl.util.ThdlDebug;
/**
* This ActionListener is like any other except in the way that it
* handles exceptions or errors thrown during the execution of
* <code>actionPerformed()</code>. Because event listeners are on
* threads, an exception during <code>actionPerformed()</code> is just
* printed out on the console by
* <code>java.awt.EventDispatchThread.run()</code>. It does not cause
* the program to terminate. In our code, it helps developers more
* quickly get to the root of a problem if the program terminates as
* soon after a problem as possible.
*
* Thus, this class calls <code>System.exit(1)</code> when an
* exception is throw by <code>theRealActionPerformed()</code>, which
* is the method that subclasses should implement.
*
* @see ThdlActionListener
*
* @author David Chandler
*
* There is a pertinent Usenet thread at <code>http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=6ntgl6%244hl%241%40tarantula.europe.shiva.com&rnum=2&prev=/groups%3Fq%3Dexception%2BactionPerformed%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26selm%3D6ntgl6%25244hl%25241%2540tarantula.europe.shiva.com%26rnum%3D2</code>.
*/
public class ThdlAbstractAction extends AbstractAction {
/** Just calls the super's constructor with the same args. */
public ThdlAbstractAction(String s, Icon i) {
super(s, i);
}
/** Subclasses don't override this. Instead, they override
* <code>theRealActionPerformed()</code>.
* @see #actionPerformed(ActionEvent)
*/
public final void actionPerformed(ActionEvent e) {
try {
theRealActionPerformed(e);
} catch (NoClassDefFoundError err) {
/* This is an especially common exception, and is in fact
the motivating force behind the ThdlActionListener
class and this class. Handle it well so that users
know what's up: */
ThdlDebug.handleClasspathError(null, err);
} catch (Throwable t) {
System.err.println("THDL_ERR 107: This application failed due to the following exception: ");
t.printStackTrace(System.err);
System.exit(1);
}
}
/** Subclasses should override this method to do the real action
* performed.
* @see #actionPerformed(ActionEvent)
*/
protected void theRealActionPerformed(ActionEvent e)
throws Throwable
{
/* do nothing */
}
}

View file

@ -0,0 +1,157 @@
/*
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 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.util;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import org.thdl.util.ThdlDebug;
/**
* This ActionListener is like any other except in the way that it
* handles exceptions or errors thrown during the execution of
* <code>actionPerformed()</code>. Because event listeners are on
* threads, an exception during <code>actionPerformed()</code> is just
* printed out on the console by
* <code>java.awt.EventDispatchThread.run()</code>. It does not cause
* the program to terminate. In our code, it helps developers more
* quickly get to the root of a problem if the program terminates as
* soon after a problem as possible.
*
* Thus, this class calls <code>System.exit(1)</code> when an
* exception is throw by <code>theRealActionPerformed()</code>, which
* is the method that subclasses should implement.
*
* @see ThdlAbstractAction
*
* @author David Chandler
*
* Here is a pertinent Usenet thread from <code>http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=6ntgl6%244hl%241%40tarantula.europe.shiva.com&rnum=2&prev=/groups%3Fq%3Dexception%2BactionPerformed%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26selm%3D6ntgl6%25244hl%25241%2540tarantula.europe.shiva.com%26rnum%3D2</code>:
<pre>
From: Denis (denisb@europe.shiva.com)
Subject: Exception in event handlers
View this article only
Newsgroups: comp.lang.java.gui, comp.lang.java.help, comp.lang.java.programmer
Date: 1998/07/07
Hi everyone !
I've got a wee question regarding propagation of exceptions in event
handlers :
here's the fun :
Say, you've got a method A() that is called from within an event handler
(mostly it'll be in actionPerformed(ActionEvent) from ActionListener
interface).
Now this A() method produces an exception. This exception will be propagated
up to the caller of actionPerformed which is into the event handler queue.
This exception never gets propagated higher than the handler (and produces a
message "exception occured in event handler")
Now I would like this exception NOT to be caught there but to propagate
until the program terminates or it is caught somewhere else.
Is there a way to do that ? There's no mean to re-throw that exception as
the event handler is part of the core java.
Basically what I would like to do is catch ANY exception that occurs in a
java application in order to display a message box, without having to put
try{} catch{} blocks all other the place...
Thanks for any help on that
Chunk of code to illustrate :
class MyClass extends Object implements ActionListener {
// blah blah
public void actionPerformed(ActionEvent event) {
A(); //May throw an exception here but the actionPerformed is called
// from the event handler and the exception is caught into it
//So the actionPerformed finishes because of the exception but the
// rest of the app is likely to be in an unstable state, but still running
}
// So here the exception has been caught without an explicit try{}
// catch{} WHICH I DONT WANT
//You then can happily do something else....even if A() failed....
}//MyClass
Message 2 in thread
From: David Holmes (dholmes@mri.mq.edu.au)
Subject: Re: Exception in event handlers
View this article only
Newsgroups: comp.lang.java.gui, comp.lang.java.help, comp.lang.java.programmer
Date: 1998/07/09
Denis &lt;denisb@europe.shiva.com&gt; wrote in article
&lt;6ntgl6$4hl$1@tarantula.europe.shiva.com&gt;...
&gt; Now I would like this exception NOT to be caught there but to propagate
> until the program terminates or it is caught somewhere else.
Once an exception is caught it is up to the catcher what to do with it. The
event dispatch thread simply catches the exception and tells you about it.
There is no way to make this exception go any further - indeed there is
nowhere further for it to go. Exceptions occur per-thread and if the thread
doesn't catch it the thread will terminate. A more sophisticated event
mechanism might allow you to register a handler/listener to take some
action when this occurred but the current AWT does not.
David
</pre>
*/
public class ThdlActionListener implements ActionListener {
/** Subclasses don't override this. Instead, they override
* <code>theRealActionPerformed()</code>.
* @see #actionPerformed(ActionEvent)
*/
public final void actionPerformed(ActionEvent e) {
try {
theRealActionPerformed(e);
} catch (NoClassDefFoundError err) {
/* This is an especially common exception, and is in fact
the motivating force behind the ThdlActionListener
class. Handle it well so that users know what's up: */
ThdlDebug.handleClasspathError(null, err);
} catch (Throwable t) {
System.err.println("THDL_ERR 106: This application failed due to the following exception: ");
t.printStackTrace(System.err);
System.exit(1);
}
}
/** Subclasses should override this method to do the real action
* performed by this action listener.
* @see #actionPerformed(ActionEvent)
*/
protected void theRealActionPerformed(ActionEvent e)
throws Throwable
{
/* do nothing */
}
}

View file

@ -0,0 +1,136 @@
/*
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 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.util;
import java.io.PrintStream;
import java.io.FileOutputStream;
import org.thdl.util.TeeStream;
/**
* This uninstantiable class provides assertions and the like in a
* JVM-version-independent fashion.
* @author David Chandler
*/
public class ThdlDebug {
/* FIXME: make this configurable. */
static final String contactMsg
= " Please visit http://thdltools.sf.net/ or contact thdltools-devel@lists.sourceforge.net and give us a bug report so that we can improve the quality of this software.";
/** Do not instantiate this class. */
private ThdlDebug() { }
/** Throws an unchecked exception if condition is not true. Note that
* unlike a real assertion, this happens always. We can certainly
* use AspectJ (with which I, DC, am intimately familiar) to avoid
* the overhead of such things in release builds if performance
* becomes a real issue. */
public static void verify(boolean condition) {
verify(null, condition);
}
/** Throws an unchecked exception if condition is not true. The
* exception's message will include the string msg if msg is not
* null. Note that unlike a real assertion, this happens always.
* We can certainly use AspectJ (with which I, DC, am intimately
* familiar) to avoid the overhead of such things in release
* builds if performance becomes a real issue.
*
* Throws a THDL-specific exception so that you can catch these
* specially in case you want to ignore them.
*
* @throws ThdlLazyException if condition is not true */
public static void verify(String msg, boolean condition)
throws ThdlLazyException
{
if (!condition) {
throw new ThdlLazyException(new Error(((msg == null)
? "THDL Tools sanity check: "
: msg)
+ "An assertion failed. This means that there is a bug in this software."
+ contactMsg));
}
}
/** Call this from control-flow paths that are not well thought
* out. For example, if you have to catch an IOException, but
* you're fairly certain that it'll never be thrown, call this
* function if it is indeed thrown. Developers can set the
* THDL_DIE_EAGERLY property to true (using <code>'java
* -DTHDL_DIE_ON_IFFY_CODE=true'</code>) in order to test the
* code's robustness.
*
* Throws a THDL-specific exception so that you can catch these
* specially in case you want to ignore them.
*
* @throws ThdlLazyException if the THDL_DIE_ON_IFFY_CODE system
* property is set to "true" */
public static void noteIffyCode()
throws ThdlLazyException
{
/* FIXME: find all calls to this function and rethink or shore
up the calling code. */
if (Boolean.getBoolean("THDL_DIE_ON_IFFY_CODE"))
throw new ThdlLazyException(new Error("You've reached some iffy code, some code that's not well thought-out. Because you invoked the Java runtime environment with the property THDL_DIE_ON_IFFY_CODE set to true (developers: use 'ant -Dthdl.die.on.iffy=false' to prevent this), the program is now aborting."));
}
/** Exits the program with a message that the CLASSPATH is not set
properly. */
public static void handleClasspathError(String whoseWhat, Throwable error) {
System.err.println(((whoseWhat == null) ? "Your CLASSPATH" : whoseWhat)
+ " is not set properly.");
/* FIXME */
System.err.println("Note that Savant and QuillDriver CANNOT be invoked via the");
System.err.println("'java -jar Savant-xyz.jar' option, because that silently ignores");
System.err.println("the CLASSPATH. This means that double-clicking them won't work");
System.err.println("either, because we don't set the JARs' manifest files to contain");
System.err.println("Class-path attributes. See installation instructions."); /* FIXME: we don't HAVE installation instructions, do we? */
System.err.println("");
System.err.println("Details: Missing class: "
+ ((error == null)
? "unknown!" : error.getMessage()));
if (Boolean.getBoolean("THDL_DEBUG")) {
System.err.println("Details: Stack trace: "
+ ((error == null)
? "unknown!" : error.getMessage()));
error.printStackTrace(System.err);
}
System.exit(1);
}
/** Sets it up so that a call to System.out or System.err prints
* to standard output/error but ALSO prints to the log file named
* logFile. */
public static void attemptToSetUpLogFile(String logFile) {
try {
PrintStream logFilePrintStream
= new PrintStream(new FileOutputStream(logFile));
PrintStream psOut = new TeeStream(System.out, logFilePrintStream);
PrintStream psErr = new TeeStream(System.err, logFilePrintStream);
System.setErr(psErr);
System.setOut(psOut);
} catch (Exception e) {
/* don't let this stop us. */
noteIffyCode();
}
}
};

View file

@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides classes and methods not specific to any one application.
<p>
These classes aim to be of general use to the THDL's Java programs.
</body>
</html>

112
source/overview.html Normal file
View file

@ -0,0 +1,112 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)overview.html
Copyright 2001-2002 Tibetan and Himalayan Digital Library
This software is the confidential and proprietary information of
the Tibetan and Himalayan Digital Library. You shall use such
information only in accordance with the terms of the license
agreement you entered into with the THDL.
-->
</head>
<body bgcolor="white">
Provides facilities for manipulating text, audio, and video in Tibetan and other Himalayan languages.
<p>
From the THDL Tools project's
<a href="http://sourceforge.net/forum/forum.php?forum_id=214100">
News</a> archive:
<pre>
Posted By: eg3p
Date: 2002-09-26 12:14
Summary:THDL Projects and Goals
</pre>
<p>
Hello. You'll see that we at the Tibetan and Himalayan Digital Library
have been developing several Tibetan language and culture related
software tools, all of which take advantage of Tony Duff's free
cross-platform TibetanMachineWeb fonts. We think these tools have
reached a level of development that they now need the active
participation of the larger programming community in order to
progress.
</p>
<p>
On the one hand, we've developed Java-based tools for inputting and
displaying Tibetan script (Jskad), as well as for the transcription of
Tibetan-language videos (QuillDriver), and the synchronized playback
of videos along with their associated transcripts (Savant).
</p>
<p>
On the other hand, recognizing the ubiquity of Word, we've also
developed Visual Basic macros for inputting Tibetan script (WylieWord)
and diacritics useful for Asian studies (DiacriticsForWord,
DiacriticsForWin2k) into Microsoft Word.
</p>
<p>
The Java side of our project has several goals. First, we'd like to
create a high quality cross-platform word processor/display engine
optimized for Tibetan script input and display. This probably means
embedding Jskad in an established open source text editor.
</p>
<p>
Second, we are developing educational and research-oriented software
that takes advantage of these basic Tibetan display
capabilities. QuillDriver, designed for transcription of videos, and
Savant, an integrated tool for learning language from digital video,
are examples of this. Here, several tasks are on the horizon: merging
QuillDriver and Savant into the same tool, which has both edit
(QuillDriver) and display (Savant) modes; and integrating both with
Tibetan dictionary, grammar and pedagogy modules also being developed
at the THDL. Finally, note that unlike Jskad, both QuillDriver and
Savant are meant to be truly multilingual, and not just specialized
Tibetan software.
</p>
<p>
Still, we know that no matter what the open source community does,
Microsoft Word will still remain the most dominant (and arguably the
best) word-processor. There will always be people, and always
occasions, to type Tibetan into Word. Therefore, we are also pushing
our Visual Basic macros for Tibetan and diacritic input. Our main
goals with these tools is to make them as bug-free and user-friendly
as possible, and to develop stable Mac versions. Another possible goal
would be to extend these tools to work with other Office applications,
such as Excel or Access.
</p>
<p>
Given the various projects, we are setting up several forums for
specialized discussion:
</p>
<p>
1) General
2) Jskad
3) QuillDriver/Savant
4) WylieWord
5) Diacritics
</p>
<p>
Please occasionally consult those forums of interest to you. Also,
please take a look at the mailing lists and subscribe to those you
want to follow.
</p>
<p>
Spread the word: THDL Tools are on SourceForge!
</p>
</body>
</html>