}
@Override
public void run() {
IRSECoreRegistry coreReg = RSECorePlugin.getTheCoreRegistry();
ISystemRegistry sysReg = RSECorePlugin.getTheSystemRegistry();
String systemTypeId = CloudFoundryBrandingExtensionPoint.getRemoteSystemTypeId(serverTypeId);
if (systemTypeId != null && systemTypeId.trim().length() > 0) {
IRSESystemType systemType = coreReg.getSystemTypeById(systemTypeId);
IHost host = null;
IHost[] hosts = sysReg.getHostsBySystemType(systemType);
if (hosts.length >= 1) {
host = hosts[0];
}
if (host == null) {
try {
host = sysReg.createHost(systemType, systemType.getLabel(), server.getUrl(), ""); //$NON-NLS-1$
ISubSystem[] subSystems = sysReg.getSubSystems(host);
CloudFoundryConnectorServiceManager serviceManager = CloudFoundryConnectorServiceManager.getInstance();
CloudFoundryConnectorService service = (CloudFoundryConnectorService) serviceManager
.createConnectorService(host);
for (int i = 0; i < subSystems.length; i++) {
service.registerSubSystem(subSystems[i]);
}
}
catch (Exception e) {
CloudFoundryRsePlugin.logError("An error occurred while connecting to service.", e); //$NON-NLS-1$
}
}
if (host != null) {
SystemViewPart viewPart = (SystemViewPart) SystemPerspectiveHelpers.showView(SystemViewPart.ID);
final SystemView view = viewPart.getSystemView();
ISubSystem[] subSystems = sysReg.getSubSystems(host);
if (subSystems.length > 0) {
final ISubSystem system = subSystems[0];
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
view.setExpandedState(system.getHost(), true);