Source Code Cross Referenced for MVMDisplayController.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » main » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.midp.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        package com.sun.midp.main;
027:
028:        import java.util.*;
029:
030:        /**
031:         * This class controls which MIDlet's display is in the foreground.
032:         * Running only in the AMS Isolate (0) the controller consulted by the MIDlet
033:         * proxy list for any foreground when various state changes occur in a MIDlet.
034:         * The display controller defers the display decision to the user by choosing
035:         * the foreground selector to be the next foreground.
036:         * <p>
037:         * From the user perspective when the last MIDlet the user launched sets its
038:         * current displayable for the first time, that MIDlet should automatically
039:         * get the foreground (see the midletCreated and foregroundRequest methods).
040:         * <p>
041:         * A MIDlet that is paused or destroyed is treated as if it has requested the
042:         * background as described above.
043:         */
044:        public class MVMDisplayController extends DisplayController {
045:            /** Foreground Selector MIDlet. */
046:            private MIDletProxy foregroundSelector;
047:
048:            /**
049:             * Construct a DisplayController with a reference to the ProxyList.
050:             *
051:             * @param theMIDletProxyList reference to the MIDlet proxy list
052:             * @param theForegroundSelector the proxy of foreground selector
053:             */
054:            public MVMDisplayController(MIDletProxyList theMIDletProxyList,
055:                    MIDletProxy theForegroundSelector) {
056:                super (theMIDletProxyList);
057:
058:                foregroundSelector = theForegroundSelector;
059:
060:                /*
061:                 * Ensure the foreground selector will get the foreground
062:                 * when requested.
063:                 */
064:                lastMidletCreated = foregroundSelector;
065:            }
066:
067:            /**
068:             * Handles MIDlet foreground requests.
069:             * <p>
070:             * If proxy being updated belongs last MIDlet created in the proxy list,
071:             * then put the MIDlet in the foreground.
072:             * <p>
073:             * Otherwise, the request will not be granted. Foreground will not change.
074:             *
075:             * @param midlet The proxy of the MIDlet that was updated
076:             *
077:             * @return Proxy of the next foreground MIDlet, may be the foreground
078:             *         MIDlet if the foreground should not change
079:             */
080:            MIDletProxy foregroundRequest(MIDletProxy midlet) {
081:                /*
082:                 * When the last MIDlet started wants the foreground automatically
083:                 * put in the foreground this time only.
084:                 */
085:                return (midlet == lastMidletCreated) ? midlet : midletProxyList
086:                        .getForegroundMIDlet();
087:            }
088:
089:            /**
090:             * Handles MIDlet background requests.
091:             * <p>
092:             * If the MIDlet is the foreground MIDlet, then bring the foreground
093:             * selector to the foreground.
094:             *
095:             * @param midlet The proxy of the MIDlet that was updated
096:             *
097:             * @return Proxy of the next foreground MIDlet, may be the foreground
098:             *         MIDlet if the foreground should not change
099:             */
100:            MIDletProxy backgroundRequest(MIDletProxy midlet) {
101:                MIDletProxy foreground = midletProxyList.getForegroundMIDlet();
102:
103:                if (midlet != foreground) {
104:                    // not in the foreground, so don't change the foreground
105:                    return foreground;
106:                }
107:
108:                /*
109:                 * Normal MVM mode case,
110:                 * Let the user choose the next foreground.
111:                 */
112:                return getForegroundSelector();
113:            }
114:
115:            /**
116:             * Preempt an Isolate's displays.
117:             *
118:             * @param preempting proxy of the preempting MIDlet to be put in the
119:             *  foreground when a preempted MIDlet gets the foreground
120:             *
121:             * @return Proxy of the next foreground MIDlet, may be the foreground
122:             *         MIDlet if the foreground should not change
123:             * 
124:             */
125:            MIDletProxy startPreempting(MIDletProxy preempting) {
126:                Enumeration midlets;
127:                MIDletProxy preempted;
128:                MIDletProxy foreground;
129:
130:                /*
131:                 * Preempt all of the MIDlets in the same Isolate as the preempting
132:                 * proxy.
133:                 */
134:                midlets = midletProxyList.getMIDlets();
135:                while (midlets.hasMoreElements()) {
136:                    MIDletProxy current = (MIDletProxy) midlets.nextElement();
137:
138:                    if (current.getIsolateId() != preempting.getIsolateId()) {
139:                        continue;
140:                    }
141:
142:                    preempting.setPreemptedMidlet(current);
143:                    current.setPreemptingDisplay(preempting);
144:                    midletProxyList.notifyListenersOfProxyUpdate(current,
145:                            MIDletProxyListListener.PREEMPTING_DISPLAY);
146:                }
147:
148:                foreground = midletProxyList.getForegroundMIDlet();
149:                if (foreground == null) {
150:                    return preempting;
151:                }
152:
153:                if (foreground.getIsolateId() == preempting.getIsolateId()) {
154:                    preempting.setPreemptedMidlet(foreground);
155:                    return preempting;
156:                }
157:
158:                return foreground;
159:            }
160:
161:            /**
162:             * Called to process a select foreground event.
163:             * Returns the foreground selector MIDlet in the foreground.
164:             *
165:             * @param onlyFromLaunchedList true if midlet should
166:             *        be selected from the list of already launched midlets,
167:             *        if false then possibility to launch midlet is needed.
168:             * @return Proxy of the next foreground MIDlet, may be the foreground
169:             *         MIDlet if the foreground should not change
170:             */
171:            MIDletProxy selectForeground(boolean onlyFromLaunchedList) {
172:
173:                notifyListenersOfSelectForeground(onlyFromLaunchedList);
174:                return getForegroundSelector();
175:            }
176:
177:            /**
178:             * Returns the foreground selector MIDlet.
179:             *
180:             * @return Proxy of the foreground selector MIDlet
181:             */
182:            private MIDletProxy getForegroundSelector() {
183:                return foregroundSelector;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.