use of org.eclipse.emf.cdo.eresource.CDOResource 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;
}
use of org.eclipse.emf.cdo.eresource.CDOResource in project InformationSystem by ObeoNetwork.
the class CollaborativeBusinessProjectImporter method getTargetRemoteResource.
private CDOResource getTargetRemoteResource(String targetResourcePath) {
CDOResource targetResource = null;
CDOTransaction transaction = getTransactionOnSession(getTargetSession());
if (transaction != null && transaction.hasResource(targetResourcePath)) {
try {
targetResource = transaction.getResource(targetResourcePath);
} catch (Exception e) {
// unable to get resource, it probably doesn't exist
}
}
return targetResource;
}
use of org.eclipse.emf.cdo.eresource.CDOResource in project InformationSystem by ObeoNetwork.
the class EmbeddedCDOServer method getRemoteProjectsURIs.
private Collection<URI> getRemoteProjectsURIs(CDOTransaction transaction) {
Collection<URI> remoteProjectsURIs = new ArrayList<URI>();
CDOResource rootResource = transaction.getRootResource();
for (EObject object : rootResource.getContents()) {
// CDOResourceNode
if (object instanceof CDOResourceFolder) {
// Search in folder
remoteProjectsURIs.addAll(getRemoteProjectsURIs((CDOResourceFolder) object));
} else if (object instanceof CDOResourceNode) {
CDOResourceNode node = (CDOResourceNode) object;
if (isSessionResource(node)) {
remoteProjectsURIs.add(node.getURI());
}
}
}
return remoteProjectsURIs;
}
use of org.eclipse.emf.cdo.eresource.CDOResource in project InformationSystem by ObeoNetwork.
the class ScaffoldingOperation method createScaffoldResourceForSharedProject.
private Resource createScaffoldResourceForSharedProject(CDOView cdoView) {
CDOTransaction transaction = (CDOTransaction) cdoView;
String name = getScaffoldModelName();
int count = 0;
while (count < 10) {
String path = SCAFFOLD_FOLDER + "/" + getFilenameForScaffoldModel(name, count);
// Create resource
CDOResource resource = transaction.getOrCreateResource(path);
// Check if it is empty
if (resource.getContents().isEmpty()) {
resource.getContents().add(scaffoldInfo);
return resource;
} else {
// try with another name
count++;
}
}
return null;
}
use of org.eclipse.emf.cdo.eresource.CDOResource in project InformationSystem by ObeoNetwork.
the class CollaborativeBusinessProjectImporter method addToRemoteSemanticResource.
private void addToRemoteSemanticResource(final EObject copyObject, final String targetPath) {
CDOTransaction transaction = getTransactionOnSession(getTargetSession());
if (transaction != null) {
CDOResource targetResource = transaction.getOrCreateResource(targetPath);
targetResource.getContents().add(copyObject);
if (!existsTargetSemanticResource(targetResource.getURI())) {
addToSemanticResources(getTargetSession(), targetResource.getURI(), new NullProgressMonitor());
}
}
}
Aggregations