From beb118fdf288101b1e40c7e0078840295b23c5a3 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 3 May 2016 14:31:34 -0400 Subject: [PATCH] Bug 492922 - Property test against the connection type ID Test the connection type id instead of if the connection has a service implementing ISerialPortService to prevent the test passing for connections that it should not. Change-Id: I6201e0f479e3bda7384daa4f0159e998b4fc2d22 Signed-off-by: Jonathan Williams --- .../META-INF/MANIFEST.MF | 3 ++- bundles/org.eclipse.remote.core/plugin.xml | 10 +++++++++ bundles/org.eclipse.remote.core/pom.xml | 2 +- .../core/RemoteConnectionPropertyTester.java} | 21 +++++++++++-------- .../serial/core/ISerialPortService.java | 2 +- .../org.eclipse.remote.serial.ui/plugin.xml | 15 ++----------- .../ui/SerialPortConnectionPropertyPage.java | 4 ++-- 7 files changed, 30 insertions(+), 27 deletions(-) rename bundles/{org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/internal/ui/SerialPortConnectionPropertyTester.java => org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionPropertyTester.java} (66%) diff --git a/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF index 6938a2c48ff..6b50341e72b 100644 --- a/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.remote.core;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.1.0.qualifier Bundle-Activator: org.eclipse.remote.internal.core.RemoteCorePlugin Bundle-Vendor: %pluginProvider Bundle-ActivationPolicy: lazy @@ -15,6 +15,7 @@ Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: org.eclipse.cdt.utils.pty, org.eclipse.cdt.utils.spawner, + org.eclipse.core.expressions, org.eclipse.core.filesystem, org.eclipse.core.resources, org.eclipse.core.runtime, diff --git a/bundles/org.eclipse.remote.core/plugin.xml b/bundles/org.eclipse.remote.core/plugin.xml index 6d5154b1b81..bdb2cd3159f 100644 --- a/bundles/org.eclipse.remote.core/plugin.xml +++ b/bundles/org.eclipse.remote.core/plugin.xml @@ -77,5 +77,15 @@ class="org.eclipse.remote.internal.core.preferences.PreferenceInitializer"> + + + + diff --git a/bundles/org.eclipse.remote.core/pom.xml b/bundles/org.eclipse.remote.core/pom.xml index c394f700afc..f46f38bddd3 100644 --- a/bundles/org.eclipse.remote.core/pom.xml +++ b/bundles/org.eclipse.remote.core/pom.xml @@ -11,6 +11,6 @@ org.eclipse.remote.core + 2.1.0-SNAPSHOT eclipse-plugin -2.0.0-SNAPSHOT diff --git a/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/internal/ui/SerialPortConnectionPropertyTester.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionPropertyTester.java similarity index 66% rename from bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/internal/ui/SerialPortConnectionPropertyTester.java rename to bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionPropertyTester.java index ef20b7016d3..70b275b2aa8 100644 --- a/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/internal/ui/SerialPortConnectionPropertyTester.java +++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionPropertyTester.java @@ -8,22 +8,25 @@ * Contributors: * QNX Software Systems - initial contribution *******************************************************************************/ -package org.eclipse.remote.serial.internal.ui; +package org.eclipse.remote.core; import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.remote.core.IRemoteConnection; -import org.eclipse.remote.serial.core.ISerialPortService; -public class SerialPortConnectionPropertyTester extends PropertyTester { +/** + * @since 2.1 + */ +public class RemoteConnectionPropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof IRemoteConnection) { - IRemoteConnection remote = (IRemoteConnection) receiver; - return remote.hasService(ISerialPortService.class); - } else { - return false; + if (property.equals("isConnectionType")) { + IRemoteConnection connection = (IRemoteConnection) receiver; + if (connection.getConnectionType().getId().equals(expectedValue)) { + return true; + } + } } + return false; } - } diff --git a/bundles/org.eclipse.remote.serial.core/src/org/eclipse/remote/serial/core/ISerialPortService.java b/bundles/org.eclipse.remote.serial.core/src/org/eclipse/remote/serial/core/ISerialPortService.java index 7a2df50e638..05d1d5db9e9 100644 --- a/bundles/org.eclipse.remote.serial.core/src/org/eclipse/remote/serial/core/ISerialPortService.java +++ b/bundles/org.eclipse.remote.serial.core/src/org/eclipse/remote/serial/core/ISerialPortService.java @@ -15,7 +15,7 @@ import org.eclipse.remote.core.IRemoteConnection; public interface ISerialPortService extends IRemoteConnection.Service { - static final String TYPE_ID = "org.eclipse.remote.serial.core.connectionType"; //$NON-NLS-1$ + static final String CONNECTION_TYPE_ID = "org.eclipse.remote.serial.core.connectionType"; //$NON-NLS-1$ static final String PORT_NAME_ATTR = "serial.portName"; //$NON-NLS-1$ static final String BAUD_RATE_ATTR = "serial.baudRate"; //$NON-NLS-1$ static final String BYTE_SIZE_ATTR = "serial.byteSize"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.remote.serial.ui/plugin.xml b/bundles/org.eclipse.remote.serial.ui/plugin.xml index 2026497b1bc..ea286af5ecc 100644 --- a/bundles/org.eclipse.remote.serial.ui/plugin.xml +++ b/bundles/org.eclipse.remote.serial.ui/plugin.xml @@ -8,16 +8,6 @@ factory="org.eclipse.remote.serial.internal.ui.SerialPortConnectionsUI$Factory" service="org.eclipse.remote.ui.IRemoteUIConnectionService"> - - - - @@ -29,9 +19,8 @@ - + property="org.eclipse.remote.core.isConnectionType" + value="org.eclipse.remote.serial.core.connectionType"/> diff --git a/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/ui/SerialPortConnectionPropertyPage.java b/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/ui/SerialPortConnectionPropertyPage.java index 2d6ed88166c..262ae591068 100644 --- a/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/ui/SerialPortConnectionPropertyPage.java +++ b/bundles/org.eclipse.remote.serial.ui/src/org/eclipse/remote/serial/ui/SerialPortConnectionPropertyPage.java @@ -25,8 +25,8 @@ import org.eclipse.ui.dialogs.PropertyPage; public class SerialPortConnectionPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { - private SerialPortConnectionBlock block; - private IRemoteConnectionWorkingCopy workingCopy; + protected SerialPortConnectionBlock block; + protected IRemoteConnectionWorkingCopy workingCopy; public SerialPortConnectionPropertyPage() { super();