public MenuItem[] getMenu() {
return Menu;
}
public int menuAction(int action) {
Admin admin = Admin.getInstance();
switch ( action ) {
case ACTION_IMPORT: {
try {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(true);
int result = fc.showDialog(admin, "Import");
if ( result == JFileChooser.APPROVE_OPTION ) {
admin.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Stopwatch sw = new Stopwatch(true);
boolean docs = col.getCollectionType() == CollectionClient.TYPE_DOCUMENTS;
int count = 0;
int error = 0;
File[] files = fc.getSelectedFiles();
for ( int i = 0; i < files.length; i++ ) {
File file = files[i];
String docName = file.getName();
try {
if ( docs )
importDoc(docName, file);
else
importBin(docName, file);
count++;
}
catch ( Exception e ) {
error++;
admin.addMessage("Couldn't import '" + docName + "': "+e.getMessage());
}
}
sw.stop();
if ( error > 0 )
admin.addMessage(count+" Document(s) imported ("+error+" errors): "+sw.toString());
else
admin.setStatus(count+" Document(s) imported: "+sw.toString());
admin.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
return REFRESH_CHILDREN;
}
catch ( dbXMLException e ) {
admin.addMessage(e.getMessage());
}
}
}
return REFRESH_NONE;
}