for (int i = 0; i < availableRules.length; i++) {
availableRulesBox.addItem(availableRules[i]);
}
availableRulesBox.setSelectedIndex(0);
availableRulesBox.removeChangeListener(ruleSelectionCL);
ruleSelectionCL = new ChangeListener() {
public void onChange(Widget w) {
t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
}
};
availableRulesBox.addChangeListener(ruleSelectionCL);
h.add(availableRulesBox);
} else {
final Button showList = new Button(constants.showListButton());
h.add(showList);
showList.addClickListener(new ClickListener() {
public void onClick(Widget w) {
h.remove(showList);
final Image busy = new Image("images/searching.gif"); //NON-NLS
final Label loading = new SmallLabel(constants.loadingList1());
h.add(busy);
h.add(loading);
DeferredCommand.addCommand(new Command() {
public void execute() {
RepositoryServiceFactory.getService().listRulesInPackage(packageName, new GenericCallback<String[]>() {
public void onSuccess(String[] list) {
availableRules = (list);
final ListBox availableRulesBox = new ListBox();
availableRulesBox.addItem(constants.pleaseChoose1());
for (int i = 0; i < list.length; i++) {
availableRulesBox.addItem(list[i]);
}
ruleSelectionCL = new ChangeListener() {
public void onChange(Widget w) {
t.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
}
};