case ISearchValueType.LINK: {
final Text text = new Text(inputField, SWT.BORDER);
OwlUI.makeAccessible(text, NLS.bind(Messages.SearchConditionItem_SEARCH_VALUE_FIELD, field.getName()));
/* Show UI Hint for extra information is available */
final ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
controlDeco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage());
controlDeco.setShowOnlyOnFocus(true);
/* Listen to Changes of Input */
text.addListener(SWT.Modify, new Listener() {
private boolean isShowingWarning = false;
public void handleEvent(Event event) {
String textValue = text.getText();
fInputValue = textValue;
if (!fInputValue.equals(input))
fModified = true;
if (isShowingWarning)
controlDeco.hideHover();
/* Determine any Search Warning to show depending on field and text value */
SearchWarning warning = SearchWarning.NO_WARNING;
if (field.getId() == INews.CATEGORIES || field.getId() == INews.SOURCE || field.getId() == INews.FEED || field.getId() == INews.LINK) {
if (StringUtils.isPhraseSearch(textValue))
warning = SearchWarning.PHRASE_SEARCH_UNSUPPORTED;
} else {
if (StringUtils.isPhraseSearchWithWildcardToken(textValue))
warning = SearchWarning.PHRASE_AND_WILDCARD_SEARCH_COMBINED;
else if (StringUtils.isSpecialCharacterSearchWithWildcardToken(textValue))
warning = SearchWarning.WILDCARD_AND_SPECIAL_CHAR_SEARCH;
}
/* Indicate a warning to the user if phrase search and wildcards combined or wrongly used */
if (warning != SearchWarning.NO_WARNING && !isShowingWarning) {
updateFieldDecoration(text, controlDeco, warning, field);
isShowingWarning = true;
}
/* Clear any error if shown previously */
else if (warning == SearchWarning.NO_WARNING && isShowingWarning) {
updateFieldDecoration(text, controlDeco, warning, field);
isShowingWarning = false;
}
}
});
/* Provide auto-complete for Categories, Authors and Feeds */
if (field.getId() == INews.CATEGORIES || field.getId() == INews.AUTHOR || field.getId() == INews.FEED) {
controlDeco.setDescriptionText(Messages.SearchConditionItem_CONTENT_ASSIST_INFO);
final Pair<SimpleContentProposalProvider, ContentProposalAdapter> pair = OwlUI.hookAutoComplete(text, null, false, true);
/* Load proposals in the Background */
JobRunner.runInBackgroundThread(100, new Runnable() {
public void run() {
if (!text.isDisposed()) {
Set<String> values = new TreeSet<String>(new Comparator<String>() {
public int compare(String o1, String o2) {
return o1.compareToIgnoreCase(o2);
}
});
if (field.getId() == INews.CATEGORIES)
values.addAll(fDaoService.getCategoryDAO().loadAllNames());
else if (field.getId() == INews.AUTHOR)
values.addAll(fDaoService.getPersonDAO().loadAllNames());
else if (field.getId() == INews.FEED)
values.addAll(CoreUtils.getFeedLinks());
/* Apply Proposals */
if (!text.isDisposed())
OwlUI.applyAutoCompleteProposals(values, pair.getFirst(), pair.getSecond(), true);
}
}
});
}
/* Show UI Hint that Wildcards can be used */
else {
controlDeco.setDescriptionText(Messages.SearchConditionItem_SEARCH_HELP);
}
/* Pre-Select input if given */
Object presetInput = (input == null && fInputValue instanceof String) ? fInputValue : input;
if (presetInput != null)