private void makeActions() {
insert = new Action(getCaption("collection.insertDoc")) {
@Override
public void run() {
FileDialog dialog = new FileDialog(view.getSite().getShell(),
SWT.OPEN);
dialog.setFilterExtensions(new String[]{"*.json"});
String result = dialog.open();
if (result != null) {
try {
String jsonText = IOUtils.readFile(new File(result));
JSONObject jsonObj = new JSONObject(jsonText);
col.insert(JSONUtils.toDBObject(jsonObj));
} catch (Exception ex) {
UIUtils.openErrorDialog(view.getSite().getShell(),
ex.toString());
}
}
}
};
rename = new Action(getCaption("collection.renameColl")) {
@Override
public void run() {
InputDialog dialog = new InputDialog(view.getSite().getShell(),
getCaption("collection.renameColl"),
getCaption("collection.msg.newCollName"),
col.getName(), new RequiredInputValidator(
getCaption("collection.msg.inputCollName")));
if (dialog.open() == InputDialog.OK) {
try {
col.rename(dialog.getValue());
} catch (MongoException ex) {
UIUtils.openErrorDialog(view.getSite().getShell(),
ex.toString());
}
view.getViewer().refresh(getParent());