--- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Mon Mar 15 16:38:54 2010 -0700
@@ -22,7 +22,8 @@
org.eclipse.wst.xml.core;bundle-version="1.1.400",
org.eclipse.ui.navigator;bundle-version="3.4.0",
org.eclipse.ui.navigator.resources;bundle-version="3.4.0",
- org.w3c.css;bundle-version="1.0.0"
+ org.w3c.css;bundle-version="1.0.0",
+ org.eclipse.core.expressions;bundle-version="3.4.101"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
Bundle-ActivationPolicy: lazy
Binary file org.symbian.tools.wrttools/icons/bluetooth.gif has changed
--- a/org.symbian.tools.wrttools/plugin.xml Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/plugin.xml Mon Mar 15 16:38:54 2010 -0700
@@ -3,24 +3,6 @@
<plugin>
<!-- Generic Project Builder and Project Natures -->
- <extension id="PropertiesFileAuditor" name="Properties File Auditor Project Builder"
- point="org.eclipse.core.resources.builders">
- <builder hasNature="true">
- <run class="org.symbian.tools.wrttools.builder.PropertiesFileAuditor">
- </run>
- </builder>
- </extension>
- <extension id="PropertiesAuditorNature" name="Properties Auditor Nature"
- point="org.eclipse.core.resources.natures">
- <runtime>
- <run class="org.symbian.tools.wrttools.builder.PropertiesAuditorNature">
- </run>
- </runtime>
- <requires-nature id="org.eclipse.wst.jsdt.core.jsNature" />
- <requires-nature id="org.eclipse.pde.PluginNature" />
- <builder id="org.symbian.tools.wrttools.PropertiesFileAuditor">
- </builder>
- </extension>
<!-- Widget Project Nature -->
<extension
@@ -59,18 +41,6 @@
class="org.symbian.tools.wrttools.core.WrtIdeCorePreferences">
</initializer>
</extension>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.symbian.tools.wrttools.editing.preferences.WrtEditingPreferencePage"
- class="org.symbian.tools.wrttools.core.deploy.DeployPreferencePage"
- id="org.symbian.tools.wrttools.core.deploy.DeployPreferencePage"
- name="Deployment ">
- <keywordReference
- id="org.symbian.tools.wrttools.wrtwords">
- </keywordReference>
- </page>
- </extension>
<!-- WRT Tool Integration (Package, Validate, Include, Exclude Settings)-->
<extension
@@ -92,22 +62,6 @@
</objectContribution>
-->
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
- id="org.symbian.tools.wrttools.widget.wrttool.deploy">
- <filter
- name="projectNature"
- value="org.symbian.tools.wrttools.WidgetProjectNature"/>
-
- <action
- class="org.symbian.tools.wrttools.core.deploy.WrtDeployActionDelegate"
- enablesFor="+"
- icon="icons/deploy_widget.gif"
- id="org.symbian.tools.wrttools.widget.deploy.WrtProjectDeployActionDelegate"
- label="Deploy WRT Application"
- menubarPath="org.symbian.tools.wrttools.contextMenuGroupMarker">
- </action>
- </objectContribution>
<objectContribution
objectClass="org.eclipse.core.resources.IResource"
@@ -683,4 +637,75 @@
class="org.symbian.tools.wrttools.core.libraries.PlatformServicesTypeProvider">
</inferenceProvider>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ id="org.symbian.tools.wrttools.commands.maincategory"
+ name="WRT Tools">
+ </category>
+ <command
+ categoryId="org.symbian.tools.wrttools.commands.maincategory"
+ description="Deploys application to phone or emulator"
+ id="org.symbian.tools.wrttools.commands.deploy"
+ name="Deploy Application">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar">
+ <toolbar
+ id="org.symbian.tools.wrttools">
+ <command
+ commandId="org.symbian.tools.wrttools.commands.deploy"
+ icon="icons/deploy_widget.gif"
+ id="org.symbian.tools.wrttools.toolbars.deploy"
+ label="Deploy"
+ tooltip="Deploy application">
+ </command>
+ </toolbar>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.symbian.tools.wrttools.handlers.DeployHandler"
+ commandId="org.symbian.tools.wrttools.commands.deploy">
+ <enabledWhen>
+ <or>
+ <with
+ variable="selection">
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.symbian.tools.wrttools.WidgetProjectNature">
+ </test>
+ </adapt>
+ </iterate>
+ </and>
+ </with>
+ <and>
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.ui.IEditorPart">
+ </instanceof>
+ </with>
+ <with
+ variable="activeEditorInput">
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ </adapt>
+ </with>
+ </and>
+ </or>
+ </enabledWhen>
+ </handler>
+ </extension>
</plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/WRTProject.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.InvalidPropertiesFormatException;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.symbian.tools.wrttools.wizards.deploy.DeploymentTarget;
+import org.symbian.tools.wrttools.wizards.deploy.DeploymentTargetRegistry;
+
+public class WRTProject {
+ private static final IPath PROPERTIES_FILE = new Path(".settings").append(Activator.PLUGIN_ID + ".properties");
+ private static final String PROP_DEPLOYMENT_TARGET_NAME = "deployment.target.name";
+ private static final String PROP_DEPLOYMENT_TARGET_TYPE = "deployment.target.type";
+ private final IProject project;
+
+ public WRTProject(IProject project) {
+ this.project = project;
+ }
+
+ private Properties getProps() {
+ Properties props = new Properties();
+ IFile file = project.getFile(PROPERTIES_FILE);
+ if (file.exists()) {
+ try {
+ InputStream contents = file.getContents();
+ try {
+ props.loadFromXML(contents);
+ } finally {
+ contents.close();
+ }
+ } catch (InvalidPropertiesFormatException e) {
+ Activator.log(e);
+ } catch (IOException e) {
+ Activator.log(e);
+ } catch (CoreException e) {
+ Activator.log(e);
+ }
+ }
+ return props;
+ }
+
+ public void setDeploymentTarget(DeploymentTarget target) {
+ Properties props = getProps();
+ props.setProperty(PROP_DEPLOYMENT_TARGET_NAME, target.getName());
+ props.setProperty(PROP_DEPLOYMENT_TARGET_TYPE, target.getType());
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setValue(PROP_DEPLOYMENT_TARGET_NAME, target.getName());
+ store.setValue(PROP_DEPLOYMENT_TARGET_TYPE, target.getType());
+ saveProperties(props);
+ }
+
+ public DeploymentTarget getDeploymentTarget() {
+ Properties props = getProps();
+ String property = props.getProperty(PROP_DEPLOYMENT_TARGET_NAME);
+ if (property != null) {
+ return DeploymentTargetRegistry.getRegistry().findTarget(property,
+ props.getProperty(PROP_DEPLOYMENT_TARGET_TYPE));
+ } else {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String name = store.getString(PROP_DEPLOYMENT_TARGET_NAME);
+ if (name != null) {
+ return DeploymentTargetRegistry.getRegistry().findTarget(name,
+ store.getString(PROP_DEPLOYMENT_TARGET_TYPE));
+ }
+
+ }
+ return null;
+ }
+
+ private void saveProperties(Properties props) {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try {
+ props.storeToXML(stream, null);
+ IFile file = project.getFile(PROPERTIES_FILE);
+ if (!file.exists()) {
+ file.create(new ByteArrayInputStream(stream.toByteArray()), false, new NullProgressMonitor());
+ } else {
+ file
+ .setContents(new ByteArrayInputStream(stream.toByteArray()), false, true,
+ new NullProgressMonitor());
+ }
+ } catch (IOException e) {
+ Activator.log(e);
+ } catch (CoreException e) {
+ Activator.log(e);
+ }
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/WRTImages.java Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/WRTImages.java Mon Mar 15 16:38:54 2010 -0700
@@ -20,17 +20,22 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
import org.symbian.tools.wrttools.Activator;
public class WRTImages {
private static final String IMAGE_IMPORT_WIZARD_BANNER = "import_wizard_banner.png";
private static final String IMAGE_IMPORT_WGZ_BANNER = "import_w_banner.png";
private static final String IMAGE_NEW_WIZARD_BANNER = "WRT_wizard_banner.png";
+ private static final String IMAGE_EMULATOR = "deploy_widget.gif";
+ private static final String IMAGE_BLUETOOTH = "bluetooth.gif";
public static void init(ImageRegistry reg) {
add(reg, IMAGE_IMPORT_WIZARD_BANNER);
add(reg, IMAGE_IMPORT_WGZ_BANNER);
add(reg, IMAGE_NEW_WIZARD_BANNER);
+ add(reg, IMAGE_EMULATOR);
+ add(reg, IMAGE_BLUETOOTH);
}
private static void add(ImageRegistry reg, String key) {
@@ -49,4 +54,12 @@
return Activator.getDefault().getImageRegistry().getDescriptor(IMAGE_NEW_WIZARD_BANNER);
}
+ public static Image getEmulatorImage() {
+ return Activator.getDefault().getImageRegistry().get(IMAGE_EMULATOR);
+ }
+
+ public static Image getBluetoothImage() {
+ return Activator.getDefault().getImageRegistry().get(IMAGE_BLUETOOTH);
+ }
+
}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/WrtDeployActionDelegate.java Fri Mar 12 10:14:08 2010 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-/**
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-
-package org.symbian.tools.wrttools.core.deploy;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobChangeListener;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionDelegate;
-
-import org.symbian.tools.wrttools.sdt.utils.Logging;
-import org.symbian.tools.wrttools.Activator;
-import org.symbian.tools.wrttools.WRTStatusListener;
-import org.symbian.tools.wrttools.core.deployer.DeployException;
-import org.symbian.tools.wrttools.core.deployer.DeployerMessages;
-import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
-import org.symbian.tools.wrttools.core.deployer.WidgetDeployerFactory;
-import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
-
-public class WrtDeployActionDelegate extends ActionDelegate implements IObjectActionDelegate {
-
- private Shell shell;
- private static Job job;
-
- public void run(IAction action) {
- PlatformUI.getWorkbench().saveAllEditors(true);
- deploy();
- }
-
- /**
- * deploys the actual widget.
- */
- @SuppressWarnings("restriction")
- private void deploy() {
- String destinationPath = null;
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String deployerType = store.getString(PreferenceConstants.WRT_DEPLOY_CHOICE);
-
- if (deployerType.equalsIgnoreCase(PreferenceConstants.WRT_DEPLOY_CHOICE_EMULATOR)) {
- destinationPath = store.getString(PreferenceConstants.SELECTED_EMULATOR_PATH);
- } else if (deployerType.equalsIgnoreCase(PreferenceConstants.WRT_DEPLOY_CHOICE_DEVICE)) {
- destinationPath = store.getString(PreferenceConstants.SELECTED_DEVICE_NAME);
- }
-
- if (destinationPath != null
- && destinationPath.length() > 0
- && !destinationPath.equalsIgnoreCase(DeployMessages.getString("View.none.text"))) {
- job = new DeployJob("Deploying widget", destinationPath, deployerType);
- job.setUser(true);
- job.schedule();
- job.addJobChangeListener(new IJobChangeListener() {
- public void sleeping(IJobChangeEvent event) {}
- public void awake(IJobChangeEvent event) {
- }
- public void aboutToRun(IJobChangeEvent event) {
- }
- public void scheduled(IJobChangeEvent event) {
- }
- public void running(IJobChangeEvent event) {
- }
- public void done(IJobChangeEvent event) {
- /*synchronized (job) {
- job.notify();}*/
- }
- });
-
- } else {
- MessageDialog.openInformation(shell, "Deploy error",
- " Invalid deployment preferences. Use \"Preferences\"->\"WRT\"->\"Deployment\" to set deployment preferences.");
- }
- }
-
- @SuppressWarnings("unchecked")
- public void selectionChanged(IAction action, ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- DeployJob.projectList.clear();
- DeployJob.wgzList.clear();
- IStructuredSelection ss = (IStructuredSelection) selection;
- for (Iterator iter = ss.iterator(); iter.hasNext();) {
- Object obj = iter.next();
- if (obj instanceof IProject) {
- // multi project selection enabled
- DeployJob.projectList.add((IProject) obj);
- }
- if (obj instanceof IFile) {
- // multi wgz selection enabled
- IFile wgzFile = (IFile) obj;
- if(wgzFile.getName().endsWith("wgz")){
- DeployJob.wgzList.add((IFile) obj);}
- }
- }
- }
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- private static final class DeployJob extends Job {
- //private String widgetPackagedPath;
- private final String destination;
- private final String deployType;
-
- public static List<IProject> projectList = new ArrayList<IProject>();
- public static List<IFile> wgzList = new ArrayList<IFile>();
-
- private WrtPackageActionDelegate packagerAction = new WrtPackageActionDelegate();
-
- private DeployJob(String name, String deployDestination, String deployType) {
- super(name);
- //this.widgetPackagedPath = widgetPackagedPath;
- this.destination = deployDestination;
- this.deployType = deployType;
- }
-
- public IStatus run(IProgressMonitor monitor) {
- WRTStatusListener statusListener = new WRTStatusListener();
- IWidgetDeployer wd = WidgetDeployerFactory.createWidgetDeployer(deployType, statusListener);
- IStatus result = new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null);
-
- if (projectList != null && projectList.size() > 0) {
- for (IProject project : projectList) {
- if (project != null) {
- /* package the files before deployment */
- boolean packageSuccess = packagerAction.packageProject(project);
- if (!packageSuccess) {
- continue;
- }
- String packagedPath;
- try {
- IPath wgzPath = new Path(project.getName() + ".wgz");
- IFile wgz = project.getFile(wgzPath);
- packagedPath = wgz.getLocation().toFile().getCanonicalFile().toString();
- try {
- result = wd.deploy(packagedPath, destination, monitor);
- if (result.isOK()) {
- job.setName("Deployment Completed");
- } else if (result.getCode() == IStatus.CANCEL){
- job.setName("Deployment Cancelled");
- }
- } catch (DeployException e) {
- result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getMessage(), e);
- Logging.log(Activator.getDefault(), result);
- }
- } catch (IOException e) {
- Activator.log(IStatus.ERROR, "Error deploying widget", e);
- }
- }
- }
- }
- if (wgzList != null && wgzList.size() > 0) {
- for (IFile wgzFile : wgzList) {
- File wgzF = new File(wgzFile.getLocation().toString());
- if(!wgzF.exists()){
- if (wgzList != null && wgzList.size() > 0) {
- IProject project = wgzFile.getProject();
- if (project != null) {
- boolean packageSuccess=packagerAction.packageProject(project);// check & handle if the file is deleted outside aptana
- if(!packageSuccess)
- {
- continue;
- }
- }
- }
- }
- if (wgzFile.exists()) {
- String packagedPath;
- try {
- packagedPath = wgzFile.getLocation().toFile().getCanonicalFile().toString();
-
- try {
- result = wd.deploy(packagedPath, destination, monitor);
- if (result.isOK()) {
- job.setName("Deployment Completed");
- } else if (result.getCode() == IStatus.CANCEL){
- job.setName("Deployment Cancelled");
- }
- } catch (DeployException e) {
- result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getMessage(), e);
- Logging.log(Activator.getDefault(), result);
- }
- } catch (IOException e) {
- Activator.log(IStatus.ERROR, "Error deploying widget", e);
- }
- }
- }
- }
- statusListener.close();
- return result;
- }
- }
-}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java Mon Mar 15 16:38:54 2010 -0700
@@ -19,10 +19,10 @@
package org.symbian.tools.wrttools.core.deploy.device;
+import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.MessageFormat;
@@ -37,9 +37,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-
import org.symbian.tools.wrttools.Activator;
import org.symbian.tools.wrttools.core.deployer.DeployerMessages;
import org.symbian.tools.wrttools.core.deployer.IWidgetDeployerConstants;
@@ -174,7 +171,7 @@
os.close();
long elapsed = System.currentTimeMillis() - start;
- emitStatus("elapsed time: " + (double)elapsed/1000.0 + " seconds");
+ emitStatus("elapsed time: " + elapsed/1000.0 + " seconds");
int responseCode = putOperation.getResponseCode();
if (responseCode == ResponseCodes.OBEX_HTTP_OK) {
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/WrtPackageActionDelegate.java Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/WrtPackageActionDelegate.java Mon Mar 15 16:38:54 2010 -0700
@@ -45,6 +45,7 @@
import org.symbian.tools.wrttools.Activator;
import org.symbian.tools.wrttools.WRTStatusListener;
import org.symbian.tools.wrttools.core.status.IWRTConstants;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
import org.symbian.tools.wrttools.core.status.WRTStatus;
public class WrtPackageActionDelegate extends ActionDelegate implements
@@ -63,13 +64,14 @@
if (projectList != null && projectList.size() > 0) {
for (IProject project : projectList) {
if (project != null) {
- packageProject( project);
+ WRTStatusListener statusListener = new WRTStatusListener();
+ packageProject(project, statusListener);
}
}
}
}
- public boolean packageProject(IProject project) {
+ public boolean packageProject(IProject project, IWRTStatusListener statusListener) {
boolean packaedSucess=false;
if (project != null) {
try {
@@ -138,7 +140,6 @@
String projectPath = project.getLocation().toString();
String prjName = project.getName();
String dprojectPath = projectPath+"/"+prjName;
- WRTStatusListener statusListener = new WRTStatusListener();
WidgetPackager widgetPackager = new WidgetPackager(statusListener);
try {
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/status/IWRTStatusListener.java Fri Mar 12 10:14:08 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/status/IWRTStatusListener.java Mon Mar 15 16:38:54 2010 -0700
@@ -34,4 +34,6 @@
* @param status
*/
public void emitStatus(WRTStatus status);
+
+ public void close();
}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/ValidateAction.java Fri Mar 12 10:14:08 2010 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,300 +0,0 @@
-/**
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-package org.symbian.tools.wrttools.core.validator;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-import org.symbian.tools.wrttools.Activator;
-import org.symbian.tools.wrttools.core.exception.ReportException;
-import org.symbian.tools.wrttools.core.exception.ValidationException;
-import org.symbian.tools.wrttools.core.marker.MarkerUtil;
-import org.symbian.tools.wrttools.core.packager.WRTPackagerConstants;
-import org.symbian.tools.wrttools.core.report.IMessageListener;
-import org.symbian.tools.wrttools.core.report.Message;
-import org.symbian.tools.wrttools.core.status.IWRTConstants;
-import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
-import org.symbian.tools.wrttools.core.status.WRTStatus;
-import org.symbian.tools.wrttools.core.status.WRTStatus;
-import org.symbian.tools.wrttools.core.validator.Messages;
-public class ValidateAction implements IObjectActionDelegate {
-
-// WRTStatusListener statusListener = new WRTStatusListener();
- private StatusListener statusListener = new StatusListener();
- public MessageListener messageListener = new MessageListener();
- private final List<IProject> projectList = new ArrayList<IProject>();
-// private String widgetProjectPath;
- IProject projectvalidating =null;
- private Shell shell;
-
- private boolean validateSucess=false;
- private boolean initialValidate;
-
-
- public ValidateAction() {
- super();
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public void run(IAction action) {
- try{
- PlatformUI.getWorkbench().saveAllEditors(true);
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.views.ProblemView");
- }
- catch(PartInitException e)
- {
- Activator.log(IStatus.ERROR, "Problem View exception", e);
- }
- IProject emptyfilesProject = null;
- initialValidate = false;
- if (projectList != null && projectList.size() > 0) {
- for (IProject project : projectList) {
- if (project != null) {
- validateSucess=true;
- validateProject( project);
- emptyfilesProject = project;
- }
- }
- }
- /* if all the mandatory files are missing then display error on the screen*/
- if (emptyfilesProject != null && ! initialValidate) {
- WidgetValidator widgetValidator = new WidgetValidator(messageListener, statusListener);
- try {
- widgetValidator.validateWidgetProject(emptyfilesProject.getLocation().toString());
- } catch (ValidationException e) {
- Activator.log(IStatus.ERROR, "Validation exception ", e);
- } catch (ReportException e) {
- Activator.log(IStatus.ERROR, "Report exception", e);
- }
- }
- }
-
- public boolean isValidProject(IProject project) {
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
-
- public void run() {
-
- IWorkbenchWindow dwindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = dwindow.getActivePage();
-
- if (page != null) {
- try {
- page.showView("org.eclipse.ui.views.ProblemView");
- }catch (PartInitException pie) {
- }
- }
- }
- });
-
- validateSucess = true;
- validateProject(project);
-
- return validateSucess;
- }
-
- public void validateProject(IProject project) {
- projectvalidating=project;
-// statusListener.setStatusSource(IWRTConstants.StatusSourceType.VALIDATOR.name());
- messageListener.setMessageSource(IWRTConstants.VALIDATOR);
- WidgetValidator widgetValidator = new WidgetValidator(messageListener, statusListener);
- final List<String> filesToPackage = new ArrayList<String>();
- try {
- project.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- boolean add = true;
- // skip user-excluded and automatically-excluded files
- String value = file
- .getPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY);
- if (value != null) {
- add = false;
- }
- String name = file.getName();
- // skip Aptana temporarily generated files
- if (name.startsWith(".tmp_")) {
- add = false;
- }
- // if(name.endsWith(".wgz")){
- // add = false;
- // }
- if (name.equals("Thumbs.db")) {
- add = false;
- }
- if (add) {
- if (file.getProject().getLocation().toString()
- .endsWith(file.getProject().getName())) {
-
- filesToPackage.add(file.getLocation()
- .toString().substring(
- file.getProject().getLocation()
- .toString().length()
- - file.getProject()
- .getName()
- .length()));
- } else {
- String projectDir = file.getProject()
- .getLocation().toString().substring(
- file.getProject().getLocation()
- .toString()
- .lastIndexOf("/") + 1);
- String fullpath = file.getFullPath().toString();
- fullpath = fullpath.substring(fullpath
- .indexOf(file.getProject().getName())
- + file.getProject().getName().length());
- fullpath = projectDir + fullpath;
- filesToPackage.add(fullpath);
-
- }
- }
- }
- return true;
- }
- });
- }
- catch (CoreException x) {
- Activator.log(IStatus.ERROR, "Core Exception ", x);
- }
- if (filesToPackage != null && filesToPackage.size() > 0) {
- widgetValidator.setFilesSelected(filesToPackage);
-
- try {
- MarkerUtil.deleteMarker(project);
- widgetValidator.validateWidgetProject(project.getLocation().toString());
- initialValidate = true;
- } catch (ValidationException e) {
- Activator.log(IStatus.ERROR, "Validation exception ", e);
- } catch (ReportException e) {
- Activator.log(IStatus.ERROR, "Report exception", e);
- }
-
- if (validateSucess) {
-// WRTStatus status = new WRTStatus();
-// status.setStatusSource(IWRTConstants.StatusSourceType.VALIDATOR.name());
-// status.setStatusDescription("Validation completed, no errors were found.");
-// status.setStatusDescription(Messages.getString("widget.validation.complete"));
-// statusListener.emitStatus(status);
- }
- }
- else {
- if(shell != null)
- MessageDialog.openInformation(shell,"Validate Widget Project","Please Select Files to validate");
- }
-
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- projectList.clear();
- IStructuredSelection ss = (IStructuredSelection) selection;
- for (Iterator iter = ss.iterator(); iter.hasNext();) {
-
- Object obj = iter.next();
- if (obj instanceof IProject) {
- projectList.add((IProject) obj);
-
- }
- }
- }
- }
-
-// -------------------------------inner class-------------------------------------//
-
- public class MessageListener implements IMessageListener {
- private int messageSource;
- public int getMessageSource() {
- return 1;
- }
- public void setMessageSource(int messageSource) {
- this.messageSource = messageSource;
- }
- public boolean isMessageHandled(Message msg) {
-
- if (msg.getMessageSource() == (messageSource)) {
- return true;
- }
- return false;
- }
- public void receiveMessage(Message msg) {
- if (IWRTConstants.ERROR.equals(msg.getSeverity())) {
- validateSucess = false;
- }
- MarkerUtil.addMarker(msg, projectvalidating);
- }
- }
-
- public class StatusListener implements IWRTStatusListener {
- private String statusSource;
-
- public String getStatusSource() {
- return statusSource;
- }
-
- public void setStatusSource(String statusSource) {
- this.statusSource = statusSource;
- }
-
- public boolean isStatusHandled(WRTStatus status) {
-//
-// if (status.getStatusSource().equals(statusSource)) {
-// return true;
-// }
- return false;
- }
-
- public void emitStatus(WRTStatus status) {
- // TODO Auto-generated method stub
-
- }
-
-// public void emitStatus(final WRTStatus status) {
-// parentShell.getDisplay().asyncExec(new Runnable(){
-// public void run() {
-// setStatusText(status.getStatusDescription().toString());
-// }
-// });
-// }
- }
-// -------------------------------inner class-------------------------------------//
-
-}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/DeployHandler.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,60 @@
+package org.symbian.tools.wrttools.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.symbian.tools.wrttools.WRTProject;
+import org.symbian.tools.wrttools.wizards.deploy.DeployWizard;
+
+/**
+ * Our sample handler extends AbstractHandler, an IHandler base class.
+ * @see org.eclipse.core.commands.IHandler
+ * @see org.eclipse.core.commands.AbstractHandler
+ */
+public class DeployHandler extends AbstractHandler {
+ /**
+ * The constructor.
+ */
+ public DeployHandler() {
+ }
+
+ /**
+ * the command has been executed, so extract extract the needed information
+ * from the application context.
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+
+ IResource resource = null;
+
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ if (activePart instanceof IEditorPart) {
+ resource = (IResource) ((IEditorPart) activePart).getEditorInput().getAdapter(IResource.class);
+ } else {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Object[] array = ((IStructuredSelection) selection).toArray();
+ if (array.length == 1 && array[0] instanceof IAdaptable) {
+ resource = (IResource) ((IAdaptable) array[0]).getAdapter(IResource.class);
+ }
+ }
+ }
+ if (resource != null) {
+ window.getActivePage().saveAllEditors(true);
+ WizardDialog dialog = new WizardDialog(window.getShell(), new DeployWizard(new WRTProject(resource
+ .getProject())));
+ dialog.open();
+ }
+
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeployWizard.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,170 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.WRTProject;
+import org.symbian.tools.wrttools.core.deployer.DeployException;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+import org.symbian.tools.wrttools.core.status.WRTStatus;
+import org.symbian.tools.wrttools.sdt.utils.Logging;
+
+public class DeployWizard extends Wizard {
+ public class PagePrinter implements IWRTStatusListener {
+ private final DeploymentSummaryWizardPage page;
+
+ public PagePrinter(DeploymentSummaryWizardPage summaryPage) {
+ page = summaryPage;
+ }
+
+ public void emitStatus(WRTStatus status) {
+ page.log(status.getStatusDescription().toString());
+ }
+
+ public boolean isStatusHandled(WRTStatus status) {
+ return true;
+ }
+
+ public void close() {
+ // Do nothing
+ }
+
+ }
+
+ private final DeployWizardContext context;
+ private final DeploymentSummaryWizardPage summaryPage = new DeploymentSummaryWizardPage();
+ private final WRTProject project;
+
+ public DeployWizard(WRTProject project) {
+ this.project = project;
+ setNeedsProgressMonitor(true);
+ setWindowTitle("Deploy WRT Application");
+ context = new DeployWizardContext(project);
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new DeploymentTargetWizardPage(context, project.getDeploymentTarget()));
+ addPage(summaryPage);
+ }
+
+ @Override
+ public boolean performFinish() {
+ summaryPage.clear();
+ getContainer().showPage(summaryPage);
+ return deploy();
+ }
+
+ @Override
+ public boolean needsPreviousAndNextButtons() {
+ return false;
+ }
+
+ /**
+ * deploys the actual widget.
+ */
+ private boolean deploy() {
+ DeploymentTarget target = context.getTarget();
+ DeployJob job = new DeployJob(context.getProject(), target);
+ try {
+ getContainer().run(true, true, job);
+ } catch (InvocationTargetException e) {
+ Activator.log(e);
+ } catch (InterruptedException e) {
+ Activator.log(e);
+ }
+ return job.isSuccessful();
+ }
+
+ private final class DeployJob implements IRunnableWithProgress {
+ private final DeploymentTarget target;
+ private final WrtPackageActionDelegate packagerAction = new WrtPackageActionDelegate();
+ private final IProject project;
+ private boolean successful = false;
+
+ private DeployJob(IProject project, DeploymentTarget deploymentTarget) {
+ this.project = project;
+ this.target = deploymentTarget;
+ }
+
+ public boolean isSuccessful() {
+ return successful;
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ IWRTStatusListener statusListener = new PagePrinter(summaryPage);
+ IWidgetDeployer wd = target.createDeployer(statusListener);
+
+ IStatus result = new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null);
+
+ if (project != null) {
+ /* package the files before deployment */
+ boolean packageSuccess = packagerAction.packageProject(project, statusListener);
+ if (!packageSuccess) {
+ return;
+ }
+ String packagedPath;
+ try {
+ IPath wgzPath = new Path(project.getName() + ".wgz");
+ IFile wgz = project.getFile(wgzPath);
+ packagedPath = wgz.getLocation().toFile().getCanonicalFile().toString();
+ try {
+ result = wd.deploy(packagedPath, target.getName(), monitor);
+ if (result.isOK()) {
+ DeployWizard.this.project.setDeploymentTarget(target);
+ successful = true;
+ signalDeploymentComplete(target);
+ }
+ } catch (DeployException e) {
+ result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getMessage(), e);
+ Logging.log(Activator.getDefault(), result);
+ }
+ } catch (IOException e) {
+ Activator.log(IStatus.ERROR, "Error deploying widget", e);
+ }
+ }
+ }
+
+ }
+
+ private void signalDeploymentComplete(final DeploymentTarget target) {
+ if (target.getDeployMessage() != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openWarning(getShell(), "WRT Application Deployment", target.getDeployMessage());
+ }
+ });
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeployWizardContext.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.symbian.tools.wrttools.WRTProject;
+
+public class DeployWizardContext {
+ private DeploymentTarget target;
+ private final WRTProject project;
+
+ public DeployWizardContext(WRTProject project) {
+ this.project = project;
+ }
+
+ public void setTarget(DeploymentTarget target) {
+ this.target = target;
+ }
+
+ public DeploymentTarget getTarget() {
+ return target;
+ }
+
+ public IProject getProject() {
+ return project.getProject();
+ }
+
+ public DeploymentTarget[] getDeploymentTargets() {
+ return DeploymentTargetRegistry.getRegistry().getDeploymentTargets();
+ }
+
+ public void doSearch(SubProgressMonitor monitor) throws CoreException {
+ DeploymentTargetRegistry.getRegistry().doSearch(monitor);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeploymentSummaryWizardPage.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class DeploymentSummaryWizardPage extends WizardPage {
+ private StringBuilder buffer = new StringBuilder(1000);
+ private Text log;
+
+ protected DeploymentSummaryWizardPage() {
+ super("deploy");
+ setTitle("WRT Application Deployment");
+ setDescription("Please wait while deployment is in progress");
+ }
+
+ public void createControl(Composite parent) {
+ log = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
+ setControl(log);
+ }
+
+ public void log(String line) {
+ synchronized (buffer) {
+ buffer.append(line).append("\n");
+ }
+ log.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ synchronized (buffer) {
+ log.setText(buffer.toString());
+ }
+ }
+ });
+ }
+
+ public void clear() {
+ log.setText("");
+ buffer = new StringBuilder();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeploymentTarget.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import org.eclipse.swt.graphics.Image;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+
+public abstract class DeploymentTarget {
+ private final String name;
+ protected String addr;
+
+ public DeploymentTarget(String name) {
+ this.name = name;
+ }
+
+ public String getAddr() {
+ return addr;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public abstract String getDescription();
+ public abstract IWidgetDeployer createDeployer(IWRTStatusListener statusListener);
+ public abstract String getType();
+ public abstract Image getIcon();
+
+ public boolean isResolved() {
+ return true;
+ }
+
+ public abstract String getDeployMessage();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeploymentTargetRegistry.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,122 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.core.deploy.device.DeployDeviceInfo;
+import org.symbian.tools.wrttools.core.deploy.device.DeviceListProvider;
+import org.symbian.tools.wrttools.core.deploy.emulator.EmulatorListProvider;
+import org.symbian.tools.wrttools.core.deployer.DeployerMessages;
+
+public class DeploymentTargetRegistry {
+ private static DeploymentTargetRegistry INSTANCE;
+
+ public synchronized static DeploymentTargetRegistry getRegistry() {
+ if (INSTANCE == null) {
+ INSTANCE = new DeploymentTargetRegistry();
+ }
+ return INSTANCE;
+ }
+ private final DeploymentTarget[] emulators;
+ private DeploymentTarget[] phones = new DeploymentTarget[0];
+
+ private DeploymentTargetRegistry() {
+ HashMap<String, String> map = EmulatorListProvider.populateEmulators();
+ Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
+ emulators = new DeploymentTarget[map.size()];
+
+ for (int i = 0; i < emulators.length; i++) {
+ emulators[i] = new EmulatorTarget(iterator.next());
+ }
+ }
+
+ public synchronized void doSearch(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Bluetooth search", IProgressMonitor.UNKNOWN);
+ if (DeviceListProvider.isBloothToothConnected()) {
+ loadDevices(monitor);
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, DeployerMessages
+ .getString("Deployer.bluetooth.notconnected.msg")));
+ }
+
+ }
+
+ private DeploymentTarget findOrCreate(DeploymentTarget[] prev, DeployDeviceInfo next) {
+ for (DeploymentTarget deploymentTarget : prev) {
+ if (deploymentTarget instanceof PhoneTarget
+ && deploymentTarget.getName().equals(next.getDeviceName())) {
+ ((PhoneTarget) deploymentTarget).update(next);
+ return deploymentTarget;
+ }
+ }
+ return new PhoneTarget(next);
+ }
+
+ public synchronized DeploymentTarget[] getDeploymentTargets() {
+ ProgramTarget target = ProgramTarget.getInstance();
+ DeploymentTarget[] all = new DeploymentTarget[emulators.length + phones.length + (target != null ? 1 : 0)];
+ System.arraycopy(emulators, 0, all, 0, emulators.length);
+ System.arraycopy(phones, 0, all, emulators.length, phones.length);
+ if (target != null) {
+ all[all.length - 1] = target;
+ }
+ return all;
+ }
+
+ /**
+ * Runs a thread to load the devices present for the deployment.
+ * Does not effect the loading of the UI.
+ * @param device the device earlier saved .
+ * @param monitor
+ */
+ private void loadDevices(IProgressMonitor monitor) {
+ List<DeployDeviceInfo> devices = DeviceListProvider.getDevices(monitor);
+ Iterator<DeployDeviceInfo> iterator = devices.iterator();
+ final DeploymentTarget[] prev = phones;
+ phones = new DeploymentTarget[devices.size()];
+ for (int i = 0; i < phones.length; i++) {
+ phones[i] = findOrCreate(prev, iterator.next());
+ }
+ }
+
+ public DeploymentTarget findTarget(String name, String type) {
+ DeploymentTarget[] targets = getDeploymentTargets();
+ for (DeploymentTarget deploymentTarget : targets) {
+ if (deploymentTarget.getName().equals(name) && deploymentTarget.getType().equals(type)) {
+ return deploymentTarget;
+ }
+ }
+ if (type.equals(PhoneTarget.TYPE) && phones.length == 0) {
+ DeploymentTarget target = new PhoneTarget(name);
+ phones = new DeploymentTarget[] { target };
+ return target;
+ }
+ return null;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeploymentTargetWizardPage.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,235 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.Policy;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.symbian.tools.wrttools.Activator;
+
+public class DeploymentTargetWizardPage extends WizardPage {
+ public class EmulatorBluetoothLabelProvider extends LabelProvider implements ILabelProvider, IColorProvider {
+ @Override
+ public Image getImage(Object element) {
+ return ((DeploymentTarget) element).getIcon();
+ }
+
+ @Override
+ public String getText(Object element) {
+ return ((DeploymentTarget) element).getName();
+ }
+
+ public Color getBackground(Object element) {
+ return null;
+ }
+
+ public Color getForeground(Object element) {
+ Display display = DeploymentTargetWizardPage.this.getContainer().getShell().getDisplay();
+ if (((DeploymentTarget) element).isResolved()) {
+ return null;
+ } else {
+ return display.getSystemColor(SWT.COLOR_DARK_GRAY);
+ }
+ }
+ }
+
+ private final DeployWizardContext context;
+ private TableViewer list;
+ private Text description;
+ private Button enableLogging;
+ private final DeploymentTarget prev;
+
+ public DeploymentTargetWizardPage(DeployWizardContext context, DeploymentTarget prev) {
+ super("TargetPage", "Select Deployment Target", null);
+ this.context = context;
+ this.prev = prev;
+ setDescription(MessageFormat.format("Select emulator or device to deploy WRT application ''{0}''", context
+ .getProject().getName()));
+ }
+
+ public void createControl(Composite parent) {
+ Composite root = new Composite(parent, SWT.NONE);
+
+ root.setLayout(new FormLayout());
+
+ list = new TableViewer(root, SWT.BORDER);
+ list.setContentProvider(new ArrayContentProvider());
+ list.setLabelProvider(new EmulatorBluetoothLabelProvider());
+ list.setSorter(new ViewerSorter() {
+ @Override
+ public int category(Object element) {
+ return ((DeploymentTarget) element).getType().charAt(0);
+ }
+ });
+ list.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = ((IStructuredSelection) event.getSelection());
+ DeploymentTarget target = (DeploymentTarget) selection.getFirstElement();
+ selectDeploymentTarget(target);
+ }
+ });
+ list.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ if (getWizard().performFinish()) {
+ IWizardContainer container = getWizard().getContainer();
+ if (container instanceof WizardDialog) {
+ ((WizardDialog) container).close();
+ }
+ }
+ }
+ });
+ final Button search = new Button(root, SWT.NONE);
+ search.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ doBluetoothSearch(search);
+ }
+ });
+ search.setText("Search");
+
+ description = new Text(root, SWT.BORDER | SWT.READ_ONLY);
+ enableLogging = new Button(root, SWT.CHECK);
+ enableLogging.setText("Enable diagnostic logging");
+ enableLogging.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ toggleLogging();
+ }
+ });
+
+ FormData data = new FormData();
+ data.bottom = new FormAttachment(100, -5);
+ data.left = new FormAttachment(0, 5);
+ enableLogging.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 5);
+ data.right = new FormAttachment(100, -5);
+ data.bottom = new FormAttachment(enableLogging, -20);
+ description.setLayoutData(data);
+
+ data = new FormData();
+ data.top = new FormAttachment(0, 5);
+ data.right = new FormAttachment(100, -5);
+ search.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 5);
+ data.top = new FormAttachment(0, 5);
+ data.bottom = new FormAttachment(description, -10);
+ data.right = new FormAttachment(search, -10);
+
+ list.getControl().setLayoutData(data);
+
+ list.setInput(context.getDeploymentTargets());
+
+ setPageComplete(false);
+ if (prev != null) {
+ list.setSelection(new StructuredSelection(prev));
+ }
+
+ setControl(root);
+ }
+
+ protected void toggleLogging() {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected void doBluetoothSearch(final Button search) {
+ try {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
+ try {
+ context.doSearch(new SubProgressMonitor(monitor, 100));
+ } catch (CoreException e) {
+ Policy.getStatusHandler().show(e.getStatus(), "WRT Application Deployment");
+ }
+ monitor.done();
+ search.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ list.setInput(context.getDeploymentTargets());
+ ISelection selection = list.getSelection();
+ if (selection.isEmpty()) {
+ selectDeploymentTarget(null);
+ } else {
+ selectDeploymentTarget((DeploymentTarget) ((IStructuredSelection) selection)
+ .getFirstElement());
+ }
+ }
+ });
+ }
+ });
+ } catch (InvocationTargetException e) {
+ Activator.log(e);
+ } catch (InterruptedException e) {
+ Activator.log(e);
+ }
+ }
+
+ protected void selectDeploymentTarget(DeploymentTarget target) {
+ if (target != null) {
+ context.setTarget(target);
+ String desc = target.getDescription();
+ this.description.setText(desc);
+ setErrorMessage(null);
+ setPageComplete(true);
+ } else {
+ context.setTarget(null);
+ description.setText("");
+ setPageComplete(false);
+ setErrorMessage("Select device or emulator to deploy the application");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/EmulatorTarget.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.text.MessageFormat;
+import java.util.Map.Entry;
+
+import org.eclipse.swt.graphics.Image;
+import org.symbian.tools.wrttools.core.WRTImages;
+import org.symbian.tools.wrttools.core.deploy.emulator.EmulatorDeployer;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+
+public class EmulatorTarget extends DeploymentTarget {
+ public EmulatorTarget(Entry<String, String> emulatorEntry) {
+ super(emulatorEntry.getKey());
+ addr = emulatorEntry.getValue();
+ }
+
+ @Override
+ public String getDescription() {
+ return MessageFormat.format("Emulator path: {0}", getAddr());
+ }
+
+ @Override
+ public IWidgetDeployer createDeployer(IWRTStatusListener statusListener) {
+ IWidgetDeployer widgetDeployer = new EmulatorDeployer();
+ widgetDeployer.setStatusListener(statusListener);
+ return widgetDeployer;
+ }
+
+ @Override
+ public String getType() {
+ return "emulator";
+ }
+
+ @Override
+ public Image getIcon() {
+ return WRTImages.getEmulatorImage();
+ }
+
+ public String getDeployMessage() {
+ return "Application was copied to emulator Phone Memory.\nYou should manually install it using the File Manager before running.";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/PhoneTarget.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.text.MessageFormat;
+
+import org.eclipse.swt.graphics.Image;
+import org.symbian.tools.wrttools.core.WRTImages;
+import org.symbian.tools.wrttools.core.deploy.device.DeployDeviceInfo;
+import org.symbian.tools.wrttools.core.deploy.device.DeviceDeployer;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+
+public class PhoneTarget extends DeploymentTarget {
+ public static final String TYPE = "bluetooth";
+ private boolean discovered;
+
+ public PhoneTarget(DeployDeviceInfo deviceInfo) {
+ super(deviceInfo.getDeviceName());
+ addr = deviceInfo.getDeviceBlueToothAddress();
+ discovered = true;
+ }
+
+ public PhoneTarget(String name) {
+ super(name);
+ discovered = false;
+ }
+
+ @Override
+ public String getDescription() {
+ if (isResolved()) {
+ return MessageFormat.format("Bluetooth address: {0}", getAddr());
+ } else {
+ return "This deviced was used in the previous session and might not be available";
+ }
+ }
+
+ @Override
+ public IWidgetDeployer createDeployer(IWRTStatusListener statusListener) {
+ IWidgetDeployer widgetDeployer = new DeviceDeployer();
+ widgetDeployer.setStatusListener(statusListener);
+ return widgetDeployer;
+ }
+
+ public void update(DeployDeviceInfo info) {
+ addr = info.getDeviceBlueToothAddress();
+ discovered = true;
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+
+ @Override
+ public boolean isResolved() {
+ return discovered;
+ }
+
+ @Override
+ public Image getIcon() {
+ return WRTImages.getBluetoothImage();
+ }
+
+ @Override
+ public String getDeployMessage() {
+ return "The application was sent to your phone.\nYou need to complete the installation on your phone before running the application.";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/ProgramTarget.java Mon Mar 15 16:38:54 2010 -0700
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Display;
+import org.symbian.tools.wrttools.core.deployer.DeployException;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.deployer.WidgetDeployer;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+
+public class ProgramTarget extends DeploymentTarget {
+ public class Deployer extends WidgetDeployer {
+ public IStatus deploy(String inputPath, String destinationPath, IProgressMonitor progressMonitor)
+ throws DeployException {
+ emitStatus(MessageFormat.format("Running {0}", program.getName()));
+ boolean b = program.execute(inputPath);
+ System.out.println(b);
+ return Status.OK_STATUS;
+ }
+ }
+
+ private static ProgramTarget instance;
+
+ private final Program program;
+ private Image image;
+
+ private ProgramTarget(Program program) {
+ super(program.getName());
+ this.program = program;
+ }
+
+ public static ProgramTarget getInstance() {
+ if (instance == null) {
+ Program program = Program.findProgram("wgz");
+ if (program != null) {
+ instance = new ProgramTarget(program);
+ }
+ }
+ return instance;
+ }
+
+ @Override
+ public IWidgetDeployer createDeployer(IWRTStatusListener statusListener) {
+ Deployer deployer = new Deployer();
+ deployer.setStatusListener(statusListener);
+ return deployer;
+ }
+
+ @Override
+ public String getDescription() {
+ return "External application will be used to deploy the widget";
+ }
+
+ @Override
+ public String getType() {
+ return "program";
+ }
+
+ @Override
+ public Image getIcon() {
+ if (image == null || image.isDisposed()) {
+ Display current = Display.getCurrent();
+ image = new Image(current, program.getImageData());
+ }
+ return image;
+ }
+
+ public String getDeployMessage() {
+ return "Packaged WGZ archive was passed to external application. Follow application prompts to deploy WGZ file.";
+ }
+}