1 /** |
|
2 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Symbian Foundation - initial contribution. |
|
11 * Contributors: |
|
12 * Description: |
|
13 * Overview: |
|
14 * Details: |
|
15 * Platforms/Drives/Compatibility: |
|
16 * Assumptions/Requirement/Pre-requisites: |
|
17 * Failures and causes: |
|
18 */ |
|
19 package org.symbian.tools.mtw.internal.deployment.externalapp; |
|
20 |
|
21 import java.io.File; |
|
22 |
|
23 import org.eclipse.core.runtime.CoreException; |
|
24 import org.eclipse.core.runtime.IProgressMonitor; |
|
25 import org.eclipse.core.runtime.IStatus; |
|
26 import org.eclipse.core.runtime.PlatformObject; |
|
27 import org.eclipse.core.runtime.Status; |
|
28 import org.eclipse.core.runtime.jobs.ISchedulingRule; |
|
29 import org.eclipse.swt.program.Program; |
|
30 import org.eclipse.ui.IMemento; |
|
31 import org.symbian.tools.mtw.core.MTWCore; |
|
32 import org.symbian.tools.mtw.core.projects.IMTWProject; |
|
33 import org.symbian.tools.mtw.core.runtimes.IPackager; |
|
34 import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget; |
|
35 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType; |
|
36 |
|
37 public class ExternalApplicationDeploymentType extends PlatformObject implements IDeploymentTargetType, |
|
38 IDeploymentTarget { |
|
39 |
|
40 private IMTWProject project; |
|
41 |
|
42 public IStatus deploy(IMTWProject project, IPackager packager, IProgressMonitor monitor) |
|
43 throws CoreException { |
|
44 Program app = getExternalApp(project); |
|
45 File file = packager.packageApplication(project, monitor); |
|
46 if (file != null) { |
|
47 app.execute(file.toString()); |
|
48 return new Status( |
|
49 IStatus.OK, |
|
50 MTWCore.PLUGIN_ID, |
|
51 "Mobile web application was passed as an argument to external application. Please follow its prompts to complete deployment."); |
|
52 } else { |
|
53 return new Status(IStatus.ERROR, MTWCore.PLUGIN_ID, "Application packaging failed"); |
|
54 } |
|
55 } |
|
56 |
|
57 public void discoverTargets(IProgressMonitor monitor) throws CoreException { |
|
58 // Do nothing |
|
59 } |
|
60 |
|
61 public IDeploymentTarget findTarget(IMTWProject project, String id) { |
|
62 if (getExternalApp(project) != null) { |
|
63 return this; |
|
64 } else { |
|
65 return null; |
|
66 } |
|
67 } |
|
68 |
|
69 public String getDescription() { |
|
70 return getExternalApp(project).getName(); |
|
71 } |
|
72 |
|
73 private Program getExternalApp(IMTWProject project) { |
|
74 this.project = project; |
|
75 IPackager packager = MTWCore.getDefault().getRuntimesManager().getPackager(project); |
|
76 if (packager != null) { |
|
77 return Program.findProgram(packager.getFileType(project)); |
|
78 } else { |
|
79 return null; |
|
80 } |
|
81 } |
|
82 |
|
83 public String getId() { |
|
84 return "mtw.externalapp"; |
|
85 } |
|
86 |
|
87 public String getName() { |
|
88 return "Use external application"; |
|
89 } |
|
90 |
|
91 public Program getProgram() { |
|
92 return getExternalApp(project); |
|
93 } |
|
94 |
|
95 public ISchedulingRule getSchedulingRule(IDeploymentTarget target) { |
|
96 return null; |
|
97 } |
|
98 |
|
99 public IDeploymentTarget[] getTargets(IMTWProject project) { |
|
100 if (getExternalApp(project) != null) { |
|
101 return new IDeploymentTarget[] { this }; |
|
102 } else { |
|
103 return null; |
|
104 } |
|
105 } |
|
106 |
|
107 public void load(IMemento memento) { |
|
108 // Do nothing |
|
109 } |
|
110 |
|
111 public void save(IMemento memento) { |
|
112 // Do nothing |
|
113 } |
|
114 |
|
115 public boolean targetsDiscovered() { |
|
116 return true; |
|
117 } |
|
118 } |
|