/** * @deprecated use getResourceSet() */ public ResourceSet getXmiResourceSet() { return getResourceSet(); }
/** * Create a folder relative to the project based on aProjectRelativePathString. * * @param aProjectRelativePathString * @return * @throws CoreException * * @since 1.0.0 */ public IFolder createFolder(String aProjectRelativePathString) throws CoreException { if (aProjectRelativePathString != null && aProjectRelativePathString.length() > 0) return createFolder(new Path(aProjectRelativePathString)); return null; }
/** * @deprecated use createResource(URI) */ public Resource makeXmiResource(String uri) { return createResource(URI.createURI(uri)); }
protected boolean flushPrimaryKeyClass(JavaClass primaryKeyClass) { // ensure the primary key class is flushed and reloaded to get latest // content IProject p = ProjectUtilities.getProject(primaryKeyClass); try { List natures = EMFNature.getRegisteredRuntimes(p); EMFNature nature = null; for (int i = 0; i < natures.size(); i++) { if (natures.get(i) instanceof EMFNature) nature = (EMFNature) natures.get(i); } List adapterFactories = nature.getResourceSet().getAdapterFactories(); AdapterFactory factory = EcoreUtil.getAdapterFactory(adapterFactories, ReadAdaptor.TYPE_KEY); if (factory instanceof JavaJDOMAdapterFactory) { JavaJDOMAdapterFactory javaFactory = (JavaJDOMAdapterFactory) factory; javaFactory.flushReflectionNoNotification(primaryKeyClass.getQualifiedName()); return true; } } catch (Exception e) { // We don't really care what the exception was, we'll just bail out // and return false; } return false; } }
/** * Get the server property of the project from the supplied key * * @param key * java.lang.String * @deprecated we cannont use persistent properties because they are not stored in the repository * @since 1.0.0 */ protected String getProjectServerValue(String key) { if (key == null) return null; try { QualifiedName wholeName = qualifiedKey(key); return getProject().getPersistentProperty(wholeName); } catch (CoreException exception) { //If we can't find it assume it is null exception.printStackTrace(); return null; } }
protected boolean initializeEMFContextFromContributors(IProject aProject, EMFWorkbenchContextBase emfContext, IEMFContextContributor contributor) { boolean contributorFound = false; if (aProject == null || emfContext == null) return contributorFound; List runtimes = EMFNature.getRegisteredRuntimes(aProject); for (int i = 0; i < runtimes.size(); i++) { IProjectNature nature = (IProjectNature) runtimes.get(i); if (nature != null && CONTRIBUTOR_CLASS.isInstance(nature)) { if (nature == contributor) contributorFound = true; ((IEMFContextContributor) nature).primaryContributeToContext(emfContext); } } return contributorFound; }
/** * Create a folder relative to the project based on aProjectRelativePathString. * * @param aProjectRelativePath * @return * @throws CoreException * * @since 1.0.0 */ public IFolder createFolder(IPath aProjectRelativePath) throws CoreException { if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) { IFolder folder = getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath)); if (!folder.exists()) { ProjectUtilities.ensureContainerNotReadOnly(folder); folder.create(true, true, null); } return folder; } return null; }
/** * Returns the EMF root folder for the project. Defaults to the project. Subclasses can override. * * @return EMF root folder for the project. * * @since 1.0.0 */ public IContainer getEMFRoot() { return getProject(); }
/** * @deprecated use getResource(URI) */ public Resource getXmiResource(String uri) { return getResource(URI.createURI(uri)); }
/** * Get the resource set for the project * * @return * * @since 1.0.0 */ public ResourceSet getResourceSet() { return getEmfContextBase().getResourceSet(); }
private QualifiedName qualifiedKey(String key) { return new QualifiedName(getPluginID(), key); }
/** * Lazy initializer; for migration of existing workspaces where configure will never get called. * * @return context base for the project. * * @since 1.0.0 */ protected EMFWorkbenchContextBase getEmfContextBase() { if (emfContext == null) { try { createEmfContext(); } catch (CoreException ex) { Logger.getLogger().logError(ex); } } return emfContext; }
/** * Set the server property of the project from the supplied value * * @param key * java.lang.String * @param value * String * @deprecated we cannont use persistent properties because they are not stored in the repository */ protected void setProjectServerValue(String key, String value) { if (key != null) { try { QualifiedName wholeName = qualifiedKey(key); getProject().setPersistentProperty(wholeName, value); } catch (CoreException exception) { //If we can't find it assume it is null exception.printStackTrace(); return; } } }
/** * Create an EMF context for the project. * * @throws CoreException * * @since 1.0.0 */ protected void createEmfContext() throws CoreException { WorkbenchResourceHelperBase.createEMFContext(getProject(), this); }
/** * Shutdown the EMF nature * * * @since 1.0.0 */ public void shutdown() { if (getResourceSet() != null) ((ProjectResourceSet) getResourceSet()).release(); }
/** * Return the full path of the project. * * @return full project path (relative to workspace) * @since 1.0.0 */ public IPath getProjectPath() { return getProject().getFullPath(); }
/** * Create the resource for this uri. It will use the resource set of the project to create it. * * @param uri * @return resource * * @since 1.0.0 */ public Resource createResource(URI uri) { return getResourceSet().createResource(uri); }
public IWorkspace getWorkspace() { return getProject().getWorkspace(); }
/** * Get WorkbenchURIConverter for this project. * <p> * This method assumes the URIConverter on the ResourceSet is the one that was created for the ResourceSet on behalf of this nature runtime. * </p> * * @return * * @since 1.0.0 */ protected WorkbenchURIConverter getWorkbenchURIConverter() { return (WorkbenchURIConverter) getResourceSet().getURIConverter(); }
/** * Get the resource for this uri. It will use the resource set of the project to find it. It will load if not already loaded. * * @param uri * @return resource or <code>null</code> if resource is not found. * * @since 1.0.0 */ public Resource getResource(URI uri) { try { return getResourceSet().getResource(uri, true); } catch (WrappedException ex) { if (!WorkbenchResourceHelperBase.isResourceNotFound(ex)) throw ex; } return null; }