diff options
author | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-28 09:01:25 +0000 |
---|---|---|
committer | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-28 09:01:25 +0000 |
commit | 2a06ac5bc654ab86f0b94e30af23b0619a7e6fa4 (patch) | |
tree | d3fd5513ce60e521c74366dd53e0da5dcf3da97e /Tools/Source | |
parent | 2c71f6e5abba8841dce06d4686e6b4733c655285 (diff) | |
download | edk2-platforms-2a06ac5bc654ab86f0b94e30af23b0619a7e6fa4.tar.xz |
Add no mouse support for table cell editors.
Add auto-search function in FrameworkModules tables by detecting keyboard typing.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1637 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source')
7 files changed, 112 insertions, 9 deletions
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java index 9c0674ee07..4e65c3c81d 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java @@ -20,6 +20,7 @@ import javax.swing.JPanel; import javax.swing.JDialog;
import java.awt.GridLayout;
+import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
@@ -27,12 +28,14 @@ import javax.swing.JLabel; import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
+import javax.swing.KeyStroke;
import org.tianocore.frameworkwizard.common.Tools;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -62,6 +65,7 @@ public class GenGuidDialog extends JDialog implements ActionListener{ private JButton jButtonCancel = null;
private JButton jButtonNew = null;
private JButton jButtonOk = null;
+ private ActionListener outerListener = null;
// private String guid = null;
@@ -121,7 +125,7 @@ public class GenGuidDialog extends JDialog implements ActionListener{ // else {
// JOptionPane.showMessageDialog(frame, "Incorrect GUID Value Format.");
// }
- this.dispose();
+// this.dispose();
}
if (arg0.getSource() == jButtonCancel){
@@ -227,6 +231,7 @@ public class GenGuidDialog extends JDialog implements ActionListener{ jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(this);
+ jButtonCancel.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
return jButtonCancel;
}
@@ -243,6 +248,7 @@ public class GenGuidDialog extends JDialog implements ActionListener{ jButtonNew.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
jButtonNew.setText("New");
jButtonNew.addActionListener(this);
+ jButtonNew.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
return jButtonNew;
}
@@ -258,7 +264,9 @@ public class GenGuidDialog extends JDialog implements ActionListener{ jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
jButtonOk.setText("Ok");
jButtonOk.setActionCommand("GenGuidValue");
- jButtonOk.addActionListener(this);
+// jButtonOk.addActionListener(this);
+ jButtonOk.registerKeyboardAction(outerListener, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
+
}
return jButtonOk;
}
@@ -289,6 +297,7 @@ public class GenGuidDialog extends JDialog implements ActionListener{ public GenGuidDialog(ActionListener i){
super();
+ outerListener = i;
initialize();
jButtonOk.addActionListener(i);
this.addWindowListener(new WindowAdapter(){
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java index 7b2683a830..c9f73b04bc 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java @@ -16,11 +16,14 @@ package org.tianocore.frameworkwizard.packaging.ui; import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+//import java.awt.event.KeyEvent;
import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
+//import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTable;
+//import javax.swing.KeyStroke;
import javax.swing.table.TableCellEditor;
@@ -45,6 +48,7 @@ public class GuidEditor extends AbstractCellEditor implements TableCellEditor, A button = new JButton();
button.setActionCommand(EDIT);
button.addActionListener(this);
+// button.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0, false), JComponent.WHEN_FOCUSED);
button.setBorderPainted(false);
@@ -86,7 +90,8 @@ public class GuidEditor extends AbstractCellEditor implements TableCellEditor, A }
else { //User pressed dialog's "OK" button.
currentGuid = dialog.getGuid();
-
+// button.setText(currentGuid);
+ dialog.dispose();
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index ae74471c21..cd9d0dd825 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -38,6 +38,7 @@ import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
import java.awt.FlowLayout;
+import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
@@ -52,6 +53,12 @@ public class FpdFrameworkModules extends IInternalFrame { */
private static final long serialVersionUID = 1L;
+ private static final int timeToWait = 3000;
+
+ private long savedMs = 0;
+
+ String searchField = "";
+
public static final int forceDbgColForFpdModTable = 7;
static JFrame frame;
@@ -309,11 +316,51 @@ public class FpdFrameworkModules extends IInternalFrame { }
}
});
+ jTableAllModules.addKeyListener(new java.awt.event.KeyAdapter() {
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ int selectedRow = jTableAllModules.getSelectedRow();
+ if (selectedRow < 0) {
+ return;
+ }
+ TableSorter sorter = (TableSorter) jTableAllModules.getModel();
+ selectedRow = sorter.getModelRowIndex(selectedRow);
+ addModuleIntoPlatform (selectedRow);
+ }
+ }
+ });
+
+ jTableAllModules.addKeyListener(new java.awt.event.KeyAdapter() {
+ public void keyTyped(java.awt.event.KeyEvent e) {
+
+ if (System.currentTimeMillis() - savedMs < timeToWait) {
+ searchField += e.getKeyChar();
+ }
+ else {
+ searchField = "" + e.getKeyChar();
+ }
+
+ int viewIndex = gotoFoundRow (searchField, (TableSorter) jTableAllModules.getModel());
+ if (viewIndex >= 0){
+ jTableAllModules.changeSelection(viewIndex, 0, false, false);
+ }
+ savedMs = System.currentTimeMillis();
+ }
+ });
}
return jTableAllModules;
}
+
+ private int gotoFoundRow (String s, TableSorter model) {
+ for (int i = 0; i < model.getRowCount(); ++i) {
+ if (model.getValueAt(i, 0) != null && model.getValueAt(i, 0).toString().regionMatches(true, 0, s, 0, s.length())) {
+ return model.getViewIndexArray()[i];
+ }
+ }
+ return -1;
+ }
/**
* This method initializes jPanelTopSouth
@@ -560,6 +607,38 @@ public class FpdFrameworkModules extends IInternalFrame { }
});
+ jTableFpdModules.addKeyListener(new java.awt.event.KeyAdapter() {
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ int selectedRow = jTableFpdModules.getSelectedRow();
+ if (selectedRow < 0) {
+ return;
+ }
+ TableSorter sorter = (TableSorter) jTableFpdModules.getModel();
+ selectedRow = sorter.getModelRowIndex(selectedRow);
+ showSettingsDlg (selectedRow);
+ }
+ }
+ });
+
+ jTableFpdModules.addKeyListener(new java.awt.event.KeyAdapter() {
+ public void keyTyped(java.awt.event.KeyEvent e) {
+
+ if (System.currentTimeMillis() - savedMs < timeToWait) {
+ searchField += e.getKeyChar();
+ }
+ else {
+ searchField = "" + e.getKeyChar();
+ }
+
+ int viewIndex = gotoFoundRow (searchField, (TableSorter) jTableFpdModules.getModel());
+ if (viewIndex >= 0){
+ jTableFpdModules.changeSelection(viewIndex, 0, false, false);
+ }
+ savedMs = System.currentTimeMillis();
+ }
+ });
+
jTableFpdModules.getModel().addTableModelListener(this);
}
return jTableFpdModules;
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java index e21ee547e9..f4894a3601 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java @@ -16,8 +16,10 @@ import java.awt.BorderLayout; import java.awt.Dimension;
import java.awt.Toolkit;
+import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JDialog;
+import javax.swing.KeyStroke;
import javax.swing.JButton;
@@ -25,6 +27,7 @@ import javax.swing.JButton; import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
import java.util.Vector;
import javax.swing.JScrollPane;
@@ -59,7 +62,7 @@ public class GenListDialog extends JDialog implements ActionListener{ if (arg0.getSource() == jButtonOk){
- this.dispose();
+// this.dispose();
}
if (arg0.getSource() == jButtonCancel){
@@ -111,6 +114,7 @@ public class GenListDialog extends JDialog implements ActionListener{ jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(this);
+ jButtonCancel.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
return jButtonCancel;
}
@@ -185,7 +189,7 @@ public class GenListDialog extends JDialog implements ActionListener{ public GenListDialog(ActionListener i){
this();
jButtonOk.addActionListener(i);
-
+ jButtonOk.registerKeyboardAction(i, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
/**
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java index 574be8a397..e8aafa7249 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java @@ -16,13 +16,18 @@ import java.awt.BorderLayout; import java.awt.Dimension;
import java.awt.Toolkit;
+import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JTextArea;
import javax.swing.JButton;
+import javax.swing.KeyStroke;
+
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
import javax.swing.JScrollPane;
@@ -48,13 +53,11 @@ public class GenLongTextDialog extends JDialog implements ActionListener{ private JScrollPane jScrollPane = null;
-
-
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk){
- this.dispose();
+// this.dispose();
}
if (arg0.getSource() == jButtonCancel){
@@ -107,6 +110,7 @@ public class GenLongTextDialog extends JDialog implements ActionListener{ jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(this);
+ jButtonCancel.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
return jButtonCancel;
}
@@ -170,7 +174,7 @@ public class GenLongTextDialog extends JDialog implements ActionListener{ public GenLongTextDialog(ActionListener i){
this();
jButtonOk.addActionListener(i);
-
+ jButtonOk.registerKeyboardAction(i, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
}
/**
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java index e604e1f051..89523b209c 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java @@ -98,6 +98,7 @@ public class ListEditor extends AbstractCellEditor implements TableCellEditor, A s += " ";
}
archs = s.trim();
+ dialog.dispose();
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java index 86a2d1295b..3d84dce4d2 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java @@ -86,6 +86,7 @@ public class LongTextEditor extends AbstractCellEditor implements TableCellEdito else { //User pressed dialog's "OK" button.
text = dialog.getText().trim();
+ dialog.dispose();
}
}
|