int state = cloudModule.getState();
// Based on property testers, this should already be started
if (state == IServer.STATE_STARTED) {
IURLProvider cloudServer = (IURLProvider)selectedServer.loadAdapter(IURLProvider.class, null);
CloudFoundryServer cfs = (CloudFoundryServer)selectedServer.loadAdapter(CloudFoundryServer.class, null);
String contextRoot = null;
if (cfs != null){
// IModule[][] because IModule[] is the correct representation of module structure
IModule[][] launchables = cfs.getLaunchableModules(selectedModule);
if (launchables != null){
if (launchables.length == 1){
contextRoot = cfs.getLaunchableModuleContextRoot(launchables[0]);
}
else if (launchables.length > 1 ){
List<String> selectionOptions = new ArrayList<String>();
Map<String, String> index = new HashMap<String, String>();
for (int i = 0; i < launchables.length; i++){
String option = ""; //$NON-NLS-1$
for (int j = 0; j < launchables[i].length; j++){
option += launchables[i][j].getName() + "/"; //$NON-NLS-1$
}
if (option.endsWith("/")){ //$NON-NLS-1$
option = option.substring(0, option.length() - 1);
}
selectionOptions.add(option);
index.put(option, String.valueOf(i));
}
ElementListSelectionDialog dialog = new ElementListSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), new LabelProvider());
dialog.setTitle(TITLE);
dialog.setMessage(DESCRIPTION);
dialog.setElements(selectionOptions.toArray());
if (dialog.open() != Window.OK) {
if (dialog.getReturnCode() == Window.CANCEL){
CloudFoundryPlugin.logWarning("User pressed cancel on selection dialog"); //$NON-NLS-1$
return null;
}
CloudFoundryPlugin.logError(("Failed to open the Open Home Page selection dialog")); //$NON-NLS-1$
return null;
}
Object[] result = dialog.getResult();
contextRoot = cfs.getLaunchableModuleContextRoot(launchables[Integer.valueOf(index.get(result[0]))]);
}
}
}
try {