Skip to content

Instantly share code, notes, and snippets.

@jmini
Created November 13, 2014 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmini/1ab329fefbf7bd169704 to your computer and use it in GitHub Desktop.
Save jmini/1ab329fefbf7bd169704 to your computer and use it in GitHub Desktop.
Smart Field Example to select a time (minute and seconds. hour is always 0). http://www.eclipse.org/forums/index.php/t/855355/
@Order(10.0)
public class TimeField extends AbstractSmartField<Date> {
@Override
protected String getConfiguredLabel() {
return TEXTS.get("TimeField");
}
@Override
protected Class<? extends ILookupCall<Date>> getConfiguredLookupCall() {
return TimeLookupCall.class;
}
}
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.scout.commons.DateUtility;
import org.eclipse.scout.commons.exception.ProcessingException;
import org.eclipse.scout.rt.shared.services.lookup.ILookupRow;
import org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall;
import org.eclipse.scout.rt.shared.services.lookup.LookupRow;
public class TimeLookupCall extends LocalLookupCall<Date> {
private static final long serialVersionUID = 1L;
@Override
protected List<? extends ILookupRow<Date>> execCreateLookupRows() throws ProcessingException {
List<ILookupRow<Date>> rows = new ArrayList<ILookupRow<Date>>();
Date date = DateUtility.convertDoubleTimeToDate(0);
for (int i = 0; i < 120; i++) {
rows.add(createLookupRow(date));
date = DateUtility.addSeconds(date, 30);
}
return rows;
}
private ILookupRow<Date> createLookupRow(Date date) {
return new LookupRow<Date>(date, DateUtility.format(date, "H:mm:ss"));
}
@Override
protected Pattern createSearchPattern(String humanReadbleFilterPattern) {
return super.createSearchPattern("*" + humanReadbleFilterPattern);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment