Rearranged the Tools menu; made the converter smart about "find some..."

and "find all..." modes.
This commit is contained in:
dchandler 2003-07-05 21:02:46 +00:00
parent 72d2eee503
commit 8c4ab30a52
2 changed files with 142 additions and 108 deletions

View file

@ -89,6 +89,21 @@ public class ConverterGUI implements FontConversion, FontConverterConstants {
"Errors in Conversion", "Errors in Conversion",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return false; return false;
} else if (1 == returnCode) {
if (FIND_SOME_NON_TMW == whichConversion
|| FIND_ALL_NON_TMW == whichConversion) {
JOptionPane.showMessageDialog(cd,
"Something besides TibetanMachineWeb was found; see output file.",
"Not entirely TMW",
JOptionPane.PLAIN_MESSAGE);
} else if (FIND_SOME_NON_TM == whichConversion
|| FIND_ALL_NON_TM == whichConversion) {
JOptionPane.showMessageDialog(cd,
"Something besides TibetanMachine was found; see output file.",
"Not entirely TM",
JOptionPane.PLAIN_MESSAGE);
}
return false;
} else if (0 != returnCode) { } else if (0 != returnCode) {
JOptionPane.showMessageDialog(cd, JOptionPane.showMessageDialog(cd,
"The conversion failed with code " + returnCode + "; please e-mail\ndchandler@users.sourceforge.net to learn what that means if\nyou can't find out from the output.", "The conversion failed with code " + returnCode + "; please e-mail\ndchandler@users.sourceforge.net to learn what that means if\nyou can't find out from the output.",
@ -96,11 +111,26 @@ public class ConverterGUI implements FontConversion, FontConverterConstants {
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return false; return false;
} else { } else {
if (!ThdlOptions.getBooleanOption("thdl.skip.conversion.success.message")) if (!ThdlOptions.getBooleanOption("thdl.skip.conversion.success.message")) {
if (FIND_SOME_NON_TMW == whichConversion
|| FIND_ALL_NON_TMW == whichConversion) {
JOptionPane.showMessageDialog(cd,
"Nothing except TibetanMachineWeb was found.",
"All TMW",
JOptionPane.PLAIN_MESSAGE);
} else if (FIND_SOME_NON_TM == whichConversion
|| FIND_ALL_NON_TM == whichConversion) {
JOptionPane.showMessageDialog(cd,
"Nothing except TibetanMachine was found.",
"All TM",
JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(cd, JOptionPane.showMessageDialog(cd,
"The conversion went perfectly.", "The conversion went perfectly.",
"Conversion succeeded", "Conversion succeeded",
JOptionPane.PLAIN_MESSAGE); JOptionPane.PLAIN_MESSAGE);
}
}
return true; return true;
} }
} }

View file

@ -396,13 +396,15 @@ public class Jskad extends JPanel implements DocumentListener {
JMenu toolsMenu = new JMenu("Tools"); JMenu toolsMenu = new JMenu("Tools");
JMenu convertSelectionMenu = new JMenu("Convert Selection");
JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie"); JMenuItem TMWWylieItem = new JMenuItem("Convert Tibetan to Wylie");
TMWWylieItem.addActionListener(new ThdlActionListener() { TMWWylieItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
toWylie(); toWylie();
} }
}); });
toolsMenu.add(TMWWylieItem); convertSelectionMenu.add(TMWWylieItem);
toolsMenu.add(convertSelectionMenu);
JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan"); JMenuItem wylieTMWItem = new JMenuItem("Convert Wylie to Tibetan");
wylieTMWItem.addActionListener(new ThdlActionListener() { wylieTMWItem.addActionListener(new ThdlActionListener() {
@ -410,29 +412,11 @@ public class Jskad extends JPanel implements DocumentListener {
toTibetan(); toTibetan();
} }
}); });
toolsMenu.add(wylieTMWItem); convertSelectionMenu.add(wylieTMWItem);
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) { JMenu convertAllMenu = new JMenu("Convert All");
JMenuItem openWithItem = new JMenuItem("Open With External Viewer...");
openWithItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
openWithExternalViewer();
}
});
toolsMenu.addSeparator();
toolsMenu.add(openWithItem);
JMenuItem toTMItem = new JMenuItem("Convert Tibetan to TM"); // DLC FIXME: do it just in the selection?
JMenuItem importItem = new JMenuItem("Import Wylie as Tibetan");
importItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
importWylie();
}
});
toolsMenu.addSeparator();
toolsMenu.add(importItem);
JMenuItem toTMItem = new JMenuItem("Convert TMW to TM"); // DLC FIXME: do it just in the selection?
toTMItem.addActionListener(new ThdlActionListener() { toTMItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
StringBuffer errors = new StringBuffer(); StringBuffer errors = new StringBuffer();
@ -444,7 +428,7 @@ public class Jskad extends JPanel implements DocumentListener {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
"At least one error occurred while converting Tibetan Machine Web\nto Tibetan Machine. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n" "At least one error occurred while converting Tibetan Machine Web\nto Tibetan Machine. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n"
+ errors.toString(), + errors.toString(),
"TMW to TM Errors", "Tibetan to TM Errors",
JOptionPane.PLAIN_MESSAGE); JOptionPane.PLAIN_MESSAGE);
} else { } else {
if (numAttemptedReplacements[0] > 0) { if (numAttemptedReplacements[0] > 0) {
@ -462,7 +446,7 @@ public class Jskad extends JPanel implements DocumentListener {
} }
}); });
JMenuItem toTMWItem = new JMenuItem("Convert TM to TMW"); // DLC FIXME: do it just in the selection? JMenuItem toTMWItem = new JMenuItem("Convert TM to Tibetan"); // DLC FIXME: do it just in the selection?
toTMWItem.addActionListener(new ThdlActionListener() { toTMWItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
StringBuffer errors = new StringBuffer(); StringBuffer errors = new StringBuffer();
@ -474,7 +458,7 @@ public class Jskad extends JPanel implements DocumentListener {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
"At least one error occurred while converting Tibetan Machine\nto Tibetan Machine Web. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n" "At least one error occurred while converting Tibetan Machine\nto Tibetan Machine Web. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n"
+ errors.toString(), + errors.toString(),
"TM to TMW Errors", JOptionPane.PLAIN_MESSAGE); "TM to Tibetan Errors", JOptionPane.PLAIN_MESSAGE);
} else { } else {
if (numAttemptedReplacements[0] > 0) { if (numAttemptedReplacements[0] > 0) {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
@ -491,7 +475,7 @@ public class Jskad extends JPanel implements DocumentListener {
} }
}); });
JMenuItem toUnicodeItem = new JMenuItem("Convert TMW to Unicode"); // DLC FIXME: do it just in the selection? JMenuItem toUnicodeItem = new JMenuItem("Convert Tibetan to Unicode (not perfect yet)"); // DLC FIXME: do it just in the selection?
toUnicodeItem.addActionListener(new ThdlActionListener() { toUnicodeItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
StringBuffer errors = new StringBuffer(); StringBuffer errors = new StringBuffer();
@ -504,7 +488,7 @@ public class Jskad extends JPanel implements DocumentListener {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
"At least one error occurred while converting Tibetan Machine Web\nto Unicode. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n" "At least one error occurred while converting Tibetan Machine Web\nto Unicode. Your document is mostly converted,\nexcept for the following glyphs, which you should replace manually\nbefore retrying:\n"
+ errors.toString(), + errors.toString(),
"TMW to Unicode Errors", JOptionPane.PLAIN_MESSAGE); "Tibetan to Unicode Errors", JOptionPane.PLAIN_MESSAGE);
} else { } else {
if (numAttemptedReplacements[0] > 0) { if (numAttemptedReplacements[0] > 0) {
JOptionPane.showMessageDialog(Jskad.this, JOptionPane.showMessageDialog(Jskad.this,
@ -520,7 +504,12 @@ public class Jskad extends JPanel implements DocumentListener {
} }
} }
}); });
convertAllMenu.add(toTMItem);
convertAllMenu.add(toTMWItem);
convertAllMenu.add(toUnicodeItem);
toolsMenu.add(convertAllMenu);
if (parentObject instanceof JFrame || parentObject instanceof JInternalFrame) {
JMenuItem converterItem = new JMenuItem("Launch Converter..."); JMenuItem converterItem = new JMenuItem("Launch Converter...");
converterItem.addActionListener(new ThdlActionListener() { converterItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
@ -532,12 +521,27 @@ public class Jskad extends JPanel implements DocumentListener {
: null)); : null));
} }
}); });
toolsMenu.addSeparator();
toolsMenu.add(toTMItem);
toolsMenu.add(toTMWItem);
toolsMenu.add(toUnicodeItem);
toolsMenu.addSeparator();
toolsMenu.add(converterItem); toolsMenu.add(converterItem);
JMenuItem importItem = new JMenuItem("Import Wylie as Tibetan...");
importItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
importWylie();
}
});
toolsMenu.addSeparator();
toolsMenu.add(importItem);
JMenuItem openWithItem = new JMenuItem("Open With External Viewer...");
openWithItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
openWithExternalViewer();
}
});
toolsMenu.addSeparator();
toolsMenu.add(openWithItem);
} }