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.midlet.MIDlet;
030: import javax.microedition.midlet.MIDletStateChangeException;
031: import javax.microedition.lcdui.Display;
032:
033: import javax.microedition.lcdui.Form;
034: import javax.microedition.lcdui.Command;
035: import javax.microedition.lcdui.CommandListener;
036: import javax.microedition.lcdui.Displayable;
037:
038: import com.sun.midp.log.Logging;
039: import com.sun.midp.log.LogChannels;
040:
041: /**
042: * Base class for several Dummy MIDlets used in NAMS I3 testing
043: */
044: public class DummyNamsMIDlet extends MIDlet implements CommandListener {
045:
046: protected String name; // = "Dummy Nams MIDlet";
047: private Command cmdMgr;
048: private Command cmdHide;
049: private Command cmdPause;
050: private Command cmdDestroy;
051:
052: /** main midlet screen */
053: private Form form;
054:
055: /**
056: * public constructor
057: *
058: * @param dummyName name of the MIDlet (i.e.name of its its screen)
059: *
060: */
061: public DummyNamsMIDlet(String dummyName) {
062: int i;
063:
064: name = dummyName;
065:
066: cmdDestroy = new Command("Destroy", Command.EXIT, 0);
067: cmdPause = new Command("Pause", Command.STOP, 0);
068: cmdHide = new Command("Hide", Command.SCREEN, 0);
069: cmdMgr = new Command("Show Manager", Command.SCREEN, 0);
070:
071: form = new Form(name + " screen");
072:
073: form.addCommand(cmdMgr);
074: form.addCommand(cmdHide);
075: form.addCommand(cmdPause);
076: form.addCommand(cmdDestroy);
077:
078: form.setCommandListener(this );
079:
080: Logging.report(Logging.WARNING, LogChannels.LC_CORE, "DEBUG: "
081: + name + ": created in isolate #"
082: + MIDletSuiteUtils.getIsolateId());
083: }
084:
085: protected void startApp() throws MIDletStateChangeException {
086: Logging.report(Logging.WARNING, LogChannels.LC_CORE, "DEBUG: "
087: + name + ": entered active state ...");
088:
089: Display.getDisplay(this ).setCurrent(form);
090: };
091:
092: protected void pauseApp() {
093: Logging.report(Logging.WARNING, LogChannels.LC_CORE, "DEBUG: "
094: + name + ": entered paused state ...");
095: notifyPaused();
096: }
097:
098: protected void destroyApp(boolean unconditional)
099: throws MIDletStateChangeException {
100: Logging.report(Logging.WARNING, LogChannels.LC_CORE, "DEBUG: "
101: + name + ": entered destroyed state ...");
102: notifyDestroyed();
103: }
104:
105: public void commandAction(Command c, Displayable s) {
106:
107: if (c == cmdDestroy) {
108: /*
109: Logging.report(Logging.WARNING, LogChannels.LC_CORE,
110: "DEBUG: " + name + ": user requested to destroy ...");
111: */
112: try {
113: destroyApp(true);
114: } catch (MIDletStateChangeException e) {
115: }
116: ;
117: } else if (c == cmdPause) {
118: /*
119: Logging.report(Logging.WARNING, LogChannels.LC_CORE,
120: "DEBUG: " + name + ": user requested to pause ...");
121: */
122: pauseApp();
123: } else if (c == cmdHide) {
124: /*
125: Logging.report(Logging.WARNING, LogChannels.LC_CORE,
126: "DEBUG: " + name + ": user requested to go to background ...");
127: */
128: NamsManager.midletSetBackground();
129: } else if (c == cmdMgr) {
130: /*
131: Logging.report(Logging.WARNING, LogChannels.LC_CORE,
132: "DEBUG: " + name + ": user requested to show NamsManager ...");
133: */
134: NamsManager.midletSetForeground(0);
135: }
136: }
137: }
|