--- a/org.symbian.tools.mtw.ui/plugin.xml Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/plugin.xml Wed Jul 28 14:07:39 2010 -0700
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="deploymentTargetsProvider" name="Provides targets for project deployments" schema="schema/deploymentTargetsProvider.exsd"/>
+ <extension-point id="deploymentTargetType" name="Provides targets for project deployments" schema="schema/deploymentTargetType.exsd"/>
<!-- Navigator Extensions -->
<extension point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
@@ -134,13 +134,26 @@
</handler>
</extension>
<extension
- point="org.symbian.tools.mtw.ui.deploymentTargetsProvider">
- <deployment-target-platform
- class="org.symbian.tools.mtw.ui.deployment.bluetooth.BluetoothProvider"
+ point="org.symbian.tools.mtw.ui.deploymentTargetType">
+ <deployment-target-type
+ class="org.symbian.tools.mtw.ui.deployment.bluetooth.BluetoothTargetType"
icon="icons/full/obj16/bluetooth.gif"
id="org.symbian.tools.mtw.bluetooth"
priority="10">
- </deployment-target-platform>
+ </deployment-target-type>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.symbian.tools.mtw.ui.deployment.bluetooth.BluetoothTarget"
+ class="org.symbian.tools.mtw.ui.deployment.bluetooth.BluetoothTargetAdapterFactory">
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter2">
+ </adapter>
+ </factory>
</extension>
</plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/schema/deploymentTargetType.exsd Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.symbian.tools.mtw.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.symbian.tools.mtw.ui" id="deploymentTargetType" name="Provides targets for project deployments"/>
+ </appinfo>
+ <documentation>
+ MTW extenders can provide deployment targets - these include bluetooth devices, device emulators etc.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="deployment-target-type"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="deployment-target-type">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+ This icon would be used when list of the deployment targets is presented. Dynamic icons can be provided by returning adapters for org.eclipse.ui.model.IWorkbenchAdapter or org.eclipse.ui.model.IWorkbenchAdapter2 in deployment targets.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="resource"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+ Numeric value. Targets with lower priority value will be shown first
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
--- a/org.symbian.tools.mtw.ui/schema/deploymentTargetsProvider.exsd Wed Jul 28 09:27:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.symbian.tools.mtw.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.symbian.tools.mtw.ui" id="deploymentTargetsProvider" name="Provides targets for project deployments"/>
- </appinfo>
- <documentation>
- MTW extenders can provide deployment targets - these include bluetooth devices, device emulators etc.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="deployment-target-platform"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="deployment-target-platform">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- This icon would be used when list of the deployment targets is presented. Dynamic icons can be provided by returning adapters for org.eclipse.ui.model.IWorkbenchAdapter or org.eclipse.ui.model.IWorkbenchAdapter2 in deployment targets.
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="priority" type="string">
- <annotation>
- <documentation>
- Numeric value. Targets with lower priority value will be shown first
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeployWizardContext.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeployWizardContext.java Wed Jul 28 14:07:39 2010 -0700
@@ -49,11 +49,11 @@
}
public DeploymentTargetWrapper[] getDeploymentTargets() {
- final DeploymentTargetProviderDescriptor[] providers = DeploymentTargetProviderRegistry.getInstance()
+ final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
.getProviders();
Collection<DeploymentTargetWrapper> targets = new HashSet<DeploymentTargetWrapper>();
- for (DeploymentTargetProviderDescriptor provider : providers) {
+ for (DeploymentTargetTypeDescriptor provider : providers) {
if (provider.supports(project)) {
targets.addAll(Arrays.asList(provider.getTargets(project)));
}
@@ -62,19 +62,19 @@
}
public void doSearch(IProgressMonitor monitor) throws CoreException {
- final DeploymentTargetProviderDescriptor[] providers = DeploymentTargetProviderRegistry.getInstance()
+ final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
.getProviders();
monitor.beginTask("Discovering deployment targets", providers.length * 10);
- for (DeploymentTargetProviderDescriptor descriptor : providers) {
+ for (DeploymentTargetTypeDescriptor descriptor : providers) {
descriptor.discoverTargets(new SubProgressMonitor(monitor, 10));
}
monitor.done();
}
public boolean areTargetsReady() {
- final DeploymentTargetProviderDescriptor[] providers = DeploymentTargetProviderRegistry.getInstance()
+ final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
.getProviders();
- for (DeploymentTargetProviderDescriptor descriptor : providers) {
+ for (DeploymentTargetTypeDescriptor descriptor : providers) {
if (!descriptor.targetsDiscovered()) {
return false;
}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetProviderDescriptor.java Wed Jul 28 09:27:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +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.mtw.internal.deployment;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.symbian.tools.mtw.core.projects.IMTWProject;
-import org.symbian.tools.mtw.ui.MTWCoreUI;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
-
-public final class DeploymentTargetProviderDescriptor implements IDeploymentTargetProvider {
- public class NullProvider implements IDeploymentTargetProvider {
- public IDeploymentTarget[] getTargets(IMTWProject project) {
- return null;
- }
-
- public void discoverTargets(IProgressMonitor monitor) throws CoreException {
- // Do nothing
- }
-
- public IDeploymentTarget findTarget(IMTWProject project, String id) {
- return null;
- }
-
- public boolean targetsDiscovered() {
- return true;
- }
-
- public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
- return null; // No scheduling
- }
- }
-
- private static final DeploymentTargetWrapper[] NO_TARGETS = new DeploymentTargetWrapper[0];
- private final IConfigurationElement element;
- private IDeploymentTargetProvider provider;
- private final Map<IDeploymentTarget, DeploymentTargetWrapper> wrappers = new WeakHashMap<IDeploymentTarget, DeploymentTargetWrapper>();
- private ImageDescriptor imageDescriptor = null;
-
- public DeploymentTargetProviderDescriptor(IConfigurationElement element) {
- this.element = element;
- }
-
- public boolean supports(IMTWProject project) {
- // We will support more declarative filtering later
- return true;
- }
-
- public DeploymentTargetWrapper[] getTargets(IMTWProject project) {
- final DeploymentTargetWrapper[] targets = wrap(getProvider().getTargets(project));
- return targets != null ? targets : NO_TARGETS;
- }
-
- private DeploymentTargetWrapper[] wrap(IDeploymentTarget[] targets) {
- final DeploymentTargetWrapper[] w = new DeploymentTargetWrapper[targets.length];
- for (int i = 0; i < targets.length; i++) {
- final IDeploymentTarget target = targets[i];
- DeploymentTargetWrapper wrapper = wrappers.get(target);
- if (wrapper == null) {
- wrapper = new DeploymentTargetWrapper(target, this);
- wrappers.put(target, wrapper);
- }
- w[i] = wrapper;
- }
- return w;
- }
-
- public void discoverTargets(IProgressMonitor monitor) throws CoreException {
- getProvider().discoverTargets(monitor);
- }
-
- public IDeploymentTarget findTarget(IMTWProject project, String id) {
- return getProvider().findTarget(project, id);
- }
-
- private synchronized IDeploymentTargetProvider getProvider() {
- if (provider == null) {
- try {
- provider = (IDeploymentTargetProvider) element.createExecutableExtension("class");
- } catch (CoreException e) {
- MTWCoreUI.log("Cannot instantiate provider " + getId(), e);
- provider = new NullProvider();
- }
- }
- return provider;
- }
-
- public String getId() {
- return element.getAttribute("id");
- }
-
- public boolean targetsDiscovered() {
- return getProvider().targetsDiscovered();
- }
-
- public int getPriority() {
- final String attribute = element.getAttribute("priority");
- if (attribute != null && attribute.trim().length() > 0) {
- try {
- return Integer.parseInt(attribute);
- } catch (NumberFormatException e) {
- MTWCoreUI.log(String.format("%s is not a valid priority value for %s provider", attribute, getId()),
- null);
- }
- }
- return 0;
- }
-
- public ImageDescriptor getImageDescriptor() {
- if (imageDescriptor == null) {
- final String image = element.getAttribute("icon");
- if (image == null) {
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- } else {
- imageDescriptor = MTWCoreUI.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), image);
- }
- }
- return imageDescriptor;
- }
-
- public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
- return provider.getSchedulingRule(target);
- }
-
-}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetProviderRegistry.java Wed Jul 28 09:27:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +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.mtw.internal.deployment;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
-
-public class DeploymentTargetProviderRegistry {
- private static DeploymentTargetProviderRegistry INSTANCE;
-
- private DeploymentTargetProviderDescriptor[] descriptors;
-
- private DeploymentTargetProviderRegistry() {
- readExtensions();
- }
-
- private void readExtensions() {
- final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- "org.symbian.tools.mtw.ui.deploymentTargetsProvider");
- descriptors = new DeploymentTargetProviderDescriptor[elements.length];
- for (int i = 0; i < elements.length; i++) {
- descriptors[i] = new DeploymentTargetProviderDescriptor(elements[i]);
- }
- }
-
- public static synchronized DeploymentTargetProviderRegistry getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new DeploymentTargetProviderRegistry();
- }
- return INSTANCE;
- }
-
- public DeploymentTargetProviderDescriptor[] getProviders() {
- return descriptors;
- }
-
- public IDeploymentTargetProvider getProvider(String id) {
- DeploymentTargetProviderDescriptor[] providers = getProviders();
- for (DeploymentTargetProviderDescriptor descriptor : providers) {
- if (descriptor.getId().equals(id)) {
- return descriptor;
- }
- }
- return null;
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetTypeDescriptor.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,148 @@
+/**
+ * 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.mtw.internal.deployment;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.symbian.tools.mtw.core.projects.IMTWProject;
+import org.symbian.tools.mtw.ui.MTWCoreUI;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
+
+public final class DeploymentTargetTypeDescriptor implements IDeploymentTargetType {
+ public class NullProvider implements IDeploymentTargetType {
+ public IDeploymentTarget[] getTargets(IMTWProject project) {
+ return null;
+ }
+
+ public void discoverTargets(IProgressMonitor monitor) throws CoreException {
+ // Do nothing
+ }
+
+ public IDeploymentTarget findTarget(IMTWProject project, String id) {
+ return null;
+ }
+
+ public boolean targetsDiscovered() {
+ return true;
+ }
+
+ public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
+ return null; // No scheduling
+ }
+ }
+
+ private static final DeploymentTargetWrapper[] NO_TARGETS = new DeploymentTargetWrapper[0];
+ private final IConfigurationElement element;
+ private IDeploymentTargetType type;
+ private final Map<IDeploymentTarget, DeploymentTargetWrapper> wrappers = new WeakHashMap<IDeploymentTarget, DeploymentTargetWrapper>();
+ private ImageDescriptor imageDescriptor = null;
+
+ public DeploymentTargetTypeDescriptor(IConfigurationElement element) {
+ this.element = element;
+ }
+
+ public boolean supports(IMTWProject project) {
+ // We will support more declarative filtering later
+ return true;
+ }
+
+ public DeploymentTargetWrapper[] getTargets(IMTWProject project) {
+ final DeploymentTargetWrapper[] targets = wrap(getProvider().getTargets(project));
+ return targets != null ? targets : NO_TARGETS;
+ }
+
+ private DeploymentTargetWrapper[] wrap(IDeploymentTarget[] targets) {
+ final DeploymentTargetWrapper[] w = new DeploymentTargetWrapper[targets.length];
+ for (int i = 0; i < targets.length; i++) {
+ final IDeploymentTarget target = targets[i];
+ DeploymentTargetWrapper wrapper = wrappers.get(target);
+ if (wrapper == null) {
+ wrapper = new DeploymentTargetWrapper(target, this);
+ wrappers.put(target, wrapper);
+ }
+ w[i] = wrapper;
+ }
+ return w;
+ }
+
+ public void discoverTargets(IProgressMonitor monitor) throws CoreException {
+ getProvider().discoverTargets(monitor);
+ }
+
+ public IDeploymentTarget findTarget(IMTWProject project, String id) {
+ return getProvider().findTarget(project, id);
+ }
+
+ private synchronized IDeploymentTargetType getProvider() {
+ if (type == null) {
+ try {
+ type = (IDeploymentTargetType) element.createExecutableExtension("class");
+ } catch (CoreException e) {
+ MTWCoreUI.log("Cannot instantiate provider " + getId(), e);
+ type = new NullProvider();
+ }
+ }
+ return type;
+ }
+
+ public String getId() {
+ return element.getAttribute("id");
+ }
+
+ public boolean targetsDiscovered() {
+ return getProvider().targetsDiscovered();
+ }
+
+ public int getPriority() {
+ final String attribute = element.getAttribute("priority");
+ if (attribute != null && attribute.trim().length() > 0) {
+ try {
+ return Integer.parseInt(attribute);
+ } catch (NumberFormatException e) {
+ MTWCoreUI.log(String.format("%s is not a valid priority value for %s provider", attribute, getId()),
+ null);
+ }
+ }
+ return 0;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ if (imageDescriptor == null) {
+ final String image = element.getAttribute("icon");
+ if (image == null) {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ } else {
+ imageDescriptor = MTWCoreUI.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), image);
+ }
+ }
+ return imageDescriptor;
+ }
+
+ public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
+ return type.getSchedulingRule(target);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetTypesRegistry.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,64 @@
+/**
+ * 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.mtw.internal.deployment;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.symbian.tools.mtw.ui.MTWCoreUI;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
+
+public class DeploymentTargetTypesRegistry {
+ private static DeploymentTargetTypesRegistry INSTANCE;
+
+ private DeploymentTargetTypeDescriptor[] descriptors;
+
+ private DeploymentTargetTypesRegistry() {
+ readExtensions();
+ }
+
+ private void readExtensions() {
+ final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ MTWCoreUI.PLUGIN_ID, "deploymentTargetType");
+ descriptors = new DeploymentTargetTypeDescriptor[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ descriptors[i] = new DeploymentTargetTypeDescriptor(elements[i]);
+ }
+ }
+
+ public static synchronized DeploymentTargetTypesRegistry getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new DeploymentTargetTypesRegistry();
+ }
+ return INSTANCE;
+ }
+
+ public DeploymentTargetTypeDescriptor[] getProviders() {
+ return descriptors;
+ }
+
+ public IDeploymentTargetType getProvider(String id) {
+ DeploymentTargetTypeDescriptor[] providers = getProviders();
+ for (DeploymentTargetTypeDescriptor descriptor : providers) {
+ if (descriptor.getId().equals(id)) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWrapper.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWrapper.java Wed Jul 28 14:07:39 2010 -0700
@@ -22,33 +22,66 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.model.WorkbenchAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter2;
import org.symbian.tools.mtw.core.projects.IMTWProject;
import org.symbian.tools.mtw.core.runtimes.IMobileWebRuntime;
import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
public class DeploymentTargetWrapper implements IDeploymentTarget {
- public class TargetWorkbenchAdapter extends WorkbenchAdapter {
- @Override
- public String getLabel(Object object) {
- return getName();
+ public class WorkbenchAdapter2Wrapper implements IWorkbenchAdapter2 {
+ private final IWorkbenchAdapter2 adapter;
+
+ public WorkbenchAdapter2Wrapper(IWorkbenchAdapter2 adapter) {
+ this.adapter = adapter;
}
- @Override
- public ImageDescriptor getImageDescriptor(Object object) {
- return provider.getImageDescriptor();
+ public RGB getForeground(Object element) {
+ return adapter.getForeground(((DeploymentTargetWrapper) element).getActualTarget());
+ }
+
+ public RGB getBackground(Object element) {
+ return adapter.getBackground(((DeploymentTargetWrapper) element).getActualTarget());
+ }
+
+ public FontData getFont(Object element) {
+ return adapter.getFont(((DeploymentTargetWrapper) element).getActualTarget());
}
}
- private final DeploymentTargetProviderDescriptor provider;
+ public class WorkbenchAdapterWrapper implements IWorkbenchAdapter {
+ private final IWorkbenchAdapter adapter;
+
+ public WorkbenchAdapterWrapper(IWorkbenchAdapter adapter) {
+ this.adapter = adapter;
+ }
+
+ public Object[] getChildren(Object o) {
+ return adapter.getChildren(((DeploymentTargetWrapper) o).getActualTarget());
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return adapter.getImageDescriptor(((DeploymentTargetWrapper) object).getActualTarget());
+ }
+
+ public String getLabel(Object o) {
+ return adapter.getLabel(((DeploymentTargetWrapper) o).getActualTarget());
+ }
+
+ public Object getParent(Object o) {
+ return adapter.getParent(((DeploymentTargetWrapper) o).getActualTarget());
+ }
+ }
+ final DeploymentTargetTypeDescriptor type;
private final IDeploymentTarget target;
- public DeploymentTargetWrapper(IDeploymentTarget target, DeploymentTargetProviderDescriptor provider) {
+ public DeploymentTargetWrapper(IDeploymentTarget target, DeploymentTargetTypeDescriptor type) {
this.target = target;
- this.provider = provider;
+ this.type = type;
}
public IStatus deploy(IMTWProject project, IMobileWebRuntime runtime, IProgressMonitor monitor)
@@ -79,15 +112,18 @@
}
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- Object ad = target.getAdapter(adapter);
- if (ad == null && adapter.equals(IWorkbenchAdapter.class)) {
- return new TargetWorkbenchAdapter();
+ Object a = target.getAdapter(adapter);
+ if (IWorkbenchAdapter.class.isAssignableFrom(adapter)) {
+ return a == null ? new TargetWorkbenchAdapter(this) : new WorkbenchAdapterWrapper((IWorkbenchAdapter) a);
+ } else if (IWorkbenchAdapter2.class.isAssignableFrom(adapter)) {
+ return a == null ? new TargetWorkbenchAdapter(this) : new WorkbenchAdapter2Wrapper((IWorkbenchAdapter2) a);
+ } else {
+ return a;
}
- return ad;
}
public int getCategory() {
- return provider.getPriority() * 0xFFFF + (provider.getId().hashCode() & 0xFFFF);
+ return type.getPriority() * 0xFFFF + (type.getId().hashCode() & 0xFFFF);
}
public String getId() {
@@ -99,7 +135,7 @@
}
public String getProviderId() {
- return provider.getId();
+ return type.getId();
}
@Override
@@ -118,8 +154,8 @@
target.load(child);
}
- public IDeploymentTargetProvider getProvider() {
- return provider;
+ public IDeploymentTargetType getType() {
+ return type;
}
public IDeploymentTarget getActualTarget() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/TargetWorkbenchAdapter.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,72 @@
+/**
+ * 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.mtw.internal.deployment;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter2;
+
+public class TargetWorkbenchAdapter implements IWorkbenchAdapter, IWorkbenchAdapter2 {
+ /**
+ *
+ */
+ private final DeploymentTargetWrapper deploymentTargetWrapper;
+
+ /**
+ * @param deploymentTargetWrapper
+ */
+ TargetWorkbenchAdapter(DeploymentTargetWrapper deploymentTargetWrapper) {
+ this.deploymentTargetWrapper = deploymentTargetWrapper;
+ }
+
+ public String getLabel(Object object) {
+ return this.deploymentTargetWrapper.getName();
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return this.deploymentTargetWrapper.type.getImageDescriptor();
+ }
+
+ public RGB getForeground(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public RGB getBackground(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public FontData getFont(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object[] getChildren(Object o) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getParent(Object o) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/Images.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/Images.java Wed Jul 28 14:07:39 2010 -0700
@@ -25,6 +25,7 @@
public final class Images {
private final String DISCOVER_ICON = "icons/full/obj16/discover.gif";
private final String EXCLUDED_ICON = "icons/full/obj16/excluded.gif";
+ private final String BLUETOOTH_ICON = "icons/full/obj16/bluetooth.gif";
private final ImageRegistry registry;
@@ -32,6 +33,7 @@
this.registry = registry;
add(registry, DISCOVER_ICON);
add(registry, EXCLUDED_ICON);
+ add(registry, BLUETOOTH_ICON);
}
private void add(final ImageRegistry registry, String icon) {
@@ -46,4 +48,8 @@
public ImageDescriptor getExcludedIconDescriptor() {
return registry.getDescriptor(EXCLUDED_ICON);
}
+
+ public ImageDescriptor getBluetoothImageDescriptor() {
+ return registry.getDescriptor(BLUETOOTH_ICON);
+ }
}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/ProjectMemo.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/ProjectMemo.java Wed Jul 28 14:07:39 2010 -0700
@@ -32,9 +32,9 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;
import org.symbian.tools.mtw.core.projects.IMTWProject;
-import org.symbian.tools.mtw.internal.deployment.DeploymentTargetProviderRegistry;
+import org.symbian.tools.mtw.internal.deployment.DeploymentTargetTypesRegistry;
import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
public class ProjectMemo {
private static final String DEPLOYMENT_PROVIDER = "providerId";
@@ -96,7 +96,7 @@
checkMemento();
String type = memento.getString(DEPLOYMENT_PROVIDER);
if (type != null) {
- final IDeploymentTargetProvider provider = DeploymentTargetProviderRegistry.getInstance().getProvider(
+ final IDeploymentTargetType provider = DeploymentTargetTypesRegistry.getInstance().getProvider(
type);
if (provider != null) {
IDeploymentTarget target = provider.findTarget(project, memento.getString(TARGET));
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/DeployWizard.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/DeployWizard.java Wed Jul 28 14:07:39 2010 -0700
@@ -75,7 +75,7 @@
private DeployJob(IMTWProject project, DeploymentTargetWrapper deploymentTarget) {
super(String.format("Deploying %s to %s", project.getName(), deploymentTarget.getName()));
- ISchedulingRule rule = deploymentTarget.getProvider().getSchedulingRule(deploymentTarget.getActualTarget());
+ ISchedulingRule rule = deploymentTarget.getType().getSchedulingRule(deploymentTarget.getActualTarget());
if (rule != null) {
rule = MultiRule.combine(rule, project.getProject());
} else {
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/IDeploymentTargetProvider.java Wed Jul 28 09:27:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +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.mtw.ui.deployment;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.symbian.tools.mtw.core.projects.IMTWProject;
-
-/**
- * This interface is for deployment targets providers.
- *
- * @author Eugene
- */
-public interface IDeploymentTargetProvider {
- /**
- * Returns list of the targets that accept provided project. Project
- * cannot be <code>null</code>.
- * @return List of the valid deployment targets. Both <code>null</code> and
- * empty array are a valid return value when there are no available targets.
- */
- IDeploymentTarget[] getTargets(IMTWProject project);
-
- /**
- * Discovers targets. This can be a long-running task and in most cases
- * will be triggered by the user.
- */
- void discoverTargets(IProgressMonitor monitor) throws CoreException;
-
- /**
- * Find target based on project and target ID. This method returns
- * <code>null</code> if target with given ID cannot be found or if
- * the target does not accept project any longer.
- */
- IDeploymentTarget findTarget(IMTWProject project, String id);
-
- /**
- * Return <code>false</code> if user needs to trigger long-running
- * discovery to see all potential deployment targets.
- */
- boolean targetsDiscovered();
-
- /**
- * @param target that will be used by a {@link org.eclipse.core.runtime.jobs.Job}
- * @return scheduling rule that will be used to properly schedule jobs to
- * avoid resource access conflicts. Can be <code>null</code>
- */
- ISchedulingRule getSchedulingRule(IDeploymentTarget target);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/IDeploymentTargetType.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,65 @@
+/**
+ * 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.mtw.ui.deployment;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.symbian.tools.mtw.core.projects.IMTWProject;
+
+/**
+ * This interface is for deployment targets providers.
+ *
+ * @author Eugene
+ */
+public interface IDeploymentTargetType {
+ /**
+ * Returns list of the targets that accept provided project. Project
+ * cannot be <code>null</code>.
+ * @return List of the valid deployment targets. Both <code>null</code> and
+ * empty array are a valid return value when there are no available targets.
+ */
+ IDeploymentTarget[] getTargets(IMTWProject project);
+
+ /**
+ * Discovers targets. This can be a long-running task and in most cases
+ * will be triggered by the user.
+ */
+ void discoverTargets(IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Find target based on project and target ID. This method returns
+ * <code>null</code> if target with given ID cannot be found or if
+ * the target does not accept project any longer.
+ */
+ IDeploymentTarget findTarget(IMTWProject project, String id);
+
+ /**
+ * Return <code>false</code> if user needs to trigger long-running
+ * discovery to see all potential deployment targets.
+ */
+ boolean targetsDiscovered();
+
+ /**
+ * @param target that will be used by a {@link org.eclipse.core.runtime.jobs.Job}
+ * @return scheduling rule that will be used to properly schedule jobs to
+ * avoid resource access conflicts. Can be <code>null</code>
+ */
+ ISchedulingRule getSchedulingRule(IDeploymentTarget target);
+}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothProvider.java Wed Jul 28 09:27:51 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +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.mtw.ui.deployment.bluetooth;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-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.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.symbian.tools.mtw.core.projects.IMTWProject;
-import org.symbian.tools.mtw.ui.ConsoleFactory;
-import org.symbian.tools.mtw.ui.MTWCoreUI;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
-import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
-
-import com.intel.bluetooth.BlueCoveImpl;
-
-/**
- * Discovers Bluetooth-enabled devices. This code is generic and will not
- * perform any checks if the discovered device can run application being
- * deployed.
- *
- * @author Eugene Ostroukhov (eugeneo@symbian.org)
- */
-public class BluetoothProvider implements IDeploymentTargetProvider {
- private final class WrtDiscoveryListener implements DiscoveryListener {
- final Object inquiryCompletedEvent;
- boolean isCanceled;
- final Map<String, BluetoothTarget> prevTargets;
- final IProgressMonitor progressMonitor;
-
- private WrtDiscoveryListener(Map<String, BluetoothTarget> previousTargets, Object inquiryCompletedEvent,
- IProgressMonitor progressMonitor) {
- this.prevTargets = previousTargets;
- this.inquiryCompletedEvent = inquiryCompletedEvent;
- this.progressMonitor = progressMonitor;
- }
-
- private void checkCanceled() {
- if (!isCanceled && progressMonitor != null) {
- if (progressMonitor.isCanceled()) {
- try {
- LocalDevice.getLocalDevice().getDiscoveryAgent().cancelInquiry(listener);
- } catch (BluetoothStateException e) {
- MTWCoreUI.log(e);
- }
- }
- }
- }
-
- public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
- try {
- if (btDevice.getFriendlyName(false) != null && btDevice.getFriendlyName(false).length() > 0) {
- final String name = btDevice.getFriendlyName(false);
-
- final BluetoothTarget target = prevTargets.get(name);
- if (target != null) {
- target.setAddress(btDevice);
- } else {
- targets.put(name, new BluetoothTarget(name, btDevice, BluetoothProvider.this));
- }
- checkCanceled();
- }
- } catch (BluetoothStateException e) {
- MTWCoreUI.log(e.getMessage(), e);
- } catch (IOException e) {
- MTWCoreUI.log(e.getMessage(), e);
- }
- }
-
- public void inquiryCompleted(int discType) {
- synchronized (inquiryCompletedEvent) {
- inquiryCompletedEvent.notifyAll();
- }
- }
-
- public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
- }
-
- public void serviceSearchCompleted(int transID, int respCode) {
- }
- }
-
- private static PrintStream savedSysOut;
- private boolean discovered = false;
- private WrtDiscoveryListener listener;
- private Map<String, BluetoothTarget> targets = new TreeMap<String, BluetoothTarget>();
-
- public BluetoothProvider() {
- // set parameters for BlueCove
- String param = Integer.toString(65 * 1024);
- System.setProperty("bluecove.obex.mtu", param);
- BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", param);
- }
-
- public void discoverTargets(IProgressMonitor monitor) throws CoreException {
- if (!isBloothToothConnected()) {
- throw new CoreException(new Status(IStatus.ERROR, MTWCoreUI.PLUGIN_ID, "Bluetooth is not available"));
- }
- monitor.beginTask("Discovering Bluetooth devices", IProgressMonitor.UNKNOWN);
- final Object inquiryCompletedEvent = new Object();
- final Map<String, BluetoothTarget> previousTargets = targets;
- targets = new TreeMap<String, BluetoothTarget>();
-
- listener = new WrtDiscoveryListener(previousTargets, inquiryCompletedEvent, monitor);
-
- synchronized (inquiryCompletedEvent) {
- boolean started;
- try {
- started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.GIAC, listener);
- if (started) {
- inquiryCompletedEvent.wait();
- discovered = true;
- }
- } catch (BluetoothStateException e) {
- MTWCoreUI.log(e.getMessage(), e);
- } catch (InterruptedException e) {
- MTWCoreUI.log(e.getMessage(), e);
- }
- }
- monitor.done();
- }
-
- /** Toggle BlueCove logging
- */
- public 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);
- }
- }
-
- public IDeploymentTarget findTarget(IMTWProject project, String id) {
- if (!isBloothToothConnected()) {
- return null;
- }
- if (discovered) {
- return targets.get(id);
- } else {
- BluetoothTarget target = targets.get(id);
- if (target == null) {
- target = new BluetoothTarget(id, null, this);
- targets.put(id, target);
- }
- return target;
- }
- }
-
- public IDeploymentTarget[] getTargets(IMTWProject project) {
- if (targets != null) {
- final Collection<BluetoothTarget> values = targets.values();
- return values.toArray(new IDeploymentTarget[values.size()]);
- } else {
- return null;
- }
- }
-
- /**
- * Check whether the bluetooth is on or not.
- *
- * @return whether the device is on.
- */
- public boolean isBloothToothConnected() {
- return LocalDevice.isPowerOn();
- }
-
- public boolean targetsDiscovered() {
- return discovered;
- }
-
- public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
- return BluetoothRule.INSTANCE;
- }
-}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTarget.java Wed Jul 28 09:27:51 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTarget.java Wed Jul 28 14:07:39 2010 -0700
@@ -62,10 +62,10 @@
protected String[] exceptionCodes = new String[] { "OBEX_HTTP_UNSUPPORTED_TYPE", "OBEX_HTTP_FORBIDDEN" };
private String message = "Deployment was successful. Please follow on-screen instructions to complete application deployment on your device.";
private final String name;
- private final BluetoothProvider provider;
+ private final BluetoothTargetType provider;
private final Collection<IStatus> statuses = new LinkedList<IStatus>();
- public BluetoothTarget(String name, RemoteDevice device, BluetoothProvider provider) {
+ public BluetoothTarget(String name, RemoteDevice device, BluetoothTargetType provider) {
this.name = name;
this.device = device;
this.provider = provider;
@@ -243,7 +243,7 @@
return name;
}
- public String getServicesFound() {
+ private String getServicesFound() {
try {
serviceURL = "";
UUID serviceUUID = OBEX_OBJECT_PUSH;
@@ -310,4 +310,8 @@
public void setAddress(RemoteDevice device) {
this.device = device;
}
+
+ public boolean isDiscovered() {
+ return device != null;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTargetAdapterFactory.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,41 @@
+/**
+ * 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.mtw.ui.deployment.bluetooth;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter2;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class BluetoothTargetAdapterFactory implements IAdapterFactory {
+ private final BluetoothTargetWorkbenchAdapter workbenchAdapter = new BluetoothTargetWorkbenchAdapter();
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if ((adapterType.isAssignableFrom(IWorkbenchAdapter.class) || adapterType
+ .isAssignableFrom(IWorkbenchAdapter2.class)) && adaptableObject instanceof BluetoothTarget) {
+ return workbenchAdapter;
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] { IWorkbenchAdapter2.class, IWorkbenchAdapter.class };
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTargetType.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,207 @@
+/**
+ * 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.mtw.ui.deployment.bluetooth;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+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.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.symbian.tools.mtw.core.projects.IMTWProject;
+import org.symbian.tools.mtw.ui.ConsoleFactory;
+import org.symbian.tools.mtw.ui.MTWCoreUI;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
+import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
+
+import com.intel.bluetooth.BlueCoveImpl;
+
+/**
+ * Discovers Bluetooth-enabled devices. This code is generic and will not
+ * perform any checks if the discovered device can run application being
+ * deployed.
+ *
+ * @author Eugene Ostroukhov (eugeneo@symbian.org)
+ */
+public class BluetoothTargetType implements IDeploymentTargetType {
+ private final class WrtDiscoveryListener implements DiscoveryListener {
+ final Object inquiryCompletedEvent;
+ boolean isCanceled;
+ final Map<String, BluetoothTarget> prevTargets;
+ final IProgressMonitor progressMonitor;
+
+ private WrtDiscoveryListener(Map<String, BluetoothTarget> previousTargets, Object inquiryCompletedEvent,
+ IProgressMonitor progressMonitor) {
+ this.prevTargets = previousTargets;
+ this.inquiryCompletedEvent = inquiryCompletedEvent;
+ this.progressMonitor = progressMonitor;
+ }
+
+ private void checkCanceled() {
+ if (!isCanceled && progressMonitor != null) {
+ if (progressMonitor.isCanceled()) {
+ try {
+ LocalDevice.getLocalDevice().getDiscoveryAgent().cancelInquiry(listener);
+ } catch (BluetoothStateException e) {
+ MTWCoreUI.log(e);
+ }
+ }
+ }
+ }
+
+ public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
+ try {
+ final String name = btDevice.getFriendlyName(false);
+ if (name != null && name.length() > 0) {
+ final BluetoothTarget target = prevTargets.get(name);
+ if (target != null) {
+ target.setAddress(btDevice);
+ targets.put(name, target);
+ } else {
+ targets.put(name, new BluetoothTarget(name, btDevice, BluetoothTargetType.this));
+ }
+ checkCanceled();
+ }
+ } catch (BluetoothStateException e) {
+ MTWCoreUI.log(e.getMessage(), e);
+ } catch (IOException e) {
+ MTWCoreUI.log(e.getMessage(), e);
+ }
+ }
+
+ public void inquiryCompleted(int discType) {
+ synchronized (inquiryCompletedEvent) {
+ inquiryCompletedEvent.notifyAll();
+ }
+ }
+
+ public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
+ }
+
+ public void serviceSearchCompleted(int transID, int respCode) {
+ }
+ }
+
+ private static PrintStream savedSysOut;
+ private boolean discovered = false;
+ private WrtDiscoveryListener listener;
+ private Map<String, BluetoothTarget> targets = new TreeMap<String, BluetoothTarget>();
+
+ public BluetoothTargetType() {
+ // set parameters for BlueCove
+ String param = Integer.toString(65 * 1024);
+ System.setProperty("bluecove.obex.mtu", param);
+ BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", param);
+ }
+
+ public void discoverTargets(IProgressMonitor monitor) throws CoreException {
+ if (!isBloothToothConnected()) {
+ throw new CoreException(new Status(IStatus.ERROR, MTWCoreUI.PLUGIN_ID, "Bluetooth is not available"));
+ }
+ monitor.beginTask("Discovering Bluetooth devices", IProgressMonitor.UNKNOWN);
+ final Object inquiryCompletedEvent = new Object();
+ final Map<String, BluetoothTarget> previousTargets = targets;
+ targets = new TreeMap<String, BluetoothTarget>();
+
+ listener = new WrtDiscoveryListener(previousTargets, inquiryCompletedEvent, monitor);
+
+ synchronized (inquiryCompletedEvent) {
+ boolean started;
+ try {
+ started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.GIAC, listener);
+ if (started) {
+ inquiryCompletedEvent.wait();
+ discovered = true;
+ }
+ } catch (BluetoothStateException e) {
+ MTWCoreUI.log(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ MTWCoreUI.log(e.getMessage(), e);
+ }
+ }
+ monitor.done();
+ }
+
+ /** Toggle BlueCove logging
+ */
+ public 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);
+ }
+ }
+
+ public IDeploymentTarget findTarget(IMTWProject project, String id) {
+ if (!isBloothToothConnected()) {
+ return null;
+ }
+ if (discovered) {
+ return targets.get(id);
+ } else {
+ BluetoothTarget target = targets.get(id);
+ if (target == null) {
+ target = new BluetoothTarget(id, null, this);
+ targets.put(id, target);
+ }
+ return target;
+ }
+ }
+
+ public IDeploymentTarget[] getTargets(IMTWProject project) {
+ if (targets != null) {
+ final Collection<BluetoothTarget> values = targets.values();
+ return values.toArray(new IDeploymentTarget[values.size()]);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Check whether the bluetooth is on or not.
+ *
+ * @return whether the device is on.
+ */
+ public boolean isBloothToothConnected() {
+ return LocalDevice.isPowerOn();
+ }
+
+ public boolean targetsDiscovered() {
+ return discovered;
+ }
+
+ public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
+ return BluetoothRule.INSTANCE;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/deployment/bluetooth/BluetoothTargetWorkbenchAdapter.java Wed Jul 28 14:07:39 2010 -0700
@@ -0,0 +1,65 @@
+/**
+ * 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.mtw.ui.deployment.bluetooth;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter2;
+import org.symbian.tools.mtw.ui.MTWCoreUI;
+
+public class BluetoothTargetWorkbenchAdapter implements IWorkbenchAdapter, IWorkbenchAdapter2 {
+ public RGB getForeground(Object element) {
+ final BluetoothTarget target = (BluetoothTarget) element;
+ if (!target.isDiscovered()) {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay()
+ .getSystemColor(SWT.COLOR_DARK_GRAY).getRGB();
+ }
+ return null;
+ }
+
+ public RGB getBackground(Object element) {
+ return null;
+ }
+
+ public FontData getFont(Object element) {
+ return null;
+ }
+
+ public Object[] getChildren(Object o) {
+ return null;
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return MTWCoreUI.getImages().getBluetoothImageDescriptor();
+ }
+
+ public String getLabel(Object o) {
+ final BluetoothTarget target = (BluetoothTarget) o;
+ return target.getName();
+ }
+
+ public Object getParent(Object o) {
+ return null;
+ }
+
+}