2003-08-03 06:27:30 +00:00
|
|
|
package org.thdl.tib.scanner;
|
|
|
|
|
2005-07-11 03:10:32 +00:00
|
|
|
import java.awt.Button;
|
|
|
|
import java.awt.Checkbox;
|
|
|
|
import java.awt.Choice;
|
|
|
|
import java.awt.Dialog;
|
|
|
|
import java.awt.Frame;
|
|
|
|
import java.awt.Label;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.ItemEvent;
|
|
|
|
import java.awt.event.ItemListener;
|
2003-08-03 06:27:30 +00:00
|
|
|
|
|
|
|
/** provides a friendly user interface when the command-line
|
|
|
|
is not used for choosing a dictionary or connection to open.
|
|
|
|
*/
|
2004-12-23 19:31:26 +00:00
|
|
|
abstract class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListener
|
2003-08-03 06:27:30 +00:00
|
|
|
{
|
2004-12-23 19:31:26 +00:00
|
|
|
protected String response;
|
|
|
|
protected int dictType;
|
|
|
|
protected Button ok, cancel;
|
|
|
|
protected Checkbox useOnline, useOffline;
|
|
|
|
protected Choice availDictsOnline;
|
|
|
|
protected Label localDict;
|
|
|
|
protected Button browse;
|
|
|
|
protected Frame owner;
|
|
|
|
protected String dictsOnline[], dictTypes[];
|
|
|
|
protected Checkbox ckbDefault;
|
2003-08-03 06:27:30 +00:00
|
|
|
|
2004-12-23 19:31:26 +00:00
|
|
|
public WhichDictionaryFrame(Frame owner)
|
2003-08-03 06:27:30 +00:00
|
|
|
{
|
|
|
|
super(owner, "Welcome to the Tibetan to English Translation Tool", true);
|
2004-12-23 19:31:26 +00:00
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
this.owner = owner;
|
|
|
|
response="";
|
|
|
|
|
2003-09-07 03:40:51 +00:00
|
|
|
// FIXME: values should not be hardwired
|
2005-12-10 21:42:34 +00:00
|
|
|
if (TibetanScanner.mode == TibetanScanner.DEBUG_MODE)
|
|
|
|
{
|
|
|
|
dictsOnline = new String[2];
|
|
|
|
dictsOnline[1] = "http://localhost:8080/tibetan/org.thdl.tib.scanner.RemoteScannerFilter";
|
|
|
|
dictTypes = new String[3];
|
|
|
|
dictTypes[2] = "development";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dictsOnline = new String[1];
|
|
|
|
dictTypes = new String[2];
|
|
|
|
}
|
2004-12-23 19:31:26 +00:00
|
|
|
|
2005-12-10 21:42:34 +00:00
|
|
|
dictsOnline[0] = "http://www.thdl.org/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
|
|
|
|
|
|
|
dictTypes[0] = "local";
|
|
|
|
dictTypes[1] = "public";
|
2003-08-03 06:27:30 +00:00
|
|
|
|
2004-12-23 19:31:26 +00:00
|
|
|
availDictsOnline = new Choice();
|
2003-08-03 06:27:30 +00:00
|
|
|
//availDictsOnline.add("Local (only on my computer!)");
|
|
|
|
|
|
|
|
availDictsOnline.addItemListener(this);
|
|
|
|
availDictsOnline.setEnabled(false);
|
2003-09-07 03:40:51 +00:00
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
localDict = new Label();
|
|
|
|
localDict.setEnabled(true);
|
2003-09-07 03:40:51 +00:00
|
|
|
|
2005-12-10 21:42:34 +00:00
|
|
|
dictType = 0;
|
2004-12-23 19:31:26 +00:00
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
browse = new Button("Browse...");
|
|
|
|
browse.setEnabled(true);
|
|
|
|
browse.addActionListener(this);
|
2004-12-23 19:31:26 +00:00
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
ok = new Button("Ok");
|
|
|
|
ok.setEnabled(false);
|
|
|
|
ok.addActionListener(this);
|
2004-12-23 19:31:26 +00:00
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
cancel = new Button("Cancel");
|
|
|
|
cancel.addActionListener(this);
|
2004-12-23 19:31:26 +00:00
|
|
|
|
|
|
|
useOnline=null;
|
|
|
|
useOffline=null;
|
|
|
|
ckbDefault=null;
|
2003-08-03 06:27:30 +00:00
|
|
|
}
|
|
|
|
|
2004-12-23 19:31:26 +00:00
|
|
|
public abstract void actionPerformed(ActionEvent e);
|
2003-08-03 06:27:30 +00:00
|
|
|
|
|
|
|
/** Implement the disabling of other guys here
|
|
|
|
*/
|
2004-12-23 19:31:26 +00:00
|
|
|
public abstract void itemStateChanged(ItemEvent e);
|
|
|
|
|
2003-08-03 06:27:30 +00:00
|
|
|
public String getResponse()
|
|
|
|
{
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getDefaultOption()
|
|
|
|
{
|
|
|
|
return ckbDefault.getState();
|
|
|
|
}
|
2003-09-07 03:40:51 +00:00
|
|
|
|
|
|
|
public String getDictionaryType()
|
|
|
|
{
|
|
|
|
return dictTypes[dictType];
|
|
|
|
}
|
2003-08-03 06:27:30 +00:00
|
|
|
}
|