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.wrttools.wizards.deploy; |
|
20 |
|
21 import java.text.MessageFormat; |
|
22 |
|
23 import org.eclipse.core.runtime.IProgressMonitor; |
|
24 import org.eclipse.core.runtime.IStatus; |
|
25 import org.eclipse.core.runtime.Status; |
|
26 import org.eclipse.swt.graphics.Image; |
|
27 import org.eclipse.swt.program.Program; |
|
28 import org.eclipse.swt.widgets.Display; |
|
29 import org.symbian.tools.wrttools.core.deployer.DeployException; |
|
30 import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer; |
|
31 import org.symbian.tools.wrttools.core.deployer.WidgetDeployer; |
|
32 import org.symbian.tools.wrttools.core.status.IWRTStatusListener; |
|
33 |
|
34 public class ProgramTarget extends DeploymentTarget { |
|
35 public class Deployer extends WidgetDeployer { |
|
36 public IStatus deploy(String inputPath, String destinationPath, IProgressMonitor progressMonitor) |
|
37 throws DeployException { |
|
38 emitStatus(MessageFormat.format("Running {0}", program.getName())); |
|
39 boolean b = program.execute(inputPath); |
|
40 System.out.println(b); |
|
41 return Status.OK_STATUS; |
|
42 } |
|
43 } |
|
44 |
|
45 private static ProgramTarget instance; |
|
46 |
|
47 private final Program program; |
|
48 private Image image; |
|
49 |
|
50 private ProgramTarget(Program program) { |
|
51 super(program.getName()); |
|
52 this.program = program; |
|
53 } |
|
54 |
|
55 public static ProgramTarget getInstance() { |
|
56 if (instance == null) { |
|
57 Program program = Program.findProgram("wgz"); |
|
58 if (program != null) { |
|
59 instance = new ProgramTarget(program); |
|
60 } |
|
61 } |
|
62 return instance; |
|
63 } |
|
64 |
|
65 @Override |
|
66 public IWidgetDeployer createDeployer(IWRTStatusListener statusListener) { |
|
67 Deployer deployer = new Deployer(); |
|
68 deployer.setStatusListener(statusListener); |
|
69 return deployer; |
|
70 } |
|
71 |
|
72 @Override |
|
73 public String getDescription() { |
|
74 return "External application will be used to deploy the widget"; |
|
75 } |
|
76 |
|
77 @Override |
|
78 public String getType() { |
|
79 return "program"; |
|
80 } |
|
81 |
|
82 @Override |
|
83 public Image getIcon() { |
|
84 if (image == null || image.isDisposed()) { |
|
85 Display current = Display.getCurrent(); |
|
86 image = new Image(current, program.getImageData()); |
|
87 } |
|
88 return image; |
|
89 } |
|
90 |
|
91 public String getDeployMessage() { |
|
92 return "Packaged WGZ archive was passed to external application. Follow application prompts to deploy WGZ file."; |
|
93 } |
|
94 } |
|