Why is my list returning nothing?
This code creates my list and adds it to the view
Code:
//Servers
new Label(banner, SWT.NONE).setText("Servers:");
Server[] servers = ServerGroup.getChildren();
final String[] serverNames = new String[servers.length];
for(int i = 0; i < servers.length; i++){
serverNames[i] = servers[i].getName();
}
categories = new List(banner, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
String[] testString = {"Test1","Test2","Test3"};
categories.setItems(testString);
//categories.setItems(serverNames);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
gridData.verticalSpan = 4;
int listHeight = categories.getItemHeight()*servers.length;
Rectangle trim = categories.computeTrim(0, 0, 0, listHeight);
gridData.heightHint = trim.height;
categories.setLayoutData(gridData);
and this is my selection listener that gets called after I press a button on the view
Code:
enter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
final String newDeploymentName = deploymentNameText.getText();
if (newDeploymentName.trim().isEmpty()) {
MessageDialog.openError(new Shell(), "Invalid Name", "Name field must not be blank.");
return;
}
if ( MessageDialog.openConfirm(new Shell(), "Confirm creation", "You are about to create a new Deployment")){
System.out.println("Categories:");
//I think it fails here String[] cats = categories.getItems();
// String[] cats = categories.getSelection();
for (int i = 0; i > cats.length; i++) {
System.out.println("Test");
System.out.println("\t" + cats[i]);
}
// Deployment newDeployment = new Deployment(newDeploymentName, ,);
// views.NavigationView.deploymentGroup.addChild(newDeployment);
}
}
});
I think getItems() is killing my program somehow. All that gets printed is Categories:
It never starts the loop for some reason. Any ideas?