--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/BluetoothRule.java Wed Jun 09 13:33:59 2010 -0700
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.core.deploy;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class BluetoothRule implements ISchedulingRule {
+ public static final ISchedulingRule INSTANCE = new BluetoothRule();
+
+ private BluetoothRule() {
+ // No instantiation
+ }
+
+ public boolean contains(ISchedulingRule rule) {
+ return isConflicting(rule);
+ }
+
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule instanceof BluetoothRule;
+ }
+
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployJob.java Wed Jun 09 11:21:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/**
- * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-package org.symbian.tools.wrttools.core.deploy;
-
-import java.io.IOException;
-
-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.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressConstants2;
-import org.symbian.tools.wrttools.Activator;
-import org.symbian.tools.wrttools.WRTProject;
-import org.symbian.tools.wrttools.core.deployer.DeployException;
-import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
-import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
-import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
-import org.symbian.tools.wrttools.sdt.utils.Logging;
-import org.symbian.tools.wrttools.wizards.deploy.DeploymentTarget;
-
-public class DeployJob extends Job {
- public class AlwaysErrorMultiStatus extends MultiStatus {
- public AlwaysErrorMultiStatus(String message) {
- super(Activator.PLUGIN_ID, 0, message, null);
- }
-
- @Override
- public int getSeverity() {
- return IStatus.ERROR;
- }
- }
-
- private final DeploymentTarget target;
- private final WrtPackageActionDelegate packagerAction = new WrtPackageActionDelegate();
- private final WRTProject project;
-
- public DeployJob(WRTProject project, DeploymentTarget deploymentTarget) {
- super(String.format("Deploying %s to %s", project.getProject().getName(), deploymentTarget.getName()));
- setUser(true);
- setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
- this.project = project;
- this.target = deploymentTarget;
- }
-
- private void signalDeploymentComplete(final DeploymentTarget target) {
- if (target.getDeployMessage() != null) {
- final Shell shell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell();
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openWarning(shell, "WRT Application Deployment", target.getDeployMessage());
- }
- });
- }
- }
-
- public IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Deploying application", IProgressMonitor.UNKNOWN);
- final MultiStatus status = new AlwaysErrorMultiStatus(String.format("Cannot deploy appliction to %s",
- target.getName()));
- final IWRTStatusListener statusListener = new ProgressMonitorAndLogger(monitor, status);
- IWidgetDeployer wd = target.createDeployer(statusListener);
-
- IStatus result = new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null);
- IProject p = project.getProject();
- if (p != null) {
- /* package the files before deployment */
- boolean packageSuccess = packagerAction.packageProject(p, statusListener);
- if (!packageSuccess) {
- return status;
- }
- String packagedPath;
- try {
- IPath wgzPath = new Path(p.getName() + ".wgz");
- IFile wgz = p.getFile(wgzPath);
- packagedPath = wgz.getLocation().toFile().getCanonicalFile().toString();
- try {
- result = wd.deploy(packagedPath, target.getName(), monitor);
- if (result.isOK()) {
- project.setDeploymentTarget(target);
- signalDeploymentComplete(target);
- } else {
- result = status;
- }
- } 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);
- }
- }
- return result;
- }
-
-}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/DeployPreferencePage.java Wed Jun 09 11:21:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,418 +0,0 @@
-/**
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-
-package org.symbian.tools.wrttools.core.deploy;
-
-
-import java.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<String, String> emulatorHashMap = EmulatorListProvider.populateEmulators();
- private Set<String> 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());
-
-/* TODO -- do not enable blueCove diagnostics
- 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<DeployDeviceInfo> 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);
- }
-*/
- }
- }
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/ProgressRunnableDialog.java Wed Jun 09 11:21:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/**
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-
-package org.symbian.tools.wrttools.core.deploy;
-
-import 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();
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/BluetoothDeploymentJob.java Wed Jun 09 13:33:59 2010 -0700
@@ -0,0 +1,233 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.core.deploy.device;
+
+import java.io.EOFException;
+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 java.util.Collection;
+import java.util.LinkedList;
+
+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.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.core.deploy.BluetoothRule;
+import org.symbian.tools.wrttools.core.deployer.DeployerMessages;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployerConstants;
+
+public class BluetoothDeploymentJob extends Job {
+ protected String[] exceptionCodes = new String[] { "OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ private final Collection<IStatus> statuses = new LinkedList<IStatus>();
+ private String message = "Deployment was successful";
+ private final File inputWidget;
+ private final String device;
+
+ public BluetoothDeploymentJob(final File inputWidget, final String device) {
+ super(String.format("Deploy %s to %s", inputWidget.getName(), device));
+ this.device = device;
+ this.inputWidget = inputWidget;
+ setRule(BluetoothRule.INSTANCE);
+ setUser(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ deployWidget(inputWidget, device, monitor);
+ MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, 0, statuses.toArray(new IStatus[0]), message, null);
+ if (multiStatus.getSeverity() != IStatus.ERROR && multiStatus.getSeverity() != IStatus.WARNING) {
+ StatusManager.getManager().handle(multiStatus, StatusManager.SHOW);
+ }
+ return multiStatus;
+ }
+
+ /**
+ * 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 void deployWidget(File inputWidget, String device, IProgressMonitor progressMonitor) {
+ progressMonitor.beginTask("Deploying application", IProgressMonitor.UNKNOWN);
+ InputStream in = null;
+ OutputStream os = null;
+ Operation putOperation = null;
+ ClientSession clientSession = null;
+ try {
+ if (!DeviceListProvider.isBloothToothConnected()) {
+ String msg = DeployerMessages.getString("Deployer.bluetooth.notconnected.msg");
+ emitStatus(IStatus.ERROR, msg, progressMonitor);
+ return;
+ }
+
+ String message = MessageFormat.format(
+ DeployerMessages.getString("Deployer.searchservice.msg"), new Object[] { device });//$NON-NLS-1$
+ emitStatus(IStatus.OK, message, progressMonitor);
+ 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(IStatus.ERROR, message, progressMonitor);
+ return;
+ }
+
+ message = MessageFormat.format(
+ DeployerMessages.getString("Deployer.servicefound.msg"), new Object[] { device });//$NON-NLS-1$
+ emitStatus(IStatus.OK, message, progressMonitor);
+
+ clientSession = (ClientSession) Connector.open(servicesFound);
+ HeaderSet hsConnectReply = clientSession.connect(null);
+ if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) {
+ emitStatus(IStatus.OK, DeployerMessages.getString("Deployer.services.connect.err.msg"), progressMonitor);//$NON-NLS-1$
+ }
+
+ emitStatus(IStatus.OK, DeployerMessages.getString("Deployer.begin.msg"), progressMonitor);
+
+ HeaderSet hsOperation = clientSession.createHeaderSet();
+
+ if (progressMonitor.isCanceled()) {
+ emitStatus(IStatus.CANCEL, "Deployment was canceled", progressMonitor);
+ return;
+ }
+
+ // Send widget to server
+ in = new FileInputStream(inputWidget);
+ message = MessageFormat
+ .format(DeployerMessages.getString("Deployer.inputfile.msg"), new Object[] { inputWidget.getAbsolutePath() });//$NON-NLS-1$
+ emitStatus(IStatus.OK, message, progressMonitor);
+
+ 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();
+ emitStatus(IStatus.CANCEL, "Deployment was canceled", progressMonitor);
+ return;
+ }
+ }
+
+ os.flush();
+ os.close();
+
+ long elapsed = System.currentTimeMillis() - start;
+ emitStatus(IStatus.OK, "elapsed time: " + elapsed / 1000.0 + " seconds", progressMonitor);
+
+ 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(IStatus.OK, message, progressMonitor);
+ } else {
+ message = "Error during deployment, OBEX error: " + responseCode;
+ emitStatus(IStatus.ERROR, message, progressMonitor);
+ }
+
+ } catch (BluetoothConnectionException x) {
+ String message = getExceptionMessage(x.getMessage());
+ emitStatus(IStatus.ERROR, message, progressMonitor);
+ } catch (IOException e) {
+ String message = getExceptionMessage(e.getMessage());
+ emitStatus(IStatus.ERROR, message, progressMonitor);
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ if (putOperation != null) {
+ putOperation.close();
+ }
+ if (clientSession != null) {
+ clientSession.disconnect(null);
+ clientSession.close();
+ }
+ } catch (EOFException eof) {
+ // EOFException is now caught
+ // Ignore the error since deployment has already completed
+ //Activator.log(IStatus.ERROR, "EOF encountered while cleaning up Bluetooth deployment", eof);
+ } catch (IOException x) {
+ Activator.log(IStatus.ERROR, "Error cleaning up BlueTooth deployment", x);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Creates the status specific to the widget deployer
+ * @param statusDescription the description of the status
+ * @param monitor TODO
+ * @return the WRTStatus created
+ */
+ protected void emitStatus(int severity, String statusDescription, IProgressMonitor monitor) {
+ statuses.add(new Status(severity, Activator.PLUGIN_ID, statusDescription));
+ monitor.setTaskName(statusDescription);
+ if (severity != IStatus.OK) {
+ message = statusDescription;
+ }
+ }
+
+ /**
+ * 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;
+ }
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java Wed Jun 09 11:21:51 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deploy/device/DeviceDeployer.java Wed Jun 09 13:33:59 2010 -0700
@@ -19,27 +19,11 @@
package org.symbian.tools.wrttools.core.deploy.device;
-import java.io.EOFException;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.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.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;
@@ -52,171 +36,19 @@
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
+ // 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);
+ new BluetoothDeploymentJob(inputFile, device).schedule();
}
- 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;
+ emitStatus("Background deployment job started");//$NON-NLS-1$
+ return Status.OK_STATUS;
}
- /**
- * 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: " + 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 (EOFException eof) {
- // EOFException is now caught
- // Ignore the error since deployment has already completed
- //Activator.log(IStatus.ERROR, "EOF encountered while cleaning up Bluetooth deployment", eof);
- } 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;
- }
+ @Override
+ public boolean needsReport() {
+ return false;
+ }
}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployer.java Wed Jun 09 11:21:51 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/IWidgetDeployer.java Wed Jun 09 13:33:59 2010 -0700
@@ -21,7 +21,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-
import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
/**
@@ -52,4 +51,6 @@
*/
public void setStatusListener(IWRTStatusListener statusListener);
+ public boolean needsReport();
+
}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployer.java Wed Jun 09 11:21:51 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/deployer/WidgetDeployer.java Wed Jun 09 13:33:59 2010 -0700
@@ -39,8 +39,6 @@
IWRTStatusListener statusListener;
- protected String[] exceptionCodes = new String[] {"OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN"}; //$NON-NLS-1$ //$NON-NLS-2$
-
public WidgetDeployer() {
setStatus();
}
@@ -105,20 +103,8 @@
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;
- }
+
+ public boolean needsReport() {
+ return true;
+ }
}
\ No newline at end of file
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeployWizard.java Wed Jun 09 11:21:51 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeployWizard.java Wed Jun 09 13:33:59 2010 -0700
@@ -18,12 +18,57 @@
*/
package org.symbian.tools.wrttools.wizards.deploy;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
+import org.symbian.tools.wrttools.Activator;
import org.symbian.tools.wrttools.WRTProject;
-import org.symbian.tools.wrttools.core.deploy.DeployJob;
+import org.symbian.tools.wrttools.core.deployer.DeployException;
+import org.symbian.tools.wrttools.core.deployer.IWidgetDeployer;
+import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
+import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
+import org.symbian.tools.wrttools.core.status.WRTStatus;
+import org.symbian.tools.wrttools.sdt.utils.Logging;
+import org.symbian.tools.wrttools.util.ProjectUtils;
public class DeployWizard extends Wizard {
+ public class PagePrinter implements IWRTStatusListener {
+ private final DeploymentSummaryWizardPage page;
+
+ public PagePrinter(DeploymentSummaryWizardPage summaryPage) {
+ page = summaryPage;
+ }
+
+ public void emitStatus(WRTStatus status) {
+ page.log(status.getStatusDescription().toString());
+ }
+
+ public boolean isStatusHandled(WRTStatus status) {
+ return true;
+ }
+
+ public void close() {
+ // Do nothing
+ }
+
+ public boolean canPackageWithErrors(IProject project) {
+ return ProjectUtils.canPackageWithErrors(project);
+ }
+
+ }
+
private final DeployWizardContext context;
+ private final DeploymentSummaryWizardPage summaryPage = new DeploymentSummaryWizardPage();
private final WRTProject project;
public DeployWizard(WRTProject project) {
@@ -36,10 +81,13 @@
@Override
public void addPages() {
addPage(new DeploymentTargetWizardPage(context, project.getDeploymentTarget()));
+ addPage(summaryPage);
}
@Override
public boolean performFinish() {
+ summaryPage.clear();
+ getContainer().showPage(summaryPage);
return deploy();
}
@@ -53,8 +101,77 @@
*/
private boolean deploy() {
DeploymentTarget target = context.getTarget();
- DeployJob job = new DeployJob(project, target);
- job.schedule();
- return true;
+ DeployJob job = new DeployJob(context.getProject(), target);
+ try {
+ getContainer().run(true, true, job);
+ } catch (InvocationTargetException e) {
+ Activator.log(e);
+ } catch (InterruptedException e) {
+ Activator.log(e);
+ }
+ return job.isSuccessful();
+ }
+
+ private final class DeployJob implements IRunnableWithProgress {
+ private final DeploymentTarget target;
+ private final WrtPackageActionDelegate packagerAction = new WrtPackageActionDelegate();
+ private final IProject project;
+ private boolean successful = false;
+
+ private DeployJob(IProject project, DeploymentTarget deploymentTarget) {
+ this.project = project;
+ this.target = deploymentTarget;
+ }
+
+ public boolean isSuccessful() {
+ return successful;
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ IWRTStatusListener statusListener = new PagePrinter(summaryPage);
+ IWidgetDeployer wd = target.createDeployer(statusListener);
+
+ IStatus result = new Status(IStatus.OK, Activator.PLUGIN_ID, 0, "", null);
+
+ if (project != null) {
+ /* package the files before deployment */
+ boolean packageSuccess = packagerAction.packageProject(project, statusListener);
+ if (!packageSuccess) {
+ return;
+ }
+ String packagedPath;
+ try {
+ IPath wgzPath = new Path(project.getName() + ".wgz");
+ IFile wgz = project.getFile(wgzPath);
+ packagedPath = wgz.getLocation().toFile().getCanonicalFile().toString();
+ try {
+ result = wd.deploy(packagedPath, target.getName(), monitor);
+ if (result.isOK()) {
+ DeployWizard.this.project.setDeploymentTarget(target);
+ successful = true;
+ if (wd.needsReport()) {
+ signalDeploymentComplete(target);
+ }
+ }
+ } catch (DeployException e) {
+ result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getMessage(), e);
+ Logging.log(Activator.getDefault(), result);
+ }
+ } catch (IOException e) {
+ Activator.log(IStatus.ERROR, "Error deploying widget", e);
+ }
+ }
+ }
+
+ }
+
+ private void signalDeploymentComplete(final DeploymentTarget target) {
+ if (target.getDeployMessage() != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openWarning(getShell(), "WRT Application Deployment", target.getDeployMessage());
+ }
+ });
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/deploy/DeploymentSummaryWizardPage.java Wed Jun 09 13:33:59 2010 -0700
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards.deploy;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class DeploymentSummaryWizardPage extends WizardPage {
+ private StringBuilder buffer = new StringBuilder(1000);
+ private Text log;
+
+ protected DeploymentSummaryWizardPage() {
+ super("deploy");
+ setTitle("WRT Application Deployment");
+ setDescription("Please wait while deployment is in progress");
+ }
+
+ public void createControl(Composite parent) {
+ log = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
+ setControl(log);
+ }
+
+ public void log(String line) {
+ synchronized (buffer) {
+ buffer.append(line).append("\n");
+ }
+ log.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ synchronized (buffer) {
+ log.setText(buffer.toString());
+ }
+ }
+ });
+ }
+
+ public void clear() {
+ log.setText("");
+ buffer = new StringBuilder();
+ }
+}