typeTree.getControl().setLayoutData(
new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
typeTree.getControl().setFocus();
filterText.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP) {
typeTree.getControl().setFocus();
Tree tree = (Tree) typeTree.getControl();
if (tree.getItemCount() > 0) {
tree.setSelection(tree.getItem(0));
}
}
}
public void keyReleased(KeyEvent e) {
typeTree.refresh(false);
}
});
typeTree.setContentProvider(new ITreeContentProvider() {
public Object[] getChildren(Object parentElement) {
return null;
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public Object[] getElements(Object inputElement) {
return (Type[]) inputElement;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
typeTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// check if the string from the filterText is contained in the type name
Type type = (Type) element;
return type.getName().contains(filterText.getText());
}
} });
typeTree.setLabelProvider(new ILabelProvider() {
public Image getImage(Object element) {
return null;
}
public String getText(Object element) {
Type type = (Type) element;
Character key = typeShortcutMap.get(type);
if (key != null) {
return "[" + key + "] " + type.getShortName();
} else {
return type.getShortName();
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
typeTree.getControl().addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
Type type = shortcutTypeMap.get(Character.toLowerCase(e.character));
if (type != null) {