/** * Returns true for: - non-hidden projects - non-RDT projects - projects that does not have remote * systems temporary nature - projects that are located remotely */ public boolean isCandidate(IProject project) { boolean a = false; boolean b = false; boolean c = false; boolean d = false; a = !project.isHidden(); try { // b = !project.hasNature(RemoteNature.REMOTE_NATURE_ID); try { ServiceModelManager.getInstance().getConfigurations(project); } catch (ProjectNotConfiguredException e) { b = true; } c = !project.hasNature("org.eclipse.rse.ui.remoteSystemsTempNature"); // $NON-NLS-1$ IHost host = RSEUtils.getConnection(project.getLocationURI()); if (host != null) { d = !host.getSystemType().isLocal(); } else { IFileStore fileStore = EFS.getStore(project.getLocationURI()); if (fileStore != null) { if (!(fileStore instanceof LocalFile)) { d = true; } } } } catch (CoreException e) { RDTLog.logError(e); } return a && b && c && d; }
/** * Performs a git clone to a temporary location and then copies the files over top the already * generated project. This is because git cannot clone into an existing directory. * * @param monitor * @throws Exception */ protected void cloneAfter(IProgressMonitor monitor) throws Exception { SubMonitor sub = SubMonitor.convert(monitor, Messages.AbstractNewProjectWizard_CloningFromGitMsg, 100); // clone to tmp dir then copy files over top the project! File tmpFile = File.createTempFile("delete_me", "tmp"); // $NON-NLS-1$ //$NON-NLS-2$ File dest = new File(tmpFile.getParent(), "git_clone_tmp"); // $NON-NLS-1$ GitExecutable.instance() .clone( selectedTemplate.getLocation(), Path.fromOSString(dest.getAbsolutePath()), true, sub.newChild(85)); IFileStore tmpClone = EFS.getStore(dest.toURI()); // Wipe the .git folder before copying? Wipe the .project file before copying? IFileStore dotGit = tmpClone.getChild(".git"); // $NON-NLS-1$ dotGit.delete(EFS.NONE, sub.newChild(2)); IFileStore dotProject = tmpClone.getChild(IProjectDescription.DESCRIPTION_FILE_NAME); if (dotProject.fetchInfo().exists()) { dotProject.delete(EFS.NONE, sub.newChild(1)); } // OK, copy the cloned template's contents over IFileStore projectStore = EFS.getStore(newProject.getLocationURI()); tmpClone.copy(projectStore, EFS.OVERWRITE, sub.newChild(9)); // Now get rid of the temp clone! tmpClone.delete(EFS.NONE, sub.newChild(3)); sub.done(); }
/** * @return a collection of resources which are associated with this problem. The collection might * be empty. */ public Collection<IResource> getResources() { if (resources == null) { resources = new LinkedList<IResource>(); if (file != null) { URI fileUri; if (!file.isAbsolute()) { // make file absolute and convert to URI (does not work the // other way round, because File.toURI always returns an // absolute URI fileUri = new File(new File(project.getLocationURI().getPath()), file.toString()).toURI(); } else { fileUri = file.toURI(); } // find file in workspace (absolute path) IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // consider linked paths also IFile[] file = root.findFilesForLocationURI(fileUri); resources.addAll(Arrays.asList(file)); } if (resources.isEmpty()) { // if no resource could be resolved take project resources.add(project); } } return resources; }
protected IFile findFileInWorkspace(IPath path) { IFile file = null; if (path.isAbsolute()) { IWorkspaceRoot root = getProject().getWorkspace().getRoot(); // construct a URI, based on the project's locationURI, that points // to the given path URI projectURI = project.getLocationURI(); URI newURI = EFSExtensionManager.getDefault().createNewURIFromPath(projectURI, path.toString()); IFile[] files = root.findFilesForLocationURI(newURI); for (int i = 0; i < files.length; i++) { if (files[i].getProject().equals(getProject())) { file = files[i]; break; } } } else { file = getProject().getFile(path); } return file; }
/** @since 2.0 */ protected IServiceConfiguration getConfig(IProject project) { IServiceConfiguration config = projectConfigs.get(project); IHost host = RSEUtils.getConnection(project.getLocationURI()); if (config == null && host != null) { config = ServiceModelManager.getInstance().newServiceConfiguration(project.getName()); projectConfigs.put(project, config); } return config; }
protected boolean doesntHaveGitRepo() { IProject project = getProject(); if (project == null) { return false; // Seems like we have big issues if we ever got into this state... } GitRepository repo = GitPlugin.getDefault() .getGitRepositoryManager() .getUnattachedExisting(project.getLocationURI()); return repo == null; }
/* * (non-Javadoc) * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { Object[] result; if (inputElement instanceof IProject) { IProject project = (IProject) inputElement; Index index = getIndexManager().getIndex(project.getLocationURI()); result = new Object[] {new JSElement(index)}; } else { result = new Object[0]; } return result; }
/** * For a full build, we grab all files inside the project and then call build on each file. * * @param monitor * @throws CoreException */ private void fullBuild(List<IBuildParticipant> participants, IProgressMonitor monitor) throws CoreException { SubMonitor sub = SubMonitor.convert(monitor, 100); indexProjectBuildPaths(sub.newChild(50)); // Index files contributed... // TODO Remove these special "contributed" files? IProject project = getProjectHandle(); URI uri = project.getLocationURI(); Set<IFileStore> contributedFiles = getContributedFiles(uri); sub.worked(2); buildContributedFiles(participants, contributedFiles, sub.newChild(6)); // Now index the actual files in the project CollectingResourceVisitor visitor = new CollectingResourceVisitor(); project.accept(visitor); visitor.files.trimToSize(); // shrink it down to size when we're done sub.worked(2); buildFiles(participants, visitor.files, sub.newChild(40)); sub.done(); }
/** * Installs the bundle corresponding to the model. * * @param model Model of the bundle to be installed. */ private void installBundle(IPluginModelBase model) { try { final IResource candidateManifest = model.getUnderlyingResource(); final IProject project = candidateManifest.getProject(); URL url = null; try { url = project.getLocationURI().toURL(); } catch (MalformedURLException e) { // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=354360 try { URI uri = project.getLocationURI(); IFileStore store = EFS.getStore(uri); File file = store.toLocalFile(0, null); if (file != null) { url = file.toURI().toURL(); } } catch (CoreException ex) { // Logging both exceptions just to be sure AcceleoCommonPlugin.log(e, false); AcceleoCommonPlugin.log(ex, false); } } if (url != null) { final String candidateLocationReference = REFERENCE_URI_PREFIX + URLDecoder.decode( url.toExternalForm(), System.getProperty("file.encoding")); // $NON-NLS-1$ Bundle bundle = getBundle(candidateLocationReference); /* * Install the bundle if needed. Note that we'll check bundle dependencies in two phases as * even if there cannot be cyclic dependencies through the "require-bundle" header, there * could be through the "import package" header. */ if (bundle == null) { checkRequireBundleDependencies(model); bundle = installBundle(candidateLocationReference); setBundleClasspath(project, bundle); workspaceInstalledBundles.put(model, bundle); checkImportPackagesDependencies(model); } refreshPackages( new Bundle[] { bundle, }); } } catch (BundleException e) { String bundleName = model.getBundleDescription().getName(); if (!logOnceProjectLoad.contains(bundleName)) { logOnceProjectLoad.add(bundleName); AcceleoCommonPlugin.log( new Status( IStatus.WARNING, AcceleoCommonPlugin.PLUGIN_ID, AcceleoCommonMessages.getString( "WorkspaceUtil.InstallationFailure", //$NON-NLS-1$ bundleName, e.getMessage()), e)); } } catch (MalformedURLException e) { AcceleoCommonPlugin.log(e, false); } catch (UnsupportedEncodingException e) { AcceleoCommonPlugin.log(e, false); } }
public EmbeddedServer(String id, String name, IProject serverProject) { super(id, name); this.installDir = serverProject.getLocationURI().getPath(); this.serverProject = serverProject; }
public static File getRepositoryPathFor(IProject project) { return new File(project.getLocationURI().getPath(), Constants.DOT_GIT); }