public void setDefaults() { if (fEntry.getSourceAttachmentPath() != null) { fFileNameField.setText(fEntry.getSourceAttachmentPath().toString()); } else { fFileNameField.setText(""); //$NON-NLS-1$ } }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentPath() */ @Override public IPath getSourceAttachmentPath() { IClasspathEntry entry = getClasspathEntry(); return entry != null ? entry.getSourceAttachmentPath() : null; }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentPath() */ @Override public IPath getSourceAttachmentPath() { IClasspathEntry entry = getClasspathEntry(); return entry != null ? entry.getSourceAttachmentPath() : null; }
@Override public Image getImage(Object obj) { IClasspathEntry entry = (IClasspathEntry) obj; int kind = entry.getEntryKind(); if (kind == IClasspathEntry.CPE_PROJECT) return projectImage; else if (kind == IClasspathEntry.CPE_LIBRARY) { IPath sourceAtt = entry.getSourceAttachmentPath(); return sourceAtt != null ? slibraryImage : libraryImage; } return null; }
private void setDeletedEntryProperties(IClasspathEntry entry){ fEntryKind= entry.getEntryKind(); fPath= entry.getPath(); fSourceAttachmentPath= entry.getSourceAttachmentPath(); fSourceAttachmentRootPath= entry.getSourceAttachmentRootPath(); }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentLocation() */ @Override public String getSourceAttachmentLocation() { IPath path = null; switch (getType()) { case VARIABLE : case ARCHIVE : IClasspathEntry resolved = getResolvedClasspathEntry(); if (resolved != null) { path = resolved.getSourceAttachmentPath(); } break; default : break; } return resolveToOSPath(path); }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentLocation() */ @Override public String getSourceAttachmentLocation() { IPath path = null; switch (getType()) { case VARIABLE : case ARCHIVE : IClasspathEntry resolved = getResolvedClasspathEntry(); if (resolved != null) { path = resolved.getSourceAttachmentPath(); } break; default : break; } return resolveToOSPath(path); }
private static void addLibraryEntry(IProject project, IPluginLibrary library, IPath sourceAttachment, IClasspathAttribute[] attrs, ArrayList<IClasspathEntry> result) throws JavaModelException { String name = ClasspathUtilCore.expandLibraryName(library.getName()); IResource jarFile = project.findMember(name); if (jarFile == null) return; IPackageFragmentRoot root = JavaCore.create(project).getPackageFragmentRoot(jarFile); if (root.exists() && root.getKind() == IPackageFragmentRoot.K_BINARY) { IClasspathEntry oldEntry = root.getRawClasspathEntry(); // If we have the same binary root but new or different source, we should recreate the entry if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null) || (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) { if (!result.contains(oldEntry)) { result.add(oldEntry); return; } } } IClasspathEntry entry = createClasspathEntry(project, jarFile, name, sourceAttachment, attrs, library.isExported()); if (!result.contains(entry)) result.add(entry); }
private static void updateProjectClasspath(IJavaProject javaProject, IClasspathEntry newEntry, IProgressMonitor monitor) throws JavaModelException { List<IClasspathEntry> newEntries = updateElements(javaProject.getRawClasspath(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); JavaLanguageServerPlugin.logInfo("Update source attachment " + (newEntry.getSourceAttachmentPath() == null ? null : newEntry.getSourceAttachmentPath().toOSString()) + " to the file " + newEntry.getPath().toOSString()); javaProject.setRawClasspath(newEntries.toArray(new IClasspathEntry[0]), monitor); }
private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) { if (entry == null) return null; IPath srcPath = entry.getSourceAttachmentPath(); if (srcPath != null && srcPath.segmentCount() > 0) { IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()); rte.setSourceAttachmentPath(srcPath); rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath()); return rte; } return null; }
public static SourceAttachmentResult resolveSourceAttachment(IPackageFragmentRoot root, IProgressMonitor monitor) { ClasspathEntryWrapper entryWrapper = null; try { entryWrapper = getClasspathEntry(root); } catch (CoreException e) { return new SourceAttachmentResult(e.getMessage(), null); } IResource jarResource = null; try { jarResource = root.getUnderlyingResource(); } catch (JavaModelException e1) { // do nothing. } String jarPath = jarResource != null ? jarResource.getLocation().toOSString() : entryWrapper.original.getPath().toOSString(); String sourceAttachmentPath = entryWrapper.original.getSourceAttachmentPath() != null ? entryWrapper.original.getSourceAttachmentPath().toOSString() : null; String sourceAttachmentEncoding = getSourceAttachmentEncoding(entryWrapper.original); return new SourceAttachmentResult(null, new SourceAttachmentAttribute(jarPath, sourceAttachmentPath, sourceAttachmentEncoding, entryWrapper.canEditEncoding)); }
/** * Prompts source attachment. * * @see org.eclipse.jface.action.IAction#run() */ public void run() { IClasspathEntry classpathEntry = BuildPathDialogAccess.configureSourceAttachment(getShell(), fEntries[0].getClasspathEntry()); if (classpathEntry != null) { for (int i = 0; i < fEntries.length; i++) { IRuntimeClasspathEntry entry = fEntries[i]; entry.setSourceAttachmentPath(classpathEntry.getSourceAttachmentPath()); entry.setSourceAttachmentRootPath(classpathEntry.getSourceAttachmentRootPath()); getViewer().refresh(entry); } getViewer().notifyChanged(); } }
private static IClasspathEntry addAttributes(IClasspathEntry entry, IClasspathAttribute[] extraAttributes) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); default: return entry; // other kinds are not handled } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private IClasspathEntry addAttributes(IClasspathEntry entry, IClasspathAttribute[] extraAttributes) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), extraAttributes, entry.isExported()); default: return entry; // other kinds are not handled } }