Created
November 13, 2014 12:04
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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