if (modules.size() == 0)
return;
CollideSettings settings = CollideSettings.get();
String requested = settings.getModule();
GwtRecompile best = null;
if (requested == null) {
requested = Browser.getWindow().getLocalStorage().getItem(CookieKeys.GWT_COMPILE_TARGET);
}
if (requested != null) {
for (GwtRecompile compile : modules.asIterable()) {
if (requested.equals(compile.getModule())) {
best = compile;
break;
}
}
}
this.modules = Collections.mapFromStringTo();
HTMLCollection opts = (list).getOptions();
int m = opts.length();
if (m == 0) {
m = modules.size();
for (int i = 0; i < m; i++) {
list.appendChild(createOption(modules.get(i), i == 0));
}
} else {
// There are modules, let's merge
MapFromStringTo<Node> existing = Collections.mapFromStringTo();
for (int i = 0; i < m; i++) {
Node opt = opts.item(i);
Node attr = opt.getAttributes().getNamedItem("value");
if (attr != null)
existing.put(attr.getNodeValue(), opt);
}
m = modules.size();
for (int i = 0; i < m; i++) {
GwtRecompile module = modules.get(i);
Node duplicate = existing.get(module.getModule());
if (duplicate != null) {
// TODO check revision # and take freshest
duplicate.removeFromParent();
}
OptionElement opt = createOption(module, i == 0);