Now translation tool displays to where is it connected
This commit is contained in:
parent
b489034598
commit
f57cdda867
2 changed files with 42 additions and 10 deletions
|
@ -12,6 +12,7 @@ import javax.swing.*;
|
||||||
class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListener
|
class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListener
|
||||||
{
|
{
|
||||||
private String response;
|
private String response;
|
||||||
|
private int dictType;
|
||||||
private Button ok, cancel;
|
private Button ok, cancel;
|
||||||
private Checkbox useOnline, useOffline, createNewDictDB;
|
private Checkbox useOnline, useOffline, createNewDictDB;
|
||||||
private Choice availDictsOnline;
|
private Choice availDictsOnline;
|
||||||
|
@ -20,19 +21,20 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
private Frame owner;
|
private Frame owner;
|
||||||
private boolean pocketpc;
|
private boolean pocketpc;
|
||||||
private DictionaryFileFilter dicFilter;
|
private DictionaryFileFilter dicFilter;
|
||||||
private String dictsOnline[];
|
private String dictsOnline[], dictTypes[];
|
||||||
private Checkbox ckbDefault;
|
private Checkbox ckbDefault;
|
||||||
private CreateDatabaseWizard cdw;
|
private CreateDatabaseWizard cdw;
|
||||||
|
|
||||||
public WhichDictionaryFrame(Frame owner, boolean pocketpc)
|
public WhichDictionaryFrame(Frame owner, boolean pocketpc)
|
||||||
{
|
{
|
||||||
super(owner, "Welcome to the Tibetan to English Translation Tool", true);
|
super(owner, "Welcome to the Tibetan to English Translation Tool", true);
|
||||||
|
Panel p;
|
||||||
|
CheckboxGroup cbg = new CheckboxGroup();
|
||||||
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.pocketpc = pocketpc;
|
this.pocketpc = pocketpc;
|
||||||
dicFilter = null;
|
dicFilter = null;
|
||||||
response="";
|
response="";
|
||||||
Panel p;
|
|
||||||
CheckboxGroup cbg = new CheckboxGroup();
|
|
||||||
|
|
||||||
this.setLayout(new GridLayout(6, 1));
|
this.setLayout(new GridLayout(6, 1));
|
||||||
if (pocketpc)
|
if (pocketpc)
|
||||||
|
@ -43,6 +45,10 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
if (pocketpc) this.add(new Label("Would you like open:"));
|
if (pocketpc) this.add(new Label("Would you like open:"));
|
||||||
else this.add(new Label("Would you like to:"));
|
else this.add(new Label("Would you like to:"));
|
||||||
|
|
||||||
|
// FIXME: values should not be hardwired
|
||||||
|
dictsOnline = new String[2];
|
||||||
|
dictTypes = new String[3];
|
||||||
|
|
||||||
availDictsOnline = null;
|
availDictsOnline = null;
|
||||||
p = new Panel(new BorderLayout());
|
p = new Panel(new BorderLayout());
|
||||||
if (pocketpc) useOnline = new Checkbox("An on-line dict", false, cbg);
|
if (pocketpc) useOnline = new Checkbox("An on-line dict", false, cbg);
|
||||||
|
@ -50,17 +56,17 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
useOnline.addItemListener(this);
|
useOnline.addItemListener(this);
|
||||||
p.add(useOnline, BorderLayout.WEST);
|
p.add(useOnline, BorderLayout.WEST);
|
||||||
|
|
||||||
// FIXME: values should not be hardwired
|
|
||||||
dictsOnline = new String[2];
|
|
||||||
availDictsOnline = new Choice();
|
availDictsOnline = new Choice();
|
||||||
|
|
||||||
if (pocketpc) availDictsOnline.add("Public");
|
if (pocketpc) availDictsOnline.add("Public");
|
||||||
else availDictsOnline.add("Public version");
|
else availDictsOnline.add("Public version");
|
||||||
dictsOnline[0] = "http://iris.lib.virginia.edu/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
dictsOnline[0] = "http://iris.lib.virginia.edu/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
||||||
|
dictTypes[0] = "public";
|
||||||
|
|
||||||
if (pocketpc) availDictsOnline.add("Private version");
|
if (pocketpc) availDictsOnline.add("Private version");
|
||||||
else availDictsOnline.add("Private version (only within UVa)");
|
else availDictsOnline.add("Private version (only within UVa)");
|
||||||
dictsOnline[1] = "http://wyllie.lib.virginia.edu/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
dictsOnline[1] = "http://wyllie.lib.virginia.edu/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
||||||
|
dictTypes[1] = "private";
|
||||||
|
|
||||||
//availDictsOnline.add("Local (only on my computer!)");
|
//availDictsOnline.add("Local (only on my computer!)");
|
||||||
//dictsOnline[2] = "http://localhost:8080/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
//dictsOnline[2] = "http://localhost:8080/tibetan/servlet/org.thdl.tib.scanner.RemoteScannerFilter";
|
||||||
|
@ -75,9 +81,13 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
else useOffline = new Checkbox("Access a local dictionary: ", true, cbg);
|
else useOffline = new Checkbox("Access a local dictionary: ", true, cbg);
|
||||||
useOffline.addItemListener(this);
|
useOffline.addItemListener(this);
|
||||||
p.add(useOffline, BorderLayout.WEST);
|
p.add(useOffline, BorderLayout.WEST);
|
||||||
|
|
||||||
localDict = new Label();
|
localDict = new Label();
|
||||||
localDict.setEnabled(true);
|
localDict.setEnabled(true);
|
||||||
p.add(localDict, BorderLayout.CENTER);
|
p.add(localDict, BorderLayout.CENTER);
|
||||||
|
dictTypes[2] = "local";
|
||||||
|
dictType = 2;
|
||||||
|
|
||||||
browse = new Button("Browse...");
|
browse = new Button("Browse...");
|
||||||
browse.setEnabled(true);
|
browse.setEnabled(true);
|
||||||
browse.addActionListener(this);
|
browse.addActionListener(this);
|
||||||
|
@ -87,6 +97,7 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
else createNewDictDB = new Checkbox("Create a new dictionary...", false, cbg);
|
else createNewDictDB = new Checkbox("Create a new dictionary...", false, cbg);
|
||||||
createNewDictDB.addItemListener(this);
|
createNewDictDB.addItemListener(this);
|
||||||
this.add(createNewDictDB);
|
this.add(createNewDictDB);
|
||||||
|
|
||||||
p = new Panel(new FlowLayout());
|
p = new Panel(new FlowLayout());
|
||||||
ok = new Button("Ok");
|
ok = new Button("Ok");
|
||||||
ok.setEnabled(false);
|
ok.setEnabled(false);
|
||||||
|
@ -180,7 +191,8 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
browse.setEnabled(false);
|
browse.setEnabled(false);
|
||||||
availDictsOnline.setEnabled(true);
|
availDictsOnline.setEnabled(true);
|
||||||
ok.setEnabled(true);
|
ok.setEnabled(true);
|
||||||
response = dictsOnline[availDictsOnline.getSelectedIndex()];
|
dictType = availDictsOnline.getSelectedIndex();
|
||||||
|
response = dictsOnline[dictType];
|
||||||
}
|
}
|
||||||
else if (chx == useOffline)
|
else if (chx == useOffline)
|
||||||
{
|
{
|
||||||
|
@ -189,6 +201,7 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
if (availDictsOnline!=null) availDictsOnline.setEnabled(false);
|
if (availDictsOnline!=null) availDictsOnline.setEnabled(false);
|
||||||
ok.setEnabled(!localDict.getText().equals(""));
|
ok.setEnabled(!localDict.getText().equals(""));
|
||||||
response = localDict.getText();
|
response = localDict.getText();
|
||||||
|
dictType = 2;
|
||||||
}
|
}
|
||||||
else if (chx == createNewDictDB)
|
else if (chx == createNewDictDB)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +210,7 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
if (availDictsOnline!=null) availDictsOnline.setEnabled(false);
|
if (availDictsOnline!=null) availDictsOnline.setEnabled(false);
|
||||||
ok.setEnabled(true);
|
ok.setEnabled(true);
|
||||||
response="";
|
response="";
|
||||||
|
dictType = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (obj instanceof Choice)
|
else if (obj instanceof Choice)
|
||||||
|
@ -215,4 +229,9 @@ class WhichDictionaryFrame extends Dialog implements ActionListener, ItemListene
|
||||||
{
|
{
|
||||||
return ckbDefault.getState();
|
return ckbDefault.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDictionaryType()
|
||||||
|
{
|
||||||
|
return dictTypes[dictType];
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -46,6 +46,7 @@ import org.thdl.util.*;
|
||||||
public class WindowScannerFilter implements WindowListener, FocusListener, ActionListener, ItemListener
|
public class WindowScannerFilter implements WindowListener, FocusListener, ActionListener, ItemListener
|
||||||
{
|
{
|
||||||
private static String defOpenOption = "thdl.scanner.default.open";
|
private static String defOpenOption = "thdl.scanner.default.open";
|
||||||
|
private static String dictOpenType = "thdl.scanner.default.type";
|
||||||
|
|
||||||
private ScannerPanel sp;
|
private ScannerPanel sp;
|
||||||
private MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref;
|
private MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref;
|
||||||
|
@ -57,14 +58,15 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
||||||
|
|
||||||
public WindowScannerFilter(boolean pocketpc)
|
public WindowScannerFilter(boolean pocketpc)
|
||||||
{
|
{
|
||||||
String response;
|
String response, dictType;
|
||||||
this.pocketpc = pocketpc;
|
this.pocketpc = pocketpc;
|
||||||
|
|
||||||
if (!pocketpc) response = ThdlOptions.getStringOption(defOpenOption);
|
if (!pocketpc) response = ThdlOptions.getStringOption(defOpenOption);
|
||||||
else response=null;
|
else response=null;
|
||||||
|
|
||||||
if (response==null || response.equals(""))
|
if (response==null || response.equals(""))
|
||||||
{
|
{
|
||||||
mainWindow = new Frame("Tibetan Scanner");
|
mainWindow = new Frame("Tibetan Translation Tool");
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.toFront();
|
mainWindow.toFront();
|
||||||
WhichDictionaryFrame wdf = new WhichDictionaryFrame(mainWindow, pocketpc);
|
WhichDictionaryFrame wdf = new WhichDictionaryFrame(mainWindow, pocketpc);
|
||||||
|
@ -74,9 +76,12 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
||||||
if (response.equals("")) System.exit(0);
|
if (response.equals("")) System.exit(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
dictType = wdf.getDictionaryType();
|
||||||
|
mainWindow.setTitle("Tibetan Translation Tool: Connected to " + dictType + " database");
|
||||||
if (!pocketpc && wdf.getDefaultOption())
|
if (!pocketpc && wdf.getDefaultOption())
|
||||||
{
|
{
|
||||||
ThdlOptions.setUserPreference(defOpenOption, response);
|
ThdlOptions.setUserPreference(defOpenOption, response);
|
||||||
|
ThdlOptions.setUserPreference(dictOpenType, dictType);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ThdlOptions.saveUserPreferences();
|
ThdlOptions.saveUserPreferences();
|
||||||
|
@ -110,8 +115,16 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
||||||
}
|
}
|
||||||
|
|
||||||
public void makeWindow(String file)
|
public void makeWindow(String file)
|
||||||
{
|
{
|
||||||
if (mainWindow==null) mainWindow = new Frame("Tibetan Scanner");
|
if (mainWindow==null)
|
||||||
|
{
|
||||||
|
String dictType=null;
|
||||||
|
if (!pocketpc) dictType = ThdlOptions.getStringOption(dictOpenType);
|
||||||
|
if (dictType!=null && !dictType.equals(""))
|
||||||
|
mainWindow = new Frame("Tibetan Translation Tool: Connected to " + dictType + " database");
|
||||||
|
else
|
||||||
|
mainWindow = new Frame("Tibetan Translation Tool");
|
||||||
|
}
|
||||||
else mainWindow.setVisible(false);
|
else mainWindow.setVisible(false);
|
||||||
mainWindow.setLayout(new GridLayout(1,1));
|
mainWindow.setLayout(new GridLayout(1,1));
|
||||||
mainWindow.setBackground(Color.white);
|
mainWindow.setBackground(Color.white);
|
||||||
|
|
Loading…
Reference in a new issue