use of org.erlide.ui.util.StatusInfo in project erlide_eclipse by erlang.
the class DirectorySelectUtil method chooseLocation.
public static IContainer chooseLocation(final String dialogTitle, final String labelText, final IProject project2, final String outputLocation, final Shell shell) {
final IWorkspaceRoot root = project2.getWorkspace().getRoot();
final Class<?>[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
final IProject[] allProjects = root.getProjects();
final List<IProject> rejectedElements = new ArrayList<>(allProjects.length);
for (final IProject allProject : allProjects) {
if (!allProject.equals(project2)) {
rejectedElements.add(allProject);
}
}
final ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
final ILabelProvider lp = new WorkbenchLabelProvider();
final ITreeContentProvider cp = new WorkbenchContentProvider();
IResource initSelection = null;
if (outputLocation != null) {
initSelection = root.findMember(outputLocation);
}
final FolderSelectionDialog dialog = new FolderSelectionDialog(shell, lp, cp);
dialog.setTitle(dialogTitle);
final ISelectionStatusValidator validator = new ISelectionStatusValidator() {
ISelectionStatusValidator myValidator = new TypedElementSelectionValidator(acceptedClasses, false);
@Override
public IStatus validate(final Object[] selection) {
final IStatus typedStatus = myValidator.validate(selection);
if (!typedStatus.isOK()) {
return typedStatus;
}
if (selection[0] instanceof IFolder) {
// }
return new StatusInfo();
}
return new StatusInfo(IStatus.ERROR, "");
}
};
dialog.setValidator(validator);
dialog.setMessage(labelText);
dialog.addFilter(filter);
dialog.setInput(root);
dialog.setInitialSelection(initSelection);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
return (IContainer) dialog.getFirstResult();
}
return null;
}
use of org.erlide.ui.util.StatusInfo in project erlide_eclipse by erlang.
the class ProjectSelectionDialog method doSelectionChanged.
void doSelectionChanged(final Object[] objects) {
if (objects.length != 1) {
// $NON-NLS-1$
updateStatus(new StatusInfo(IStatus.ERROR, ""));
setSelectionResult(null);
} else {
updateStatus(new StatusInfo());
setSelectionResult(objects);
}
}
use of org.erlide.ui.util.StatusInfo in project erlide_eclipse by erlang.
the class AddRuntimeDialog method validateLocation.
protected IStatus validateLocation() {
final StatusInfo status = new StatusInfo();
final String loc = fOtpHome.getText();
if (loc == null || loc.trim().isEmpty()) {
status.setInfo("Enter the installation's location");
} else {
final File f = new File(loc);
if (!f.exists()) {
status.setError("Location doesn't exist");
} else if (!f.isDirectory()) {
status.setError("Location isn't a directory");
} else if (!RuntimeInfo.validateLocation(loc)) {
status.setError("Location is not a valid OTP home");
}
}
return status;
}
use of org.erlide.ui.util.StatusInfo in project erlide_eclipse by erlang.
the class CodeAssistPreferencePage method validateCommaSeparatedCharacters.
private IStatus validateCommaSeparatedCharacters(final String text) {
final StatusInfo status = new StatusInfo();
status.setOK();
if (text.length() > 1) {
final String[] chars = text.split(",");
for (final String c : chars) {
if (c.trim().length() != 1) {
status.setError("Trigger keys should be a list of comma-separated characters");
break;
}
}
}
return status;
}
use of org.erlide.ui.util.StatusInfo in project erlide_eclipse by erlang.
the class AddRuntimeDialog method validateName.
protected IStatus validateName() {
final StatusInfo status = new StatusInfo();
final String name = fName.getText();
if (name == null || name.trim().isEmpty()) {
// $NON-NLS-1$
status.setError("Enter the runtime's name");
} else if (fRequestor.isDuplicateName(name) && (fEditedRuntime == null || !name.equals(fEditedRuntime.getName()))) {
// $NON-NLS-1$
status.setError("The name is already used");
} else {
final IStatus s = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
if (!s.isOK()) {
status.setError(MessageFormat.format("Name is invalid: %s", (Object[]) new String[] { s.getMessage() }));
}
}
return status;
}
Aggregations