Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2015-11-03 21:03:43 +0000
committerGerrit Code Review @ Eclipse.org2015-11-05 04:59:46 +0000
commit790f90ee55388d24c3b9969fda470b7919ee8237 (patch)
tree9f6a9972edb49fcb0ae5ea0c2d64325253cce4e4 /toolchains
parent19cd53ec1013c32ee90d61779f5077bae376942c (diff)
downloadorg.eclipse.cdt-790f90ee55388d24c3b9969fda470b7919ee8237.tar.gz
org.eclipse.cdt-790f90ee55388d24c3b9969fda470b7919ee8237.tar.xz
org.eclipse.cdt-790f90ee55388d24c3b9969fda470b7919ee8237.zip
Bug 481352 - Adapt Qt and Arduino providers to ILaunchTargets
ILaunchTarget replaces IRemoteConnection. Change-Id: I77825ae1347cec7095655548e06cb6dbc5c2aaf4
Diffstat (limited to 'toolchains')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml14
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java6
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java20
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoLaunchTargetProvider.java45
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnectionListener.java40
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoTargetAdapterFactory.java35
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml7
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoLaunchTargetLabelProvider.java28
8 files changed, 184 insertions, 11 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
index ae405304997..198bb473d45 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
@@ -107,6 +107,13 @@
type="org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration">
</adapter>
</factory>
+ <factory
+ adaptableType="org.eclipse.launchbar.core.target.ILaunchTarget"
+ class="org.eclipse.cdt.arduino.core.internal.remote.ArduinoTargetAdapterFactory">
+ <adapter
+ type="org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection">
+ </adapter>
+ </factory>
</extension>
<extension
point="org.eclipse.cdt.core.ToolChainFactory">
@@ -115,4 +122,11 @@
family="Arduino GCC">
</factory>
</extension>
+ <extension
+ point="org.eclipse.launchbar.core.launchTargetTypes">
+ <launchTargetType
+ id="org.eclipse.cdt.arduino.core.connectionType"
+ provider="org.eclipse.cdt.arduino.core.internal.remote.ArduinoLaunchTargetProvider">
+ </launchTargetType>
+ </extension>
</plugin>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java
index b373743ed32..d46509fda4c 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/Activator.java
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.arduino.core.internal;
+import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnectionListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.remote.core.IRemoteServicesManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -43,9 +45,13 @@ public class Activator extends Plugin {
public void start(BundleContext bundleContext) throws Exception {
plugin = this;
+ IRemoteServicesManager remoteManager = getService(IRemoteServicesManager.class);
+ remoteManager.addRemoteConnectionChangeListener(ArduinoRemoteConnectionListener.INSTANCE);
}
public void stop(BundleContext bundleContext) throws Exception {
+ IRemoteServicesManager remoteManager = getService(IRemoteServicesManager.class);
+ remoteManager.removeRemoteConnectionChangeListener(ArduinoRemoteConnectionListener.INSTANCE);
plugin = null;
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java
index 63459835a5e..71db1a293db 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/launch/ArduinoLaunchConfigurationProvider.java
@@ -21,26 +21,25 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.ProjectPerTargetLaunchConfigProvider;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionType;
-import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.ILaunchTargetManager;
public class ArduinoLaunchConfigurationProvider extends ProjectPerTargetLaunchConfigProvider {
@Override
- public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
+ public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
return DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurationType(ArduinoLaunchConfigurationDelegate.TYPE_ID);
}
@Override
- public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
+ public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
if (!super.supports(descriptor, target)) {
return false;
}
- if (target != null && !target.getConnectionType().getId().equals(ArduinoRemoteConnection.TYPE_ID)) {
+ if (target != null && !target.getTypeId().equals(ArduinoRemoteConnection.TYPE_ID)) {
return false;
}
@@ -50,7 +49,7 @@ public class ArduinoLaunchConfigurationProvider extends ProjectPerTargetLaunchCo
}
@Override
- protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
+ protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
super.populateLaunchConfiguration(descriptor, target, workingCopy);
if (target != null) {
@@ -59,14 +58,13 @@ public class ArduinoLaunchConfigurationProvider extends ProjectPerTargetLaunchCo
}
@Override
- protected IRemoteConnection getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
+ protected ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) throws CoreException {
String name = configuration.getAttribute(ArduinoLaunchConfigurationDelegate.CONNECTION_NAME, ""); //$NON-NLS-1$
if (name.isEmpty()) {
return null;
}
- IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
- IRemoteConnectionType type = manager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
- return type.getConnection(name);
+ ILaunchTargetManager manager = Activator.getService(ILaunchTargetManager.class);
+ return manager.getLaunchTarget(ArduinoRemoteConnection.TYPE_ID, name);
}
@Override
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoLaunchTargetProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoLaunchTargetProvider.java
new file mode 100644
index 00000000000..f2acfb371f9
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoLaunchTargetProvider.java
@@ -0,0 +1,45 @@
+package org.eclipse.cdt.arduino.core.internal.remote;
+
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.ILaunchTargetManager;
+import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
+import org.eclipse.launchbar.core.target.TargetStatus;
+import org.eclipse.launchbar.core.target.TargetStatus.Code;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+
+public class ArduinoLaunchTargetProvider implements ILaunchTargetProvider {
+
+ @Override
+ public void init(ILaunchTargetManager targetManager) {
+ IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
+ IRemoteConnectionType remoteType = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
+
+ // remove any targets that don't have connections
+ for (ILaunchTarget target : targetManager.getLaunchTargetsOfType(ArduinoRemoteConnection.TYPE_ID)) {
+ if (remoteType.getConnection(target.getName()) == null) {
+ targetManager.removeLaunchTarget(target);
+ }
+ }
+
+ // add any targets that are missing
+ for (IRemoteConnection connection : remoteType.getConnections()) {
+ if (targetManager.getLaunchTarget(ArduinoRemoteConnection.TYPE_ID, connection.getName()) == null) {
+ targetManager.addLaunchTarget(ArduinoRemoteConnection.TYPE_ID, connection.getName());
+ }
+ }
+ }
+
+ @Override
+ public TargetStatus getStatus(ILaunchTarget target) {
+ ArduinoRemoteConnection connection = target.getAdapter(ArduinoRemoteConnection.class);
+ if (connection.getRemoteConnection().isOpen()) {
+ return TargetStatus.OK_STATUS;
+ } else {
+ return new TargetStatus(Code.ERROR, "Not connected");
+ }
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnectionListener.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnectionListener.java
new file mode 100644
index 00000000000..a031393ae27
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoRemoteConnectionListener.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.arduino.core.internal.remote;
+
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.launchbar.core.target.ILaunchTargetManager;
+import org.eclipse.remote.core.IRemoteConnectionChangeListener;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
+
+public class ArduinoRemoteConnectionListener implements IRemoteConnectionChangeListener {
+
+ public static ArduinoRemoteConnectionListener INSTANCE = new ArduinoRemoteConnectionListener();
+
+ @Override
+ public void connectionChanged(RemoteConnectionChangeEvent event) {
+ switch (event.getType()) {
+ case RemoteConnectionChangeEvent.CONNECTION_ADDED:
+ if (event.getConnection().getConnectionType().getId().equals(ArduinoRemoteConnection.TYPE_ID)) {
+ ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class);
+ targetManager.addLaunchTarget(ArduinoRemoteConnection.TYPE_ID, event.getConnection().getName());
+ }
+ case RemoteConnectionChangeEvent.CONNECTION_REMOVED:
+ if (event.getConnection().getConnectionType().getId().equals(ArduinoRemoteConnection.TYPE_ID)) {
+ ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class);
+ ILaunchTarget target = targetManager.getLaunchTarget(ArduinoRemoteConnection.TYPE_ID,
+ event.getConnection().getName());
+ if (target != null) {
+ targetManager.removeLaunchTarget(target);
+ }
+ }
+ }
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoTargetAdapterFactory.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoTargetAdapterFactory.java
new file mode 100644
index 00000000000..e7734e3481c
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/remote/ArduinoTargetAdapterFactory.java
@@ -0,0 +1,35 @@
+package org.eclipse.cdt.arduino.core.internal.remote;
+
+import org.eclipse.cdt.arduino.core.internal.Activator;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+
+public class ArduinoTargetAdapterFactory implements IAdapterFactory {
+
+ private IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+ if (adaptableObject instanceof ILaunchTarget) {
+ ILaunchTarget target = (ILaunchTarget) adaptableObject;
+ if (target.getTypeId().equals(ArduinoRemoteConnection.TYPE_ID)) {
+ IRemoteConnectionType connectionType = remoteManager.getConnectionType(target.getTypeId());
+ IRemoteConnection connection = connectionType.getConnection(target.getName());
+ if (connection != null) {
+ return (T) connection.getService(ArduinoRemoteConnection.class);
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Class<?>[] getAdapterList() {
+ return new Class<?>[] { ArduinoRemoteConnection.class };
+ }
+
+}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
index c3a33f866c0..86fdc231a0c 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/plugin.xml
@@ -90,4 +90,11 @@
name="Boards">
</page>
</extension>
+ <extension
+ point="org.eclipse.launchbar.ui.launchTargetTypeUI">
+ <launchTargetTypeUI
+ id="org.eclipse.cdt.arduino.core.connectionType"
+ labelProvider="org.eclipse.cdt.arduino.ui.internal.remote.ArduinoLaunchTargetLabelProvider">
+ </launchTargetTypeUI>
+ </extension>
</plugin>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoLaunchTargetLabelProvider.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoLaunchTargetLabelProvider.java
new file mode 100644
index 00000000000..65186d4a302
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoLaunchTargetLabelProvider.java
@@ -0,0 +1,28 @@
+package org.eclipse.cdt.arduino.ui.internal.remote;
+
+import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
+import org.eclipse.cdt.arduino.ui.internal.Activator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
+import org.eclipse.swt.graphics.Image;
+
+public class ArduinoLaunchTargetLabelProvider extends LabelProvider {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof ILaunchTarget) {
+ return ((ILaunchTarget) element).getName();
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof ILaunchTarget
+ && ((ILaunchTarget) element).getTypeId().equals(ArduinoRemoteConnection.TYPE_ID)) {
+ return Activator.getDefault().getImageRegistry().get(Activator.IMG_ARDUINO);
+ }
+ return super.getImage(element);
+ }
+
+}

Back to the top