@Override public void writeArchive(ZipFile jarFile, IProgressMonitor progressMonitor) { File jarPathFile= new File(jarFile.getName()); String jarName = jarPathFile.getName(); while (jarNames.contains(jarName)) { jarName= FatJarPackagerUtil.nextNumberedFileName(jarName); } jarNames.add(jarName); JarEntry newEntry = new JarEntry(jarName); newEntry.setMethod(ZipEntry.STORED); byte[] readBuffer= new byte[4096]; try { if (!fJarPackage.isCompressed()) JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(jarPathFile), readBuffer); getJarWriter().addZipEntryStream(newEntry, new FileInputStream(jarPathFile), jarName); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void writeArchive(ZipFile jarFile, IProgressMonitor progressMonitor) { File jarPathFile= new File(jarFile.getName()); String jarName = jarPathFile.getName(); while (jarNames.contains(jarName)) { jarName= FatJarPackagerUtil.nextNumberedFileName(jarName); } jarNames.add(jarName); JarEntry newEntry = new JarEntry(jarName); newEntry.setMethod(ZipEntry.STORED); byte[] readBuffer= new byte[4096]; try { if (!fJarPackage.isCompressed()) JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(jarPathFile), readBuffer); getJarWriter().addZipEntryStream(newEntry, new FileInputStream(jarPathFile), jarName); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
private void xmlWriteOptions(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element options= document.createElement("options"); //$NON-NLS-1$ xmlJarDesc.appendChild(options); options.setAttribute("overwrite", "" + jarPackage.allowOverwrite()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("compress", "" + jarPackage.isCompressed()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportErrors", "" + jarPackage.areErrorsExported()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportWarnings", "" + jarPackage.exportWarnings()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("saveDescription", "" + jarPackage.isDescriptionSaved()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("descriptionLocation", jarPackage.getDescriptionLocation().toPortableString()); //$NON-NLS-1$ options.setAttribute("useSourceFolders", "" + jarPackage.useSourceFolderHierarchy()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("buildIfNeeded", "" + jarPackage.isBuildingIfNeeded()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("includeDirectoryEntries", "" + jarPackage.areDirectoryEntriesIncluded()); //$NON-NLS-1$//$NON-NLS-2$ options.setAttribute("storeRefactorings", "" + jarPackage.isRefactoringAware()); //$NON-NLS-1$//$NON-NLS-2$ }
private void xmlWriteOptions(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element options= document.createElement("options"); //$NON-NLS-1$ xmlJarDesc.appendChild(options); options.setAttribute("overwrite", "" + jarPackage.allowOverwrite()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("compress", "" + jarPackage.isCompressed()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportErrors", "" + jarPackage.areErrorsExported()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportWarnings", "" + jarPackage.exportWarnings()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("saveDescription", "" + jarPackage.isDescriptionSaved()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("descriptionLocation", jarPackage.getDescriptionLocation().toPortableString()); //$NON-NLS-1$ options.setAttribute("useSourceFolders", "" + jarPackage.useSourceFolderHierarchy()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("buildIfNeeded", "" + jarPackage.isBuildingIfNeeded()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("includeDirectoryEntries", "" + jarPackage.areDirectoryEntriesIncluded()); //$NON-NLS-1$//$NON-NLS-2$ options.setAttribute("storeRefactorings", "" + jarPackage.isRefactoringAware()); //$NON-NLS-1$//$NON-NLS-2$ }
private void addFile(File file, IPath path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.toString().replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(file), new byte[4096]); } newEntry.setTime(file.lastModified()); addEntry(newEntry, new FileInputStream(file)); } }
private void xmlWriteOptions(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element options= document.createElement("options"); //$NON-NLS-1$ xmlJarDesc.appendChild(options); options.setAttribute("overwrite", "" + jarPackage.allowOverwrite()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("compress", "" + jarPackage.isCompressed()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportErrors", "" + jarPackage.areErrorsExported()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("exportWarnings", "" + jarPackage.exportWarnings()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("saveDescription", "" + jarPackage.isDescriptionSaved()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("descriptionLocation", jarPackage.getDescriptionLocation().toPortableString()); //$NON-NLS-1$ options.setAttribute("useSourceFolders", "" + jarPackage.useSourceFolderHierarchy()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("buildIfNeeded", "" + jarPackage.isBuildingIfNeeded()); //$NON-NLS-2$ //$NON-NLS-1$ options.setAttribute("includeDirectoryEntries", "" + jarPackage.areDirectoryEntriesIncluded()); //$NON-NLS-1$//$NON-NLS-2$ options.setAttribute("storeRefactorings", "" + jarPackage.isRefactoringAware()); //$NON-NLS-1$//$NON-NLS-2$ }
private void addFile(File file, IPath path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.toString().replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(file), new byte[4096]); } newEntry.setTime(file.lastModified()); addEntry(newEntry, new FileInputStream(file)); } }
if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED);
/** * Hook method for restoring widget values to the values that they held * last time this wizard was used to completion. */ @Override protected void restoreWidgetValues() { if (!((JarPackageWizard)getWizard()).isInitializingFromJarPackage()) initializeJarPackage(); fExportClassFilesCheckbox.setSelection(fJarPackage.areClassFilesExported()); fExportOutputFoldersCheckbox.setSelection(fJarPackage.areOutputFoldersExported()); fExportJavaFilesCheckbox.setSelection(fJarPackage.areJavaFilesExported()); super.restoreWidgetValues(); // options if (fExportRefactoringsCheckbox != null) fExportRefactoringsCheckbox.setSelection(fJarPackage.isRefactoringAware()); fCompressCheckbox.setSelection(fJarPackage.isCompressed()); fIncludeDirectoryEntriesCheckbox.setSelection(fJarPackage.areDirectoryEntriesIncluded()); fOverwriteCheckbox.setSelection(fJarPackage.allowOverwrite()); }
public void addZipEntry(ZipEntry zipEntry, ZipFile zipFile, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, zipFile.getInputStream(zipEntry)); }
/** * Hook method for restoring widget values to the values that they held * last time this wizard was used to completion. */ @Override protected void restoreWidgetValues() { if (!((JarPackageWizard)getWizard()).isInitializingFromJarPackage()) initializeJarPackage(); fExportClassFilesCheckbox.setSelection(fJarPackage.areClassFilesExported()); fExportOutputFoldersCheckbox.setSelection(fJarPackage.areOutputFoldersExported()); fExportJavaFilesCheckbox.setSelection(fJarPackage.areJavaFilesExported()); super.restoreWidgetValues(); // options if (fExportRefactoringsCheckbox != null) fExportRefactoringsCheckbox.setSelection(fJarPackage.isRefactoringAware()); fCompressCheckbox.setSelection(fJarPackage.isCompressed()); fIncludeDirectoryEntriesCheckbox.setSelection(fJarPackage.areDirectoryEntriesIncluded()); fOverwriteCheckbox.setSelection(fJarPackage.allowOverwrite()); }
public void addZipEntry(ZipEntry zipEntry, ZipFile zipFile, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, zipFile.getInputStream(zipEntry)); }
public void addZipEntryStream(ZipEntry zipEntry, InputStream is, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, is); }
public void addZipEntryStream(ZipEntry zipEntry, InputStream is, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, is); }
byte[] readBuffer= new byte[4096]; if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED);
byte[] readBuffer= new byte[4096]; if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED);
fCompressCheckbox.setSelection(fJarPackage.isCompressed()); fIncludeDirectoryEntriesCheckbox.setSelection(fJarPackage.areDirectoryEntriesIncluded()); fOverwriteCheckbox.setSelection(fJarPackage.allowOverwrite());
/** * Persists resource specification control setting that are to be restored * in the next instance of this page. Subclasses wishing to persist * settings for their controls should extend the hook method * <code>internalSaveWidgetValues</code>. */ @Override public final void saveWidgetValues() { super.saveWidgetValues(); // update directory names history IDialogSettings settings= getDialogSettings(); if (settings != null) { settings.put(STORE_EXPORT_CLASS_FILES, fJarPackage.areClassFilesExported()); settings.put(STORE_EXPORT_OUTPUT_FOLDERS, fJarPackage.areOutputFoldersExported()); settings.put(STORE_EXPORT_JAVA_FILES, fJarPackage.areJavaFilesExported()); // options settings.put(STORE_REFACTORINGS, fJarPackage.isRefactoringAware()); settings.put(STORE_COMPRESS, fJarPackage.isCompressed()); settings.put(STORE_INCLUDE_DIRECTORY_ENTRIES, fJarPackage.areDirectoryEntriesIncluded()); settings.put(STORE_OVERWRITE, fJarPackage.allowOverwrite()); } // Allow subclasses to save values internalSaveWidgetValues(); }
/** * Persists resource specification control setting that are to be restored * in the next instance of this page. Subclasses wishing to persist * settings for their controls should extend the hook method * <code>internalSaveWidgetValues</code>. */ @Override public final void saveWidgetValues() { super.saveWidgetValues(); // update directory names history IDialogSettings settings= getDialogSettings(); if (settings != null) { settings.put(STORE_EXPORT_CLASS_FILES, fJarPackage.areClassFilesExported()); settings.put(STORE_EXPORT_OUTPUT_FOLDERS, fJarPackage.areOutputFoldersExported()); settings.put(STORE_EXPORT_JAVA_FILES, fJarPackage.areJavaFilesExported()); // options settings.put(STORE_REFACTORINGS, fJarPackage.isRefactoringAware()); settings.put(STORE_COMPRESS, fJarPackage.isCompressed()); settings.put(STORE_INCLUDE_DIRECTORY_ENTRIES, fJarPackage.areDirectoryEntriesIncluded()); settings.put(STORE_OVERWRITE, fJarPackage.allowOverwrite()); } // Allow subclasses to save values internalSaveWidgetValues(); }
/** * Persists resource specification control setting that are to be restored * in the next instance of this page. Subclasses wishing to persist * settings for their controls should extend the hook method * <code>internalSaveWidgetValues</code>. */ public final void saveWidgetValues() { // update directory names history IDialogSettings settings= getDialogSettings(); if (settings != null) { String[] directoryNames= settings.getArray(STORE_DESTINATION_NAMES); if (directoryNames == null) directoryNames= new String[0]; directoryNames= addToHistory(directoryNames, getDestinationValue()); settings.put(STORE_DESTINATION_NAMES, directoryNames); settings.put(STORE_EXPORT_CLASS_FILES, fJarPackage.areClassFilesExported()); settings.put(STORE_EXPORT_OUTPUT_FOLDERS, fJarPackage.areOutputFoldersExported()); settings.put(STORE_EXPORT_JAVA_FILES, fJarPackage.areJavaFilesExported()); // options settings.put(STORE_REFACTORINGS, fJarPackage.isRefactoringAware()); settings.put(STORE_COMPRESS, fJarPackage.isCompressed()); settings.put(STORE_INCLUDE_DIRECTORY_ENTRIES, fJarPackage.areDirectoryEntriesIncluded()); settings.put(STORE_OVERWRITE, fJarPackage.allowOverwrite()); } // Allow subclasses to save values internalSaveWidgetValues(); }