org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTarget.java
changeset 460 c0bff5ed874c
parent 459 c278f0c8917f
equal deleted inserted replaced
459:c278f0c8917f 460:c0bff5ed874c
    43 import javax.obex.ResponseCodes;
    43 import javax.obex.ResponseCodes;
    44 
    44 
    45 import org.eclipse.core.runtime.CoreException;
    45 import org.eclipse.core.runtime.CoreException;
    46 import org.eclipse.core.runtime.IProgressMonitor;
    46 import org.eclipse.core.runtime.IProgressMonitor;
    47 import org.eclipse.core.runtime.IStatus;
    47 import org.eclipse.core.runtime.IStatus;
       
    48 import org.eclipse.core.runtime.MultiStatus;
    48 import org.eclipse.core.runtime.PlatformObject;
    49 import org.eclipse.core.runtime.PlatformObject;
    49 import org.eclipse.core.runtime.Status;
    50 import org.eclipse.core.runtime.Status;
    50 import org.eclipse.core.runtime.SubProgressMonitor;
    51 import org.eclipse.core.runtime.SubProgressMonitor;
    51 import org.eclipse.ui.IMemento;
    52 import org.eclipse.ui.IMemento;
    52 import org.symbian.tools.mtw.core.MTWCore;
    53 import org.symbian.tools.mtw.core.MTWCore;
    68         this.name = name;
    69         this.name = name;
    69         this.device = device;
    70         this.device = device;
    70         this.provider = provider;
    71         this.provider = provider;
    71     }
    72     }
    72 
    73 
    73     public IStatus deploy(IMTWProject project, IPackager packager, IProgressMonitor monitor)
    74     public IStatus deploy(IMTWProject project, IPackager packager, IProgressMonitor monitor) throws CoreException {
    74             throws CoreException {
    75         message = "Deployment was successful. Please follow on-screen instructions to complete application deployment on your device.";
       
    76         statuses.clear();
    75         monitor.beginTask(String.format("Deploying application %s to %s", project.getName(), name),
    77         monitor.beginTask(String.format("Deploying application %s to %s", project.getName(), name),
    76                 IProgressMonitor.UNKNOWN);
    78                 IProgressMonitor.UNKNOWN);
    77         final File application = packager.packageApplication(project, new SubProgressMonitor(monitor, 100));
    79         final File application = packager.packageApplication(project, new SubProgressMonitor(monitor, 100));
    78         try {
    80         try {
    79             deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10));
    81             deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10));
    80         } finally {
    82         } finally {
    81             application.delete();
    83             application.delete();
    82         }
    84         }
    83         monitor.done();
    85         monitor.done();
    84         return new Status(IStatus.OK, MTWCore.PLUGIN_ID, message);
    86         MultiStatus multiStatus = new MultiStatus(MTWCore.PLUGIN_ID, 0, message, null);
       
    87         for (IStatus status : statuses) {
       
    88             multiStatus.add(status);
       
    89         }
       
    90         return multiStatus;
    85     }
    91     }
    86 
    92 
    87     private void deployWidget(File inputWidget, String fileType, IProgressMonitor progressMonitor) throws CoreException {
    93     private void deployWidget(File inputWidget, String fileType, IProgressMonitor progressMonitor) throws CoreException {
    88         if (device == null) {
    94         if (device == null) {
    89             provider.discoverTargets(new SubProgressMonitor(progressMonitor, 10));
    95             provider.discoverTargets(new SubProgressMonitor(progressMonitor, 10));
   290             MTWCore.log("Error in Bluetooth service discovery", e);
   296             MTWCore.log("Error in Bluetooth service discovery", e);
   291         }
   297         }
   292         return serviceURL;
   298         return serviceURL;
   293     }
   299     }
   294 
   300 
   295     public void load(IMemento memento) {
   301     public void init(IMTWProject project, IPackager packager, IMemento memento) {
   296         // nothing
   302         // nothing
   297     }
   303     }
   298 
   304 
   299     public void save(IMemento memento) {
   305     public void save(IMemento memento) {
   300         // nothing
   306         // nothing
   301 
       
   302     }
   307     }
   303 
   308 
   304     public void setAddress(RemoteDevice device) {
   309     public void setAddress(RemoteDevice device) {
   305         this.device = device;
   310         this.device = device;
   306     }
   311     }