Source Code Cross Referenced for RunningMIDletSuiteInfo.java in  » 6.0-JDK-Modules » j2me » com » sun » midp » appmanager » 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.appmanager 
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:
027:        package com.sun.midp.appmanager;
028:
029:        import com.sun.midp.main.*;
030:        import com.sun.midp.midletsuite.*;
031:        import com.sun.midp.installer.*;
032:        import javax.microedition.lcdui.*;
033:        import com.sun.midp.configurator.Constants;
034:
035:        import com.sun.midp.log.Logging;
036:        import com.sun.midp.log.LogChannels;
037:        import com.sun.midp.midlet.MIDletSuite;
038:
039:        /** Simple attribute storage for MIDlet suites */
040:        public class RunningMIDletSuiteInfo extends MIDletSuiteInfo {
041:            /** Proxy if running. It is set from AppManagerUI.java. */
042:            public MIDletProxy proxy = null;
043:            /** Icon for this suite. */
044:            public Image icon = null;
045:
046:            /**
047:             * Constructs a RunningMIDletSuiteInfo object for a suite.
048:             *
049:             * @param theID ID the system has for this suite
050:             */
051:            public RunningMIDletSuiteInfo(int theID) {
052:                super (theID);
053:            }
054:
055:            /**
056:             * Constructs a RunningMIDletSuiteInfo object for a suite.
057:             *
058:             * @param theID ID the system has for this suite
059:             * @param theMidletToRun Class name of the only midlet in the suite
060:             * @param theDisplayName Name to display to the user
061:             * @param isEnabled true if the suite is enabled
062:             */
063:            public RunningMIDletSuiteInfo(int theID, String theMidletToRun,
064:                    String theDisplayName, boolean isEnabled) {
065:                super (theID, theMidletToRun, theDisplayName, isEnabled);
066:                icon = getDefaultSingleSuiteIcon();
067:            }
068:
069:            /**
070:             * Constructs a RunningMIDletSuiteInfo object for a suite.
071:             *
072:             * @param theID ID the system has for this suite
073:             * @param theMidletSuite MIDletSuite information
074:             * @param mss the midletSuite storage
075:             */
076:            public RunningMIDletSuiteInfo(int theID,
077:                    MIDletSuiteImpl theMidletSuite, MIDletSuiteStorage mss) {
078:                super (theID, theMidletSuite);
079:
080:                icon = getIcon(theID,
081:                        theMidletSuite.getProperty("MIDlet-Icon"), mss);
082:                if (icon == null && numberOfMidlets == 1) {
083:                    MIDletInfo midlet = new MIDletInfo(theMidletSuite
084:                            .getProperty("MIDlet-1"));
085:
086:                    // MIDlet icons are optional, so it the icon may be null
087:                    icon = getIcon(theID, midlet.icon, mss);
088:                }
089:
090:                if (icon == null) {
091:                    icon = getDefaultSingleSuiteIcon();
092:                }
093:            }
094:
095:            /**
096:             * Constructs a RunningMIDletSuiteInfo from MIDletSuiteInfo.
097:             *
098:             * @param info MIDletSuiteInfo reference
099:             * @param mss the midletSuite storage
100:             */
101:            public RunningMIDletSuiteInfo(MIDletSuiteInfo info,
102:                    MIDletSuiteStorage mss) {
103:                super (info.suiteId, info.midletToRun, info.displayName,
104:                        info.enabled);
105:
106:                storageId = info.storageId;
107:                numberOfMidlets = info.numberOfMidlets;
108:                trusted = info.trusted;
109:                preinstalled = info.preinstalled;
110:                iconName = info.iconName;
111:
112:                loadIcon(mss);
113:            }
114:
115:            /**
116:             * Loads an icon for this suite.
117:             *
118:             * @param mss the midletSuite storage
119:             */
120:            public void loadIcon(MIDletSuiteStorage mss) {
121:                if (iconName != null) {
122:                    icon = getIcon(suiteId, iconName, mss);
123:                }
124:
125:                if (icon == null) {
126:                    if (numberOfMidlets == 1) {
127:                        icon = getDefaultSingleSuiteIcon();
128:                    } else {
129:                        icon = getDefaultMultiSuiteIcon();
130:                    }
131:                }
132:            }
133:
134:            /**
135:             * Gets suite icon either from image cache, or from the suite jar.
136:             *
137:             * @param theID the suite id that system has for this suite
138:             * @param iconName the name of the file where the icon is
139:             *     stored in the JAR
140:             * @param mss The midletSuite storage
141:             * @return Image provided by the application with
142:             *     the passed in iconName
143:             */
144:            public static Image getIcon(int theID, String iconName,
145:                    MIDletSuiteStorage mss) {
146:                byte[] iconBytes;
147:
148:                try {
149:                    iconBytes = mss.getMIDletSuiteIcon(theID, iconName);
150:
151:                    if (iconBytes == null) {
152:                        if (Logging.REPORT_LEVEL <= Logging.WARNING) {
153:                            Logging.report(Logging.WARNING, LogChannels.LC_AMS,
154:                                    "getIcon: iconBytes == null");
155:                        }
156:                        return null;
157:                    }
158:
159:                    return Image.createImage(iconBytes, 0, iconBytes.length);
160:                } catch (Throwable t) {
161:                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
162:                        Logging.report(Logging.WARNING, LogChannels.LC_AMS,
163:                                "getIcon threw an " + t.getClass());
164:                    }
165:                    return null;
166:                }
167:            }
168:
169:            /**
170:             * Returns a string representation of the MIDletSuiteInfo object.
171:             * For debug only.
172:             */
173:            public String toString() {
174:                StringBuffer b = new StringBuffer();
175:                b.append("id = " + suiteId);
176:                b.append(", midletToRun = " + midletToRun);
177:                b.append(", proxy = " + proxy);
178:                return b.toString();
179:            }
180:
181:            /**
182:             * Compares this MIDletSuiteInfo with the passed in MIDletProxy.
183:             * Returns true if both belong to the same suite and
184:             * if current proxy or midetToRun points to the same class as
185:             * in the passed in MIDletProxy.
186:             * @param midlet The MIDletProxy to compare with
187:             * @return true if The MIDletSuiteInfo points to the same midlet as
188:             *         the MIDletProxy, false - otherwise
189:             */
190:            public boolean equals(MIDletProxy midlet) {
191:                if (suiteId == midlet.getSuiteId()) {
192:                    if (proxy != null) {
193:                        return proxy == midlet;
194:                    }
195:
196:                    if ((numberOfMidlets == 1 || suiteId == MIDletSuite.INTERNAL_SUITE_ID)
197:                            && midletToRun != null) {
198:                        return midletToRun.equals(midlet.getClassName());
199:                    }
200:
201:                    return true;
202:                }
203:
204:                return false;
205:            }
206:
207:            /** Cache of the suite icon. */
208:            private static Image multiSuiteIcon;
209:
210:            /** Cache of the single suite icon. */
211:            private static Image singleSuiteIcon;
212:
213:            /**
214:             * Gets the single MIDlet suite icon from storage.
215:             *
216:             * @return icon image
217:             */
218:            private static Image getDefaultSingleSuiteIcon() {
219:                if (singleSuiteIcon == null) {
220:                    singleSuiteIcon = GraphicalInstaller
221:                            .getImageFromInternalStorage("_ch_single");
222:                }
223:                return singleSuiteIcon;
224:            }
225:
226:            /**
227:             * Gets the MIDlet suite icon from storage.
228:             *
229:             * @return icon image
230:             */
231:            private static Image getDefaultMultiSuiteIcon() {
232:                if (multiSuiteIcon == null) {
233:                    multiSuiteIcon = GraphicalInstaller
234:                            .getImageFromInternalStorage("_ch_suite");
235:                }
236:                return multiSuiteIcon;
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.