|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Panel
com.google.gwt.user.client.ui.ComplexPanel
com.google.gwt.user.client.ui.CellPanel
com.google.gwt.user.client.ui.VerticalPanel
no.ntnu.ime.xmlconverter.client.ProgressBar
class ProgressBar
A simple progress bar that uses table elements to show progress and with a basic time remaining calculation built in.
You can optionally display some text above the progress bar and/or display time remaining underneath the progress bar. To control the display of those features, set the options in the constructor as shown in the following usage example:
final ProgressBar progressBar = new ProgressBar(20 ,ProgressBar.SHOW_TIME_REMAINING +ProgressBar.SHOW_TEXT); progressBar.setText("Doing something..."); RootPanel.get().add(progressBar); Timer t = new Timer() { public void run() { int progress = progressBar.getProgress()+4; if (progress>100) cancel(); progressBar.setProgress(progress); } }; t.scheduleRepeating(1000);
How the time remaining is displayed can be controlled by setting the relevant messages using the language of your choice.
The default setting for the messages are as follows:
setSecondsMessage("Time remaining: {0} Seconds"); setMinutesMessage("Time remaining: {0} Minutes"); setHoursMessage("Time remaining: {0} Hours");
To reset the time remaining/set the start time, simply set the progress to zero.
Some basic CSS styling is available to control the text, border around the progress bar itself and the colour of the progress bar elements.
.progressbar-text { font-weight: bold; } .progressbar-remaining { font-size: 12px; font-style: italic; } .progressbar-outer { border: 1px solid black; } .progressbar-inner { border: 1px solid black; margin: 1px; } .progressbar-bar { width: 5px; height: 15px; margin: 1px; } .progressbar-fullbar { background: blue; } .progressbar-blankbar { background: #eee; }
You can take advantage of the default style by adding the following to the head of your HTML page.
<link rel="stylesheet" type="text/css" href="style/gwl-progressBar.css">
This style sheet also has two additional styles which you can use by adding the stye name to the widget. You can use either one of these, or use both combined.
ProgressBar progressBar = new ProgressBar(20); progressBar.addStyleName("progressbar-solid"); progressBar.addStyleName("progressbar-noborder");
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled |
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment |
---|
com.google.gwt.user.client.ui.HasHorizontalAlignment.AutoHorizontalAlignmentConstant, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant |
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasVerticalAlignment |
---|
com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant |
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel |
---|
com.google.gwt.user.client.ui.InsertPanel.ForIsWidget |
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets |
---|
com.google.gwt.user.client.ui.HasWidgets.ForIsWidget |
Field Summary | |
---|---|
private com.google.gwt.user.client.ui.FlexTable |
barFrame
This is the frame around the progress bar |
private com.google.gwt.user.client.ui.Grid |
elementGrid
This is the grid used to show the elements |
private int |
elements
The number of bar elements to show |
private java.lang.String |
hoursMessage
|
private java.lang.String |
minutesMessage
|
private int |
progress
Current progress (as a percentage) |
private com.google.gwt.user.client.ui.Label |
remainLabel
This is the current text label below the progress bar |
private java.lang.String |
secondsMessage
Time element text |
static int |
SHOW_TEXT
Option to show text label above progress bar |
static int |
SHOW_TIME_REMAINING
Option to show time remaining |
private boolean |
showRemaining
internal flags for options |
private boolean |
showText
|
private long |
startTime
The time the progress bar was started |
private com.google.gwt.user.client.ui.Label |
textLabel
This is the current text label above the progress bar |
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment |
---|
ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT |
Fields inherited from interface com.google.gwt.user.client.ui.HasVerticalAlignment |
---|
ALIGN_BOTTOM, ALIGN_MIDDLE, ALIGN_TOP |
Constructor Summary | |
---|---|
ProgressBar(int elements)
Constructor without options |
|
ProgressBar(int elements,
int options)
Base constructor for this widget |
Method Summary | |
---|---|
java.lang.String |
getHoursMessage()
Get the message used to format the time remaining text for hours |
java.lang.String |
getMinutesMessage()
Get the message used to format the time remaining text for minutes |
int |
getProgress()
Get the current progress as a percentage |
java.lang.String |
getSecondsMessage()
Get the message used to format the time remaining text for seconds |
java.lang.String |
getText()
Get the text displayed above the progress bar |
void |
setHoursMessage(java.lang.String hoursMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setMinutesMessage(java.lang.String minutesMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setProgress(int percentage)
Set the current progress as a percentage |
void |
setSecondsMessage(java.lang.String secondsMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setText(java.lang.String text)
Set the text displayed above the progress bar |
Methods inherited from class com.google.gwt.user.client.ui.VerticalPanel |
---|
add, getHorizontalAlignment, getVerticalAlignment, insert, insert, onEnsureDebugId, remove, setHorizontalAlignment, setVerticalAlignment |
Methods inherited from class com.google.gwt.user.client.ui.CellPanel |
---|
getBody, getSpacing, getTable, setBorderWidth, setCellHeight, setCellHorizontalAlignment, setCellHorizontalAlignment, setCellVerticalAlignment, setCellVerticalAlignment, setCellWidth, setSpacing |
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel |
---|
add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove |
Methods inherited from class com.google.gwt.user.client.ui.Panel |
---|
add, adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, orphan, remove |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addAttachHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.user.client.ui.InsertPanel.ForIsWidget |
---|
add |
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget |
---|
getWidgetIndex |
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel |
---|
getWidget, getWidgetCount, getWidgetIndex, remove |
Field Detail |
---|
public static final int SHOW_TEXT
public static final int SHOW_TIME_REMAINING
private long startTime
private int elements
private java.lang.String secondsMessage
private java.lang.String minutesMessage
private java.lang.String hoursMessage
private int progress
private com.google.gwt.user.client.ui.FlexTable barFrame
private com.google.gwt.user.client.ui.Grid elementGrid
private com.google.gwt.user.client.ui.Label remainLabel
private com.google.gwt.user.client.ui.Label textLabel
private boolean showRemaining
private boolean showText
Constructor Detail |
---|
public ProgressBar(int elements, int options)
elements
- The number of elements (bars) to show on the progress baroptions
- The display options for the progress barpublic ProgressBar(int elements)
elements
- The number of elements (bars) to show on the progress barMethod Detail |
---|
public void setProgress(int percentage)
percentage
- Set current percentage for the progress barpublic int getProgress()
public java.lang.String getText()
public void setText(java.lang.String text)
text
- the text to setpublic java.lang.String getHoursMessage()
public void setHoursMessage(java.lang.String hoursMessage)
hoursMessage
- the hours message to setpublic java.lang.String getMinutesMessage()
public void setMinutesMessage(java.lang.String minutesMessage)
minutesMessage
- the minutes message to setpublic java.lang.String getSecondsMessage()
public void setSecondsMessage(java.lang.String secondsMessage)
secondsMessage
- the secondsMessage to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |