Added an About button. Code cleanup. Changed the Cancel button to the

Close button.
This commit is contained in:
dchandler 2003-06-25 00:49:11 +00:00
parent 569fba6467
commit 9e6c3009ac
3 changed files with 57 additions and 57 deletions

View file

@ -48,7 +48,7 @@ class ConvertDialog extends JDialog
JTextField oldTextField, newTextField; JTextField oldTextField, newTextField;
JButton browseOld, browseNew, convert, cancel, openDoc; JButton browseOld, browseNew, convert, cancel, openDoc, about;
JLabel type, oldLabel, newLabel; JLabel type, oldLabel, newLabel;
@ -63,7 +63,8 @@ class ConvertDialog extends JDialog
final String BROWSENEW = "Browse"; final String BROWSENEW = "Browse";
final String BROWSEOLD = BROWSENEW; final String BROWSEOLD = BROWSENEW;
final String CONVERT = "Convert"; final String CONVERT = "Convert";
final String CANCEL = "Cancel"; final String CANCEL = "Close";
final String ABOUT = "About";
private final ThdlActionListener tal = new ThdlActionListener() { private final ThdlActionListener tal = new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) { public void theRealActionPerformed(ActionEvent e) {
@ -117,12 +118,11 @@ class ConvertDialog extends JDialog
tfTemp.add(newTextField); tfTemp.add(newTextField);
temp.add(tfTemp); temp.add(tfTemp);
if (true) { // DLC if (true) {
browseNew = new JButton(BROWSENEW); browseNew = new JButton(BROWSENEW);
browseNew.addActionListener(tal); browseNew.addActionListener(tal);
} }
temp.add(browseNew); temp.add(browseNew);
// DLC temp.add(new JLabel(" "));
content.add(temp); content.add(temp);
buttonBox = Box.createHorizontalBox(); buttonBox = Box.createHorizontalBox();
@ -143,6 +143,11 @@ class ConvertDialog extends JDialog
buttonBox.add(Box.createHorizontalGlue()); buttonBox.add(Box.createHorizontalGlue());
openDoc.setVisible(false); openDoc.setVisible(false);
about = new JButton(ABOUT);
about.addActionListener(tal);
buttonBox.add(about);
buttonBox.add(Box.createHorizontalGlue());
content.add(buttonBox); content.add(buttonBox);
setContentPane(content); setContentPane(content);
pack(); pack();
@ -199,7 +204,9 @@ class ConvertDialog extends JDialog
return newFile; return newFile;
} }
public ConvertDialog(FontConversion controller, String[] choices, boolean modal) public ConvertDialog(FontConversion controller,
String[] choices,
boolean modal)
{ {
super(new JDialog(),PROGRAM_TITLE,modal); super(new JDialog(),PROGRAM_TITLE,modal);
setController(controller); setController(controller);
@ -225,11 +232,13 @@ class ConvertDialog extends JDialog
oldTextField.setText(fileName); oldTextField.setText(fileName);
updateNewFileGuess(); updateNewFileGuess();
oldFieldChanged = false; oldFieldChanged = false;
oldFile = jfc.getSelectedFile(); oldFile = chosenFile;
ThdlOptions.setUserPreference("thdl.Jskad.working.directory",
chosenFile.getParentFile().getAbsolutePath());
} else if(src.equals(browseNew)) { } else if(src.equals(browseNew)) {
newTextField.setText(chosenFile.getPath()); newTextField.setText(chosenFile.getPath());
newFieldChanged = false; newFieldChanged = false;
newFile = jfc.getSelectedFile(); newFile = chosenFile;
openDoc.setVisible(false); openDoc.setVisible(false);
} }
} else if(cmd.equals(CONVERT)) { } else if(cmd.equals(CONVERT)) {
@ -238,12 +247,12 @@ class ConvertDialog extends JDialog
if(oldFieldChanged || getOldFile() == null) { if(oldFieldChanged || getOldFile() == null) {
if (debug) if (debug)
System.out.println("DLC: old field changed"); System.out.println("old field changed");
setOldFile(updateFile(oldFile,oldTextField)); setOldFile(updateFile(oldFile,oldTextField));
} }
if(newFieldChanged || getNewFile() == null) { if(newFieldChanged || getNewFile() == null) {
if (debug) if (debug)
System.out.println("DLC: new field changed"); System.out.println("new field changed");
setNewFile(updateFile(newFile,newTextField)); setNewFile(updateFile(newFile,newTextField));
} }
@ -317,6 +326,11 @@ class ConvertDialog extends JDialog
System.runFinalization(); System.runFinalization();
this.dispose(); this.dispose();
System.exit(0); System.exit(0);
} else if(cmd.equals(ABOUT)) {
JOptionPane.showMessageDialog(this,
"This Tibetan Converter is Copyright 2003\nTibetan and Himalayan Digital Library and\nis protected by the THDL Open Community\nLicense Version 1.0.\n\nCompiled " + ThdlVersion.getTimeOfCompilation(),
"About",
JOptionPane.PLAIN_MESSAGE);
} else if (cmd.equals("comboBoxChanged")) { } else if (cmd.equals("comboBoxChanged")) {
updateNewFileGuess(); updateNewFileGuess();
} }
@ -357,22 +371,22 @@ class ConvertDialog extends JDialog
String ct = (String)choices.getSelectedItem(); String ct = (String)choices.getSelectedItem();
if ("Find all non-TMW" == ct) { if ("Find all non-TMW" == ct) {
newFileNamePrefix = "FindAllNonTMW__"; newFileNamePrefix = "FindAllNonTMW__";
} else if ("Find some non-TMW" == ct) { } else if (FIND_SOME_NON_TMW == ct) {
newFileNamePrefix = "FindSomeNonTMW__"; newFileNamePrefix = "FindSomeNonTMW__";
} else if ("Find some non-TM" == ct) { } else if (FIND_SOME_NON_TM == ct) {
newFileNamePrefix = "FindSomeNonTM__"; newFileNamePrefix = "FindSomeNonTM__";
} else if ("Find all non-TM" == ct) { } else if (FIND_ALL_NON_TM == ct) {
newFileNamePrefix = "FindAllNonTM__"; newFileNamePrefix = "FindAllNonTM__";
} else { // conversion {to Wylie or TM} mode } else { // conversion {to Wylie or TM} mode
if ("TMW to Wylie" == ct) { if (TMW_TO_WYLIE == ct) {
newFileNamePrefix = "THDL_Wylie_"; newFileNamePrefix = suggested_WYLIE_prefix;
} else if ("TMW to Unicode" == ct) { } else if (TMW_TO_UNI == ct) {
newFileNamePrefix = "Uni_"; newFileNamePrefix = suggested_TO_UNI_prefix;
} else if ("TM to TMW" == ct) { } else if (TM_TO_TMW == ct) {
newFileNamePrefix = "TMW_"; newFileNamePrefix = suggested_TO_TMW_prefix;
} else { } else {
ThdlDebug.verify("TMW to TM" == ct); ThdlDebug.verify(TMW_TO_TM == ct);
newFileNamePrefix = "TM_"; newFileNamePrefix = suggested_TO_TM_prefix;
} }
} }
newTextField.setText(oldFileDirName newTextField.setText(oldFileDirName

View file

@ -26,7 +26,7 @@ import javax.swing.JOptionPane;
/** DLC FIXMEDOC /** DLC FIXMEDOC
* @author David Chandler */ * @author David Chandler */
public class ConverterGUI implements FontConversion { public class ConverterGUI implements FontConversion, FontConverterConstants {
/** Default constructor; does nothing */ /** Default constructor; does nothing */
ConverterGUI() { } ConverterGUI() { }
@ -92,14 +92,14 @@ public class ConverterGUI implements FontConversion {
// for these, because they're // for these, because they're
// used in // used in
// TibetanConverter.java too. // TibetanConverter.java too.
"TM to TMW", TM_TO_TMW,
"TMW to Unicode", TMW_TO_UNI,
"TMW to Wylie", TMW_TO_WYLIE,
"TMW to TM", TMW_TO_TM,
"Find some non-TMW", FIND_SOME_NON_TMW,
"Find some non-TM", FIND_SOME_NON_TM,
"Find all non-TMW", FIND_ALL_NON_TMW,
"Find all non-TM" FIND_ALL_NON_TM
}, },
true); true);

View file

@ -26,36 +26,22 @@ import java.awt.*;
@author Nathaniel Garson, Tibetan and Himalayan Digital Library */ @author Nathaniel Garson, Tibetan and Himalayan Digital Library */
interface FontConverterConstants interface FontConverterConstants
{ {
final String TM_TO_TMW = "TM to TMW";
final String TMW_TO_UNI = "TMW to Unicode";
final String TMW_TO_WYLIE = "TMW to Wylie";
final String TMW_TO_TM = "TMW to TM";
final String FIND_SOME_NON_TMW = "Find some non-TMW";
final String FIND_SOME_NON_TM = "Find some non-TM";
final String FIND_ALL_NON_TMW = "Find all non-TMW";
final String FIND_ALL_NON_TM = "Find all non-TM";
final String suggested_WYLIE_prefix = "THDL_Wylie_";
final String suggested_TO_TMW_prefix = "TMW_";
final String suggested_TO_UNI_prefix = "Uni_";
final String suggested_TO_TM_prefix = "TM_";
// DLC prune // DLC prune
// File Constants
String HOME_PATH = System.getProperties().getProperty("user.dir");
File HOME_FOLDER = new File(HOME_PATH);
// GUI Constants
// Sizes
Dimension WIN_SIZE = new Dimension(600,400);
// Colors
Color BG_COLOR = Color.white;
// Data Delimiters
String COMMENT_DELIM = "////";
String HEADER_DELIM = "<?";
String DATA_DELIM = "=";
String FONT_NUM_DELIM = ",";
// Data File Headers
String OLD_FONT_HEADER = "old_fonts";
String NEW_FONT_HEADER = "new_fonts";
String CORRESP_HEADER = "correspondences";
String END_OF_SECTION = "EOS";
// Type Constants
public final int TIB_TO_TIB = 0;
public final int DIA_TO_UNICODE = 1;
// String Constants // String Constants
public final String PROGRAM_TITLE = "THDL Font Conversion (with Jskad Technology)"; public final String PROGRAM_TITLE = "THDL Font Conversion (with Jskad Technology)";