001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.main;
028:
029: import javax.microedition.lcdui.Displayable;
030:
031: import com.sun.midp.lcdui.ForegroundController;
032:
033: /**
034: * This class provides methods to abstract the central foreground control
035: * code from the the LCDUI library.
036: */
037: class CldcForegroundController implements ForegroundController {
038: /** Cached reference to the MIDletControllerEventProducer. */
039: private MIDletControllerEventProducer midletControllerEventProducer;
040:
041: /**
042: * Initializes this class.
043: *
044: * @param theMIDletControllerEventProducer event producer
045: */
046: CldcForegroundController(
047: MIDletControllerEventProducer theMIDletControllerEventProducer) {
048:
049: midletControllerEventProducer = theMIDletControllerEventProducer;
050: }
051:
052: /**
053: * Called to register a newly create Display. Must method must
054: * be called before the other methods can be called.
055: *
056: * @param displayId ID of the Display
057: * @param ownerClassName Class name of the that owns the display
058: *
059: * @return a place holder displayable to used when "getCurrent()==null",
060: * if null is returned an empty form is used
061: */
062: public Displayable registerDisplay(int displayId,
063: String ownerClassName) {
064: midletControllerEventProducer.sendDisplayCreateNotifyEvent(
065: displayId, ownerClassName);
066:
067: return new HeadlessAlert(displayId,
068: midletControllerEventProducer);
069: }
070:
071: /**
072: * Called to request the foreground.
073: *
074: * @param displayId ID of the Display
075: * @param isAlert true if the current displayable is an Alert
076: */
077: public void requestForeground(int displayId, boolean isAlert) {
078: midletControllerEventProducer
079: .sendDisplayForegroundRequestEvent(displayId, isAlert);
080: }
081:
082: /**
083: * Called to request the background.
084: *
085: * @param displayId ID of the Display
086: */
087: public void requestBackground(int displayId) {
088: midletControllerEventProducer
089: .sendDisplayBackgroundRequestEvent(displayId);
090: }
091:
092: /**
093: * Called to start preempting. The given display will preempt all other
094: * displays for this isolate.
095: *
096: * @param displayId ID of the Display
097: */
098: public void startPreempting(int displayId) {
099: midletControllerEventProducer
100: .sendDisplayPreemptStartEvent(displayId);
101: }
102:
103: /**
104: * Called to end preempting.
105: *
106: * @param displayId ID of the Display
107: */
108: public void stopPreempting(int displayId) {
109: midletControllerEventProducer
110: .sendDisplayPreemptStopEvent(displayId);
111: }
112: }
|