private void xmlWriteSelectedElements(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element selectedElements= document.createElement("selectedElements"); //$NON-NLS-1$ xmlJarDesc.appendChild(selectedElements); selectedElements.setAttribute("exportClassFiles", "" + jarPackage.areClassFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportOutputFolder", "" + jarPackage.areOutputFoldersExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportJavaFiles", "" + jarPackage.areJavaFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ Object[] elements= jarPackage.getElements(); for (int i= 0; i < elements.length; i++) { Object element= elements[i]; if (element instanceof IResource) add((IResource)element, selectedElements, document); else if (element instanceof IJavaElement) add((IJavaElement)element, selectedElements, document); // Note: Other file types are not handled by this writer } }
private void xmlWriteSelectedElements(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element selectedElements= document.createElement("selectedElements"); //$NON-NLS-1$ xmlJarDesc.appendChild(selectedElements); selectedElements.setAttribute("exportClassFiles", "" + jarPackage.areClassFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportOutputFolder", "" + jarPackage.areOutputFoldersExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportJavaFiles", "" + jarPackage.areJavaFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ Object[] elements= jarPackage.getElements(); for (int i= 0; i < elements.length; i++) { Object element= elements[i]; if (element instanceof IResource) add((IResource)element, selectedElements, document); else if (element instanceof IJavaElement) add((IJavaElement)element, selectedElements, document); // Note: Other file types are not handled by this writer } }
private void xmlWriteSelectedElements(JarPackageData jarPackage, Document document, Element xmlJarDesc) throws DOMException { Element selectedElements= document.createElement("selectedElements"); //$NON-NLS-1$ xmlJarDesc.appendChild(selectedElements); selectedElements.setAttribute("exportClassFiles", "" + jarPackage.areClassFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportOutputFolder", "" + jarPackage.areOutputFoldersExported()); //$NON-NLS-2$ //$NON-NLS-1$ selectedElements.setAttribute("exportJavaFiles", "" + jarPackage.areJavaFilesExported()); //$NON-NLS-2$ //$NON-NLS-1$ Object[] elements= jarPackage.getElements(); for (int i= 0; i < elements.length; i++) { Object element= elements[i]; if (element instanceof IResource) add((IResource)element, selectedElements, document); else if (element instanceof IJavaElement) add((IJavaElement)element, selectedElements, document); // Note: Other file types are not handled by this writer } }
/** * Updates the enablements of this page's controls. Subclasses may extend. */ protected void updateWidgetEnablements() { boolean saveDescription= fSaveDescriptionCheckbox.getSelection(); fDescriptionFileGroup.setEnabled(saveDescription); fDescriptionFileBrowseButton.setEnabled(saveDescription); fDescriptionFileText.setEnabled(saveDescription); fDescriptionFileLabel.setEnabled(saveDescription); boolean exportClassFiles= fJarPackage.areClassFilesExported() && !fJarPackage.areOutputFoldersExported(); fExportWarningsCheckbox.setEnabled(exportClassFiles); fExportErrorsCheckbox.setEnabled(exportClassFiles); boolean isAutobuilding= ResourcesPlugin.getWorkspace().isAutoBuilding(); fBuildIfNeededCheckbox.setEnabled(exportClassFiles && !isAutobuilding); fUseSourceFoldersCheckbox.setEnabled(fJarPackage.areJavaFilesExported() && !fJarPackage.areGeneratedFilesExported()); }
/** * Updates the enablements of this page's controls. Subclasses may extend. */ protected void updateWidgetEnablements() { boolean saveDescription= fSaveDescriptionCheckbox.getSelection(); fDescriptionFileGroup.setEnabled(saveDescription); fDescriptionFileBrowseButton.setEnabled(saveDescription); fDescriptionFileText.setEnabled(saveDescription); fDescriptionFileLabel.setEnabled(saveDescription); boolean exportClassFiles= fJarPackage.areClassFilesExported() && !fJarPackage.areOutputFoldersExported(); fExportWarningsCheckbox.setEnabled(exportClassFiles); fExportErrorsCheckbox.setEnabled(exportClassFiles); boolean isAutobuilding= ResourcesPlugin.getWorkspace().isAutoBuilding(); fBuildIfNeededCheckbox.setEnabled(exportClassFiles && !isAutobuilding); fUseSourceFoldersCheckbox.setEnabled(fJarPackage.areJavaFilesExported() && !fJarPackage.areGeneratedFilesExported()); }
/** * Updates the enablements of this page's controls. Subclasses may extend. */ protected void updateWidgetEnablements() { boolean saveDescription= fSaveDescriptionCheckbox.getSelection(); fDescriptionFileGroup.setEnabled(saveDescription); fDescriptionFileBrowseButton.setEnabled(saveDescription); fDescriptionFileText.setEnabled(saveDescription); fDescriptionFileLabel.setEnabled(saveDescription); boolean exportClassFiles= fJarPackage.areClassFilesExported() && !fJarPackage.areOutputFoldersExported(); fExportWarningsCheckbox.setEnabled(exportClassFiles); fExportErrorsCheckbox.setEnabled(exportClassFiles); boolean isAutobuilding= ResourcesPlugin.getWorkspace().isAutoBuilding(); fBuildIfNeededCheckbox.setEnabled(exportClassFiles && !isAutobuilding); fUseSourceFoldersCheckbox.setEnabled(fJarPackage.areJavaFilesExported() && !fJarPackage.areGeneratedFilesExported()); }
/** * Updates the enablements of this page's controls. Subclasses may extend. */ protected void updateWidgetEnablements() { boolean saveDescription= fSaveDescriptionCheckbox.getSelection(); fDescriptionFileGroup.setEnabled(saveDescription); fDescriptionFileBrowseButton.setEnabled(saveDescription); fDescriptionFileText.setEnabled(saveDescription); fDescriptionFileLabel.setEnabled(saveDescription); boolean exportClassFiles= fJarPackage.areClassFilesExported() && !fJarPackage.areOutputFoldersExported(); fExportWarningsCheckbox.setEnabled(exportClassFiles); fExportErrorsCheckbox.setEnabled(exportClassFiles); boolean isAutobuilding= ResourcesPlugin.getWorkspace().isAutoBuilding(); fBuildIfNeededCheckbox.setEnabled(exportClassFiles && !isAutobuilding); fUseSourceFoldersCheckbox.setEnabled(fJarPackage.areJavaFilesExported() && !fJarPackage.areGeneratedFilesExported()); }
/** * 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()); }
/** * 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()); }
/** * Stores the widget values in the JAR package. */ @Override protected void updateModel() { if (getControl() == null) return; // source if (fExportClassFilesCheckbox.getSelection() && !fJarPackage.areClassFilesExported()) fExportOutputFoldersCheckbox.setSelection(false); if (fExportOutputFoldersCheckbox.getSelection() && !fJarPackage.areOutputFoldersExported()) fExportClassFilesCheckbox.setSelection(false); fJarPackage.setExportClassFiles(fExportClassFilesCheckbox.getSelection()); fJarPackage.setExportOutputFolders(fExportOutputFoldersCheckbox.getSelection()); fJarPackage.setExportJavaFiles(fExportJavaFilesCheckbox.getSelection()); fJarPackage.setElements(getSelectedElements()); super.updateModel(); // options if (fExportRefactoringsCheckbox != null) fJarPackage.setRefactoringAware(fExportRefactoringsCheckbox.getSelection()); else fJarPackage.setRefactoringAware(false); fJarPackage.setCompress(fCompressCheckbox.getSelection()); fJarPackage.setIncludeDirectoryEntries(fIncludeDirectoryEntriesCheckbox.getSelection()); fJarPackage.setOverwrite(fOverwriteCheckbox.getSelection()); }
/** * Stores the widget values in the JAR package. */ @Override protected void updateModel() { if (getControl() == null) return; // source if (fExportClassFilesCheckbox.getSelection() && !fJarPackage.areClassFilesExported()) fExportOutputFoldersCheckbox.setSelection(false); if (fExportOutputFoldersCheckbox.getSelection() && !fJarPackage.areOutputFoldersExported()) fExportClassFilesCheckbox.setSelection(false); fJarPackage.setExportClassFiles(fExportClassFilesCheckbox.getSelection()); fJarPackage.setExportOutputFolders(fExportOutputFoldersCheckbox.getSelection()); fJarPackage.setExportJavaFiles(fExportJavaFilesCheckbox.getSelection()); fJarPackage.setElements(getSelectedElements()); super.updateModel(); // options if (fExportRefactoringsCheckbox != null) fJarPackage.setRefactoringAware(fExportRefactoringsCheckbox.getSelection()); else fJarPackage.setRefactoringAware(false); fJarPackage.setCompress(fCompressCheckbox.getSelection()); fJarPackage.setIncludeDirectoryEntries(fIncludeDirectoryEntriesCheckbox.getSelection()); fJarPackage.setOverwrite(fOverwriteCheckbox.getSelection()); }
private void exportClassFiles(IProgressMonitor progressMonitor, ITypeRoot typeRootElement, IPath destinationPath) { if (fJarPackage.areClassFilesExported()) { try { if (!typeRootElement.exists()) return; // find corresponding file(s) on classpath and export Iterator iter= filesOnClasspath(typeRootElement, destinationPath, progressMonitor); IPath baseDestinationPath= destinationPath.removeLastSegments(1); while (iter.hasNext()) { IFile file= (IFile)iter.next(); IPath classFilePath= baseDestinationPath.append(file.getName()); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, classFilePath.toString())); fJarWriter.write(file, classFilePath); } } catch (CoreException ex) { addToStatus(ex); } } }
private void exportClassFiles(IProgressMonitor progressMonitor, IPackageFragmentRoot pkgRoot, IResource resource, IJavaProject jProject, IPath destinationPath) { if (fJarPackage.areClassFilesExported() && isJavaFile(resource) && pkgRoot != null) { try { if (!jProject.isOnClasspath(resource)) return; // find corresponding file(s) on classpath and export Iterator iter= filesOnClasspath((IFile)resource, destinationPath, jProject, pkgRoot, progressMonitor); IPath baseDestinationPath= destinationPath.removeLastSegments(1); while (iter.hasNext()) { IFile file= (IFile)iter.next(); if (!resource.isLocal(IResource.DEPTH_ZERO)) file.setLocal(true , IResource.DEPTH_ZERO, progressMonitor); IPath classFilePath= baseDestinationPath.append(file.getName()); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, classFilePath.toString())); fJarWriter.write(file, classFilePath); } } catch (CoreException ex) { addToStatus(ex); } } }
private void exportClassFiles(IProgressMonitor progressMonitor, ITypeRoot typeRootElement, IPath destinationPath) { if (fJarPackage.areClassFilesExported()) { try { if (!typeRootElement.exists()) return; // find corresponding file(s) on classpath and export Iterator<? extends IResource> iter= filesOnClasspath(typeRootElement, destinationPath, progressMonitor); IPath baseDestinationPath= destinationPath.removeLastSegments(1); while (iter.hasNext()) { IFile file= (IFile)iter.next(); IPath classFilePath= baseDestinationPath.append(file.getName()); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, BasicElementLabels.getPathLabel(classFilePath, false))); try { fJarBuilder.writeFile(file, classFilePath); } catch (CoreException ex) { handleCoreExceptionOnExport(ex); } } } catch (CoreException ex) { addToStatus(ex); } } }
private void exportClassFiles(IProgressMonitor progressMonitor, ITypeRoot typeRootElement, IPath destinationPath) { if (fJarPackage.areClassFilesExported()) { try { if (!typeRootElement.exists()) return; // find corresponding file(s) on classpath and export Iterator<? extends IResource> iter= filesOnClasspath(typeRootElement, destinationPath, progressMonitor); IPath baseDestinationPath= destinationPath.removeLastSegments(1); while (iter.hasNext()) { IFile file= (IFile)iter.next(); IPath classFilePath= baseDestinationPath.append(file.getName()); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, BasicElementLabels.getPathLabel(classFilePath, false))); try { fJarBuilder.writeFile(file, classFilePath); } catch (CoreException ex) { handleCoreExceptionOnExport(ex); } } } catch (CoreException ex) { addToStatus(ex); } } }
private void exportResource(IProgressMonitor progressMonitor, IPackageFragmentRoot pkgRoot, boolean isInJavaProject, IResource resource, IPath destinationPath) { // Handle case where META-INF/MANIFEST.MF is part of the exported files if (fJarPackage.areClassFilesExported() && destinationPath.toString().equals("META-INF/MANIFEST.MF")) {//$NON-NLS-1$ if (fJarPackage.isManifestGenerated()) addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_didNotAddManifestToJar, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), null); return; } boolean isNonJavaResource= !isInJavaProject || pkgRoot == null; boolean isInClassFolder= false; try { isInClassFolder= pkgRoot != null && !pkgRoot.isArchive() && pkgRoot.getKind() == IPackageFragmentRoot.K_BINARY; } catch (JavaModelException ex) { addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_cantGetRootKind, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), ex); } if ((fJarPackage.areClassFilesExported() && ((isNonJavaResource || (pkgRoot != null && !isJavaFile(resource) && !isClassFile(resource))) || isInClassFolder && isClassFile(resource))) || (fJarPackage.areJavaFilesExported() && (isNonJavaResource || (pkgRoot != null && !isClassFile(resource)) || (isInClassFolder && isClassFile(resource) && !fJarPackage.areClassFilesExported())))) { try { progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, BasicElementLabels.getPathLabel(destinationPath, false))); fJarBuilder.writeFile((IFile)resource, destinationPath); } catch (CoreException ex) { handleCoreExceptionOnExport(ex); } } }
private void exportResource(IProgressMonitor progressMonitor, IPackageFragmentRoot pkgRoot, boolean isInJavaProject, IResource resource, IPath destinationPath) { // Handle case where META-INF/MANIFEST.MF is part of the exported files if (fJarPackage.areClassFilesExported() && destinationPath.toString().equals("META-INF/MANIFEST.MF")) {//$NON-NLS-1$ if (fJarPackage.isManifestGenerated()) addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_didNotAddManifestToJar, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), null); return; } boolean isNonJavaResource= !isInJavaProject || pkgRoot == null; boolean isInClassFolder= false; try { isInClassFolder= pkgRoot != null && !pkgRoot.isArchive() && pkgRoot.getKind() == IPackageFragmentRoot.K_BINARY; } catch (JavaModelException ex) { addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_cantGetRootKind, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), ex); } if ((fJarPackage.areClassFilesExported() && ((isNonJavaResource || (pkgRoot != null && !isJavaFile(resource) && !isClassFile(resource))) || isInClassFolder && isClassFile(resource))) || (fJarPackage.areJavaFilesExported() && (isNonJavaResource || (pkgRoot != null && !isClassFile(resource)) || (isInClassFolder && isClassFile(resource) && !fJarPackage.areClassFilesExported())))) { try { progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, BasicElementLabels.getPathLabel(destinationPath, false))); fJarBuilder.writeFile((IFile)resource, destinationPath); } catch (CoreException ex) { handleCoreExceptionOnExport(ex); } } }
/** * 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(); }