use of org.mongodb.meclipse.util.RequiredInputValidator in project meclipse by flaper87.
the class Collection method makeActions.
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());
}
}
};
delete = new Action(getCaption("collection.deleteColl")) {
@Override
public void run() {
if (MessageDialog.openConfirm(view.getSite().getShell(), getCaption("confirm"), String.format(getCaption("collection.msg.reallyDeleteColl"), col.getName()))) {
col.drop();
view.getViewer().refresh(getParent());
}
}
};
}
Aggregations