Fields Summary |
---|
private static com.sun.midp.security.SecurityToken | classSecurityTokenSecurity token to allow access to implementation APIs |
private static final Command | DISMISS_COMMANDInternal command used to visually represent
Alert.DISMISS_COMMAND . |
private static final int | DEFAULT_TIMEOUTThe default timeout of all alerts. |
private static Timer | timeoutTimerA Timer which serves all Alert objects
to schedule their timeout tasks. |
private Alert | alertAlert associated with this view. |
private TimerTask | timerTaskA TimerTask which will be set to expire this
Alert after its timeout period has elapsed. |
private int | isContentScrollA flag that indicates whether the content of the alert
needs scrolling.
Valid values are: -1: unknown, 0: no scrolling, 1: scrolling needed. |
private static Image | ALERT_ALRMAn image to be drawn in Alert when it was
created with AlertType ALARM. |
private static Image | ALERT_CFMAn image to be drawn in Alert when it was
created with AlertType CONFIRMATION.. |
private static Image | ALERT_ERRAn image to be drawn in Alert when it was
created with AlertType ERROR. |
private static Image | ALERT_INFOAn image to be drawn in Alert when it was
created with AlertType INFO. |
private static Image | ALERT_WARNAn image to be drawn in Alert when it was
created with AlertType WARNING. |
Methods Summary |
---|
void | createNativeResource()Create native resource for this Alert .
Gauge resource will not be created.
nativeId = createNativeResource0(alert.title,
alert.ticker == null ? null : alert.ticker.getString(),
alert.type == null ? 0 : alert.type.getType());
|
private native int | createNativeResource0(java.lang.String title, java.lang.String tickerText, int type)Create native dialog with image and text widget for this
Alert .
|
private Image | getAlertImage(AlertType alertType)Get the corresponding image for a given alert type.
if (alertType != null) {
if (alertType.equals(AlertType.INFO)) {
if (ALERT_INFO == null) {
ALERT_INFO = getSystemImage("alert.image_icon_info");
}
return ALERT_INFO;
} else if (alertType.equals(AlertType.WARNING)) {
if (ALERT_WARN == null) {
ALERT_WARN = getSystemImage("alert.image_icon_warn");
}
return ALERT_WARN;
} else if (alertType.equals(AlertType.ERROR)) {
if (ALERT_ERR == null) {
ALERT_ERR = getSystemImage("alert.image_icon_errr");
}
return ALERT_ERR;
} else if (alertType.equals(AlertType.ALARM)) {
if (ALERT_ALRM == null) {
ALERT_ALRM = getSystemImage("alert.image_icon_alrm");
}
return ALERT_ALRM;
} else if (alertType.equals(AlertType.CONFIRMATION)) {
if (ALERT_CFM == null) {
ALERT_CFM = getSystemImage("alert.image_icon_cnfm");
}
return ALERT_CFM;
}
}
return null;
|
private Image | getSystemImage(java.lang.String imageName)Obtain system image resource and create Image object from it.
byte[] imageData = ResourceHandler.getSystemImageResource(
classSecurityToken, imageName);
if (imageData != null) {
return Image.createImage(imageData, 0, imageData.length);
} else {
// Use a empty immutable image as placeholder
return Image.createImage(Image.createImage(16, 16));
}
|
void | lCallHide()Notify this Alert that it will no longer be displayed.
Override the version in DisplayableLFImpl .
// Stop the timer
if (timerTask != null) {
try {
timerTask.cancel();
timerTask = null;
} catch (Throwable t) { }
}
// Hide and delete gauge resource
if (alert.indicator != null) {
GaugeLFImpl gaugeLF = (GaugeLFImpl)alert.indicator.gaugeLF;
gaugeLF.lHideNativeResource();
gaugeLF.deleteNativeResource();
if (gaugeLF.visibleInViewport) {
gaugeLF.lCallHideNotify();
}
}
// Hide and delete alert dialog window including title and ticker
super.lCallHide();
|
void | lCallShow()Notify this Alert that it is being displayed.
Override the version in DisplayableLFImpl .
// Create native resource with title and ticker
super.lCallShow();
// Play sound
if (alert.type != null) {
currentDisplay.playAlertSound(alert.type);
}
// Setup contained items and show them
showContents();
// Show the Alert dialog window
showNativeResource0(nativeId);
// Start Java timer
// If native dialog will cause VM to freeze, this timer
// needs to be moved to native.
if (alert.time != Alert.FOREVER
&& alert.numCommands == 1
&& isContentScroll == 0) {
if (timeoutTimer == null) {
timeoutTimer = new Timer();
}
timerTask = new TimeoutTask();
timeoutTimer.schedule(timerTask, alert.time);
}
|
public int | lGetDefaultTimeout()Gets default timeout for the Alert associated with
this view.
return DEFAULT_TIMEOUT;
|
public Command | lGetDismissCommand()Return the command that should be mapped to
Alert.DISMISS_COMMAND .
return DISMISS_COMMAND;
|
public boolean | lIsModal()Determines if Alert associated with this view is modal.
if (alert.numCommands > 1) {
return true;
}
if (isContentScroll < 0) {
layout();
}
return (isContentScroll == 1);
|
void | lRequestInvalidate()Called upon content change to schedule a request for relayout and
repaint.
super.lRequestInvalidate();
isContentScroll = -1; // Unknown scrolling state
|
public void | lSetImage(Image oldImg, Image newImg)Notifies image change.
lRequestInvalidate();
|
public void | lSetIndicator(Gauge oldIndicator, Gauge newIndicator)Notifies indicator change.
lRequestInvalidate();
|
public void | lSetString(java.lang.String oldString, java.lang.String newString)Notifies string change.
lRequestInvalidate();
|
public void | lSetTimeout(int timeout)Notifies timeout change.
Changing timeout on an already visible Alert will
restart the timer, but has no effect on current layout.
if (timerTask != null) {
try {
timerTask.cancel();
if (timeout == Alert.FOREVER) {
timerTask = null;
} else {
timerTask = new TimeoutTask();
timeoutTimer.schedule(timerTask, timeout);
}
} catch (Throwable t) { }
}
|
public void | lSetType(AlertType type)Notifies Alert type change.
Changing type on an already visible Alert will only
update the default icon. No sound will be played.
lRequestInvalidate();
|
private void | layout()Layout the content of this Alert .
Query native resource for two informations:
- Whether the content needs scrolling, in 'isContentScroll'
- Location of the gauge indicator
SYNC NOTE: Caller of this function should hold LCDUILock around
this call.
boolean wasNoNative = (nativeId == INVALID_NATIVE_ID);
// If no native resource yet, create it temporarily
if (wasNoNative) {
createNativeResource();
}
Image img = alert.image;
// If no image is specified, default icon for that type should be used
if (img == null && alert.type != null) {
img = getAlertImage(alert.type);
}
// Bounds array of gauge
// The reason gauge bounds is passed back from native is to be
// consistent with Form's Java layout code.
int[] gaugeBounds;
GaugeLFImpl gaugeLF;
if (alert.indicator == null) {
gaugeLF = null;
gaugeBounds = null;
} else {
// We temporarily use bounds array in gauge
// The real values will be set later by setSize() and setLocation()
gaugeLF = (GaugeLFImpl)alert.indicator.gaugeLF;
gaugeBounds = new int[4];
// Pass gauge's preferred size to native layout code
gaugeBounds[WIDTH] = gaugeLF.lGetPreferredWidth(-1);
gaugeBounds[HEIGHT] = gaugeLF.lGetPreferredHeight(-1);
}
ImageData imageData = null;
if (img != null) {
imageData = img.getImageData();
}
// Set content to native dialog and get layout information back
if (setNativeContents0(nativeId, imageData,
gaugeBounds, alert.text)) {
isContentScroll = 1; // scrolling needed
} else {
isContentScroll = 0; // no scrolling
}
// Set gauge location and size based on return from native layout code
if (gaugeBounds != null) {
gaugeLF.lSetSize(gaugeBounds[WIDTH], gaugeBounds[HEIGHT]);
gaugeLF.lSetLocation(gaugeBounds[X], gaugeBounds[Y]);
}
// Native resource should only be kept alive if it's visible
// Free temporarily created native resource here
if (wasNoNative) {
deleteNativeResource();
}
|
private native boolean | setNativeContents0(int nativeId, ImageData imgId, int[] indicatorBounds, java.lang.String text)Set content to native dialog.
|
private void | showContents()Show or update contents on a visible Alert .
SYNC NOTE: Caller must hold LCDUILock around this call.
// Make sure gauge has native resource ready
GaugeLFImpl gaugeLF = (alert.indicator == null)
? null
: (GaugeLFImpl)alert.indicator.gaugeLF;
if (gaugeLF != null && gaugeLF.nativeId == INVALID_NATIVE_ID) {
gaugeLF.createNativeResource(nativeId);
}
// Re-populate the alert with updated contents
layout();
// Make sure gauge is shown
if (gaugeLF != null) {
gaugeLF.lShowNativeResource();
// SYNC NOTE: Since Gauge show and showNotify does not involve
// application code, we can call it while holding LCDUILock
gaugeLF.lCallShowNotify();
// IMPLEMENTATION NOTE: when gauge is present in the Alert
// its visibleInViewport will always be set to true.
// If dynamic update of gauge's visibleInViewport flag is
// required in AlertLFImpl
// uViewportChanged() can be moved up from FormLFImpl to
// DisplayableLFImpl
}
|
private native void | showNativeResource0(int nativeId)(Re)Show native dialog with image and text widget for this
Alert.
|
public void | uCallInvalidate()Called by the event handler to perform a re-layout
on this AlertLF .
synchronized (Display.LCDUILock) {
showContents();
}
|
public void | uCallSizeChanged(int w, int h)Notify return screen about screen size change
super.uCallSizeChanged(w,h);
Displayable returnScreen = alert.getReturnScreen();
if (returnScreen != null) {
(returnScreen.displayableLF).uCallSizeChanged(w,h);
}
|