1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Merge "Bug 461324 - Fix NPE in Remote Connections preference page"

This commit is contained in:
Greg Watson 2015-03-05 17:27:15 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit fab5645c94

View file

@ -33,7 +33,7 @@ import org.osgi.service.prefs.Preferences;
public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy { public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy {
private RemoteConnection original; private RemoteConnection original;
private RemoteConnectionType connectionType; private final RemoteConnectionType connectionType;
private String newName; private String newName;
private final Map<String, String> newAttributes = new HashMap<>(); private final Map<String, String> newAttributes = new HashMap<>();
private final Map<String, String> newSecureAttributes = new HashMap<>(); private final Map<String, String> newSecureAttributes = new HashMap<>();
@ -52,6 +52,7 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
*/ */
public RemoteConnectionWorkingCopy(RemoteConnection original) { public RemoteConnectionWorkingCopy(RemoteConnection original) {
this.original = original; this.original = original;
this.connectionType = (RemoteConnectionType) original.getConnectionType();
} }
/* /*
@ -63,11 +64,13 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
public String getName() { public String getName() {
if (newName != null) { if (newName != null) {
return newName; return newName;
} else if (original != null) {
return original.getName();
} else {
return null;
} }
if (original != null) {
return original.getName();
}
return null;
} }
/* /*
@ -77,7 +80,7 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
*/ */
@Override @Override
public void setName(String name) { public void setName(String name) {
// set if only if it's changed // set it only if it's changed
if (original == null || !name.equals(original.getName())) { if (original == null || !name.equals(original.getName())) {
newName = name; newName = name;
} }
@ -224,11 +227,7 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
*/ */
@Override @Override
public <T extends Service> T getService(Class<T> service) { public <T extends Service> T getService(Class<T> service) {
if (original != null) { return connectionType.getConnectionService(this, service);
return original.getService(service);
} else {
return connectionType.getConnectionService(this, service);
}
} }
/* /*
@ -373,15 +372,15 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
public boolean isOpen() { public boolean isOpen() {
if (original != null) { if (original != null) {
return original.isOpen(); return original.isOpen();
} else {
IRemoteConnectionControlService controlService = connectionType.getConnectionService(this,
IRemoteConnectionControlService.class);
if (controlService != null) {
return controlService.isOpen();
} else {
return true;
}
} }
IRemoteConnectionControlService controlService = connectionType.getConnectionService(this,
IRemoteConnectionControlService.class);
if (controlService != null) {
return controlService.isOpen();
}
return true;
} }
/* /*
@ -393,15 +392,15 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
public String getProperty(String key) { public String getProperty(String key) {
if (original != null) { if (original != null) {
return original.getProperty(key); return original.getProperty(key);
} else {
IRemoteConnectionPropertyService propertyService = connectionType.getConnectionService(this,
IRemoteConnectionPropertyService.class);
if (propertyService != null) {
return propertyService.getProperty(key);
} else {
return null;
}
} }
IRemoteConnectionPropertyService propertyService = connectionType.getConnectionService(this,
IRemoteConnectionPropertyService.class);
if (propertyService != null) {
return propertyService.getProperty(key);
}
return null;
} }
} }