use of org.erlide.ui.util.FolderSelectionDialog 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;
}
Aggregations