1 / 13

Mobile Tools for the Java Platform

Mobile Tools for the Java Platform. Coding Examples Version 0. 3. Get Extension Implementation. import org.eclipse.mtj.api.extension.DeviceManagement; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.extension.MtjExtension;

chen
Download Presentation

Mobile Tools for the Java Platform

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mobile Tools forthe Java Platform Coding Examples Version 0.3

  2. Get Extension Implementation import org.eclipse.mtj.api.extension.DeviceManagement; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.extension.MtjExtension; import org.eclipse.mtj.core.MtjServices; ... String version = null; String vendor = null; boolean onlyActive = true; MtjExtension[] list = MtjServices.getInstance() .getImplementations(ExtensionType.DEVICE_MANAGEMENT_LITERAL, version, vendor, onlyActive); DeviceManagement deviceManagement = (DeviceManagement ) list[0];

  3. Get DevicePlatform, Device and RuntimePlatform DevicePlatforms, that are defined by DevicePlatformProviders, define their content with specific data model. The model right describes the main parts of the object model structure of the DevicePlatform –definition.

  4. Get DevicePlatform, Device and RuntimePlatform (cont.) import org.eclipse.mtj.api.extension.DeviceManagement; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.extension.MtjExtension; import org.eclipse.mtj.core.MtjServices; import org.eclipse.mtj.api.devices.Device; import org.eclipse.mtj.api.devices.DevicePlatform; import org.eclipse.mtj.api.runtimes.RuntimePlatformDefinition; ... DeviceManagement deviceManagement = (DeviceManagement) MtjServices.getInstance() .getImplementations(ExtensionType.DEVICE_MANAGEMENT_LITERAL,null,null)[0]; DevicePlatform[] devicePlatform = deviceManagement .getDevicePlatforms()[0]; Device device = devicePlatform.getDevices().get(1); RuntimePlatformDefinition runtimePlatformDefinition = device .getRuntimePlatformDefinitions().get(1);

  5. 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.

  6. Modify Project Data (cont.) import org.eclipse.jdt.core.IJavaProject; import org.eclipse.mtj.api.model.IMtjProject; import org.eclipse.mtj.core.project.MtjProject; import org.eclipse.mtj.api.project.Project; ... IJavaProject javaProject; ... IMtjProject mtjProject = MtjProject.getMtjProject(javaProject); Project project = mtjProject.getProjectData(); ObfuscationDetail obfuscationDetail = new ObfuscationDetail(); obfuscationDetail.setLevel(1); project.setObfuscationDetail(obfuscationDetail); mtjProject.setProjectData(project);

  7. Add Runtime Platform Definition To Project import org.eclipse.mtj.api.devices.Device; import org.eclipse.mtj.api.devices.DevicePlatform; import org.eclipse.mtj.api.runtimes.RuntimePlatformDefinition; import org.eclipse.mtj.api.project.Project; import org.eclipse.mtj.api.project.ProjectFactory; import org.eclipse.mtj.api.project.TargetDevice; import org.eclipse.mtj.core.util.MtjEmfUtil; ... Project project; DevicePlatform devicePlatform; Device device; RuntimePlatformDefinition runtimePlatformDefinition; ... TargetDevice targetDevice = ProjectFactory.eINSTANCE.createTargetDevice(); targetDevice.setName(”Nokia S80 Device”); targetDevice.setDevicePlatformName(devicePlatform.getName()); targetDevice.setDeviceName(device.getName()); // create a project specific copy of the RuntimePlatformDefinition RuntimePlatformDefinition copyRPD = MtjEmfUtil.clone(runtimePlatformDefinition); targetDevice.setRuntimePlatform(copyRPD); mtjProject.setProjectData(project);

  8. Get Project’s Default Targets import org.eclipse.jdt.core.IJavaProject; import org.eclipse.mtj.api.model.IMtjProject; import org.eclipse.mtj.core.project.MtjProject; import org.eclipse.mtj.api.project.Project; import org.eclipse.mtj.api.devices.Device; import org.eclipse.mtj.api.devices.DevicePlatform; import org.eclipse.mtj.api.runtimes.RuntimePlatformDefinition; ... IJavaProject javaProject; ... IMtjProject mtjProject = MtjProject.getMtjProject(javaProject); DevicePlatform devicePlatform = mtjProject.getPlatformDefinition(); Device device = mtjProject.getDefaultDevice(); RuntimePlatformDefinition runtimePlatformDefinition = mtjProject.getProjectData().getDefaultTargetDevice().getRuntimePlatform();

  9. Deploy Project’s Data import org.eclipse.mtj.api.model.IMtjProject; import org.eclipse.mtj.api.devices.Device; import org.eclipse.mtj.api.extension. DeploymentManagement ; import org.eclipse.mtj.api.runtimes.RuntimePlatformDefinition; import org.eclipse.mtj.api.enumerations.DeviceCommunicationProtocol; import org.eclipse.core.runtime.IProgressMonitor; ... IMtjProject mtjProject; ... RuntimePlatformDefinition runtimePlatformDefinition = mtjProject.getProjectData().getDefaultTargetDevice().getRuntimePlatform(); DeploymentManagement deploymentManagement = (DeploymentManagement)MtjServices.getInstance() .getImplementations(ExtensionType.DEPLOYMENT_MANAGEMENT_LITERAL,null,null)[0]; Device[] devices = deploymentManagement.getTargetDevices(runtimePlatformDefinition); DeviceCommunicationProtocol[] transferProtocols = null; IProgressMonitor monitor = null; deploymentManagement.deploy(mtjProject. getDeployment(), devices, transferProtocols, monitor);

  10. Persistent Store Usage & RuntimePlatforms RuntimePlatforms, that are stored by the Workspaces, are stored with the PersistentStorageProvider –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 RuntimePlatform –definitions.

  11. Persistent Store Usage & RuntimePlatforms (cont.) import org.eclipse.mtj.api.extension.PersistentStoreProvider; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.runtimes.RuntimePlatform; ... PersistentStoreProvider pstore = (PersistentStoreProvider)MtjServices.getInstance() .getImplementations(ExtensionType.PERSISTENT_STORE_PROVIDER_LITERAL,null,null)[0]; String dataExtension = ”runtimes”; String projectName = "org.eclipse.mtj.extension.rpm.ui"; String key = ”MtjRuntimePlatforms”; EList runtimePlatforms = (EList)pstore.get(PersistentStoreProvider.DATA_TYPE_EMF, dataExtension , projectName , key); RuntimePlatform runtimePlatform= (RuntimePlatform) runtimePlatforms.get(0);

  12. Persistent Store Usage & RuntimePlatforms (cont.) import org.eclipse.mtj.api.extension.PersistentStoreProvider; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.runtimes.RuntimePlatform; ... PersistentStoreProvider pstore; Elist runtimePlatforms; RuntimePlatform newRuntimePlatform; ... runtimePlatforms.add(newRuntimePlatform); String dataExtension = ”runtimes”; String projectName = "org.eclipse.mtj.extension.rpm.ui"; String key = ”MtjRuntimePlatforms”; pstore.store( runtimePlatforms , PersistentStoreProvider.DATA_TYPE_EMF, dataExtension , projectName , key);

  13. Get Admin GUI import org.eclipse.mtj.api.extension.DeviceManagement; import org.eclipse.mtj.api.enumerations.ExtensionType; import org.eclipse.mtj.api.extension.MtjExtension; import org.eclipse.mtj.core.MtjServices; import org.eclipse.swt.widgets.Composite; import org.eclipse.SWT; ... DeviceManagement mtjExtension = null; Composite composite; AdminGuiProvider adminGuiProvider = MtjServices.getInstance() .getCorrespondingAdminGuiProvider(MtjExtension extension); Composite composite = adminGuiProvider.create(Composite composite, SWT.NONE);

More Related