"Browse..." buttons are smart about file types now.

This commit is contained in:
dchandler 2003-10-19 23:17:25 +00:00
parent 3aa3859354
commit 5d9305c9d5

View file

@ -76,12 +76,15 @@ class ConvertDialog extends JDialog
this.warningLevels.setEnabled(choices.getSelectedItem() == ACIP_TO_UNI_TEXT this.warningLevels.setEnabled(choices.getSelectedItem() == ACIP_TO_UNI_TEXT
|| choices.getSelectedItem() == ACIP_TO_TMW); || choices.getSelectedItem() == ACIP_TO_TMW);
} }
private javax.swing.filechooser.FileFilter acipff, rtfff;
private void init() private void init()
{ {
jfc = new JFileChooser(controller.getDefaultDirectory()); jfc = new JFileChooser(controller.getDefaultDirectory());
jfc.setDialogTitle(LOCATE_FILE); jfc.setDialogTitle(LOCATE_FILE);
jfc.addChoosableFileFilter(new ACIPFileFilter()); jfc.addChoosableFileFilter(acipff = new ACIPFileFilter());
jfc.addChoosableFileFilter(new RTFFileFilter()); jfc.addChoosableFileFilter(rtfff = new RTFFileFilter());
content = new JPanel(new GridLayout(0,1)); content = new JPanel(new GridLayout(0,1));
JPanel temp = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5)); JPanel temp = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));
@ -209,6 +212,16 @@ class ConvertDialog extends JDialog
|| cmd.equals(BROWSENEW)) || cmd.equals(BROWSENEW))
{ {
JButton src = (JButton)ae.getSource(); JButton src = (JButton)ae.getSource();
if (src == browseOld) {
jfc.setFileFilter((ACIP_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| ACIP_TO_TMW.equals((String)choices.getSelectedItem()))
? acipff : rtfff);
} else {
jfc.setFileFilter((ACIP_TO_UNI_TEXT.equals((String)choices.getSelectedItem())
|| TMW_TO_ACIP_TEXT.equals((String)choices.getSelectedItem())
|| TMW_TO_WYLIE_TEXT.equals((String)choices.getSelectedItem()))
? acipff : rtfff);
}
if (jfc.showOpenDialog(this) != jfc.APPROVE_OPTION) if (jfc.showOpenDialog(this) != jfc.APPROVE_OPTION)
return; return;
File chosenFile = jfc.getSelectedFile(); File chosenFile = jfc.getSelectedFile();
@ -504,7 +517,7 @@ class ConvertDialog extends JDialog
public String getDescription() public String getDescription()
{ {
return "ACIP text files only"; return "Text files only (including ACIP files)";
} }
} }
} }