@SuppressWarnings("unchecked") private static URI createNewResource( Resource projectResource, String projectPath, ProjectElement projectElement) { int i = 0; List<Resource> list = projectResource.getResourceSet().getResources(); URIConverter uriConverter = projectResource.getResourceSet().getURIConverter(); URI uri = null; boolean found = false; do { found = false; i++; // TODO Add file extension name to ProjectElement uri = generateResourceName(projectPath, projectElement, i); URI normalizedURI = uriConverter.normalize(uri); for (Resource resource2 : list) { if (uriConverter.normalize(resource2.getURI()).equals(normalizedURI)) { found = true; break; } } if (!found) { File file = new File(uri.toFileString()); if (file.exists()) found = true; } } while (found); uri.deresolve(projectResource.getURI(), true, true, true); return uri; }
private boolean pickedAnotherAird(Session existingSession) { if (existingSession.getSessionResource() != null) { URI sessURI = existingSession.getSessionResource().getURI(); URIConverter conv = existingSession.getTransactionalEditingDomain().getResourceSet().getURIConverter(); if (sessURI != null && conv != null) { return !conv.normalize(airdFilePage.getURI()).equals(conv.normalize(sessURI)); } } return true; }
/** * Normalizes the given URI using the parent environment. * * @param uri The uri we are to normalize. * @return The normalized form of <code>uri</code>. */ private URI normalizeWithParent(URI uri) { if (parent != null) { return parent.normalize(uri); } return uri; }