final Window w = new Window();
w.setTitle("Import File Name");
w.setWidth("300px");
w.setClosable(true);
w.setPage(this.getPage());
final Textbox t = new Textbox();
t.setWidth("98%");
t.setMultiline(true);
t.setRows(20);
t.setParent(w);
t.setConstraint("no empty");
final Button ok = new Button("OK");
final Button cancel = new Button("Cancel");
ok.setParent(w);
ok.addEventListener(Events.ON_CLICK,
new EventListener() {
public void onEvent(Event e) throws Exception {
String val = t.getValue();
String[] vals = val.trim().split("\n");
final StringBuffer sb = new StringBuffer();
fileModel.clear();
final String r = getDesktop().getWebApp().getRealPath("/");
final File test2 = new File(r, PATH);
final File[] files = test2.listFiles(new MyFilenameFilter("", false));
for(int j = 0; j < vals.length; j++) {
boolean exist = false;
for (int i = 0; i < files.length; i++) {
if (vals[j].trim().equalsIgnoreCase(files[i].getName())) {
fileModel.add(files[i]);
exist = true;
break;
}
}
if (!exist) sb.append(vals[j].trim()).append("\n");
}
if (sb.toString().trim().length() > 0) t.setValue("Failed File Name:\n" + sb.toString());
w.insertBefore(new Label(" \nsuccess : [" + fileModel.size() + "] failed : [" + (vals.length - fileModel.size())+ "]"),
(Component)w.getChildren().get(0));
ok.detach();
cancel.detach();
}
});
cancel.setParent(w);
cancel.addEventListener(Events.ON_CLICK,
new EventListener() {
public void onEvent(Event e) throws Exception {
w.detach();
}
});
t.focus();
w.doModal();
}