/** * Returns the archive associated with this source * location. * * @return zip file * @throws IOException if unable to create the zip * file associated with this location */ protected ZipFile getArchive() throws IOException { return getZipFile(getName()); }
@Override public void resourceChanged(IResourceChangeEvent event) { ArchiveSourceLocation.closeArchives(); }
/** * Constructs a new source location that will retrieve source * elements from the zip file with the given name. * * @param archiveName zip file * @param sourceRoot a path to the root source folder in the * specified archive, or <code>null</code> if the root source folder * is the root of the archive */ public ArchiveSourceLocation(String archiveName, String sourceRoot) { super(); setName(archiveName); setRootPath(sourceRoot); }
@Override public Object findSourceElement(String name) throws CoreException { try { if (getArchive() == null) { return null; do { IPath entryPath = new Path(typeName + ".java"); //$NON-NLS-1$ autoDetectRoot(entryPath); if (getRootPath() != null) { entryPath = getRootPath().append(entryPath); ZipEntry entry = getArchive().getEntry(entryPath.toString()); if (entry != null) { return new ZipEntryStorage(getArchive(), entry); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, NLS.bind(LaunchingMessages.ArchiveSourceLocation_Unable_to_locate_source_element_in_archive__0__1, new String[] {getName()}), e));
@Override public void initializeFrom(String memento) throws CoreException { Exception ex = null; try { Element root = null; DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); String path = root.getAttribute("archivePath"); //$NON-NLS-1$ if (isEmpty(path)) { abort(LaunchingMessages.ArchiveSourceLocation_Unable_to_initialize_source_location___missing_archive_path__3, null); } String rootPath = root.getAttribute("rootPath"); //$NON-NLS-1$ setName(path); setRootPath(rootPath); return; } catch (ParserConfigurationException e) { ex = e; } catch (SAXException e) { ex = e; } catch (IOException e) { ex = e; } abort(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_initializing_source_location__5, ex); }
ZipFile zip = null; try { zip = getArchive(); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, NLS.bind(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_while_detecting_root_source_directory_in_archive__0__1, new String[] {getName()}), e)); if (rootLength > 0) { String root = entryName.substring(0, rootLength); setRootPath(root); NLS.bind(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_while_detecting_root_source_directory_in_archive__0__2, new String[] {getName()}), e));
@Override public String getMemento() throws CoreException { Document doc = DebugPlugin.newDocument(); Element node = doc.createElement("archiveSourceLocation"); //$NON-NLS-1$ doc.appendChild(node); node.setAttribute("archivePath", getName()); //$NON-NLS-1$ if (getRootPath() != null) { node.setAttribute("rootPath", getRootPath().toString()); //$NON-NLS-1$ } return DebugPlugin.serializeDocument(doc); }
location = new DirectorySourceLocation(file); } else { location = new ArchiveSourceLocation(path, entry.getSourceAttachmentRootLocation()); String source = entry.getSourceAttachmentLocation(); if (source != null) { location = new ArchiveSourceLocation(source, entry.getSourceAttachmentRootLocation());
@Override public Object findSourceElement(String name) throws CoreException { try { if (getArchive() == null) { return null; do { IPath entryPath = new Path(typeName + ".java"); //$NON-NLS-1$ autoDetectRoot(entryPath); if (getRootPath() != null) { entryPath = getRootPath().append(entryPath); ZipEntry entry = getArchive().getEntry(entryPath.toString()); if (entry != null) { return new ZipEntryStorage(getArchive(), entry); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, NLS.bind(LaunchingMessages.ArchiveSourceLocation_Unable_to_locate_source_element_in_archive__0__1, new String[] {getName()}), e));
@Override public void initializeFrom(String memento) throws CoreException { Exception ex = null; try { Element root = null; DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); parser.setErrorHandler(new DefaultHandler()); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); String path = root.getAttribute("archivePath"); //$NON-NLS-1$ if (isEmpty(path)) { abort(LaunchingMessages.ArchiveSourceLocation_Unable_to_initialize_source_location___missing_archive_path__3, null); } String rootPath = root.getAttribute("rootPath"); //$NON-NLS-1$ setName(path); setRootPath(rootPath); return; } catch (ParserConfigurationException e) { ex = e; } catch (SAXException e) { ex = e; } catch (IOException e) { ex = e; } abort(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_initializing_source_location__5, ex); }
ZipFile zip = null; try { zip = getArchive(); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, NLS.bind(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_while_detecting_root_source_directory_in_archive__0__1, new String[] {getName()}), e)); if (rootLength > 0) { String root = entryName.substring(0, rootLength); setRootPath(root); NLS.bind(LaunchingMessages.ArchiveSourceLocation_Exception_occurred_while_detecting_root_source_directory_in_archive__0__2, new String[] {getName()}), e));
@Override public String getMemento() throws CoreException { Document doc = DebugPlugin.newDocument(); Element node = doc.createElement("archiveSourceLocation"); //$NON-NLS-1$ doc.appendChild(node); node.setAttribute("archivePath", getName()); //$NON-NLS-1$ if (getRootPath() != null) { node.setAttribute("rootPath", getRootPath().toString()); //$NON-NLS-1$ } return DebugPlugin.serializeDocument(doc); }
location = new DirectorySourceLocation(file); } else { location = new ArchiveSourceLocation(path, entry.getSourceAttachmentRootLocation()); String source = entry.getSourceAttachmentLocation(); if (source != null) { location = new ArchiveSourceLocation(source, entry.getSourceAttachmentRootLocation());
/** * Returns the archive associated with this source * location. * * @return zip file * @throws IOException if unable to create the zip * file associated with this location */ protected ZipFile getArchive() throws IOException { return getZipFile(getName()); }
@Override public int hashCode() { return getName().hashCode(); }
@Override public void launchesRemoved(ILaunch[] launches) { ArchiveSourceLocation.closeArchives(); }
/** * Constructs a new source location that will retrieve source * elements from the zip file with the given name. * * @param archiveName zip file * @param sourceRoot a path to the root source folder in the * specified archive, or <code>null</code> if the root source folder * is the root of the archive */ public ArchiveSourceLocation(String archiveName, String sourceRoot) { super(); setName(archiveName); setRootPath(sourceRoot); }
@Override public int hashCode() { return getName().hashCode(); }