/* Provide Auto-Complete Field */
hookAutoComplete(text, field.getSearchValueType().getEnumValues());
/* Show UI Hint that Content Assist is available */
ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
controlDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
controlDeco.setDescriptionText("Content Assist Available (Press Arrow-Down Key)");
controlDeco.setShowOnlyOnFocus(true);
/* Pre-Select input if given */
String inputValue = (input != null ? input.toString() : null);
if (inputValue != null)
text.setText(inputValue);
/* Update Input Value */
fInputValue = text.getText();
break;
}
/* Type: Number */
case ISearchValueType.NUMBER:
case ISearchValueType.INTEGER: {
final Spinner spinner = new Spinner(inputField, SWT.BORDER);
spinner.setMinimum(0);
spinner.setMaximum(1000);
spinner.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
fInputValue = spinner.getSelection();
if (!fInputValue.equals(input))
fModified = true;
}
});
/* Pre-Select input if given */
Object presetInput = (input == null) ? fInputValue : input;
if (presetInput != null && presetInput instanceof Integer)
spinner.setSelection((Integer) presetInput);
/* Update Input Value */
fInputValue = spinner.getSelection();
break;
}
/* Type: String */
case ISearchValueType.STRING:
case ISearchValueType.LINK: {
final Text text = new Text(inputField, SWT.BORDER);
text.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
fInputValue = text.getText();
if (!fInputValue.equals(input))
fModified = true;
}
});
/* Provide auto-complete for Categories, Authors and Feeds */
if (field.getId() == INews.CATEGORIES || field.getId() == INews.AUTHOR || field.getId() == INews.FEED) {
final Pair<SimpleContentProposalProvider, ContentProposalAdapter> pair = hookAutoComplete(text, null);
/* Load proposals in the Background */
JobRunner.runDelayedInBackgroundThread(new Runnable() {
public void run() {
if (!text.isDisposed()) {
Set<String> values = null;
if (field.getId() == INews.CATEGORIES)
values = fDaoService.getCategoryDAO().loadAllNames();
else if (field.getId() == INews.AUTHOR)
values = fDaoService.getPersonDAO().loadAllNames();
else if (field.getId() == INews.FEED)
values = Controller.getDefault().getCacheService().getFeedLinks();
/* Apply Proposals */
if (!text.isDisposed())
applyProposals(values, pair.getFirst(), pair.getSecond());
}
}
});
/* Show UI Hint that Content Assist is available */
ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
controlDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
controlDeco.setDescriptionText("Content Assist Available (Press Arrow-Down Key)");
controlDeco.setShowOnlyOnFocus(true);
}
/* Pre-Select input if given */
Object presetInput = (input == null && fInputValue instanceof String) ? fInputValue : input;
if (presetInput != null)