public static String getContainer(IProject project, IContainer container) { return (project == container.getProject() ? container.getProjectRelativePath() : container.getFullPath()).toString(); }
@Override public IProject[] getProjects() { return new IProject[] {container.getResource().getProject()}; }
@Override public IProject[] getProjects() { return new IProject[] { container.getResource().getProject() }; }
public static String getContainer(IProject project, IContainer container) { return (project == container.getProject() ? container.getProjectRelativePath() : container.getFullPath()).toString(); } }
@Override public IProject[] getProjects() { return new IProject[] { container.getResource().getProject() }; }
@Override protected boolean initialize(Object element) { if (element instanceof IContainer) { IProject project = ((IContainer) element).getProject(); if (WorkspaceModelManager.isPluginProject(project)) { IPath path = ((IContainer) element).getProjectRelativePath().removeLastSegments(1); String newName = path.append(getArguments().getNewName()).toString(); fProject = project; fElements = new HashMap<>(); fElements.put(element, newName); return true; } } return false; }
/** * Returns the name of a {@link IProject} with a location that includes * targetDirectory. Returns null if there is no such {@link IProject}. * * @param targetDirectory * the path of the directory to check. * @return the overlapping project name or <code>null</code> */ private String getOverlappingProjectName(String targetDirectory){ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath testPath = new Path(targetDirectory); IContainer[] containers = root.findContainersForLocation(testPath); if(containers.length > 0){ return containers[0].getProject().getName(); } return null; }
@Override public void initializeValues() { if (fContainer != null) { fPluginIdText.setText(fContainer.getProject().getName()); if (!isPluginIdFinal()) fSchemaLocationText.setText(fContainer.getProject().getName() + "/" + fContainer.getProjectRelativePath().toString()); //$NON-NLS-1$ } if (fPoint == null) return; if (fIdText != null && fPoint.getId() != null) fIdText.setText(fPoint.getId()); if (fNameText != null && fPoint.getName() != null) fNameText.setText(fPoint.getName()); if (fSchemaText != null && fPoint.getSchema() != null) fSchemaText.setText(fPoint.getSchema()); fPluginIdText.setEnabled(!isPluginIdFinal); fPluginBrowseButton.setEnabled(!isPluginIdFinal); }
/** * validates the local shared config file location * * @return true if the local shared file exists, false otherwise */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); IContainer container = getContainer(path); if (container == null || container.equals(ResourcesPlugin.getWorkspace().getRoot())) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); return false; } else if (!container.getProject().isOpen()) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); return false; } } return true; }
/** * validates the local shared config file location * @return true if the local shared file exists, false otherwise */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); IContainer container = getContainer(path); if (container == null || container.equals(ResourcesPlugin.getWorkspace().getRoot())) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); return false; } else if (!container.getProject().isOpen()) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); return false; } } return true; }
@Override public String getUrlRegexForResource(IResource resource) { IContainer container = getSourceContainer(); String relPath = calcRelPath(container, resource); if (relPath != null) { return URIUtilities.uriEncode(relPath); } // Check for package or self-reference links. if (container.getProject().equals(resource.getProject())) { String path = resource.getFullPath().toString(); if (path.contains("/packages/") || path.contains("/lib/")) { if (path.startsWith("/")) { path = path.substring(1); } return URIUtilities.uriEncode(path); } } return null; }
/** * validates the local shared config file location * @return true if the local shared file exists, false otherwise */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); IContainer container = getContainer(path); if (container == null || container.equals(ResourcesPlugin.getWorkspace().getRoot())) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Invalid_shared_configuration_location_14); return false; } else if (!container.getProject().isOpen()) { setErrorMessage(LaunchConfigurationsMessages.CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1); return false; } } return true; }
private void setDefaultValues(File dir, String buildFilename) { try { IContainer container = PDEPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(dir.toString())); if (container != null && container.exists()) { IProject project = container.getProject(); if (project != null) { project.refreshLocal(IResource.DEPTH_INFINITE, null); IFile file = container.getFile(new Path(buildFilename)); if (file.exists()) BaseBuildAction.setDefaultValues(file); } } } catch (CoreException e) { } }
public SiteBuildOperation(IFeatureModel[] features, ISiteModel site, String jobName) { super(getInfo(features, site), jobName); fFeatureModels = features; fSiteModel = site; fSiteContainer = site.getUnderlyingResource().getParent(); setRule(MultiRule.combine(fSiteContainer.getProject(), getRule())); }
/** * Get the project associated with the given Resource. (If in a ProjectResourceSet, then the project from that resource set). * * @param resource * @return project if associated or <code>null</code> if not found. * * @since 1.0.0 */ public static IProject getProject(Resource resource) { ResourceSet set = resource == null ? null : resource.getResourceSet(); if (set instanceof ProjectResourceSet) return ((ProjectResourceSet) set).getProject(); URIConverter converter = set == null ? null : set.getURIConverter(); if (converter != null && converter instanceof WorkbenchURIConverter && ((WorkbenchURIConverter) converter).getOutputContainer() != null) return ((WorkbenchURIConverter) converter).getOutputContainer().getProject(); else return null; }
protected IFile getManifestFile(Archive anArchive) { URIConverter conv = anArchive.getResourceSet().getURIConverter(); if (conv instanceof WorkbenchURIConverter) { WorkbenchURIConverter wbConv = (WorkbenchURIConverter) conv; IContainer input = wbConv.getInputContainer(); if (input == null) return null; IProject p = input.getProject(); if (p == null || JemProjectUtilities.isBinaryProject(p)) return null; IFile result = J2EEProjectUtilities.getManifestFile(p, false); if (result != null && result.exists()) return result; } return null; }
protected MoveResourcesDescriptor createDescriptor() { MoveResourcesDescriptor descriptor= new MoveResourcesDescriptor(); descriptor.setProject(fDestination.getProject().getName()); descriptor.setDescription(getMoveDescription()); if (fResourcesToMove.length <= 1) { descriptor.setComment(descriptor.getDescription()); } else { StringBuffer buf= new StringBuffer(); for (int i= 0; i < fResourcesToMove.length; i++) { if (i > 0) buf.append(", "); //$NON-NLS-1$ buf.append(fResourcesToMove[i].getName()); } descriptor.setComment(Messages.format(RefactoringCoreMessages.MoveResourceProcessor_comment, new String[] { buf.toString(), BasicElementLabels.getResourceName(fDestination) })); } descriptor.setFlags(RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE); descriptor.setDestination(fDestination); descriptor.setUpdateReferences(isUpdateReferences()); descriptor.setResourcesToMove(fResourcesToMove); return descriptor; }
/** * @since 2.4 */ @Override protected void createContainer(IContainer container) throws CoreException { super.createContainer(container); // make it a source folder IJavaProject jp = JavaCore.create(container.getProject()); if (jp.exists() && !jp.isOnClasspath(container)) { IClasspathEntry srcFolderClasspathEntry = JavaCore.newSourceEntry(container.getFullPath()); IClasspathEntry[] classPath = jp.getRawClasspath(); IClasspathEntry[] newClassPath = new IClasspathEntry[classPath.length + 1]; System.arraycopy(classPath, 0, newClassPath, 1, classPath.length); newClassPath[0] = srcFolderClasspathEntry; jp.setRawClasspath(newClassPath, getMonitor()); } } }
private void exportContainer(IProgressMonitor progressMonitor, IContainer container) throws InterruptedException { if (container.getType() == IResource.FOLDER && isOutputFolder((IFolder)container)) return; IResource[] children= null; try { children= container.members(); } catch (CoreException exception) { // this should never happen because an #isAccessible check is done before #members is invoked addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringExport, BasicElementLabels.getPathLabel(container.getFullPath(), false)), exception); } if (children != null) { IJavaProject javaProject= JavaCore.create(container.getProject()); boolean isOnCP= javaProject.isOnClasspath(container); for (int i= 0; i < children.length; i++) { IResource child= children[i]; if (isOnCP || !javaProject.isOnClasspath(child) || isInternalJar(child)) exportElement(child, progressMonitor); } } }
private void exportContainer(IProgressMonitor progressMonitor, IContainer container) throws InterruptedException { if (container.getType() == IResource.FOLDER && isOutputFolder((IFolder)container)) return; IResource[] children= null; try { children= container.members(); } catch (CoreException exception) { // this should never happen because an #isAccessible check is done before #members is invoked addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringExport, BasicElementLabels.getPathLabel(container.getFullPath(), false)), exception); } if (children != null) { IJavaProject javaProject= JavaCore.create(container.getProject()); boolean isOnCP= javaProject.isOnClasspath(container); for (int i= 0; i < children.length; i++) { IResource child= children[i]; if (isOnCP || !javaProject.isOnClasspath(child) || isInternalJar(child)) exportElement(child, progressMonitor); } } }