use of org.erlide.wrangler.refactoring.ui.validator.IValidator in project erlide_eclipse by erlang.
the class ComboInputPage method createControl.
@Override
public void createControl(final Composite parent) {
composite = new Composite(parent, SWT.NONE);
inputLabel = new Label(composite, SWT.LEFT);
inputLabel.setText(labelText);
// GridData gridData = new GridData();
// gridData.horizontalAlignment = GridData.FILL;
// gridData.horizontalSpan = 2;
// inputLabel.setLayoutData(gridData);
selectionList = new Combo(composite, SWT.DROP_DOWN);
for (final String s : moduleNames) {
selectionList.add(s);
}
// gridData = new GridData();
// gridData.horizontalAlignment = GridData.FILL;
// gridData.horizontalSpan = 2;
// selectionList.setLayoutData(gridData);
// GridLayout layout = new GridLayout();
final RowLayout layout = new RowLayout();
layout.spacing = 5;
layout.center = true;
composite.setLayout(layout);
setControl(composite);
selectionList.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
}
@Override
@SuppressWarnings("synthetic-access")
public void widgetSelected(final SelectionEvent e) {
((SimpleOneStepWranglerRefactoring) getRefactoring()).setUserInput(selectionList.getText());
setPageComplete(true);
}
});
final IValidator validator = new AtomValidator();
selectionList.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
if (validator.isValid(selectionList.getText())) {
((SimpleWranglerRefactoring) getRefactoring()).setUserInput(selectionList.getText());
setErrorMessage(null);
setPageComplete(true);
} else {
setPageComplete(false);
setErrorMessage("Module name must be a a valid atom!");
}
}
});
}
use of org.erlide.wrangler.refactoring.ui.validator.IValidator in project erlide_eclipse by erlang.
the class RecordDataInputPage method isInputValid.
@Override
protected boolean isInputValid() {
final IValidator theValidator = new AtomValidator();
boolean valid = theValidator.isValid(recordName.getText());
final List<String> fn = new ArrayList<>();
for (final Text t : fieldNames) {
valid = valid && theValidator.isValid(t.getText());
fn.add(t.getText());
if (!valid) {
break;
}
}
if (valid) {
refactoring.setRecordData(recordName.getText(), fn);
setErrorMessage(null);
setPageComplete(true);
} else {
setPageComplete(false);
setErrorMessage("Please provide valid record name, and field names!");
}
return valid;
}
use of org.erlide.wrangler.refactoring.ui.validator.IValidator 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