Added the following features: now starts with focus on the input pane, shortcut ctrl+T to translate, and after translating focus is automatically set on the first element.
This commit is contained in:
parent
58819cf43d
commit
efec654ee8
5 changed files with 58 additions and 45 deletions
|
@ -156,6 +156,11 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener
|
||||||
keyboard.addItemListener(this);
|
keyboard.addItemListener(this);
|
||||||
toolBar.add(keyboard);
|
toolBar.add(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocusToInput()
|
||||||
|
{
|
||||||
|
duffInput.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
|
||||||
public void addFocusListener(FocusListener fl)
|
public void addFocusListener(FocusListener fl)
|
||||||
{
|
{
|
||||||
|
@ -235,41 +240,42 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener
|
||||||
|
|
||||||
public void translate()
|
public void translate()
|
||||||
{
|
{
|
||||||
String in;
|
String in;
|
||||||
setDicts(scanner.getDictionarySource());
|
setDicts(scanner.getDictionarySource());
|
||||||
|
|
||||||
in = "";
|
in = "";
|
||||||
if (showingTibetan)
|
if (showingTibetan)
|
||||||
in = duffInput.getWylie(new boolean[] { false });
|
in = duffInput.getWylie(new boolean[] { false });
|
||||||
else
|
else
|
||||||
in = txtInput.getText();
|
in = txtInput.getText();
|
||||||
|
|
||||||
if (!in.equals(""))
|
if (!in.equals(""))
|
||||||
{
|
{
|
||||||
doingStatus("Translating...");
|
doingStatus("Translating...");
|
||||||
scanner.scanBody(in);
|
scanner.scanBody(in);
|
||||||
scanner.finishUp();
|
scanner.finishUp();
|
||||||
model.newSearch(scanner.getWordArray());
|
model.newSearch(scanner.getWordArray());
|
||||||
//printAllDefs();
|
//printAllDefs();
|
||||||
scanner.clearTokens();
|
scanner.clearTokens();
|
||||||
returnStatusToNorm();
|
returnStatusToNorm();
|
||||||
fullDef.setText("");
|
fullDef.setText("");
|
||||||
/*ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel();
|
/*ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel();
|
||||||
if (!lsm.isSelectionEmpty())
|
if (!lsm.isSelectionEmpty())
|
||||||
{
|
{
|
||||||
int selectedRow = lsm.getMinSelectionIndex();
|
int selectedRow = lsm.getMinSelectionIndex();
|
||||||
//TableModel tm = table.getModel();
|
//TableModel tm = table.getModel();
|
||||||
if (selectedRow<model.getRowCount())
|
if (selectedRow<model.getRowCount())
|
||||||
fullDef.setText(model.getValueAt(selectedRow, 1).toString());
|
fullDef.setText(model.getValueAt(selectedRow, 1).toString());
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.newSearch(null);
|
model.newSearch(null);
|
||||||
fullDef.setText("");
|
fullDef.setText("");
|
||||||
}
|
}
|
||||||
table.tableChanged(new TableModelEvent(model));
|
table.tableChanged(new TableModelEvent(model));
|
||||||
table.repaint();
|
table.repaint();
|
||||||
|
if (table.getRowCount()>0) table.setRowSelectionInterval(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWylieInput(boolean enabled)
|
public void setWylieInput(boolean enabled)
|
||||||
|
|
|
@ -215,5 +215,6 @@ public abstract class ScannerPanel extends Panel implements ActionListener
|
||||||
public abstract void translate();
|
public abstract void translate();
|
||||||
public abstract void clear();
|
public abstract void clear();
|
||||||
public abstract void setWylieInput(boolean enabled);
|
public abstract void setWylieInput(boolean enabled);
|
||||||
|
public abstract void setFocusToInput();
|
||||||
public void addFocusListener(FocusListener fl) {}
|
public void addFocusListener(FocusListener fl) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,11 @@ public class SimpleScannerPanel extends ScannerPanel implements ItemListener
|
||||||
add(cardPanel, BorderLayout.CENTER);
|
add(cardPanel, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocusToInput()
|
||||||
|
{
|
||||||
|
txtInput.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent e)
|
public void itemStateChanged(ItemEvent e)
|
||||||
{
|
{
|
||||||
int n = listDefs.getSelectedIndex();
|
int n = listDefs.getSelectedIndex();
|
||||||
|
|
|
@ -18,21 +18,11 @@ Contributor(s): ______________________________________.
|
||||||
|
|
||||||
package org.thdl.tib.scanner;
|
package org.thdl.tib.scanner;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Frame;
|
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.Menu;
|
|
||||||
import java.awt.MenuBar;
|
|
||||||
import java.awt.MenuItem;
|
|
||||||
import java.awt.TextArea;
|
|
||||||
import java.awt.TextComponent;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
@ -145,7 +135,13 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
mnuDicts=null;
|
mnuDicts=null;
|
||||||
|
|
||||||
mb.add(m);
|
mb.add(m);
|
||||||
|
m = new Menu("Tools");
|
||||||
|
mnuTranslate = new MenuItem ("Translate");
|
||||||
|
mnuTranslate.setShortcut(new MenuShortcut(KeyEvent.VK_T));
|
||||||
|
mnuTranslate.addActionListener(this);
|
||||||
|
m.add(mnuTranslate);
|
||||||
|
mb.add(m);
|
||||||
|
|
||||||
m = new Menu("Help");
|
m = new Menu("Help");
|
||||||
|
|
||||||
for (int i = 0; i < DuffScannerPanel.keybdMgr.size(); i++)
|
for (int i = 0; i < DuffScannerPanel.keybdMgr.size(); i++)
|
||||||
|
@ -191,6 +187,7 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
//else mainWindow.setSize(500,600);
|
//else mainWindow.setSize(500,600);
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.toFront();
|
mainWindow.toFront();
|
||||||
|
sp.setFocusToInput();
|
||||||
|
|
||||||
if (!ThdlOptions.getBooleanOption(AboutDialog.windowAboutOption))
|
if (!ThdlOptions.getBooleanOption(AboutDialog.windowAboutOption))
|
||||||
{
|
{
|
||||||
|
@ -323,6 +320,10 @@ public class SwingWindowScannerFilter extends WindowScannerFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (clicked == mnuTranslate)
|
||||||
|
{
|
||||||
|
sp.translate();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (objModified==null) return;
|
if (objModified==null) return;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class WindowScannerFilter implements WindowListener, FocusListen
|
||||||
protected static String defaultOutputRows = "thdl.scanner.output-pane.rows";
|
protected static String defaultOutputRows = "thdl.scanner.output-pane.rows";
|
||||||
|
|
||||||
protected ScannerPanel sp;
|
protected ScannerPanel sp;
|
||||||
protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref;
|
protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref, mnuTranslate;
|
||||||
protected CheckboxMenuItem mnuDicts;
|
protected CheckboxMenuItem mnuDicts;
|
||||||
protected Object objModified;
|
protected Object objModified;
|
||||||
protected AboutDialog diagAbout;
|
protected AboutDialog diagAbout;
|
||||||
|
|
Loading…
Reference in a new issue