From 8fbd8850f81927b265c6e9e4e24c08c02a0b6c64 Mon Sep 17 00:00:00 2001 From: dchandler Date: Sat, 8 Nov 2003 23:22:06 +0000 Subject: [PATCH] New feature: Convert Selection from TWM to ACIP. --- source/org/thdl/tib/input/Jskad.java | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/source/org/thdl/tib/input/Jskad.java b/source/org/thdl/tib/input/Jskad.java index c1a1a83..3ab050a 100644 --- a/source/org/thdl/tib/input/Jskad.java +++ b/source/org/thdl/tib/input/Jskad.java @@ -425,12 +425,21 @@ public class Jskad extends JPanel implements DocumentListener { JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie"); TMWWylieItem.addActionListener(new ThdlActionListener() { public void theRealActionPerformed(ActionEvent e) { - toWylie(); + toTranslit(true); } }); convertSelectionMenu.add(TMWWylieItem); toolsMenu.add(convertSelectionMenu); + JMenuItem TMWACIPItem = new JMenuItem("Convert Tibetan to ACIP"); + TMWACIPItem.addActionListener(new ThdlActionListener() { + public void theRealActionPerformed(ActionEvent e) { + toTranslit(false); + } + }); + convertSelectionMenu.add(TMWACIPItem); + toolsMenu.add(convertSelectionMenu); + JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan"); wylieTMWItem.addActionListener(new ThdlActionListener() { public void theRealActionPerformed(ActionEvent e) { @@ -1144,13 +1153,25 @@ public class Jskad extends JPanel implements DocumentListener { Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } - private void toWylie() { + private void toTranslit(boolean toWylieNotACIP) { Jskad.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - if (!((TibetanDocument)dp.getDocument()).toWylie(dp.getSelectionStart(), - dp.getSelectionEnd(), - new long[] { 0 })) { + if (!(toWylieNotACIP + ? ((TibetanDocument)dp.getDocument()).toWylie(dp.getSelectionStart(), + dp.getSelectionEnd(), + new long[] { 0 }) + : ((TibetanDocument)dp.getDocument()).toACIP(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.", + "Though some " + + (toWylieNotACIP + ? "Extended Wylie" + : "ACIP") + + " has been produced, it\ncontains ugly error messages" + + (toWylieNotACIP + ? " 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 transliteration.", "Attention Required", JOptionPane.ERROR_MESSAGE); }