Better error messages in TMW->Wylie conversions. The user knows what's
up.
This commit is contained in:
parent
3113a4b8de
commit
a48ec641d5
8 changed files with 211 additions and 132 deletions
|
@ -67,6 +67,12 @@ public class ConverterGUI implements FontConversion, FontConverterConstants {
|
|||
"Conversion failed",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
} else if (44 == returnCode) {
|
||||
JOptionPane.showMessageDialog(cd,
|
||||
"Though an output file has been created, it contains ugly\nerror messages like\n\"<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE:\n Cannot convert DuffCode...\".\nPlease edit the output by hand to replace all such\ncreatures with the correct EWTS transliteration.",
|
||||
"Attention required",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
} else if (43 == returnCode) {
|
||||
JOptionPane.showMessageDialog(cd,
|
||||
"Though an output file has been created, this conversion did nothing.\nDid you choose the correct original file?\nDid you choose the correct type of conversion?",
|
||||
|
|
|
@ -299,12 +299,11 @@ public class DuffPane extends TibetanPane implements FocusListener {
|
|||
private void setupEditor() {
|
||||
rtfBoard = getToolkit().getSystemClipboard();
|
||||
|
||||
newDocument();
|
||||
|
||||
romanFontFamily = ThdlOptions.getStringOption("thdl.default.roman.font.face",
|
||||
"Serif");
|
||||
romanFontSize = defaultRomanFontSize();
|
||||
setRomanAttributeSet(romanFontFamily, romanFontSize);
|
||||
|
||||
newDocument();
|
||||
|
||||
caret = getCaret();
|
||||
|
||||
|
@ -471,6 +470,9 @@ public class DuffPane extends TibetanPane implements FocusListener {
|
|||
StyleConstants.setFontFamily(defaultStyle, "TibetanMachineWeb");
|
||||
StyleConstants.setFontSize(defaultStyle, defaultTibFontSize());
|
||||
|
||||
setRomanAttributeSet(romanFontFamily, romanFontSize);
|
||||
|
||||
|
||||
newGlyphList.clear();
|
||||
initKeyboard();
|
||||
}
|
||||
|
@ -773,7 +775,10 @@ public class DuffPane extends TibetanPane implements FocusListener {
|
|||
return;
|
||||
}
|
||||
|
||||
String wylie = TibetanMachineWeb.getWylieForGlyph(fontNum, k);
|
||||
String wylie
|
||||
= TibetanMachineWeb.getWylieForGlyph(fontNum,
|
||||
k,
|
||||
TibTextUtils.weDoNotCareIfThereIsCorrespondingWylieOrNot);
|
||||
if (TibetanMachineWeb.isWyliePunc(wylie)) {
|
||||
if (charList.isEmpty() && !TibetanMachineWeb.isAChenRequiredBeforeVowel()) {
|
||||
printAChenWithVowel(v);
|
||||
|
@ -873,7 +878,10 @@ public class DuffPane extends TibetanPane implements FocusListener {
|
|||
if (k<32 || k>126) //if previous character is formatting or some other non-character
|
||||
break special_bindu_block;
|
||||
|
||||
String wylie = TibetanMachineWeb.getWylieForGlyph(fontNum, k);
|
||||
String wylie
|
||||
= TibetanMachineWeb.getWylieForGlyph(fontNum,
|
||||
k,
|
||||
TibTextUtils.weDoNotCareIfThereIsCorrespondingWylieOrNot);
|
||||
if (!TibetanMachineWeb.isWylieVowel(wylie))
|
||||
break special_bindu_block;
|
||||
|
||||
|
@ -1587,10 +1595,14 @@ public void paste(int offset) {
|
|||
* Converts the entire associated document into Extended Wylie. If the
|
||||
* document consists of both Tibetan and non-Tibetan fonts, however,
|
||||
* the conversion stops at the first non-Tibetan font.
|
||||
* @param noSuchWylie an array which will not be touched if this is
|
||||
* successful; however, if there is no THDL Extended Wylie
|
||||
* corresponding to one of these glyphs, then noSuchWylie[0] will be
|
||||
* set to true
|
||||
* @return the string of Wylie corresponding to the associated document
|
||||
* @see org.thdl.tib.text.TibetanDocument#getWylie() */
|
||||
public String getWylie() {
|
||||
return getTibDoc().getWylie();
|
||||
public String getWylie(boolean noSuchWylie[]) {
|
||||
return getTibDoc().getWylie(noSuchWylie);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1076,9 +1076,14 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
|
||||
private void toWylie() {
|
||||
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
((TibetanDocument)dp.getDocument()).toWylie(dp.getSelectionStart(),
|
||||
dp.getSelectionEnd(),
|
||||
new long[] { 0 });
|
||||
if (!((TibetanDocument)dp.getDocument()).toWylie(dp.getSelectionStart(),
|
||||
dp.getSelectionEnd(),
|
||||
new long[] { 0 })) {
|
||||
JOptionPane.showMessageDialog(Jskad.this,
|
||||
"Though some Extended Wylie has been produced, it\ncontains ugly error messages like\n\"<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE:\n Cannot convert DuffCode...\".\nPlease edit the output by hand to replace all such\ncreatures with the correct EWTS transliteration.",
|
||||
"Attention Required",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.thdl.tib.input;
|
|||
|
||||
import java.io.*;
|
||||
import javax.swing.text.rtf.RTFEditorKit;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.StyleConstants;
|
||||
|
||||
import org.thdl.util.*;
|
||||
import org.thdl.tib.text.*;
|
||||
|
@ -122,6 +124,10 @@ public class TibetanConverter implements FontConverterConstants {
|
|||
out.println(" result to standard output (after dealing with the curly brace problem if");
|
||||
out.println(" the input is TibetanMachineWeb). Exit code is zero on success, 42 if some");
|
||||
out.println(" glyphs couldn't be converted (in which case the output is just those glyphs),");
|
||||
out.println(" 44 if a TMW->Wylie conversion ran into some glyphs that couldn't be");
|
||||
out.println(" converted, in which case ugly error messages like");
|
||||
out.println(" \"<<[[JSKAD_TMW_TO_WYLIE_ERROR_NO_SUCH_WYLIE: Cannot convert DuffCode...\"");
|
||||
out.println(" are in your document waiting for your personal attention,");
|
||||
out.println(" 43 if not even one glyph found was eligible for this conversion, which means");
|
||||
out.println(" that you probably selected the wrong conversion or the wrong document, or ");
|
||||
out.println(" nonzero otherwise.");
|
||||
|
@ -186,6 +192,16 @@ public class TibetanConverter implements FontConverterConstants {
|
|||
honored. */
|
||||
static int reallyConvert(InputStream in, PrintStream out, String ct) {
|
||||
TibetanDocument tdoc = new TibetanDocument();
|
||||
{
|
||||
SimpleAttributeSet ras = new SimpleAttributeSet();
|
||||
StyleConstants.setFontFamily(ras,
|
||||
ThdlOptions.getStringOption("thdl.default.roman.font.face",
|
||||
"Serif"));
|
||||
StyleConstants.setFontSize(ras,
|
||||
ThdlOptions.getIntegerOption("thdl.default.roman.font.size",
|
||||
14));
|
||||
tdoc.setRomanAttributeSet(ras);
|
||||
}
|
||||
try {
|
||||
// Read in the rtf file.
|
||||
if (debug) System.err.println("Start: reading in old RTF file");
|
||||
|
@ -253,9 +269,11 @@ public class TibetanConverter implements FontConverterConstants {
|
|||
long numAttemptedReplacements[] = new long[] { 0 };
|
||||
if (TMW_TO_WYLIE == ct) {
|
||||
// Convert to THDL Wylie:
|
||||
tdoc.toWylie(0,
|
||||
tdoc.getLength(),
|
||||
numAttemptedReplacements);
|
||||
if (!tdoc.toWylie(0,
|
||||
tdoc.getLength(),
|
||||
numAttemptedReplacements)) {
|
||||
exitCode = 44;
|
||||
}
|
||||
} else if (TMW_TO_UNI == ct) {
|
||||
StringBuffer errors = new StringBuffer();
|
||||
// Convert to Unicode:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue