}
/* Specially treat News-State */
if (field.getId() == INews.STATE) {
final StateConditionControl stateConditionControl = new StateConditionControl(inputField, SWT.NONE);
stateConditionControl.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
fInputValue = stateConditionControl.getSelection();
if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
fModified = true;
}
});
/* Pre-Select input if given */
Object presetInput = (input == null) ? fInputValue : input;
if (presetInput != null && presetInput instanceof EnumSet)
stateConditionControl.select((EnumSet<State>) presetInput);
/* Update Input Value */
fInputValue = stateConditionControl.getSelection();
}
/* Specially treat News-Location */
else if (field.getId() == INews.LOCATION) {
final LocationConditionControl locationConditionControl = new LocationConditionControl(inputField, SWT.NONE);
locationConditionControl.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
fInputValue = locationConditionControl.getSelection();
if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input)))
fModified = true;
}
});
/* Pre-Select input if given */
Object presetInput = (input == null) ? fInputValue : input;
if (presetInput != null && presetInput instanceof Long[][])
locationConditionControl.select((Long[][]) presetInput);
/* Update Input Value */
fInputValue = locationConditionControl.getSelection();
}
/* Create new Input Field based on search-value-type */
else {
switch (field.getSearchValueType().getId()) {
/* Type: Boolean */
case ISearchValueType.BOOLEAN: {
final Combo combo = new Combo(inputField, SWT.BORDER | SWT.READ_ONLY);
combo.add("true");
combo.add("false");
combo.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));
if (!fInputValue.equals(input))
fModified = true;
}
});
/* Pre-Select input if given */
Object presetInput = (input == null) ? fInputValue : input;
if (presetInput != null && presetInput instanceof Boolean)
combo.select(((Boolean) presetInput) ? 0 : 1);
else
combo.select(0);
/* Update Input Value */
fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex()));
break;
}
/* Type: Date / Time */
case ISearchValueType.DATE:
case ISearchValueType.TIME:
case ISearchValueType.DATETIME: {
final Calendar cal = Calendar.getInstance();
final DateTime datetime = new DateTime(inputField, SWT.DATE);
datetime.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
cal.set(Calendar.DATE, datetime.getDay());
cal.set(Calendar.MONTH, datetime.getMonth());
cal.set(Calendar.YEAR, datetime.getYear());
fInputValue = cal.getTime();
if (!fInputValue.equals(input))
fModified = true;
}
});
/* Pre-Select input if given */
Object presetInput = (input == null) ? fInputValue : input;
if (presetInput != null && presetInput instanceof Date)
cal.setTime((Date) presetInput);
datetime.setDay(cal.get(Calendar.DATE));
datetime.setMonth(cal.get(Calendar.MONTH));
datetime.setYear(cal.get(Calendar.YEAR));
/* Update Input Value */
fInputValue = cal.getTime();
break;
}
/* Type: Enumeration */
case ISearchValueType.ENUM: {
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 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;