|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.util.TimeSelector
TimeSelector is a utility class to handle the creation of a set of time drop-down menus. The code is broken into a set of static methods for quick and easy access to the individual select objects:
ElementContainer ec timeSelect = new ElementContainer(); String myName = "mytime"; ec.addElement(TimeSelector.getHourSelector(myName)); ec.addElement(TimeSelector.getMinuteSelector(myName)); ec.addElement(TimeSelector.getAMPMSelector(myName));There are also methods which will use attributes to build a complete time selector in the default 12hr format (eg HH:MM am/pm):
TimeSelector ts = new TimeSelector(myName); timeSelect = ts.ecsOutput();Minutes/Seconds are by default rounded to the nearest 5 units although this can be easily changed. 24hr TimeSelectors can also be produced. The following example creates a full precision TimeSelector (eg HH:MM:SS):
TimeSelector ts = new TimeSelector(myName); ts.setTimeFormat(TimeSelector.TWENTY_FOUR_HOUR); ts.setMinuteInterval(1); ts.setSecondInterval(1); ts.setShowSeconds(true); timeSelect = ts.toString();
Field Summary | |
static java.lang.String |
AMPM_SUFFIX
Suffix for am/pm parameter. |
static java.lang.String |
DEFAULT_PREFIX
Prefix for time names. |
static java.lang.String |
HOUR_SUFFIX
Suffix for hour parameter. |
static java.lang.String |
MINUTE_SUFFIX
Suffix for minute parameter. |
static java.lang.String |
SECOND_SUFFIX
Suffix for second parameter. |
static int |
TWELVE_HOUR
Constant for 12hr format |
static int |
TWENTY_FOUR_HOUR
Constant for 24hr format |
Constructor Summary | |
TimeSelector()
Constructor defaults to current date/time and uses the default prefix: |
|
TimeSelector(java.lang.String selName)
Constructor defaults to current date/time. |
|
TimeSelector(java.lang.String selName,
java.util.Calendar useDate)
Constructor, uses the date/time set in the calendar passed in (with the date/time set correctly). |
Method Summary | |
org.apache.ecs.ElementContainer |
ecsOutput()
Return an ECS container with the select objects inside. |
static org.apache.ecs.html.Select |
getAMPMSelector(java.lang.String name)
Return an am/pm selector. |
static org.apache.ecs.html.Select |
getAMPMSelector(java.lang.String name,
java.util.Calendar now)
Return an am/pm selector. |
static org.apache.ecs.html.Select |
getHourSelector(java.lang.String name)
Return an 12 hour selector. |
static org.apache.ecs.html.Select |
getHourSelector(java.lang.String name,
java.util.Calendar now)
Return an 12 hour selector. |
static org.apache.ecs.html.Select |
getHourSelector(java.lang.String name,
java.util.Calendar now,
int format)
Return an hour selector (either 12hr or 24hr depending on format . |
static org.apache.ecs.html.Select |
getMinuteSelector(java.lang.String name)
Return a minute selector. |
static org.apache.ecs.html.Select |
getMinuteSelector(java.lang.String name,
java.util.Calendar now)
Return a minute selector. |
static org.apache.ecs.html.Select |
getMinuteSelector(java.lang.String name,
java.util.Calendar now,
int interval)
Return a minute selector. |
static org.apache.ecs.html.Select |
getSecondSelector(java.lang.String name)
Return a second selector. |
static org.apache.ecs.html.Select |
getSecondSelector(java.lang.String name,
java.util.Calendar now)
Return a second selector. |
static org.apache.ecs.html.Select |
getSecondSelector(java.lang.String name,
java.util.Calendar now,
int interval)
Return a second selector. |
java.lang.String |
getSelName()
Get the selector name prefix. |
java.lang.String |
output()
Used to build the popupmenu in HTML. |
TimeSelector |
setMinuteInterval(int minutes)
Set the interval between options in the minute select box. |
TimeSelector |
setOnChange(java.lang.String onChange)
Adds the onChange to all of <SELECT> tags. |
TimeSelector |
setSecondInterval(int seconds)
Set the interval between options in the second select box. |
TimeSelector |
setSeconds(int seconds)
Select the second to be selected if the showSeconds(false) behavior is used. |
void |
setSelName(java.lang.String selName)
Set the selector name prefix. |
TimeSelector |
setShowSeconds(boolean show)
Whether or not to show the seconds as a popup menu. |
TimeSelector |
setTimeFormat(int format)
Set the time format to 12 or 24 hour. |
java.lang.String |
toString()
Used to build the popupmenu in HTML. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String DEFAULT_PREFIX
public static final java.lang.String HOUR_SUFFIX
public static final java.lang.String MINUTE_SUFFIX
public static final java.lang.String SECOND_SUFFIX
public static final java.lang.String AMPM_SUFFIX
public static final int TWELVE_HOUR
public static final int TWENTY_FOUR_HOUR
Constructor Detail |
public TimeSelector()
TimeSelector.DEFAULT
public TimeSelector(java.lang.String selName, java.util.Calendar useDate)
selName
- A String with the selector name.useDate
- A Calendar with a date/time.public TimeSelector(java.lang.String selName)
selName
- A String with the selector name.Method Detail |
public TimeSelector setOnChange(java.lang.String onChange)
<SELECT>
tags.
This is limited to one function for all three popups and is only
used when the output() methods are used. Individual getHour,
getMinute, getSecond, getAMPM static methods will not use this
setting.
onChange
- A String to use for onChange attribute. If null,
then nothing will be set.
public TimeSelector setSeconds(int seconds)
seconds
- The second.
public TimeSelector setMinuteInterval(int minutes)
minutes
- Interval in minutes.
public TimeSelector setSecondInterval(int seconds)
seconds
- Interval in seconds.
public TimeSelector setTimeFormat(int format)
format
- Time format.
public TimeSelector setShowSeconds(boolean show)
show
- True if the second should be shown.
public void setSelName(java.lang.String selName)
public java.lang.String getSelName()
public static org.apache.ecs.html.Select getSecondSelector(java.lang.String name)
name
- The name to use for the selected second.
public static org.apache.ecs.html.Select getSecondSelector(java.lang.String name, java.util.Calendar now)
name
- The name to use for the selected second.now
- Calendar to start with.
public static org.apache.ecs.html.Select getSecondSelector(java.lang.String name, java.util.Calendar now, int interval)
name
- The name to use for the selected second.now
- Calendar to start with.interval
- Interval between options.
public static org.apache.ecs.html.Select getMinuteSelector(java.lang.String name)
name
- The name to use for the selected minute.
public static org.apache.ecs.html.Select getMinuteSelector(java.lang.String name, java.util.Calendar now)
name
- The name to use for the selected minute.
public static org.apache.ecs.html.Select getMinuteSelector(java.lang.String name, java.util.Calendar now, int interval)
name
- The name to use for the selected minute.now
- Calendar to start with.interval
- Interval between options.
public static org.apache.ecs.html.Select getHourSelector(java.lang.String name)
name
- The name to use for the selected hour.
public static org.apache.ecs.html.Select getHourSelector(java.lang.String name, java.util.Calendar now)
name
- The name to use for the selected hour.now
- Calendar to start with.
public static org.apache.ecs.html.Select getHourSelector(java.lang.String name, java.util.Calendar now, int format)
format
.
name
- The name to use for the selected hour.now
- Calendar to start with.format
- Time format.
public static org.apache.ecs.html.Select getAMPMSelector(java.lang.String name)
name
- The name to use for the selected am/pm.
public static org.apache.ecs.html.Select getAMPMSelector(java.lang.String name, java.util.Calendar now)
name
- The name to use for the selected am/pm.now
- Calendar to start with.
public java.lang.String output()
public java.lang.String toString()
public org.apache.ecs.ElementContainer ecsOutput()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |