Mobile Tools for the Java Platform Coding Examples
Mobile Tools for the Java Platform Coding Examples Version 0. 3 1
Get Extension Implementation import org. eclipse. mtj. api. extension. Device. Management; import org. eclipse. mtj. api. enumerations. Extension. Type; import org. eclipse. mtj. api. extension. Mtj. Extension; import org. eclipse. mtj. core. Mtj. Services; . . . String version = null; String vendor = null; boolean only. Active = true; Mtj. Extension[] list = Mtj. Services. get. Instance(). get. Implementations( Extension. Type. DEVICE_MANAGEMENT_LITERAL, version, vendor, only. Active); Device. Management device. Management = (Device. Management ) list[0]; 1. 3. 2006 2
Get Device. Platform, Device and Runtime. Platform Device. Platforms, that are defined by Device. Platform. Providers, define their content with specific data model. The model right describes the main parts of the object model structure of the Device. Platform –definition. 1. 3. 2006 3
Get Device. Platform, Device and Runtime. Platform (cont. ) import org. eclipse. mtj. api. extension. Device. Management; import org. eclipse. mtj. api. enumerations. Extension. Type; import org. eclipse. mtj. api. extension. Mtj. Extension; import org. eclipse. mtj. core. Mtj. Services; import org. eclipse. mtj. api. devices. Device. Platform; import org. eclipse. mtj. api. runtimes. Runtime. Platform. Definition; . . . Device. Management device. Management = (Device. Management) Mtj. Services. get. Instance(). get. Implementations( Extension. Type. DEVICE_MANAGEMENT_LITERAL, null)[0]; Device. Platform[] device. Platform = device. Management. get. Device. Platforms()[0]; Device device = device. Platform. get. Devices(). get(1); Runtime. Platform. Definition runtime. Platform. Definition = device. get. Runtime. Platform. Definitions(). get(1); 1. 3. 2006 4
Modify Project Data Projects, that have Mtj Nature, contains Mtj specific descriptions. Next example shows, how to access Project’s descriptions and how to modify them. The model right describes the object model structure of the Project –definitions. 1. 3. 2006 5
Modify Project Data (cont. ) import org. eclipse. jdt. core. IJava. Project; import org. eclipse. mtj. api. model. IMtj. Project; import org. eclipse. mtj. core. project. Mtj. Project; import org. eclipse. mtj. api. project. Project; . . . IJava. Project java. Project; . . . IMtj. Project mtj. Project = Mtj. Project. get. Mtj. Project(java. Project); Project project = mtj. Project. get. Project. Data(); Obfuscation. Detail obfuscation. Detail = new Obfuscation. Detail(); obfuscation. Detail. set. Level(1); project. set. Obfuscation. Detail(obfuscation. Detail); mtj. Project. set. Project. Data(project); 1. 3. 2006 6
Add Runtime Platform Definition To Project import org. eclipse. mtj. api. devices. Device; import org. eclipse. mtj. api. devices. Device. Platform; import org. eclipse. mtj. api. runtimes. Runtime. Platform. Definition; import org. eclipse. mtj. api. project. Project. Factory; import org. eclipse. mtj. api. project. Target. Device; import org. eclipse. mtj. core. util. Mtj. Emf. Util; . . . Project project; Device. Platform device. Platform; Device device; Runtime. Platform. Definition runtime. Platform. Definition; . . . Target. Device target. Device = Project. Factory. e. INSTANCE. create. Target. Device(); target. Device. set. Name(”Nokia S 80 Device”); target. Device. set. Device. Platform. Name(device. Platform. get. Name()); target. Device. set. Device. Name(device. get. Name()); // create a project specific copy of the Runtime. Platform. Definition copy. RPD = Mtj. Emf. Util. clone(runtime. Platform. Definition); target. Device. set. Runtime. Platform(copy. RPD); mtj. Project. set. Project. Data(project); 1. 3. 2006 7
Get Project’s Default Targets import org. eclipse. jdt. core. IJava. Project; import org. eclipse. mtj. api. model. IMtj. Project; import org. eclipse. mtj. core. project. Mtj. Project; import org. eclipse. mtj. api. project. Project; import org. eclipse. mtj. api. devices. Device. Platform; import org. eclipse. mtj. api. runtimes. Runtime. Platform. Definition; . . . IJava. Project java. Project; . . . IMtj. Project mtj. Project = Mtj. Project. get. Mtj. Project(java. Project); Device. Platform device. Platform = mtj. Project. get. Platform. Definition(); Device device = mtj. Project. get. Default. Device(); Runtime. Platform. Definition runtime. Platform. Definition = mtj. Project. get. Project. Data(). get. Default. Target. Device(). get. Runtime. Platform(); 1. 3. 2006 8
Deploy Project’s Data import org. eclipse. mtj. api. model. IMtj. Project; import org. eclipse. mtj. api. devices. Device; import org. eclipse. mtj. api. extension. Deployment. Management ; import org. eclipse. mtj. api. runtimes. Runtime. Platform. Definition; import org. eclipse. mtj. api. enumerations. Device. Communication. Protocol; import org. eclipse. core. runtime. IProgress. Monitor; . . . IMtj. Project mtj. Project; . . . Runtime. Platform. Definition runtime. Platform. Definition = mtj. Project. get. Project. Data(). get. Default. Target. Device(). get. Runtime. Platform(); Deployment. Management deployment. Management = (Deployment. Management)Mtj. Services. get. Instance(). get. Implementations(Extension. Type. DEPLOYMENT_MANAGEMENT_LITERAL, null)[0]; Device[] devices = deployment. Management. get. Target. Devices(runtime. Platform. Definition); Device. Communication. Protocol[] transfer. Protocols = null; IProgress. Monitor monitor = null; deployment. Management. deploy(mtj. Project. get. Deployment(), devices, transfer. Protocols, monitor); 1. 3. 2006 9
Persistent Store Usage & Runtime. Platforms, that are stored by the Workspaces, are stored with the Persistent. Storage. Provider – plugin. Next example shows, how to access the stored definitions and how to modify them. The model right describes the object model structure of the Runtime. Platform –definitions. 1. 3. 2006 10
Persistent Store Usage & Runtime. Platforms (cont. ) import org. eclipse. mtj. api. extension. Persistent. Store. Provider; import org. eclipse. mtj. api. enumerations. Extension. Type; import org. eclipse. mtj. api. runtimes. Runtime. Platform; . . . Persistent. Store. Provider pstore = (Persistent. Store. Provider)Mtj. Services. get. Instance(). get. Implementations(Extension. Type. PERSISTENT_STORE_PROVIDER_LITERAL, null)[0]; String data. Extension = ”runtimes”; String project. Name = "org. eclipse. mtj. extension. rpm. ui"; String key = ”Mtj. Runtime. Platforms”; EList runtime. Platforms = (EList)pstore. get(Persistent. Store. Provider. DATA_TYPE_EMF, data. Extension , project. Name , key); Runtime. Platform runtime. Platform= (Runtime. Platform) runtime. Platforms. get(0); 1. 3. 2006 11
Persistent Store Usage & Runtime. Platforms (cont. ) import org. eclipse. mtj. api. extension. Persistent. Store. Provider; import org. eclipse. mtj. api. enumerations. Extension. Type; import org. eclipse. mtj. api. runtimes. Runtime. Platform; . . . Persistent. Store. Provider pstore; Elist runtime. Platforms; Runtime. Platform new. Runtime. Platform; . . . runtime. Platforms. add(new. Runtime. Platform); String data. Extension = ”runtimes”; String project. Name = "org. eclipse. mtj. extension. rpm. ui"; String key = ”Mtj. Runtime. Platforms”; pstore( runtime. Platforms , Persistent. Store. Provider. DATA_TYPE_EMF, data. Extension , project. Name , key); 1. 3. 2006 12
Get Admin GUI import org. eclipse. mtj. api. extension. Device. Management; import org. eclipse. mtj. api. enumerations. Extension. Type; import org. eclipse. mtj. api. extension. Mtj. Extension; import org. eclipse. mtj. core. Mtj. Services; import org. eclipse. swt. widgets. Composite; import org. eclipse. SWT; . . . Device. Management mtj. Extension = null; Composite composite; Admin. Gui. Provider admin. Gui. Provider = Mtj. Services. get. Instance(). get. Corresponding. Admin. Gui. Provider(Mtj. Extension extension); Composite composite = admin. Gui. Provider. create(Composite composite, SWT. NONE); 1. 3. 2006 13
- Slides: 13