use of org.eclipse.team.svn.ui.compare.ThreeWayResourceCompareInput in project InformationSystem by ObeoNetwork.
the class ExportAsSQLScriptsAction method getContainingFolder.
private IResource getContainingFolder(Comparison comparison) {
if (comparison.getMatches() != null && comparison.getMatches().isEmpty() == false) {
Match match = comparison.getMatches().get(0);
Resource resource = match.getLeft().eResource();
if (resource instanceof CDOResource) {
return getModelingProject(resource);
} else if (resource.getURI().isPlatformResource()) {
String uri = resource.getURI().toPlatformString(true);
Path path = new Path(uri);
return ResourcesPlugin.getWorkspace().getRoot().getFile(path).getParent();
} else if (activeEditor.getEditorInput() instanceof ThreeWayResourceCompareInput) {
// The resource is a SVN resource
try {
IEditorInput editorInput = activeEditor.getEditorInput();
Field localField = editorInput.getClass().getDeclaredField("local");
localField.setAccessible(true);
ILocalResource local = (ILocalResource) localField.get(editorInput);
return local.getResource().getParent();
} catch (ReflectiveOperationException e) {
// The fallback case below will apply
} catch (SecurityException e) {
// The fallback case below will apply
} catch (IllegalArgumentException e) {
// The fallback case below will apply
}
}
// Fallback case
ContainerSelectionDialog projectSelectionDialog = new ContainerSelectionDialog(activeEditor.getSite().getShell(), null, false, "Sélectionner le projet de destination :");
projectSelectionDialog.setTitle("Sélection de projet");
if (projectSelectionDialog.open() == ContainerSelectionDialog.OK && projectSelectionDialog.getResult().length == 1) {
Path projectPath = (Path) projectSelectionDialog.getResult()[0];
IResource selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(projectPath);
if (selectedResource instanceof IProject) {
return selectedResource;
}
}
}
return null;
}
Aggregations