* @param explorer
*/
public KeyToSelectionAdapter(GraphExplorer explorer) {
+ this(explorer,"\\p{Alnum}");
+ }
+
+ public KeyToSelectionAdapter(GraphExplorer explorer, String pattern) {
assert explorer != null;
this.explorer = (NatTableGraphExplorer)explorer;
- this.alphaNum = Pattern.compile("\\p{Alnum}");
+ this.alphaNum = Pattern.compile(pattern);
}
-
+
+ public boolean acceptKey(char key) {
+ return alphaNum.matcher(Character.toString(key)).matches();
+ }
+
@Override
public void keyPressed(KeyEvent e) {
if (explorer.isDisposed())
return;
-
- if (!alphaNum.matcher(Character.toString(e.character)).matches())
- return;
+ if (!acceptKey(e.character))
+ return;
// concatenate / replace matcher.
if ((e.time - prevEvent) > KEY_INPUT_DELAY )
matcher = "";
}
if (item != null) {
- explorer.select(item);
explorer.show(item);
+ explorer.select(item);
}
// without this the default handling would take over.
e.doit = false;
*/
protected boolean matchesColumn(TreeNode item, int column, String matcher) {
String text = item.getValueString(column);
+ if (text == null)
+ return false;
if (text.toLowerCase().startsWith(matcher)) {
return true;
}