Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2015-04-29 06:04:59 +0000
committerMarkus Schorn2015-04-29 06:04:59 +0000
commit8af8df18e6fd0a15962fc93407e3c804e3f82bab (patch)
tree47e2412678bdfae58341f548dfe18b56590817c6 /target_explorer/plugins
parent5cadb86f972898edf3b0c7a4d4dee5b1d967b677 (diff)
downloadorg.eclipse.tcf-8af8df18e6fd0a15962fc93407e3c804e3f82bab.tar.gz
org.eclipse.tcf-8af8df18e6fd0a15962fc93407e3c804e3f82bab.tar.xz
org.eclipse.tcf-8af8df18e6fd0a15962fc93407e3c804e3f82bab.zip
Bug 465758: Remove use of deprecated IFileTransferItem.PROPERTY_TARGET
Change-Id: Id3d369195443a2bc8b778e270ab3c0d4dc36fb88 Signed-off-by: Markus Schorn <markus.schorn@windriver.com>
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java74
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/filetransfer/FileTransferItemValidator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java12
5 files changed, 88 insertions, 28 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
index b90cf6e2a..f23474bcb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 Wind River Systems, Inc. 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
@@ -289,11 +289,10 @@ public abstract class AbstractFileTransferSection extends AbstractTableSection i
if (element instanceof IFileTransferItem) {
IFileTransferItem item = (IFileTransferItem)element;
Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
- return invalid.get(IFileTransferItem.PROPERTY_TARGET);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET_STRING)) {
+ return invalid.get(IFileTransferItem.PROPERTY_TARGET_STRING);
}
- String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- return target != null ? new Path(target).toPortableString() : target;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
}
return super.getText(element);
}
@@ -302,8 +301,7 @@ public abstract class AbstractFileTransferSection extends AbstractTableSection i
public String getText(Object element) {
if (element instanceof IFileTransferItem) {
IFileTransferItem item = (IFileTransferItem)element;
- String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- return target != null ? new Path(target).toPortableString() : target;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
}
return super.getText(element);
}
@@ -396,7 +394,7 @@ public abstract class AbstractFileTransferSection extends AbstractTableSection i
}
break;
case 3:
- if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET_STRING)) {
return STATE_ERROR;
}
break;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
index ae015645d..d5ffc1a4d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java
@@ -10,6 +10,9 @@
package org.eclipse.tcf.te.runtime.services.filetransfer;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
@@ -20,6 +23,8 @@ import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransfer
*/
public class FileTransferItem extends PropertiesContainer implements IFileTransferItem {
+ private boolean fPatchingSetProperty;
+
/**
* Constructor.
*/
@@ -45,7 +50,6 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf
setProperty(PROPERTY_HOST, fromHost.toPortableString());
if (toTarget != null) {
setProperty(PROPERTY_TARGET, toTarget.toPortableString());
- setProperty(PROPERTY_TARGET_STRING, toTarget.toString());
}
}
@@ -54,15 +58,73 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf
if (fromHost != null)
setProperty(PROPERTY_HOST, fromHost.toPortableString());
if (toTarget != null) {
- // Replace multiple slashes with a single slash
- toTarget = toTarget.replaceAll("/+", "/"); //$NON-NLS-1$ //$NON-NLS-2$
- // Remove trailing slash
- if (toTarget.endsWith("/") && toTarget.length() > 1) //$NON-NLS-1$
- toTarget = toTarget.substring(0, toTarget.length()-1);
setProperty(PROPERTY_TARGET_STRING, toTarget);
}
}
+ private String normalizeTargetPath(Object tgtPath) {
+ if (tgtPath == null)
+ return null;
+
+ String path = String.valueOf(tgtPath);
+ // Replace multiple slashes with a single slash
+ path = path.replaceAll("/+", "/"); //$NON-NLS-1$ //$NON-NLS-2$
+ // Remove trailing slash
+ if (path.endsWith("/") && path.length() > 1) //$NON-NLS-1$
+ path = path.substring(0, path.length()-1);
+
+ return path;
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public boolean setProperty(String key, Object value) {
+ if (!fPatchingSetProperty) {
+ try {
+ fPatchingSetProperty = true;
+ if (PROPERTY_TARGET.equals(key)) {
+ setProperty(PROPERTY_TARGET_STRING, pathToString(value));
+ return setProperty(PROPERTY_TARGET, value);
+ }
+ if (PROPERTY_TARGET_STRING.equals(key)) {
+ value = normalizeTargetPath(value);
+ setProperty(PROPERTY_TARGET, stringToPath(value));
+ return setProperty(PROPERTY_TARGET_STRING, value);
+ }
+ } finally {
+ fPatchingSetProperty = false;
+ }
+ }
+ return super.setProperty(key, value);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public final void setProperties(Map<String, Object> properties) {
+ if (properties.containsKey(PROPERTY_TARGET)) {
+ if (!properties.containsKey(PROPERTY_TARGET_STRING)) {
+ properties = new HashMap<String, Object>(properties);
+ properties.put(PROPERTY_TARGET_STRING, pathToString(properties.get(PROPERTY_TARGET)));
+ }
+ } else if (properties.containsKey(PROPERTY_TARGET_STRING)) {
+ properties = new HashMap<String, Object>(properties);
+ properties.put(PROPERTY_TARGET, stringToPath(properties.get(PROPERTY_TARGET_STRING)));
+ }
+ super.setProperties(properties);
+ }
+
+ private String pathToString(Object value) {
+ if (value == null)
+ return null;
+ return Path.fromPortableString(String.valueOf(value)).toString();
+ }
+
+ private String stringToPath(Object value) {
+ if (value == null)
+ return null;
+ return new Path(String.valueOf(value)).toPortableString();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IFileTransferItem#isEnabled()
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java
index 075ac7d9d..21bec962e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 Wind River Systems, Inc. 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
@@ -378,7 +378,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo
* @see org.eclipse.tcf.te.runtime.interfaces.IPropertiesContainer#setProperties(java.util.Map)
*/
@Override
- public final void setProperties(Map<String, Object> properties) {
+ public void setProperties(Map<String, Object> properties) {
Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(properties);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/filetransfer/FileTransferItemValidator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/filetransfer/FileTransferItemValidator.java
index 2d48a28d2..bcf07c6fe 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/filetransfer/FileTransferItemValidator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/filetransfer/FileTransferItemValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 Wind River Systems, Inc. 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
@@ -31,7 +31,7 @@ public class FileTransferItemValidator {
Map<String,String> invalid = new HashMap<String,String>();
String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
- String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
int direction = (item.getProperty(IFileTransferItem.PROPERTY_DIRECTION) != null ?
item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION) : IFileTransferItem.HOST_TO_TARGET);
@@ -60,22 +60,22 @@ public class FileTransferItemValidator {
if (target == null || target.trim().length() == 0) {
if (direction == IFileTransferItem.HOST_TO_TARGET) {
- invalid.put(IFileTransferItem.PROPERTY_TARGET, Messages.FileTransferItemValidator_missingFileOrDirectory);
+ invalid.put(IFileTransferItem.PROPERTY_TARGET_STRING, Messages.FileTransferItemValidator_missingFileOrDirectory);
}
else {
- invalid.put(IFileTransferItem.PROPERTY_TARGET, Messages.FileTransferItemValidator_missingFile);
+ invalid.put(IFileTransferItem.PROPERTY_TARGET_STRING, Messages.FileTransferItemValidator_missingFile);
}
}
else {
IPath targetPath = new Path(target);
if (direction == IFileTransferItem.HOST_TO_TARGET) {
if (!targetPath.isValidPath(target)) {
- invalid.put(IFileTransferItem.PROPERTY_TARGET, Messages.FileTransferItemValidator_invalidFileOrDirectory);
+ invalid.put(IFileTransferItem.PROPERTY_TARGET_STRING, Messages.FileTransferItemValidator_invalidFileOrDirectory);
}
}
else {
if (!targetPath.isValidPath(target)) {
- invalid.put(IFileTransferItem.PROPERTY_TARGET, Messages.FileTransferItemValidator_invalidFile);
+ invalid.put(IFileTransferItem.PROPERTY_TARGET_STRING, Messages.FileTransferItemValidator_invalidFile);
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java
index 1f5e09df7..1ea6ee780 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java
@@ -236,10 +236,10 @@ public class AddEditFileTransferDialog extends CustomTitleAreaDialog {
host.updateControlDecoration(null, IMessageProvider.NONE);
}
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
- target.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_TARGET), IMessageProvider.ERROR);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET_STRING)) {
+ target.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_TARGET_STRING), IMessageProvider.ERROR);
if (valid) {
- setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_TARGET));
+ setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_TARGET_STRING));
}
valid = false;
}
@@ -256,7 +256,7 @@ public class AddEditFileTransferDialog extends CustomTitleAreaDialog {
private void saveWidgetValues(IFileTransferItem wc) {
wc.setProperty(IFileTransferItem.PROPERTY_HOST, new Path(host.getEditFieldControlText()).toPortableString());
- wc.setProperty(IFileTransferItem.PROPERTY_TARGET, new Path(target.getEditFieldControlText()).toPortableString());
+ wc.setProperty(IFileTransferItem.PROPERTY_TARGET_STRING, target.getEditFieldControlText().trim());
wc.setProperty(IFileTransferItem.PROPERTY_OPTIONS, options.getEditFieldControlText());
int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
@@ -271,8 +271,8 @@ public class AddEditFileTransferDialog extends CustomTitleAreaDialog {
String hostPath = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
host.setEditFieldControlText(hostPath != null ? new Path(hostPath).toOSString() : ""); //$NON-NLS-1$
- String targetPath = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- target.setEditFieldControlText(targetPath != null ? new Path(targetPath).toPortableString() : ""); //$NON-NLS-1$
+ String targetPath = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET_STRING);
+ target.setEditFieldControlText(targetPath != null ? targetPath : ""); //$NON-NLS-1$
target.getButtonControl().setEnabled(launchContext != null);
String optionsString = item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);

Back to the top