/** * @return the deprecation message, or <code>null</code> iff the variable is not deprecated */ public String getDeprecationMessage() { return BuildPathSupport.getDeprecationMessage(fName); } }
@Override public void run(IProgressMonitor monitor) throws CoreException { BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, false, monitor); } };
/** * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container. * @param shell If not null and the entry could not be found on the projects classpath, a dialog will ask to put the entry on the classpath * @param newEntry The modified entry. The entry's kind or path must be unchanged. * @param changedAttributes The attributes that have changed. See {@link CPListElement} for constants values. * @param jproject Project where the entry belongs to * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container * @param isReferencedEntry <code>true</code> iff the entry has a {@link IClasspathEntry#getReferencingEntry() referencing entry} * @param monitor The progress monitor to use * @throws CoreException if the update failed */ public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, boolean isReferencedEntry, IProgressMonitor monitor) throws CoreException { if (containerPath != null) { updateContainerClasspath(jproject, containerPath, newEntry, changedAttributes, monitor); } else if (isReferencedEntry) { updateReferencedClasspathEntry(jproject, newEntry, changedAttributes, monitor); } else { updateProjectClasspath(shell, jproject, newEntry, changedAttributes, monitor); } }
/** * Apply a modified classpath entry to the classpath. The classpath entry can also be from a classpath container. * @param shell If not null and the entry could not be found on the projects classpath, a dialog will ask to put the entry on the classpath * @param newEntry The modified entry. The entry's kind or path must be unchanged. * @param changedAttributes The attibutes that have changed. See {@link CPListElement} for constants values. * @param jproject Project where the entry belongs to * @param containerPath The path of the entry's parent container or <code>null</code> if the entry is not in a container * @param monitor The progress monitor to use * @throws CoreException */ public static void modifyClasspathEntry(Shell shell, IClasspathEntry newEntry, String[] changedAttributes, IJavaProject jproject, IPath containerPath, IProgressMonitor monitor) throws CoreException { if (containerPath != null) { updateContainerClasspath(jproject, containerPath, newEntry, changedAttributes, monitor); } else { updateProjectClasspath(shell, jproject, newEntry, changedAttributes, monitor); } }
private CPListElement[] doOpenInternalJarFileDialog(CPListElement existing, Object parent) { IPath path = existing.getPath(); IPath selectedPaths[] = BuildPathDialogAccess.chooseJAREntries(this.getShell(), path, new IPath[0]); if (selectedPaths != null) { List<CPListElement> elements = new ArrayList<>(); for (int i= 0; i < selectedPaths.length; i++) { CPListElement cpElement = new CPListElement(parent, fDummyProject, IClasspathEntry.CPE_LIBRARY, selectedPaths[i], null); cpElement.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(cpElement)); cpElement.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(cpElement)); elements.add(cpElement); } return elements.toArray(new CPListElement[0]); } return null; }
private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, "Container " + containerPath + " cannot be resolved", null)); //$NON-NLS-1$//$NON-NLS-2$ } IClasspathEntry[] entries= container.getClasspathEntries(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length]; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == newEntry.getEntryKind() && curr.getPath().equals(newEntry.getPath())) { newEntries[i]= getUpdatedEntry(curr, newEntry, changedAttributes, jproject); } else { newEntries[i]= curr; } } requestContainerUpdate(jproject, container, newEntries); monitor.worked(1); }
private static void updateProjectClasspath(Shell shell, IJavaProject jproject, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry[] oldClasspath= jproject.getRawClasspath(); int nEntries= oldClasspath.length; ArrayList newEntries= new ArrayList(nEntries + 1); int entryKind= newEntry.getEntryKind(); IPath jarPath= newEntry.getPath(); boolean found= false; for (int i= 0; i < nEntries; i++) { IClasspathEntry curr= oldClasspath[i]; if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { // add modified entry newEntries.add(getUpdatedEntry(curr, newEntry, changedAttributes, jproject)); found= true; } else { newEntries.add(curr); } } if (!found) { if (!putJarOnClasspathDialog(shell)) { return; } // add new newEntries.add(newEntry); } IClasspathEntry[] newClasspath= (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]); jproject.setRawClasspath(newClasspath, monitor); }
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) { elementsToAdd.add(curr); curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr)); curr.setAttribute(CPListElement.JAVADOC, JavaUI.getLibraryJavadocLocation(curr.getPath()));
private static void convertContainer(IClasspathEntry entry, IJavaProject project, Map<IPath, String> oldLocationMap) { try { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), project); if (container == null) { return; } IClasspathEntry[] entries= container.getClasspathEntries(); boolean hasChange= false; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; IClasspathEntry updatedEntry= getConvertedEntry(curr, project, oldLocationMap); if (updatedEntry != null) { entries[i]= updatedEntry; hasChange= true; } } if (hasChange) { BuildPathSupport.requestContainerUpdate(project, container, entries); } } catch (CoreException e) { // ignore } }
/** * Evaluate if the builds path contains an execution environment and the current compliance * settings follow the EE options. * * @param ee the EE, or <code>null</code> if none available * @return {@link #DEFAULT_CONF} if the compliance follows the EE, or {@link #USER_CONF} if the * settings differ, or {@link #DISABLED} if there's no EE at all */ private String getComplianceFollowsEE(IExecutionEnvironment ee) { Map<String, String> options= BuildPathSupport.getEEOptions(ee); if (options == null) return DISABLED; return checkDefaults(PREFS_COMPLIANCE, options); }
if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { newReferencedEntries.add(getUpdatedEntry(curr, newReferencedEntry, changedAttributes, jproject)); found= true; } else {
private CPListElement[] doOpenInternalJarFileDialog(CPListElement existing, Object parent) { IPath path = existing.getPath(); IPath selectedPaths[] = BuildPathDialogAccess.chooseJAREntries(this.getShell(), path, new IPath[0]); if (selectedPaths != null) { List<CPListElement> elements = new ArrayList<>(); for (int i= 0; i < selectedPaths.length; i++) { CPListElement cpElement = new CPListElement(parent, fDummyProject, IClasspathEntry.CPE_LIBRARY, selectedPaths[i], null); cpElement.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(cpElement)); cpElement.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(cpElement)); elements.add(cpElement); } return elements.toArray(new CPListElement[0]); } return null; }
private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, "Container " + containerPath + " cannot be resolved", null)); //$NON-NLS-1$//$NON-NLS-2$ } IClasspathEntry[] entries= container.getClasspathEntries(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length]; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == newEntry.getEntryKind() && curr.getPath().equals(newEntry.getPath())) { newEntries[i]= getUpdatedEntry(curr, newEntry, changedAttributes, jproject); } else { newEntries[i]= curr; } } requestContainerUpdate(jproject, container, newEntries); monitor.worked(1); }
private static void updateProjectClasspath(Shell shell, IJavaProject jproject, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry[] oldClasspath= jproject.getRawClasspath(); int nEntries= oldClasspath.length; ArrayList<IClasspathEntry> newEntries= new ArrayList<>(nEntries + 1); int entryKind= newEntry.getEntryKind(); IPath jarPath= newEntry.getPath(); boolean found= false; for (int i= 0; i < nEntries; i++) { IClasspathEntry curr= oldClasspath[i]; if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { // add modified entry newEntries.add(getUpdatedEntry(curr, newEntry, changedAttributes, jproject)); found= true; } else { newEntries.add(curr); } } if (!found) { if (!putJarOnClasspathDialog(shell)) { return; } // add new newEntries.add(newEntry); } IClasspathEntry[] newClasspath= newEntries.toArray(new IClasspathEntry[newEntries.size()]); jproject.setRawClasspath(newClasspath, monitor); }
elementsToAdd.add(curr); curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr)); curr.setAttribute(CPListElement.JAVADOC, JavaUI .getLibraryJavadocLocation(curr.getPath()));
private static void convertContainer(IClasspathEntry entry, IJavaProject project, Map<IPath, String> oldLocationMap) { try { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), project); if (container == null) { return; } IClasspathEntry[] entries= container.getClasspathEntries(); boolean hasChange= false; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; IClasspathEntry updatedEntry= getConvertedEntry(curr, project, oldLocationMap); if (updatedEntry != null) { entries[i]= updatedEntry; hasChange= true; } } if (hasChange) { BuildPathSupport.requestContainerUpdate(project, container, entries); } } catch (CoreException e) { // ignore } }
/** * Evaluate if the builds path contains an execution environment and the current compliance * settings follow the EE options. * * @param ee the EE, or <code>null</code> if none available * @return {@link #DEFAULT_CONF} if the compliance follows the EE, or {@link #USER_CONF} if the * settings differ, or {@link #DISABLED} if there's no EE at all */ private String getComplianceFollowsEE(IExecutionEnvironment ee) { Map<String, String> options= BuildPathSupport.getEEOptions(ee); if (options == null) return DISABLED; return checkDefaults(PREFS_COMPLIANCE, options); }
if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) { newReferencedEntries.add(getUpdatedEntry(curr, newReferencedEntry, changedAttributes, jproject)); found= true; } else {
private void doAdd(List<Object> list) { if (canAdd(list)) { CPUserLibraryElement parentLibrary = getSingleSelectedLibrary(list); IPath selection= getWorkbenchWindowSelection(); IPath selectedPaths[] = BuildPathDialogAccess.chooseJAREntries(this.getShell(), selection, new IPath[0]); if (selectedPaths != null) { List<CPListElement> elements = new ArrayList<>(); for (int i= 0; i < selectedPaths.length; i++) { CPListElement cpElement = new CPListElement(parentLibrary, fDummyProject, IClasspathEntry.CPE_LIBRARY, selectedPaths[i], null); cpElement.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(cpElement)); cpElement.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(cpElement)); elements.add(cpElement); parentLibrary.add(cpElement); } fLibraryList.refresh(parentLibrary); fLibraryList.selectElements(new StructuredSelection(elements)); fLibraryList.expandElement(parentLibrary, 2); } } }
public void run(IProgressMonitor monitor) throws CoreException { BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, monitor); } };