use of org.erlide.wrangler.refactoring.ui.validator.ModuleNameValidator in project erlide_eclipse by erlang.
the class AddRefacHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Add user-defined refactoring", "Please type callback module name!", "", new IInputValidator() {
public IValidator internalV = new ModuleNameValidator();
@Override
public String isValid(final String newText) {
if (internalV.isValid(newText)) {
return null;
}
return "Please type a correct module name!";
}
});
dialog.open();
if (dialog.getReturnCode() == Window.CANCEL) {
return null;
}
final String callbackModule = dialog.getValue();
final RefacType type = checkType(callbackModule);
if (type == null) {
showErrorMesg("Callback module must implement either " + "gen_refac or gen_composite_refac behaviour");
return null;
}
if (!addAndLoad(callbackModule, type)) {
showErrorMesg("Can not load callback module");
return null;
}
if (type.equals(RefacType.ELEMENTARY)) {
UserRefactoringsManager.getInstance().addMyElementary(callbackModule);
} else {
UserRefactoringsManager.getInstance().addMyComposite(callbackModule);
}
MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Add user-defined refactoring", "Success!");
return null;
}
Aggregations