public void run(IAction action) {
if (fSelection instanceof IStructuredSelection) {
final IProject project = (IProject) ((IStructuredSelection) fSelection)
.getFirstElement();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
getDisplay().getActiveShell(),
new WorkbenchLabelProvider(),
new BaseWorkbenchContentProvider());
dialog.setMessage("Select content sync root location (containing the jcr root)");
dialog.setTitle("Content Sync Root");
IContainer initialContainer = ProjectHelper
.getInferredContentProjectContentRoot(project);
if (initialContainer != null) {
dialog.setInitialElementSelections(Arrays
.asList(initialContainer));
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
if (element instanceof IProject) {
return ((IProject) element).equals(project);
}
// display folders only
return element instanceof IContainer;
}
});
dialog.setInput(new IWorkbenchAdapter() {
@Override
public Object getParent(Object o) {
return null;
}
@Override
public String getLabel(Object o) {
return null;
}
@Override
public ImageDescriptor getImageDescriptor(Object object) {
return null;
}
@Override
public Object[] getChildren(Object o) {
return new Object[] { project };
}
}); // this is the root element
dialog.setAllowMultiple(false);
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length > 0) {
final Object item = selection[0];
if (item instanceof IContainer) {
IContainer selectedContainer = (IContainer) item;
String errorMsg = ProjectHelper
.validateContentPackageStructure(selectedContainer);
if (errorMsg != null) {
return new Status(IStatus.ERROR,
Activator.PLUGIN_ID, errorMsg);
} else {
return new Status(IStatus.OK,
Activator.PLUGIN_ID, "");
}
}
}
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "");
}
});
if (dialog.open() == ContainerSelectionDialog.OK) {
Object[] result = dialog.getResult();
if (result != null && result.length > 0) {
final IContainer container = (IContainer) result[0];
IRunnableWithProgress r = new IRunnableWithProgress() {
@Override