# HG changeset patch # User tasneems@symbian.org # Date 1266270386 28800 # Node ID 19985c154f5c1aeee495f2ee1858d38beb97a797 # Parent 14ab024ecb098b516b76c39eea4b54baada9d948 Merged. Added deployment. Fixed developer experience. Added about.ini, about.properties. diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/about.html Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,11 @@ + + + + +Eclipse.org Software User Agreement + + + +This offering is powered by Eclipse technology and includes Eclipse plug-ins that can be +installed and used with other Eclipse based offerings." + \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/about.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/about.ini Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,11 @@ +# about.ini +# Contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "they" are externalized strings defined in about.properties +# This file does not need to be translated. + +#Property "aboutText" contains blurb for About dialog. (Translated) +aboutText=%blurb + +#Property "featureImage" contains path to feature iamge. (32x32) +featureImage=feature.gif \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/about.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/about.properties Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,18 @@ +# about.properties +# contains externalized strings for about.ini +# java.io.Properties file (ISO 8859-1 with "\" escapes +# fill-ins are supplied by about.mappings +# This file should be translated + +blurb=Web Runtime Toolkit\n\ +Symbian Foundation's Open Source toolkit for developing and deploying Web applications\n\ +\n\ +Version: 1.0.0\n\ +build id: {0}\n\ +\n\ +(c) Copyright 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All rights reserved.\n +Visit http://www.symbian.org\n\ +\n\ +This offering is powered by Eclipse technology and includes\n\ +Eclipse plug-ins that can be installed and used\n\ +with other Eclipse-based offerings. \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/build.properties --- a/org.symbian.tools.wrttools.product/build.properties Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools.product/build.properties Mon Feb 15 13:46:26 2010 -0800 @@ -3,7 +3,8 @@ .,\ plugin.xml,\ plugin_customization.ini,\ - icons/ + icons/,\ + about.ini source.. = src/ # javac javacSource=1.5 javacTarget=1.5 diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/plugin.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/plugin.properties Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,14 @@ +pluginName=WebRuntime Toolkit IDE +providerName=Symbian Foundation +productName=Web Runtime Toolkit IDE +productBlurb=Symbian Foundation's Open Source Web Runtime Toolkit IDE based on Eclipse Platform for developing and deploying Web applications\n\ +\n\ +Version: 1.0.0\n\ +Build id: {0} \n\ +\n\ +(c) Copyright 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All rights reserved.\n +Visit http://www.symbian.org\n\ +\n\ +This offering is powered by Eclipse technology and includes\n\ +Eclipse plug-ins that can be installed and used\n\ +with other Eclipse-based offerings. \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/plugin.xml --- a/org.symbian.tools.wrttools.product/plugin.xml Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools.product/plugin.xml Mon Feb 15 13:46:26 2010 -0800 @@ -131,7 +131,7 @@ + value="%productBlurb"> Help + helpMenu.add(new Separator()); + helpMenu.add(aboutAction); + + } +} \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools.product/wrt-ide.product --- a/org.symbian.tools.wrttools.product/wrt-ide.product Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools.product/wrt-ide.product Mon Feb 15 13:46:26 2010 -0800 @@ -6,8 +6,7 @@ - Symbian Foundation's Open Source toolkit for -developing and deploying Web applications + %productBlurb diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/.classpath --- a/org.symbian.tools.wrttools/.classpath Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools/.classpath Mon Feb 15 13:46:26 2010 -0800 @@ -1,5 +1,6 @@ + diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Mon Feb 15 13:46:26 2010 -0800 @@ -44,7 +44,7 @@ org.eclipse.ui.wizards.newresource Bundle-ClassPath: lib/tagsoup-1.2.jar, ., - lib/jtidy-8.0-20060801.131059-3.jar -Export-Package: org.symbian.tools.wrttools, + lib/jtidy-8.0-20060801.131059-3.jar, + lib/org.bluecove_2.1.1.jar org.symbian.tools.wrttools.util, org.symbian.tools.wrttools.wizards diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/META-INF/MANIFEST.MF.orig --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF.orig Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,51 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Symbian Web Runtime Tools +Bundle-SymbolicName: org.symbian.tools.wrttools;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.symbian.tools.wrttools.Activator +Bundle-Vendor: Symbian Foundation +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.emf.ecore, + org.eclipse.core.databinding;bundle-version="1.2.0", + org.eclipse.core.databinding.beans;bundle-version="1.2.0", + org.eclipse.core.databinding.property;bundle-version="1.2.0", + org.eclipse.jface.databinding;bundle-version="1.3.0", + org.eclipse.wst.jsdt.ui;bundle-version="1.0.200", + org.eclipse.wst.jsdt.core;bundle-version="1.0.200", + org.eclipse.wst.css.core;bundle-version="1.1.300", + org.eclipse.ui.ide;bundle-version="3.5.0", + org.eclipse.wst.validation;bundle-version="1.2.102", + org.eclipse.wst.sse.core;bundle-version="1.1.400", + 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" +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Import-Package: org.apache.velocity;version="1.5.0", + org.apache.velocity.app;version="1.5.0", + org.apache.velocity.context;version="1.5.0", + org.apache.velocity.convert;version="1.5.0", + org.apache.velocity.io;version="1.5.0", + org.apache.velocity.runtime;version="1.5.0", + org.apache.velocity.util;version="1.5.0", + org.eclipse.emf.common.notify, + org.eclipse.emf.common.util, + org.eclipse.emf.ecore, + org.eclipse.emf.ecore.impl, + org.eclipse.ui.console, + org.eclipse.ui.dialogs, + org.eclipse.ui.ide, + org.eclipse.ui.internal.ide, + org.eclipse.ui.internal.ide.dialogs, + org.eclipse.ui.wizards.newresource +Bundle-ClassPath: lib/tagsoup-1.2.jar, + ., + lib/jtidy-8.0-20060801.131059-3.jar, + lib/org.bluecove_2.1.1.jar +Export-Package: org.symbian.tools.wrttools, + org.symbian.tools.wrttools.util, + org.symbian.tools.wrttools.wizards diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/build.properties --- a/org.symbian.tools.wrttools/build.properties Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools/build.properties Mon Feb 15 13:46:26 2010 -0800 @@ -11,7 +11,9 @@ lib/,\ epl-v10.html,\ license.html,\ - schema/ # javac + schema/,\ + lib/org.bluecove_2.1.1.jar +# javac javacSource=1.5 javacTarget=1.5 javacVerbose=true diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/lib/org.bluecove_2.1.1.jar Binary file org.symbian.tools.wrttools/lib/org.bluecove_2.1.1.jar has changed diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools/plugin.xml Mon Feb 15 13:46:26 2010 -0800 @@ -64,11 +64,62 @@ + + + + + + + + + + - + + + + + + + + + + + + + @@ -83,8 +134,8 @@ label="Package WRT Application" menubarPath="org.symbian.tools.wrttools.contextMenuGroupMarker"> - - + @@ -96,17 +147,17 @@ - - - - + + @@ -160,7 +211,8 @@ id="org.symbian.tools.wrttools.core.wrtwidgetwizard" name="Web Runtime Application" project="true"> - Creates a new Symbian WRT application project using one of the provided templates + Creates a new Symbian WRT application project using one of the provided + templates + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creates a new Symbian WRT application project using one of the provided + templates + + + + + + + + + + + + + This wizard generates a basic Hello project with a minimal Info.plist, html,css and js along with WRTKit. + + org.symbian.wrtkit + + + + + This wizard generates an Flickr project with a minimal Info.plist, html,css and js and WRTKit. + + org.symbian.wrtkit + + + + + This wizard generates an RSS Reader project with a minimal Info.plist, html,css and js and WRTKit. + + org.symbian.wrtkit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/Activator.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/Activator.java Fri Feb 12 15:58:58 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/Activator.java Mon Feb 15 13:46:26 2010 -0800 @@ -18,10 +18,16 @@ */ package org.symbian.tools.wrttools; +import java.io.PrintStream; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import com.intel.bluetooth.BlueCoveImpl; + +import org.symbian.tools.wrttools.core.deploy.PreferenceConstants; import org.symbian.tools.wrttools.sdt.utils.Logging; /** @@ -37,6 +43,8 @@ // The shared instance private static Activator plugin; + private static PrintStream savedSysOut; + /** * The constructor */ @@ -50,6 +58,11 @@ public void start(BundleContext context) throws Exception { super.start(context); plugin = this; + + // set parameters for BlueCove + String param = Integer.toString(65*1024); + System.setProperty("bluecove.obex.mtu", param); + BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", param); } /* @@ -60,6 +73,29 @@ plugin = null; super.stop(context); } + + public void startBluetoothOperation() { + IPreferenceStore prefStore = getPreferenceStore(); + if (prefStore.getBoolean(PreferenceConstants.DEBUG_ENABLED)) + enableBlueCoveDiagnostics(true); + } + + public void stopBluetoothOperation() { + enableBlueCoveDiagnostics(false); + } + + /** Toggle BlueCove logging + */ + public static void enableBlueCoveDiagnostics(boolean enable) { + System.setProperty("bluecove.debug", Boolean.valueOf(enable).toString()); + BlueCoveImpl.instance().enableNativeDebug(enable); + if (enable) { + System.setOut(new PrintStream(ConsoleFactory.createStream())); + } else { + System.setOut(savedSysOut); + } + } + /** * Returns the shared instance diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/Activator.java.orig --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/Activator.java.orig Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,122 @@ +/** + * 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; + +import java.io.PrintStream; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import com.intel.bluetooth.BlueCoveImpl; + +import org.symbian.tools.wrttools.core.deploy.PreferenceConstants; +import org.symbian.tools.wrttools.sdt.utils.Logging; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.symbian.tools.wrttools"; + + public static final String NAVIGATOR_ID = PLUGIN_ID + ".wrtnavigator"; + + // The shared instance + private static Activator plugin; + + private static PrintStream savedSysOut; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + // set parameters for BlueCove + String param = Integer.toString(65*1024); + System.setProperty("bluecove.obex.mtu", param); + BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", param); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public void startBluetoothOperation() { + IPreferenceStore prefStore = getPreferenceStore(); + if (prefStore.getBoolean(PreferenceConstants.DEBUG_ENABLED)) + enableBlueCoveDiagnostics(true); + } + + public void stopBluetoothOperation() { + enableBlueCoveDiagnostics(false); + } + + /** Toggle BlueCove logging + */ + public static void enableBlueCoveDiagnostics(boolean enable) { + System.setProperty("bluecove.debug", Boolean.valueOf(enable).toString()); + BlueCoveImpl.instance().enableNativeDebug(enable); + if (enable) { + System.setOut(new PrintStream(ConsoleFactory.createStream())); + } else { + System.setOut(savedSysOut); + } + } + + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + public static void log(Exception e) { + log(e.getLocalizedMessage(), e); + } + + public static void log(String message, Exception e) { + getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, e)); + } + + public static void log(int severity, String message, Throwable x) { + IStatus status = new Status(severity, PLUGIN_ID, 0, message, x); + Logging.log(getDefault(), status); + } + +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/IWRTConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/IWRTConstants.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,46 @@ +/** + * 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; + +public interface IWRTConstants { + + public static final String WRT_PROJECT_FILE_NAME = "wrt.xml"; + public static final String SYSTEM_USER_HOME = System.getProperty("user.home"); + public static final String WRT = "wrt"; + public static final String PATH = "path"; + public static final String DEPLOY = "deploy"; + public static final String PACKAGE ="package"; + public static final String CONVERT = "Converter"; + public static final String DEPLOY_PATH="\\epoc32\\winscw\\c\\Data\\Others"; + public static final String DEVICES_XML_PATH = "c:/program files/common files/symbian/devices.xml"; + public static final String DEVICES_TAG="devices"; + public static final String DEVICE_TAG="device"; + public static final String EPOC_ROOT_TAG="epocroot"; + public static final String NAME_ATTR = "name"; + public static final String ID_ATTR = "id"; + public static final String EMULATOR_NAME="com.nokia.s60"; + public static final String EMULATOR= "emulator"; + public static final String DEVICE= "device"; + public static final String DEVICE_ADDRESS= "address"; + + + + +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployMessages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployMessages.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,41 @@ +/** + * 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.util.MissingResourceException; +import java.util.ResourceBundle; + +public class DeployMessages { + private static final String BUNDLE_NAME = "org.symbian.tools.wrttools.core.deploy.deployMessages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private DeployMessages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployPreferencePage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployPreferencePage.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,415 @@ +/** + * 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.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.logging.Logger; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import org.symbian.tools.wrttools.Activator; +import org.symbian.tools.wrttools.core.IWRTConstants; +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 DeployPreferencePage extends PreferencePage implements +IWorkbenchPreferencePage { + + private Composite contents; + private Button deviceRadioButton; + private Button emulatorRadioButton; + private Combo selectionCombo; + private Button searchDevices; + private Text emulatorDeployerPathText; + private Label selectionComboLabel; + private Button debugButton; + private IRunnableWithProgress runnable; + + private Logger log = Logger.getLogger(getClass().getName()); + + + private final HashMap emulatorHashMap = EmulatorListProvider.populateEmulators(); + private Set emulatorKeySet = emulatorHashMap.keySet(); + private String[] emulatorItems = (String[])emulatorKeySet.toArray(new String[emulatorKeySet.size()]); + private static String[] devices=null; + + + public DeployPreferencePage() { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + //--------------------------------------------------------------------------------------// + /** + * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various + * types of preferences. Each field editor knows how to save and restore itself. + */ + public void createFieldEditors(Composite parent) { + GridLayout layout = new GridLayout(4, false); + parent.setLayout(layout); + deviceRadioButton = new Button(parent, SWT.RADIO); + deviceRadioButton.setText("Device"); + GridData gd = new GridData(); + gd.horizontalSpan = 2; + deviceRadioButton.setLayoutData(gd); + + emulatorRadioButton = new Button(parent, SWT.RADIO); + emulatorRadioButton.setText("Emulator"); + gd = new GridData(); + gd.horizontalSpan = 2; + emulatorRadioButton.setLayoutData(gd); + + selectionComboLabel = new Label(parent, SWT.READ_ONLY); + selectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + selectionCombo.setLayoutData(gd); + selectionCombo.setSize(100,100); + + searchDevices = new Button(parent,SWT.PUSH); + searchDevices.setVisible(false); + searchDevices.setText("Search"); + + emulatorDeployerPathText = new Text(parent, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 4; + gd.grabExcessHorizontalSpace = true; + emulatorDeployerPathText.setLayoutData(gd); + emulatorDeployerPathText.setVisible(false); + + debugButton = new Button(parent, SWT.CHECK); + debugButton.setText("Enable diagnostic logging"); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 4; + debugButton.setLayoutData(gd); + + //---------------------------start setting event listener---------------------// + selectionCombo.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (emulatorRadioButton != null && emulatorRadioButton.getSelection()) { + if (selectionCombo.getText().trim().equalsIgnoreCase( "None")) { //$NON-NLS-1$ + emulatorDeployerPathText.setText(emulatorHashMap.get(selectionCombo.getText())); + emulatorDeployerPathText.setText(""); + } else { + emulatorDeployerPathText.setText(emulatorHashMap.get(selectionCombo.getText()).concat(IWRTConstants.DEPLOY_PATH)); + } + /* TODO XXX */ + log.info("DeployPreferencePage.addSelectionListener: Emulator Deployer Path Text: "+ emulatorDeployerPathText); + } + } + }); + + emulatorRadioButton.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + selectionCombo.removeAll(); + selectionCombo.setItems(emulatorItems); + updateButtonStates(); + contents.layout(); + } + }); + + deviceRadioButton.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + // once the status is set the UI will be up and the scanning for the deployment devices + // will begin in the JOB thread so lets put the status message so that user gets the information + // that devices are being loaded. + selectionCombo.removeAll(); + if(devices!=null && DeviceListProvider.isBloothToothConnected()){ + selectionCombo.setItems(devices); + } + if(DeviceListProvider.isBloothToothConnected()){ + updateButtonStates(); + contents.layout(); + } + } + }); + + searchDevices.addSelectionListener(new SelectionAdapter() + { + public void widgetSelected(SelectionEvent e) + { + if(DeviceListProvider.isBloothToothConnected()){ + selectionCombo.removeAll(); + loadDevices("");//$NON-NLS-1$ + } + else{ + Shell shell = new Shell(); + MessageDialog.openInformation(shell,"Search Problem",DeployerMessages.getString("Deployer.bluetooth.notconnected.msg")); + } + } + }); + } + + //------------------------------------------------// + + public void init(IWorkbench workbench) { + } + + //---------------------------------------------------------------------------// + + /** + * Update the state of the deploy button based on various conditions. + */ + private void updateButtonStates() { + if (!Platform.OS_WIN32.equals(Platform.getOS())) { + emulatorRadioButton.setVisible(false); + emulatorRadioButton.setSelection(false); + deviceRadioButton.setSelection(true); + deviceRadioButton.setVisible(false); + } + if(emulatorRadioButton != null && emulatorRadioButton.getSelection()){ + searchDevices.setVisible(false); + emulatorDeployerPathText.setEnabled(false); + emulatorDeployerPathText.setVisible(true); + selectionComboLabel.setText("Select Emulator:"); + + String storeEmlItem= getPreferenceStore().getString(PreferenceConstants.SELECTED_EMULATOR_NAME); + if(emulatorItems!=null&&emulatorItems.length>0){ + int i=0; + for( String emulatorItem: emulatorItems ){ + if(storeEmlItem.trim().equalsIgnoreCase(emulatorItem.trim())){break;} + i++; + } + selectionCombo.setItems(emulatorItems); + selectionCombo.select(i); + emulatorDeployerPathText.setText(getPreferenceStore().getString(PreferenceConstants.SELECTED_EMULATOR_PATH)); + + }else{ + emulatorDeployerPathText.setText(""); + } + + /* TODO XXX */ + log.info("DeployPreferencePage.updateButtonStates: Emulator Deployer Path Text: "+ emulatorDeployerPathText); + + + } else if(deviceRadioButton != null && deviceRadioButton.getSelection()){ + searchDevices.setVisible(true); + searchDevices.setEnabled(true); + selectionComboLabel.setText("Select Device:"); + emulatorDeployerPathText.setVisible(false); + + if(devices!=null&&devices.length>1){ + String storeDeviceName= getPreferenceStore().getString(PreferenceConstants.SELECTED_DEVICE_NAME); + int i=0; + for( String devicename: devices ){ + if(storeDeviceName.trim().equalsIgnoreCase(devicename.trim())){break;} + i++; + } + if(DeviceListProvider.isBloothToothConnected()){ + selectionCombo.setItems(devices); + selectionCombo.select(i); + } + }else{ + selectionCombo.add(getPreferenceStore().getString(PreferenceConstants.SELECTED_DEVICE_NAME)); + selectionCombo.select(0); + } + } + } + + public Control createContents(Composite parent) { + initializeDialogUnits(parent); + Composite result= new Composite(parent, SWT.NONE); + result.setFont(parent.getFont()); + GridLayout layout= new GridLayout(); + layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth= 0; + layout.verticalSpacing= convertVerticalDLUsToPixels(10); + layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + result.setLayout(layout); + + createFieldEditors(result); + contents = result; + initFields(); + + Dialog.applyDialogFont(result); + + return result; + } + + private void initFields() { + performDefaults(); + } + + public void performDefaults() { + IPreferenceStore prefStore= getPreferenceStore(); + deviceRadioButton.setSelection(PreferenceConstants.WRT_DEPLOY_CHOICE_DEVICE.equals(prefStore.getString(PreferenceConstants.WRT_DEPLOY_CHOICE))); + emulatorRadioButton.setSelection(PreferenceConstants.WRT_DEPLOY_CHOICE_EMULATOR.equals(prefStore.getString(PreferenceConstants.WRT_DEPLOY_CHOICE))); + selectionCombo.removeAll(); + + if(emulatorRadioButton != null && emulatorRadioButton.getSelection()){ + selectionCombo.setItems(emulatorItems); + emulatorDeployerPathText.setText(prefStore.getString(PreferenceConstants.SELECTED_EMULATOR_PATH)); + /* TODO XXX */ + log.info("DeployPreferencePage.performDefaults: Emulator Deployer Path Text: "+ emulatorDeployerPathText); + } + + /* TODO XXX */ + log.info("DeployPreferencePage.performDefaults: emulatorRadioButton not selected: "+ emulatorDeployerPathText); + + /*if(deviceRadioButton != null && deviceRadioButton.getSelection()){ + devices = new String[1]; + devices[0] =prefStore.getString(PreferenceConstants.SELECTED_DEVICE_NAME); + } + */ + + debugButton.setSelection(prefStore.getBoolean(PreferenceConstants.DEBUG_ENABLED)); + updateButtonStates(); + super.performDefaults(); + } + protected void performApply() { + super.performOk(); + } + public boolean performOk() { + boolean wantSelection = false; + + if(selectionCombo.getSelectionIndex() < 0 || (selectionCombo.getItem(selectionCombo.getSelectionIndex()).toString().equalsIgnoreCase("none"))){ + Shell shell = new Shell(); + wantSelection = MessageDialog.openQuestion(shell,"Widget Deployment Settings","You have not made any selection. Do you want to select device?"); + } + if(!wantSelection){ + IPreferenceStore prefOkStore = getPreferenceStore(); + + if (deviceRadioButton.getSelection()) { + prefOkStore.setValue(PreferenceConstants.WRT_DEPLOY_CHOICE, PreferenceConstants.WRT_DEPLOY_CHOICE_DEVICE); + + prefOkStore.setValue(PreferenceConstants.SELECTED_DEVICE_NAME, selectionCombo.getText()); + + } else if (emulatorRadioButton.getSelection()) { + prefOkStore.setValue(PreferenceConstants.WRT_DEPLOY_CHOICE, PreferenceConstants.WRT_DEPLOY_CHOICE_EMULATOR); + prefOkStore.setValue(PreferenceConstants.SELECTED_EMULATOR_NAME, selectionCombo.getText()); + prefOkStore.setValue(PreferenceConstants.SELECTED_EMULATOR_PATH, emulatorDeployerPathText.getText()); + } + + boolean debugEnabled = debugButton.getSelection(); + prefOkStore.setValue(PreferenceConstants.DEBUG_ENABLED, + Boolean.valueOf(debugEnabled).toString()); + Activator.enableBlueCoveDiagnostics(debugEnabled); + + boolean res = super.performOk(); + return res; + } + return false; + } + + /** + * 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 . + */ + private void loadDevices(final String device) { + runnable = new IRunnableWithProgress(){ + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + List deviceInfo = DeviceListProvider + .getDevices(monitor); + devices = new String[deviceInfo.size() + 1]; + int i = 1; + + devices[0] = DeployMessages.getString("View.none.text");//$NON-NLS-1$ + for (DeployDeviceInfo deployDeviceInfo : deviceInfo) { + devices[i] = deployDeviceInfo.getDeviceName(); + i++; + } + // refresh the devices combo in the async thread + deviceRadioButton.getDisplay().asyncExec(new Runnable() { + + public void run() { + // put the devices found in the combo + if(DeviceListProvider.isBloothToothConnected()) + selectionCombo.setItems(devices); + if (device == null || device.length() < 1) { + selectionCombo.setText(DeployMessages + .getString("View.none.text")); //$NON-NLS-1$ + } else { + selectionCombo.setText(device); + } + + // Let the user know that the device can now be selected + Shell shell = new Shell(); + MessageDialog.openInformation(shell,"Deployment Preferences: Search Completed","Device Search Completed. Make the device selection."); + } + }); + + } + }; + + // Use the progess service to execute the runnable + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(searchDevices.getDisplay().getActiveShell()); + try { + dialog.run(true, true, runnable); + } catch (InvocationTargetException e) { + Activator.log(IStatus.ERROR, "Exception loading devices", e); + + } catch (InterruptedException e) { + Activator.log(IStatus.ERROR, "Exception loading devices", e); + } + + +/* + ProgressMonitorDialog dialogDone = new ProgressMonitorDialog(selectionCombo.getShell()); + try { + dialogDone.run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor ) { + monitor.beginTask("Searching for Devices", IProgressMonitor.UNKNOWN); + + monitor.setTaskName("Deployment Completed. Select the Deployment Device."); + monitor.done(); + } + }); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + Activator.log(IStatus.ERROR, "Exception loading devices", e); + + } catch (InterruptedException e) { + // TODO Auto-generated catch block + Activator.log(IStatus.ERROR, "Exception loading devices", e); + } +*/ + } + } diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/PreferenceConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/PreferenceConstants.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,46 @@ +/** + * 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; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + ///-----------------keys-----------------------// + + public static final String WRT_DEPLOY_CHOICE = "wrtDeploychoicePreference"; + + public static final String DEPLOYMENT_SETTINGE_PAGE = "org.symbian.tools.wrttools.core.deploy.DeployPreferencePage"; + + //---------------------values----------------------------// + + public static final String WRT_DEPLOY_CHOICE_DEVICE = "DEVICE"; + + public static final String WRT_DEPLOY_CHOICE_EMULATOR = "EMULATOR"; + + + + public static final String SELECTED_EMULATOR_PATH = "org.symbian.tools.wrttools.emulator"; + + public static final String SELECTED_DEVICE_NAME = "selectedDeviceName"; + public static final String SELECTED_EMULATOR_NAME = "selectedEmulatorDeviceName"; + + public static final String DEBUG_ENABLED = "debugEnabled"; +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/PreferenceInitializer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/PreferenceInitializer.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,45 @@ +/** + * 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 org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import org.symbian.tools.wrttools.Activator; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.WRT_DEPLOY_CHOICE, PreferenceConstants.WRT_DEPLOY_CHOICE_DEVICE); + store.setDefault(PreferenceConstants.WRT_DEPLOY_CHOICE, PreferenceConstants.WRT_DEPLOY_CHOICE_EMULATOR); +// store.setDefault(PreferenceConstants.WRT_EMULATOR_PATH, "none"); + + } + +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/ProgressRunnableDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/ProgressRunnableDialog.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,130 @@ +/** + * 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 org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.swt.widgets.Shell; + +import org.symbian.tools.wrttools.core.deploy.device.DeviceListProvider; + + +/** + * Progress Runnable Dialog for the searching of the devices. + * Provides the functionality to cancel the operation. + * @author avraina + * + */ +public class ProgressRunnableDialog extends ProgressMonitorDialog { + + private IProgressMonitor progressMonitor; + + /** + * Constructor. + * @param parent + */ + public ProgressRunnableDialog(Shell parent) { + super(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.ProgressMonitorDialog#configureShell(org.eclipse.swt.widgets.Shell) + */ + protected void configureShell(Shell shell) { + super.configureShell(shell); + //need to uncomment + shell.setText(DeployMessages.getString("wrt.core.Deployer.searchdevice.dialog.title")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.ProgressMonitorDialog#getProgressMonitor() + */ + public IProgressMonitor getProgressMonitor() { + progressMonitor = new IProgressMonitor(){ + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) + */ + public void beginTask(String name, int totalWork) { + progressMonitor.beginTask(name, totalWork); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public void done() { + progressMonitor.done(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) + */ + public void internalWorked(double work) { + progressMonitor.internalWorked(work); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() + */ + public boolean isCanceled() { + return progressMonitor.isCanceled(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) + */ + public void setCanceled(boolean value) { + if(value){ + DeviceListProvider.cancelSearch(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) + */ + public void setTaskName(String name) { + progressMonitor.setTaskName(name); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) + */ + public void subTask(String name) { + progressMonitor.subTask(name); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#worked(int) + */ + public void worked(int work) { + progressMonitor.worked(work); + } + }; + return progressMonitor; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.ProgressMonitorDialog#cancelPressed() + */ + protected void cancelPressed() { + progressMonitor.setCanceled(true); + super.cancelPressed(); + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/WrtDeployActionDelegate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/WrtDeployActionDelegate.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,232 @@ +/** + * 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" + " dest path: " + destinationPath + "deployerType:" + deployerType + " store:" + store); + } + } + + @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 projectList = new ArrayList(); + public static List wgzList = new ArrayList(); + + 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; + } + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/WrtDeploymentSettingsActionDelegate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/WrtDeploymentSettingsActionDelegate.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,37 @@ +/** + * 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 org.eclipse.jface.action.IAction; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.dialogs.PreferencesUtil; + +public class WrtDeploymentSettingsActionDelegate extends ActionDelegate + implements IObjectActionDelegate { + + public void run(IAction action) { + PreferencesUtil.createPreferenceDialogOn(null, PreferenceConstants.DEPLOYMENT_SETTINGE_PAGE, null, null).open(); + } + + public void setActivePart(IAction arg0, IWorkbenchPart arg1) { + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/deployMessages.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/deployMessages.properties Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,6 @@ +wrt.core.Deployer.searchdevice.dialog.title=Searching devices +View.none.text=none +wrt.core.Deploy.failed.as.package.failed=Deploy cannot be completed as Packing failed + +WRTDeployerConstants.success=Packaging Successful\n +WRTDeployerConstants.failed=Packaging Failed\n \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeployDeviceInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeployDeviceInfo.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,57 @@ +/** + * 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.device; + +import org.symbian.tools.wrttools.sdt.utils.Check; + +/** + * Holds the information about the Device to be used for the deployment + * through bluetooth + * @author avraina + * + */ +public class DeployDeviceInfo { + + private String deviceName; + private String deviceBlueToothAddress; + + public DeployDeviceInfo(String deviceName, String deviceBlueToothAddress) { + Check.checkArg(deviceName); + Check.checkArg(deviceBlueToothAddress); + this.deviceName = deviceName; + this.deviceBlueToothAddress = deviceBlueToothAddress; + } + + /** + * Returns the device name. + * @return the address + */ + public String getDeviceName() { + return deviceName; + } + + /** + * Returns the bluetooth address of the device + * @return the address + */ + public String getDeviceBlueToothAddress() { + return deviceBlueToothAddress; + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,220 @@ +/** + * 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.device; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.MessageFormat; + +import javax.bluetooth.BluetoothConnectionException; +import javax.microedition.io.Connector; +import javax.obex.ClientSession; +import javax.obex.HeaderSet; +import javax.obex.Operation; +import javax.obex.ResponseCodes; + +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; +import org.symbian.tools.wrttools.core.deployer.WidgetDeployer; +import org.symbian.tools.wrttools.core.status.IWRTConstants; + +/** + * The class needed for the deployment of the widget to device using bluetooth. + * + * @author avraina + */ +public class DeviceDeployer extends WidgetDeployer { + + public IStatus deploy(String fileName, String device, IProgressMonitor progressMonitor) { + File inputFile = new File(fileName); + IStatus result = null; + + // If the archive is directly deployed than directly deploy it + // else deploy from the folder path. + if (fileName.toLowerCase() + .endsWith(IWRTConstants.WIDGET_FILE_EXTENSION)) { + result = deployWidget(inputFile, device, progressMonitor); + } + if (result.isOK()) { + emitStatus(DeployerMessages.getString("Deployer.ends.msg"));//$NON-NLS-1$ + + } else if (result.getCode() == IStatus.CANCEL){ + emitStatus(DeployerMessages.getString("Deployer.cancelled.msg")); + } + return result; + } + + /** + * Deploys the widget using the bluetooth. + * + * @param inputWidget + * the input widget which has to be deployed. + * @param device + * the device to which the widget is deployed + * @param progressMonitor + * @throws Exception + * if the exception is throws + */ + private IStatus deployWidget(File inputWidget, String device, IProgressMonitor progressMonitor) { + InputStream in = null; + OutputStream os = null; + Operation putOperation = null; + ClientSession clientSession = null; + IStatus result = null; + try { + if (!DeviceListProvider.isBloothToothConnected()) { + String msg = DeployerMessages.getString("Deployer.bluetooth.notconnected.msg"); + emitStatus(msg); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, msg, null); + } + + String message = MessageFormat + .format( + DeployerMessages + .getString("Deployer.searchservice.msg"), new Object[] { device });//$NON-NLS-1$ + emitStatus(message); + String servicesFound = ServicesProvider.getServicesFound(device); + if (servicesFound == null || servicesFound.length() < 1) { + message = MessageFormat + .format( + DeployerMessages + .getString("Deployer.servicenotfound.err.msg"), new Object[] { device });//$NON-NLS-1$ + emitStatus(message); + + message = MessageFormat + .format( + DeployerMessages + .getString("Deployer.cannotdeploy.err.msg"), new Object[] { device });//$NON-NLS-1$ + emitStatus(message); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, message, null); + } + + message = MessageFormat + .format( + DeployerMessages + .getString("Deployer.servicefound.msg"), new Object[] { device });//$NON-NLS-1$ + emitStatus(message); + + clientSession = (ClientSession) Connector.open(servicesFound); + HeaderSet hsConnectReply = clientSession.connect(null); + if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) { + emitStatus(DeployerMessages + .getString("Deployer.services.connect.err.msg"));//$NON-NLS-1$ + } + + emitStatus(DeployerMessages.getString("Deployer.begin.msg")); + + HeaderSet hsOperation = clientSession.createHeaderSet(); + + if (progressMonitor.isCanceled()) { + return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 0, "Deployment was canceled", null); + } + + // Send widget to server + in = new FileInputStream(inputWidget); + message = MessageFormat + .format( + DeployerMessages + .getString("Deployer.inputfile.msg"), new Object[] { inputWidget.getAbsolutePath() });//$NON-NLS-1$ + emitStatus(message); + + hsOperation.setHeader(HeaderSet.NAME, inputWidget.getName()); + hsOperation.setHeader(HeaderSet.TYPE, + IWidgetDeployerConstants.WIDGET_FILE_TYPE); + int size = (int)inputWidget.length(); + byte file[] = new byte[size]; + hsOperation.setHeader(HeaderSet.LENGTH, new Long(file.length)); + + // Create PUT Operation + putOperation = clientSession.put(hsOperation); + + os = putOperation.openOutputStream(); + + long start = System.currentTimeMillis(); + + byte[] buf = new byte[16*1024]; + int len; + while ((len = in.read(buf)) > 0) { + os.write(buf, 0, len); + if (progressMonitor.isCanceled()) { + putOperation.abort(); + return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, 0, "Deployment was canceled", null); + } + } + + os.flush(); + os.close(); + + long elapsed = System.currentTimeMillis() - start; + emitStatus("elapsed time: " + (double)elapsed/1000.0 + " seconds"); + + int responseCode = putOperation.getResponseCode(); + if (responseCode == ResponseCodes.OBEX_HTTP_OK) { + message = MessageFormat.format( + DeployerMessages.getString("Deployer.outputfile.msg"), new Object[] { device });//$NON-NLS-1$ + emitStatus(message); + result = Status.OK_STATUS; + } else { + message = "Error during deployment, OBEX error: " + responseCode; + emitStatus(message); + result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, message, null); + } + + } catch (BluetoothConnectionException x) { + String message = getExceptionMessage(x.getMessage()); + emitStatus(message); + } + catch (IOException e) { + String message = getExceptionMessage(e.getMessage()); + emitStatus(message); + } finally { + try { + if (in != null) { + in.close(); + } + if (putOperation != null) { + putOperation.close(); + } + if (clientSession != null) { + clientSession.disconnect(null); + clientSession.close(); + } + } catch (IOException x) { + Activator.log(IStatus.ERROR, + "Error cleaning up BlueTooth deployment", x); + } + } + if (result == null && clientSession == null) { + String message = "An error occurred initiating a connection to the device. It may have been rejected by the user."; + result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, message, null); + } + return result; + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceListProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceListProvider.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,188 @@ +/** + * 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.device; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; + +import org.symbian.tools.wrttools.Activator; + +public class DeviceListProvider { + + private static final List deviceInfo = new ArrayList(); + + private static WrtDiscoveryListener listener; + + /** + * Check whether the bluetooth is on or not. + * + * @return whether the device is on. + */ + public static boolean isBloothToothConnected() { + return LocalDevice.isPowerOn(); + } + + public static String getDeviceAddress(String deviceName, + boolean allowDiscovery) { + String result = null; + for (DeployDeviceInfo deployDeviceInfo : deviceInfo) { + if (deployDeviceInfo.getDeviceName().equals(deviceName)) { + result = deployDeviceInfo.getDeviceBlueToothAddress(); + } + } + if (result == null && allowDiscovery) { + discoverDevices(new NullProgressMonitor(), deviceName); + for (DeployDeviceInfo deployDeviceInfo : deviceInfo) { + if (deployDeviceInfo.getDeviceName().equals(deviceName)) { + result = deployDeviceInfo.getDeviceBlueToothAddress(); + } + } + } + return result; + } + + public static List getDevices( + IProgressMonitor progressMonitor) { + discoverDevices(progressMonitor, null); + return new ArrayList(deviceInfo); + } + + /** + * Discover devices. Finds all devices if desiredDevice is null. If non-null + * search stops when the desired device is found. + */ + private static void discoverDevices(final IProgressMonitor progressMonitor, + final String desiredDevice) { + + final Object inquiryCompletedEvent = new Object(); + deviceInfo.clear(); + + listener = new WrtDiscoveryListener(desiredDevice, + inquiryCompletedEvent, progressMonitor); + + synchronized (inquiryCompletedEvent) { + boolean started; + try { + started = LocalDevice.getLocalDevice().getDiscoveryAgent() + .startInquiry(DiscoveryAgent.GIAC, listener); + if (started) { + inquiryCompletedEvent.wait(); + } + } catch (BluetoothStateException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } catch (InterruptedException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } + } + } + + public static boolean isCanceled() { + return listener != null && listener.isCanceled; + } + + public static void cancelSearch() { + if (listener != null) { + try { + listener.isCanceled = true; + if (listener.progressMonitor != null && + !listener.progressMonitor.isCanceled()) { + listener.progressMonitor.setCanceled(true); + } + LocalDevice.getLocalDevice().getDiscoveryAgent().cancelInquiry( + listener); + } catch (BluetoothStateException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } + } + } + + private static final class WrtDiscoveryListener implements + DiscoveryListener { + final String desiredDevice; + final Object inquiryCompletedEvent; + final IProgressMonitor progressMonitor; + boolean isCanceled; + + private WrtDiscoveryListener(String desiredDevice, + Object inquiryCompletedEvent, + IProgressMonitor progressMonitor) { + this.desiredDevice = desiredDevice; + this.inquiryCompletedEvent = inquiryCompletedEvent; + this.progressMonitor = progressMonitor; + } + + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + try { + if (btDevice.getFriendlyName(false) != null + && btDevice.getFriendlyName(false).length() > 0) { + DeployDeviceInfo deployDeviceInfo = new DeployDeviceInfo( + btDevice.getFriendlyName(false), btDevice + .getBluetoothAddress()); + deviceInfo.add(deployDeviceInfo); + //System.out.println("Friendly name : "+ (btDevice.getFriendlyName(false))); + // System.out.println("----device size :"+deviceInfo. + // size()); + if (desiredDevice != null + && desiredDevice.equals(deployDeviceInfo + .getDeviceName())) { + cancelSearch(); + } + checkCanceled(); + } + } catch (BluetoothStateException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } catch (IOException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } + } + + private void checkCanceled() { + if (!isCanceled && progressMonitor != null) { + if (progressMonitor.isCanceled()) { + cancelSearch(); + } + } + } + + public void inquiryCompleted(int discType) { + synchronized (inquiryCompletedEvent) { + inquiryCompletedEvent.notifyAll(); + } + } + + public void serviceSearchCompleted(int transID, int respCode) { + } + + public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { + } + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/ServicesProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/ServicesProvider.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,100 @@ +/** + * 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.device; + +import java.io.IOException; + +import javax.bluetooth.BluetoothStateException; +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.LocalDevice; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; +import javax.bluetooth.UUID; + +import org.eclipse.core.runtime.IStatus; + +import org.symbian.tools.wrttools.Activator; + +public class ServicesProvider { + + static final UUID OBEX_OBJECT_PUSH = new UUID(0x1105); + + private static String serviceURL; + private static String btAddress; + + public static String getServicesFound(final String deviceName){ + try { + serviceURL=""; + btAddress = DeviceListProvider.getDeviceAddress(deviceName, true); + + + UUID serviceUUID = OBEX_OBJECT_PUSH; + + final Object serviceSearchCompletedEvent = new Object(); + + DiscoveryListener listener = new DiscoveryListener() { + + public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { + } + + public void inquiryCompleted(int discType) { + } + + public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { + try{ + for (int i = 0; i < servRecord.length; i++) { + if(servRecord[i].getHostDevice().getFriendlyName(false).equals(deviceName)){ + serviceURL = servRecord[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); + } + } + } catch(BluetoothStateException e){ + Activator.log(IStatus.ERROR, e.getMessage(), e); + } catch (IOException e) { + Activator.log(IStatus.ERROR, e.getMessage(), e); + } + } + + public void serviceSearchCompleted(int transID, int respCode) { + synchronized(serviceSearchCompletedEvent){ + serviceSearchCompletedEvent.notifyAll(); + } + } + + }; + + UUID[] searchUuidSet = new UUID[] { serviceUUID }; + int[] attrIDs = new int[] { + 0x0100 // Service name + }; + + RemoteDevice bt = new WrapperRemoteDevice(btAddress); + synchronized(serviceSearchCompletedEvent) { + LocalDevice.getLocalDevice().getDiscoveryAgent().searchServices(attrIDs, searchUuidSet, bt, listener); + serviceSearchCompletedEvent.wait(); + } + + } catch(IOException e){ + Activator.log(IStatus.ERROR, "Error in Bluetooth service discovery", e); + } catch (InterruptedException e) { + Activator.log(IStatus.ERROR, "Error in Bluetooth service discovery", e); + } + return serviceURL; + } +} \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/WrapperRemoteDevice.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/WrapperRemoteDevice.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,35 @@ +/** + * 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.device; + +import javax.bluetooth.RemoteDevice; + +/** + * A wrapper class around the Remote Device. + * This will be used while deploying to the device. + * @author avraina + * + */ +public class WrapperRemoteDevice extends RemoteDevice{ + + public WrapperRemoteDevice(String address) { + super(address); + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/emulator/EmulatorDeployer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/emulator/EmulatorDeployer.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,105 @@ +/** + * 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.emulator; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +import org.symbian.tools.wrttools.core.deployer.DeployException; +import org.symbian.tools.wrttools.core.deployer.DeployerMessages; +import org.symbian.tools.wrttools.core.deployer.WidgetDeployer; +import org.symbian.tools.wrttools.core.status.IWRTConstants; + +/** + * The class needed for the deployment of the widget to emulator. + * @author avraina + */ +public class EmulatorDeployer extends WidgetDeployer { + + private boolean isDeploySuccessful = false; + + public IStatus deploy(String fileName, String des, IProgressMonitor monitor) throws DeployException{ + File inputFile = new File(fileName); + File outputFile = new File(des); + emitStatus(DeployerMessages.getString("Deployer.begin.msg")); //$NON-NLS-1$ + try { + if(!outputFile.isDirectory()){ + outputFile.mkdir(); + } + } catch (Exception e) { + emitStatus(DeployerMessages.getString("Deployer.failed.err.msg")); //$NON-NLS-1$ + throw new DeployException(e); + } + + // If the archive is directly deployed than directly deploy it + // else deploy from the folder path. + if(fileName.toLowerCase().endsWith(IWRTConstants.WIDGET_FILE_EXTENSION)){ + File out = new File(outputFile + "/" + inputFile.getName()); //$NON-NLS-1$ + deployWidget(inputFile, out); + } + if(isDeploySuccessful){ + emitStatus(DeployerMessages.getString("Deployer.ends.msg")); //$NON-NLS-1$ + } else { + emitStatus(DeployerMessages.getString("Deployer.failed.err.msg")); //$NON-NLS-1$ + } + return Status.OK_STATUS; + } + + // helper methods + + /** + * Deploys the widget from the source to the destination path of the emulator. + * @param inputFile the actual widget path from where widget needs to be deployed. + * @param outputFile the path of the emulator where the widget will be deoplyed. + * @throws DeployException throw a DeployException if anything goes wrong. + */ + private void deployWidget(File inputFile, File outputFile) throws DeployException{ + try { + String message = MessageFormat.format(DeployerMessages.getString("Deployer.inputfile.msg"), new Object[]{inputFile});//$NON-NLS-1$ + emitStatus(message); + + InputStream in = new FileInputStream(inputFile); + OutputStream out = new FileOutputStream(outputFile); + int c; + + while ((c = in.read()) != -1) + out.write(c); + in.close(); + out.close(); + + message = MessageFormat.format(DeployerMessages.getString("Deployer.outputfile.msg"), new Object[]{outputFile});//$NON-NLS-1$ + emitStatus(message); + isDeploySuccessful= true; + } catch (Exception e) { + emitStatus(e.getMessage()); + isDeploySuccessful=false; + emitStatus(DeployerMessages.getString("Deployer.failed.err.msg")); //$NON-NLS-1$ + throw new DeployException(e); + } + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/emulator/EmulatorListProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/emulator/EmulatorListProvider.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,180 @@ +/** + * 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.emulator; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import org.symbian.tools.wrttools.core.IWRTConstants; + + + + +/** + * The Content provider for the Emulators List displayed. + * @author avraina + * + */ +public class EmulatorListProvider{ + + /** + * Map containing of the SDKS with the corresponding paths. + */ + private static HashMap listofEmulators = new HashMap(); + + public static HashMap populateEmulators() { + if (listofEmulators == null) { + listofEmulators = new HashMap(); + } + listofEmulators.clear(); + initialize(); + return listofEmulators; + } + + // helper methods + + /** + * This will parse the xml and create the nodes to be displayed on the table + * viewer. The information will be used by content & label provider to get + * the contents and display accordingly in the list of the projects in the view. + */ + public static HashMap initialize() { + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // Parse the devices.xml and retrieve the list of the emulators from it + // and build the list to be displayed in the view. + + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + File file = new File(IWRTConstants.DEVICES_XML_PATH); + if(file.exists()){ + FileInputStream fin = new FileInputStream(file); + Document document = builder.parse(fin); + NodeList childNodes = document.getChildNodes(); + + + + for (int i = 0; i < childNodes.getLength(); i++) { + + Node node = childNodes.item(i); + String nodeName = node.getNodeName(); + // If the node name is "devices" it is the root node of the xml. + if (nodeName.equals(IWRTConstants.DEVICES_TAG)) { + // once we have the root node get the child information to + // build the devices list. + createDevicesList(node); + + } + } + if(listofEmulators.size() == 0){ + listofEmulators.put("None",""); + } + + + + } + + } catch (ParserConfigurationException e) { +// WidgetUtils.getView().getLogger().severe(e.getMessage()); + } catch (SAXException e) { +// WidgetUtils.getView().getLogger().severe(e.getMessage()); + } catch (IOException e) { +// WidgetUtils.getView().getLogger().severe(e.getMessage()); + } + return listofEmulators; + } + + /** + * Creates the devices nodes in the table. + * @param parentNode + */ + private static void createDevicesList(Node parentNode) { + NodeList list = getChildNodes(parentNode); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + String nodeName = node.getNodeName(); + if (nodeName.equals(IWRTConstants.DEVICE_TAG)) { + createDeviceChildNode(node); + } + } + } + + /** + * Gets the EPOC ROOT node and than finally the list of devices. + * @param parentNode + */ + private static void createDeviceChildNode(Node parentNode) { + NodeList list = getChildNodes(parentNode); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + String nodeName = node.getNodeName(); + if (nodeName.equals(IWRTConstants.EPOC_ROOT_TAG)) { + addProject(node,parentNode); + } + } + } + + /** + * Adds the devices to the list to be displayed. + * @param deviceNode the device node + * @param epocNode the epoc root node. + */ + private static void addProject(Node epocNode, Node deviceNode) { + NodeList list = getChildNodes(epocNode); + NamedNodeMap attributes = deviceNode.getAttributes(); + String sdkId=""; + String sdkName=""; + for (int i = 0; i < attributes.getLength(); i++) { + Node item = attributes.item(i); + if(item.getNodeName().equals(IWRTConstants.NAME_ATTR)){ + sdkName = item.getNodeValue(); + } + if(item.getNodeName().equals(IWRTConstants.ID_ATTR)){ + sdkId = item.getNodeValue(); + } + } + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + if(sdkName.equals(IWRTConstants.EMULATOR_NAME)){ + listofEmulators.put(sdkId, node.getNodeValue()); + } + } + } + + /** + * Returns the child list of the particular Node. + * @param parentNode + */ + private static NodeList getChildNodes(Node parentNode) { + return parentNode.getChildNodes(); + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployException.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,38 @@ +/** + * 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.deployer; + +import org.symbian.tools.wrttools.core.exception.WRTException; + +public class DeployException extends WRTException { + + private static final long serialVersionUID = -4322746430125745192L; + + /** + * @param cause + */ + public DeployException(Throwable cause) { + super(cause); + } + + public DeployException(String message) { + super(message); + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployStatus.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployStatus.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,37 @@ +/** + * 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.deployer; + +import org.symbian.tools.wrttools.core.status.WRTStatus; + +/** + * Raises the Deploy Status. + * @author avraina + * + */ +public class DeployStatus extends WRTStatus{ + + /** + * @param statusSource + * @param statusDescription + */ + public DeployStatus(String statusSource, String statusDescription) { + super(statusSource, statusDescription); + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployerMessages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/DeployerMessages.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,43 @@ +/** + * 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.deployer; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class DeployerMessages { + private static final String BUNDLE_NAME = "org.symbian.tools.wrttools.core.deployer.deployerMessages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private DeployerMessages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + + +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployer.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,47 @@ +/* ============================================================================ + * Copyright © 2008 Nokia. All rights reserved. + * This material, including documentation and any related computer + * programs, is protected by copyright controlled by Nokia. All + * rights are reserved. Copying, including reproducing, storing, + * adapting or translating, any or all of this material requires the + * prior written consent of Nokia. This material also contains + * confidential information which may not be disclosed to others + * without the prior written consent of Nokia. + * ============================================================================*/ + +package org.symbian.tools.wrttools.core.deployer; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import org.symbian.tools.wrttools.core.status.IWRTStatusListener; + +/** + * The main interface for the Widget Project Deployment.The deployer will deploy the + * widget to the different devices which can be an emulator, server etc. + * @author avraina + * + */ +public interface IWidgetDeployer { + + /** + * The method will deploy the widget to the target. + * All the deployer tools must implement this method. Each deployer which + * @param inputPath the widget path from where the widget needs to be deployed. + * @param destinationPath the destination path to which widget will be deployed. + * This can be an emulator , server or any other device + * @return integer IStatus code. IStatus.OK for success, IStatus.CANCEL if the user canceled, IStatus.ERROR if an + * error was caught and reported to the status listener. + * @throws DeployException throws a Deploy Exception if anything goes wrong while + * deployment is going on. + */ + public IStatus deploy(String inputPath, String destinationPath, + IProgressMonitor progressMonitor) throws DeployException; + + /** + * Sets the status listner associated with the widget deployer + * @param statusListener the status listner to be associated. + */ + public void setStatusListener(IWRTStatusListener statusListener); + +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployerConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployerConstants.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,42 @@ +/** + * 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.deployer; + +/** + * Interface to hold the constants for the Deployer. + * @author avraina + * + */ +public interface IWidgetDeployerConstants { + + /** + * Refers to the deployer with can either be Emulator or Server or Device. + * @author avraina + * + */ + public enum DeployerType { + EMULATOR, SERVER, DEVICE + }; + + /** + * Widget file type. + */ + public static final String WIDGET_FILE_TYPE = "wgz"; +} + diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployer.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,116 @@ +/* ============================================================================ + * Copyright © 2008 Nokia. All rights reserved. + * This material, including documentation and any related computer + * programs, is protected by copyright controlled by Nokia. All + * rights are reserved. Copying, including reproducing, storing, + * adapting or translating, any or all of this material requires the + * prior written consent of Nokia. This material also contains + * confidential information which may not be disclosed to others + * without the prior written consent of Nokia. + * ============================================================================*/ + +package org.symbian.tools.wrttools.core.deployer; + +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.WRTStatusHandler; + +/** + * Main Class for the widget Deployer.This implements the IWidgetDeployer. + * Different Deployer need to extend this class.This also contains the default + * implementation for the actual widget deployer such as making a sure the widget + * is validated before deploying and also if the widget is packaged correctly before + * deploying. + * @author avraina + * + */ +public abstract class WidgetDeployer implements IWidgetDeployer{ + + private WRTStatusHandler statusHandler; + + IWRTStatusListener statusListener; + + protected String[] exceptionCodes = new String[] {"OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN"}; //$NON-NLS-1$ //$NON-NLS-2$ + + public WidgetDeployer() { + setStatus(); + } + + /** + * The method is to check whether the widget project is validated. + * This should be done before calling the deploy method. + * @param fileName. The file name which needs to be validated. + * @return true if the project is validated else false. + */ + public boolean callValidator(String fileName){ + return false; + } + + /** + * The method is to check whether the widget project is packaged. + * This should be done before calling the deploy method. + * @param fileName. The file name which need to be deployed. + * @return true if the project is packaged else false. + */ + public boolean callPackager(String fileName){ + return false; + } + + /** + * The method returns the extension of the widget to be deployed. + * @return the extension of the widget. + */ + public String checkPackagedInput(){ + return IWRTConstants.WIDGET_FILE_EXTENSION; + } + + protected void setStatus() { + statusHandler = new WRTStatusHandler(); + statusHandler.addListener(getStatusListener()); + } + + /** + * Returns the associated status listner with the widget deployer + * @return status listener + */ + public IWRTStatusListener getStatusListener() { + return statusListener; + } + + /** + * Sets the status listner associated with the widget deployer + * @param statusListener the status listner to be associated. + */ + public void setStatusListener(IWRTStatusListener statusListener) { + this.statusListener = statusListener; + } + + /** + * Creates the status specific to the widget deployer + * @param statusDescription the description of the status + * @return the WRTStatus created + */ + protected void emitStatus(String statusDescription) { + WRTStatus status = new WRTStatus(); + status.setStatusSource(IWRTConstants.StatusSourceType.DEPLOYER.name()); + status.setStatusDescription(statusDescription); + getStatusListener().emitStatus(status); + } + + /** + * Returns the customized methods from the exception error code. If it + * matches it returns the customized message else returns the exception itself + * @param message exception message + * @return the customized message + */ + protected String getExceptionMessage(String message) { + + if(message.contains(exceptionCodes[0])){ + return DeployerMessages.getString("Deployer.device.notsupport.err.msg"); //$NON-NLS-1$ + } else if (message.contains(exceptionCodes[1])){ + return DeployerMessages.getString("Deployer.device.rejected.err.msg"); //$NON-NLS-1$ + } + return message; + } +} \ No newline at end of file diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployerFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployerFactory.java Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,54 @@ +/** + * 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.deployer; + +import org.symbian.tools.wrttools.core.deploy.device.DeviceDeployer; +import org.symbian.tools.wrttools.core.deploy.emulator.EmulatorDeployer; +import org.symbian.tools.wrttools.core.status.IWRTStatusListener; + +/** + * Factory class which returns the emulator based on the input provided. + * @author avraina + * + */ +public class WidgetDeployerFactory { + + /** + * @param deployerType + * @return + */ + public static IWidgetDeployer createWidgetDeployer(String deployerType, IWRTStatusListener statusListener){ + int ordinal = IWidgetDeployerConstants.DeployerType.valueOf(deployerType.toUpperCase()).ordinal(); + IWidgetDeployer widgetDeployer; + + switch(ordinal){ + case 0: + widgetDeployer = new EmulatorDeployer(); + widgetDeployer.setStatusListener(statusListener); + return widgetDeployer; + + case 2: + widgetDeployer = new DeviceDeployer(); + widgetDeployer.setStatusListener(statusListener); + return widgetDeployer; + } + return null; + } +} diff -r 14ab024ecb09 -r 19985c154f5c org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/deployerMessages.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/deployerMessages.properties Mon Feb 15 13:46:26 2010 -0800 @@ -0,0 +1,16 @@ +Deployer.begin.msg=Deployment Started. +Deployer.ends.msg=Deployment Successful. +Deployer.completed.msg=Deployment Completed. +Deployer.cancelled.msg=Deployment Cancelled. +Deployer.inputfile.msg=Deploying file from -->{0} +Deployer.outputfile.msg=File deployed to -->{0} +Deployer.searchservice.msg=Searching for the service for the selected device "{0}"...... +Deployer.servicefound.msg=Service for the device "{0}" found +Deployer.services.connect.err.msg=Failed to connect to the service +Deployer.servicenotfound.err.msg=Cannot find service to the device "{0}" +Deployer.cannotdeploy.err.msg=Cannot deploy to the device "{0}" +Deployer.failed.err.msg=Deployment Failed. +Deployer.device.notsupport.err.msg=Device does not support the widget deployment. +Deployer.device.rejected.err.msg=Deployment rejected by the device. +Deployer.bluetooth.notconnected.msg=Bluetooth is either disabled or not present in the system. +Deployer.preperation.msg=Preparing Widget Deployment. \ No newline at end of file