### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java,v retrieving revision 1.13 diff -u -r1.13 OrganizeManifest.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java 8 Jun 2007 16:35:50 -0000 1.13 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java 25 Jul 2007 15:25:44 -0000 @@ -27,6 +27,7 @@ import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jface.text.IDocument; +import org.eclipse.ltk.core.refactoring.TextFileChange; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.ExportPackageDescription; import org.eclipse.osgi.service.resolver.HostSpecification; @@ -225,7 +226,7 @@ } - public static void removeUnusedKeys( + public static TextFileChange[] removeUnusedKeys( final IProject project, final IBundle bundle, final IPluginModelBase modelBase) { @@ -234,9 +235,9 @@ localization = "plugin"; //$NON-NLS-1$ IFile propertiesFile = project.getFile(localization + ".properties"); //$NON-NLS-1$ if (!propertiesFile.exists()) - return; + return new TextFileChange[0]; - PDEModelUtility.modifyModel(new ModelModification(propertiesFile) { + return PDEModelUtility.changesForModelModication(new ModelModification(propertiesFile) { protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException { if (!(model instanceof IBuildModel)) return; Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java,v retrieving revision 1.5 diff -u -r1.5 OrganizeManifestsWizard.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java 3 Apr 2006 19:47:25 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java 25 Jul 2007 15:25:44 -0000 @@ -10,44 +10,28 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.tools; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; - -import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ltk.ui.refactoring.RefactoringWizard; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEPluginImages; import org.eclipse.pde.internal.ui.PDEUIMessages; -public class OrganizeManifestsWizard extends Wizard { +public class OrganizeManifestsWizard extends RefactoringWizard { private OrganizeManifestsWizardPage fMainPage; - private ArrayList fProjects; - public OrganizeManifestsWizard(ArrayList projects) { - fProjects = projects; + public OrganizeManifestsWizard(OrganizeManifestsRefactor refactoring) { + super(refactoring, RefactoringWizard.DIALOG_BASED_USER_INTERFACE); setNeedsProgressMonitor(true); setWindowTitle(PDEUIMessages.OrganizeManifestsWizard_title); setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); setDefaultPageImageDescriptor(PDEPluginImages.DESC_ORGANIZE_MANIFESTS); } - public boolean performFinish() { fMainPage.preformOk(); - try { - OrganizeManifestsOperation op = new OrganizeManifestsOperation(fProjects); - op.setOperations(fMainPage.getSettings()); - getContainer().run(false, true, op); - } catch (InvocationTargetException e) { - PDEPlugin.log(e); - return false; - } catch (InterruptedException e) { - PDEPlugin.log(e); - return false; - } - return true; + return super.performFinish(); } - - public void addPages() { + protected void addUserInputPages() { + setDefaultPageTitle( getRefactoring().getName() ); fMainPage = new OrganizeManifestsWizardPage(); addPage(fMainPage); } Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java,v retrieving revision 1.6 diff -u -r1.6 OrganizeManifestsWizardPage.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java 8 Jun 2007 16:35:50 -0000 1.6 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizardPage.java 25 Jul 2007 15:25:44 -0000 @@ -12,7 +12,7 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; import org.eclipse.pde.internal.ui.IHelpContextIds; import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEUIMessages; @@ -28,7 +28,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; -public class OrganizeManifestsWizardPage extends WizardPage implements IPreferenceConstants, IOrganizeManifestsSettings { +public class OrganizeManifestsWizardPage extends UserInputWizardPage implements IPreferenceConstants, IOrganizeManifestsSettings { private Button fRemoveUnresolved; private Button fCalculateUses; @@ -46,7 +46,8 @@ private Button fRemoveLazy; private Button[] fTopLevelButtons; // used for setting page complete state - private Button[] fParentButtons; // parents with children that need to be dis/enabled + + private OrganizeManifestsProcessor fProcessor; private static String title = PDEUIMessages.OrganizeManifestsWizardPage_title; @@ -61,6 +62,8 @@ container.setLayout(new GridLayout()); container.setLayoutData(new GridData(GridData.FILL_BOTH)); + fProcessor = (OrganizeManifestsProcessor)((OrganizeManifestsRefactor)getRefactoring()).getProcessor(); + createExportedPackagesGroup(container); createRequireImportGroup(container); createGeneralGroup(container); @@ -167,25 +170,56 @@ private void presetOptions() { IDialogSettings settings = getDialogSettings(); - fAddMissing.setSelection(!settings.getBoolean(PROP_ADD_MISSING)); - fMarkInternal.setSelection(!settings.getBoolean(PROP_MARK_INTERNAL)); - String filter = settings.get(PROP_INTERAL_PACKAGE_FILTER); - fPackageFilter.setText(filter != null ? filter : VALUE_DEFAULT_FILTER); - fRemoveUnresolved.setSelection(!settings.getBoolean(PROP_REMOVE_UNRESOLVED_EX)); - fCalculateUses.setSelection(settings.getBoolean(PROP_CALCULATE_USES)); - - fModifyDependencies.setSelection(!settings.getBoolean(PROP_MODIFY_DEP)); - - fRemoveImport.setSelection(!settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT)); - fOptionalImport.setSelection(settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT)); - - fUnusedDependencies.setSelection(settings.getBoolean(PROP_UNUSED_DEPENDENCIES)); - fAdditonalDependencies.setSelection(settings.getBoolean(PROP_ADD_DEPENDENCIES)); + boolean selection = !settings.getBoolean(PROP_ADD_MISSING); + fAddMissing.setSelection(selection); + fProcessor.setAddMissing(selection); + + selection = !settings.getBoolean(PROP_MARK_INTERNAL); + fMarkInternal.setSelection(selection); + fProcessor.setMarkInternal(selection); - fRemoveLazy.setSelection(!settings.getBoolean(PROP_REMOVE_LAZY)); - - fFixIconNLSPaths.setSelection(settings.getBoolean(PROP_NLS_PATH)); - fRemovedUnusedKeys.setSelection(settings.getBoolean(PROP_UNUSED_KEYS)); + String filter = settings.get(PROP_INTERAL_PACKAGE_FILTER); + if (filter == null) + filter = VALUE_DEFAULT_FILTER; + fPackageFilter.setText(filter); + fProcessor.setPackageFilter(filter); + + selection = !settings.getBoolean(PROP_REMOVE_UNRESOLVED_EX); + fRemoveUnresolved.setSelection(selection); + fProcessor.setRemoveUnresolved(selection); + + selection = settings.getBoolean(PROP_CALCULATE_USES); + fCalculateUses.setSelection(selection); + fProcessor.setCalculateUses(selection); + + selection = !settings.getBoolean(PROP_MODIFY_DEP); + fModifyDependencies.setSelection(selection); + fProcessor.setModifyDep(selection); + + selection = settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT); + fRemoveImport.setSelection(!selection); + fOptionalImport.setSelection(selection); + fProcessor.setRemoveDependencies(!selection); + + selection = settings.getBoolean(PROP_UNUSED_DEPENDENCIES); + fUnusedDependencies.setSelection(selection); + fProcessor.setUnusedDependencies(selection); + + selection = settings.getBoolean(PROP_ADD_DEPENDENCIES); + fAdditonalDependencies.setSelection(selection); + fProcessor.setAddDependencies(selection); + + selection = !settings.getBoolean(PROP_REMOVE_LAZY); + fRemoveLazy.setSelection(selection); + fProcessor.setRemoveLazy(selection); + + selection = settings.getBoolean(PROP_NLS_PATH); + fFixIconNLSPaths.setSelection(selection); + fProcessor.setPrefixIconNL(selection); + + selection = settings.getBoolean(PROP_UNUSED_KEYS); + fRemovedUnusedKeys.setSelection(selection); + fProcessor.setUnusedKeys(selection); setEnabledStates(); setPageComplete(); @@ -228,9 +262,6 @@ fRemoveUnresolved, fAddMissing, fModifyDependencies, fMarkInternal, fUnusedDependencies, fAdditonalDependencies, fFixIconNLSPaths, fRemovedUnusedKeys, fRemoveLazy, fCalculateUses }; - fParentButtons = new Button[] { - fMarkInternal, fModifyDependencies - }; } private void setPageComplete() { @@ -245,25 +276,59 @@ } private void hookListeners() { - hookListener(fParentButtons, new SelectionAdapter() { + hookListener(new Button[] {fMarkInternal, fModifyDependencies}, new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setEnabledStates(); + doProcessorSetting(e.getSource()); } }); hookListener(fTopLevelButtons, new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setPageComplete(); + doProcessorSetting(e.getSource()); + } + }); + hookListener(new Button[] { fRemoveImport, fOptionalImport }, new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + doProcessorSetting(e.getSource()); } }); } + + private void doProcessorSetting(Object source) { + if (fProcessor == null) + return; + if (fAddMissing.equals(source)) + fProcessor.setAddMissing(fAddMissing.getSelection()); + else if (fMarkInternal.equals(source)) + fProcessor.setMarkInternal(fMarkInternal.getSelection()); + else if (fPackageFilter.equals(source)) + fProcessor.setPackageFilter(fPackageFilter.getText()); + else if (fRemoveUnresolved.equals(source)) + fProcessor.setRemoveUnresolved(fRemoveUnresolved.getSelection()); + else if (fCalculateUses.equals(source)) + fProcessor.setCalculateUses(fCalculateUses.getSelection()); + else if (fModifyDependencies.equals(source)) + fProcessor.setModifyDep(fModifyDependencies.getSelection()); + else if (fOptionalImport.equals(source)) + fProcessor.setRemoveDependencies(!fOptionalImport.getSelection()); + else if (fRemoveImport.equals(source)) + fProcessor.setRemoveDependencies(fRemoveImport.getSelection()); + else if (fUnusedDependencies.equals(source)) + fProcessor.setUnusedDependencies(fUnusedDependencies.getSelection()); + else if (fAdditonalDependencies.equals(source)) + fProcessor.setAddDependencies(fAdditonalDependencies.getSelection()); + else if (fRemoveLazy.equals(source)) + fProcessor.setRemoveLazy(fRemoveLazy.getSelection()); + else if (fFixIconNLSPaths.equals(source)) + fProcessor.setPrefixIconNL(fFixIconNLSPaths.getSelection()); + else if (fRemovedUnusedKeys.equals(source)) + fProcessor.setUnusedKeys(fRemovedUnusedKeys.getSelection()); + } private void hookListener(Button[] buttons, SelectionAdapter adapter) { for (int i = 0; i < buttons.length; i++) { buttons[i].addSelectionListener(adapter); } } - - protected IDialogSettings getSettings() { - return getDialogSettings(); - } } Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsAction.java,v retrieving revision 1.5 diff -u -r1.5 OrganizeManifestsAction.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsAction.java 8 Jun 2007 16:35:50 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsAction.java 25 Jul 2007 15:25:44 -0000 @@ -19,11 +19,10 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; import org.eclipse.pde.internal.core.ICoreConstants; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; @@ -62,15 +61,15 @@ projects.add(proj); } if (projects.size() > 0) { - OrganizeManifestsWizard wizard = new OrganizeManifestsWizard(projects); - final WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); - BusyIndicator.showWhile( - PDEPlugin.getActiveWorkbenchShell().getDisplay(), - new Runnable() { - public void run() { - dialog.open(); - } - }); + OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects); + OrganizeManifestsRefactor refactor = new OrganizeManifestsRefactor(processor); + OrganizeManifestsWizard wizard = new OrganizeManifestsWizard(refactor); + RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation( wizard ); + + try { + op.run( PDEPlugin.getActiveWorkbenchShell(), "" ); //$NON-NLS-1$ + } catch( final InterruptedException irex ) { + } } else MessageDialog.openInformation( PDEPlugin.getActiveWorkbenchShell(), Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsOperation.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsOperation.java diff -N src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsOperation.java --- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsOperation.java 8 Jun 2007 16:35:50 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.ui.wizards.tools; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.core.IBaseModel; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.ISharedExtensionsModel; -import org.eclipse.pde.internal.core.ibundle.IBundle; -import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; -import org.eclipse.pde.internal.ui.PDEPlugin; -import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.pde.internal.ui.search.dependencies.AddNewDependenciesOperation; -import org.eclipse.pde.internal.ui.search.dependencies.CalculateUsesOperation; -import org.eclipse.pde.internal.ui.search.dependencies.GatherUnusedDependenciesOperation; -import org.eclipse.pde.internal.ui.util.ModelModification; -import org.eclipse.pde.internal.ui.util.PDEModelUtility; - -public class OrganizeManifestsOperation implements IRunnableWithProgress, IOrganizeManifestsSettings { - - // if operation is executed without setting operations, these defaults will be used - protected boolean fAddMissing = true; // add all packages to export-package - protected boolean fMarkInternal = true; // mark export-package as internal - protected String fPackageFilter = VALUE_DEFAULT_FILTER; - protected boolean fRemoveUnresolved = true; // remove unresolved export-package - protected boolean fCalculateUses = false; // calculate the 'uses' directive for exported packages - protected boolean fModifyDep = true; // modify import-package / require-bundle - protected boolean fRemoveDependencies = true; // if true: remove, else mark optional - protected boolean fUnusedDependencies; // find/remove unused dependencies - long running op - protected boolean fRemoveLazy = true; // remove lazy/auto start if no activator - protected boolean fPrefixIconNL; // prefix icon paths with $nl$ - protected boolean fUnusedKeys; // remove unused .properties keys - protected boolean fAddDependencies; - - private ArrayList fProjectList; - private IProject fCurrentProject; - - public OrganizeManifestsOperation(ArrayList projectList) { - fProjectList = projectList; - } - - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(PDEUIMessages.OrganizeManifestJob_taskName, fProjectList.size()); - for (int i = 0; i < fProjectList.size() && !monitor.isCanceled(); i++) - cleanProject((IProject)fProjectList.get(i), new SubProgressMonitor(monitor, 1)); - } - - private void cleanProject(IProject project, IProgressMonitor monitor) { - fCurrentProject = project; - monitor.beginTask(fCurrentProject.getName(), getTotalTicksPerProject()); - - final Exception[] ee = new Exception[1]; - ModelModification modification = new ModelModification(fCurrentProject) { - protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException { - if (model instanceof IBundlePluginModelBase) - try { - runCleanup(monitor, (IBundlePluginModelBase)model); - } catch (InvocationTargetException e) { - ee[0] = e; - } catch (InterruptedException e) { - ee[0] = e; - } - } - }; - PDEModelUtility.modifyModel(modification, monitor); - if (ee[0] != null) - PDEPlugin.log(ee[0]); - } - - - private void runCleanup(IProgressMonitor monitor, IBundlePluginModelBase modelBase) throws InvocationTargetException, InterruptedException { - - IBundle bundle = modelBase.getBundleModel().getBundle(); - ISharedExtensionsModel sharedExtensionsModel = modelBase.getExtensionsModel(); - IPluginModelBase extensionsModel = null; - if (sharedExtensionsModel instanceof IPluginModelBase) - extensionsModel = (IPluginModelBase)sharedExtensionsModel; - - String projectName = fCurrentProject.getName(); - - if (fAddMissing || fRemoveUnresolved) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_export, projectName)); - if (!monitor.isCanceled()) - OrganizeManifest.organizeExportPackages(bundle, fCurrentProject, fAddMissing, fRemoveUnresolved); - if (fAddMissing) - monitor.worked(1); - if (fRemoveUnresolved) - monitor.worked(1); - } - - if (fMarkInternal) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_filterInternal, projectName)); - if (!monitor.isCanceled()) - OrganizeManifest.markPackagesInternal(bundle, fPackageFilter); - monitor.worked(1); - } - - if (fModifyDep) { - String message = fRemoveDependencies ? - NLS.bind(PDEUIMessages.OrganizeManifestsOperation_removeUnresolved, projectName) : - NLS.bind(PDEUIMessages.OrganizeManifestsOperation_markOptionalUnresolved, projectName); - monitor.subTask(message); - if (!monitor.isCanceled()) - OrganizeManifest.organizeImportPackages(bundle, fRemoveDependencies); - monitor.worked(1); - - if (!monitor.isCanceled()) - OrganizeManifest.organizeRequireBundles(bundle, fRemoveDependencies); - monitor.worked(1); - } - - if (fCalculateUses) { - // we don't set the subTask because it is done in the CalculateUsesOperation, for each package it scans - if (!monitor.isCanceled()) { - CalculateUsesOperation op = new CalculateUsesOperation(fCurrentProject, modelBase); - op.run(new SubProgressMonitor(monitor, 2)); - } - } - - if (fAddDependencies) { - monitor.subTask(NLS.bind (PDEUIMessages.OrganizeManifestsOperation_additionalDeps, projectName)); - if (!monitor.isCanceled()) { - AddNewDependenciesOperation op = new AddNewDependenciesOperation(fCurrentProject, modelBase); - op.run(new SubProgressMonitor(monitor, 4)); - } - } - - if (fUnusedDependencies) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_unusedDeps, projectName)); - if (!monitor.isCanceled()) { - SubProgressMonitor submon = new SubProgressMonitor(monitor, 4); - GatherUnusedDependenciesOperation udo = new GatherUnusedDependenciesOperation(modelBase); - udo.run(submon); - GatherUnusedDependenciesOperation.removeDependencies(modelBase, udo.getList().toArray()); - submon.done(); - } - } - - if (fRemoveLazy) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_lazyStart, fCurrentProject.getName())); - if (!monitor.isCanceled()) - OrganizeManifest.removeUnneededLazyStart(bundle); - monitor.worked(1); - } - - if (fPrefixIconNL) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_nlIconPath, projectName)); - if (!monitor.isCanceled()) - OrganizeManifest.prefixIconPaths(extensionsModel); - monitor.worked(1); - } - - if (fUnusedKeys) { - monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_unusedKeys, projectName)); - if (!monitor.isCanceled()) - OrganizeManifest.removeUnusedKeys(fCurrentProject, bundle, extensionsModel); - monitor.worked(1); - } - } - - private int getTotalTicksPerProject() { - int ticks = 0; - if (fAddMissing) ticks += 1; - if (fMarkInternal) ticks += 1; - if (fRemoveUnresolved) ticks += 1; - if (fCalculateUses) ticks += 4; - if (fModifyDep) ticks += 2; - if (fUnusedDependencies)ticks += 4; - if (fAddDependencies) ticks += 4; - if (fRemoveLazy) ticks += 1; - if (fPrefixIconNL) ticks += 1; - if (fUnusedKeys) ticks += 1; - return ticks; - } - - - public void setOperations(IDialogSettings settings) { - fAddMissing = !settings.getBoolean(PROP_ADD_MISSING); - fMarkInternal = !settings.getBoolean(PROP_MARK_INTERNAL); - fPackageFilter = settings.get(PROP_INTERAL_PACKAGE_FILTER); - fRemoveUnresolved = !settings.getBoolean(PROP_REMOVE_UNRESOLVED_EX); - fCalculateUses = settings.getBoolean(PROP_CALCULATE_USES); - fModifyDep = !settings.getBoolean(PROP_MODIFY_DEP); - fRemoveDependencies = !settings.getBoolean(PROP_RESOLVE_IMP_MARK_OPT); - fUnusedDependencies = settings.getBoolean(PROP_UNUSED_DEPENDENCIES); - fRemoveLazy = !settings.getBoolean(PROP_REMOVE_LAZY); - fPrefixIconNL = settings.getBoolean(PROP_NLS_PATH); - fUnusedKeys = settings.getBoolean(PROP_UNUSED_KEYS); - fAddDependencies = settings.getBoolean(PROP_ADD_DEPENDENCIES); - } -} Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v retrieving revision 1.301 diff -u -r1.301 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 22 Jul 2007 05:30:17 -0000 1.301 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 25 Jul 2007 15:25:43 -0000 @@ -73,6 +73,10 @@ public static String JavaArgumentsTab_appendLauncherIni; + public static String OrganizeManifestsProcessor_invalidParam; + + public static String OrganizeManifestsProcessor_rootMessage; + public static String PDEWizardNewFileCreationPage_errorMsgStartsWithDot; public static String CommandComposerPart_formTitle; @@ -283,10 +287,6 @@ public static String PluginsTabToolBar_auto_validate; - public static String PluginsTabToolBar_filter_disabled; - - public static String PluginsTabToolBar_filter_options; - public static String PluginsTabToolBar_validate; public static String PointSelectionPage_cannotFindTemplate; @@ -1642,13 +1642,11 @@ public static String DependencyAnalysisSection_title; public static String DependencyAnalysisSection_loops; public static String DependencyAnalysisSection_noCycles; - public static String DependencyAnalysisSection_references; public static String DependencyExtentOperation_searching; public static String DependencyExtentOperation_inspecting; public static String DependencyExtentSearchResult_dependency; public static String DependencyExtentSearchResult_dependencies; public static String DependencyAnalysisSection_fragment_editable; - public static String DependencyAnalysisSection_noReferencesFound; public static String DependencyAnalysisSection_fragment_notEditable; public static String DependencyAnalysisSection_plugin_editable; public static String DependencyAnalysisSection_plugin_notEditable; @@ -2422,8 +2420,6 @@ public static String SchemaAttributeDetails_use; - public static String SchemaAttributeDetails_defaultValue; - public static String SchemaAttributeDetails_type; public static String SchemaAttributeDetails_restrictions; Index: src/org/eclipse/pde/internal/ui/pderesources.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v retrieving revision 1.894 diff -u -r1.894 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 22 Jul 2007 22:31:28 -0000 1.894 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 25 Jul 2007 15:25:43 -0000 @@ -403,7 +403,6 @@ SchemaElementReferenceDetails_reference=Reference: SchemaAttributeDetails_removeRestButton=Remove SchemaElementReferenceDetails_title=Element Reference Details -SchemaAttributeDetails_defaultValue=Default Value: SchemaDetails_translatable=Translatable: SchemaAttributeDetails_restrictions=Restrictions: SchemaAttributeDetails_browseButton=Browse... @@ -1257,7 +1256,6 @@ DependencyAnalysisSection_noCycles=The dependency graph of this plug-in does not contain cycles. DependencyPropertiesDialog_version=Version: DependencyPropertiesDialog_versionRangeError=Minimum version must be less than or equal to maximum version -DependencyAnalysisSection_references=References DependencyPropertiesDialog_properties=Properties DependencyExtentOperation_searching=Searching for dependencies on DependencyPropertiesDialog_optional=&Optional @@ -1271,7 +1269,6 @@

Find this fragment's host plug-in

\

Find unused dependencies

\ -DependencyAnalysisSection_noReferencesFound=No plug-ins reference this fragment. DependencyAnalysisSection_fragment_notEditable=
\

Find this fragment's host plug-in

\
@@ -1326,7 +1323,6 @@ PluginsTabToolBar_auto_validate=Validate {0} automatically prior to launching PluginsView_addToJavaSearch=&Add to Java Search PluginsView_removeFromJavaSearch=Remove &from Java Search -PluginsTabToolBar_filter_options=Filtering Options PluginWorkingSet_setContent=Working set content: PluginWorkingSet_selectAll_label=Select &All PluginDevelopmentPage_extensions=&Always show the Extensions and Extension Points tabs @@ -1351,7 +1347,6 @@ PluginsView_CollapseAllAction_tooltip = Collapse All # Select all is part of a submenu "Select" hence the label is not "Select all" PluginsView_SelectAllAction_label = &All -PluginsTabToolBar_filter_disabled=Filter disabled target {0} PluginSection_open=Open @@ -2034,12 +2029,14 @@ OrganizeManifestsOperation_nlIconPath=checking icon paths for missing $nl$ segments... {0} OrganizeManifestsOperation_unusedKeys=checking for unused keys... {0} OrganizeManifestsWizardPage_addMissing=&Ensure that all packages appear in the MANIFEST.MF +OrganizeManifestsProcessor_rootMessage=Organize Manifest for {0} OrganizeManifestsWizardPage_lazyStart=Remove unnecessary Eclipse-La&zyStart headers OrganizeRequireBundleResolution_Description=Organize Require Bundle Header OrganizeImportPackageResolution_Description=Organize Import Package Header OrganizeExportPackageResolution_Description=Organize Export Package Header OrganizeManifestsOperation_filterInternal=marking export packages matching filter as internal... {0} OrganizeManifestsWizardPage_description=Organize and clean up plug-in projects. +OrganizeManifestsProcessor_invalidParam=Invalid parameter passed to organize manifests processor OrganizeManifestsWizardPage_exportedGroup=Exported Packages OrganizeManifestsWizardPage_markInternal=Mark as &internal all packages that match the following filter: OrganizeManifestsWizardPage_packageFilter=Package &filter: Index: src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java,v retrieving revision 1.103 diff -u -r1.103 LauncherUtils.java --- src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java 8 Jun 2007 16:45:07 -0000 1.103 +++ src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java 25 Jul 2007 15:25:43 -0000 @@ -14,7 +14,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -30,6 +29,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; @@ -39,11 +39,10 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.osgi.util.NLS; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; @@ -55,8 +54,7 @@ import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.pde.internal.ui.wizards.tools.IOrganizeManifestsSettings; -import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsOperation; +import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor; import org.eclipse.pde.ui.launcher.IPDELauncherConstants; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -178,18 +176,19 @@ if (!projects.isEmpty()) Display.getDefault().syncExec(new Runnable() { public void run() { - OrganizeManifestsOperation op = new OrganizeManifestsOperation(projects); - op.setOperations(getSettings()); + OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects); + initializeProcessor(processor); try { - op.run(monitor); + Change change = processor.createChange(monitor); + change.perform(monitor); // update table for each project with current time stamp Properties table = getLastRun(); String ts = Long.toString(System.currentTimeMillis()); Iterator it = projects.iterator(); while (it.hasNext()) table.put(((IProject)it.next()).getName(), ts); - } catch (InvocationTargetException e) { - } catch (InterruptedException e) { + } catch (OperationCanceledException e) { + } catch (CoreException e) { } } }); @@ -204,17 +203,18 @@ } catch (CoreException e) { } } - - private static IDialogSettings getSettings() { - IDialogSettings settings = new DialogSettings(""); //$NON-NLS-1$ - settings.put(IOrganizeManifestsSettings.PROP_ADD_MISSING, true); - settings.put(IOrganizeManifestsSettings.PROP_MARK_INTERNAL, true); - settings.put(IOrganizeManifestsSettings.PROP_REMOVE_UNRESOLVED_EX, true); - settings.put(IOrganizeManifestsSettings.PROP_MODIFY_DEP, true); - settings.put(IOrganizeManifestsSettings.PROP_RESOLVE_IMP_MARK_OPT, true); - settings.put(IOrganizeManifestsSettings.PROP_REMOVE_LAZY, true); - settings.put(IOrganizeManifestsSettings.PROP_ADD_DEPENDENCIES, true); - return settings; + + private static void initializeProcessor(OrganizeManifestsProcessor processor) { + processor.setAddMissing(false); + processor.setRemoveUnresolved(false); + processor.setModifyDep(false); + processor.setRemoveLazy(false); + processor.setAddDependencies(true); + processor.setCalculateUses(false); + processor.setMarkInternal(false); + processor.setPrefixIconNL(false); + processor.setUnusedDependencies(false); + processor.setUnusedKeys(false); } private static String getTimeStamp(IProject project) { Index: src/org/eclipse/pde/internal/ui/util/PDEModelUtility.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/util/PDEModelUtility.java,v retrieving revision 1.10 diff -u -r1.10 PDEModelUtility.java --- src/org/eclipse/pde/internal/ui/util/PDEModelUtility.java 8 Jun 2007 16:43:37 -0000 1.10 +++ src/org/eclipse/pde/internal/ui/util/PDEModelUtility.java 25 Jul 2007 15:25:44 -0000 @@ -17,12 +17,14 @@ import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.filebuffers.ITextFileBufferManager; +import org.eclipse.core.filebuffers.LocationKind; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; +import org.eclipse.ltk.core.refactoring.TextFileChange; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.ISharedExtensionsModel; @@ -302,75 +304,92 @@ // open editor found, should have underlying text listeners -> apply modification modifyEditorModel(modification, editor, model, monitor); } else { - // create own model, attach listeners and grab text edits - ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); - IFile[] files; - if (modification.isFullBundleModification()) { - files = new IFile[2]; - files[F_Bi] = modification.getManifestFile(); - files[F_Xi] = modification.getXMLFile(); - } else { - files = new IFile[] { modification.getFile() }; + generateModelEdits(modification, monitor, true); + } + } + + public static TextFileChange[] changesForModelModication (final ModelModification modification, final IProgressMonitor monitor) { + return generateModelEdits(modification, monitor, false); + } + + private static TextFileChange[] generateModelEdits (final ModelModification modification, final IProgressMonitor monitor, + boolean performEdits) { + ArrayList edits = new ArrayList(); + // create own model, attach listeners and grab text edits + ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); + IFile[] files; + if (modification.isFullBundleModification()) { + files = new IFile[2]; + files[F_Bi] = modification.getManifestFile(); + files[F_Xi] = modification.getXMLFile(); + } else { + files = new IFile[] { modification.getFile() }; + } + // need to monitor number of successfull buffer connections for disconnection purposes + // @see } finally { statement + int sc = 0; + try { + ITextFileBuffer[] buffers = new ITextFileBuffer[files.length]; + IDocument[] documents = new IDocument[files.length]; + for (int i = 0; i < files.length; i++) { + if (files[i] == null || !files[i].exists()) + continue; + manager.connect(files[i].getFullPath(), LocationKind.IFILE, monitor); + sc++; + buffers[i] = manager.getTextFileBuffer(files[i].getFullPath(), LocationKind.IFILE); + if (buffers[i].isDirty()) + buffers[i].commit(monitor, true); + documents[i] = buffers[i].getDocument(); } - // need to monitor number of successfull buffer connections for disconnection purposes - // @see } finally { statement - int sc = 0; - try { - ITextFileBuffer[] buffers = new ITextFileBuffer[files.length]; - IDocument[] documents = new IDocument[files.length]; - for (int i = 0; i < files.length; i++) { - if (files[i] == null || !files[i].exists()) - continue; - manager.connect(files[i].getFullPath(), monitor); - sc++; - buffers[i] = manager.getTextFileBuffer(files[i].getFullPath()); - if (buffers[i].isDirty()) - buffers[i].commit(monitor, true); - documents[i] = buffers[i].getDocument(); - } - - IBaseModel editModel; - if (modification.isFullBundleModification()) - editModel = prepareBundlePluginModel(files, documents); - else - editModel = prepareAbstractEditingModel(files[0], documents[0]); - - modification.modifyModel(editModel, monitor); - - IModelTextChangeListener[] listeners = gatherListeners(editModel); - for (int i = 0; i < listeners.length; i++) { - if (listeners[i] == null) - continue; - TextEdit[] edits = listeners[i].getTextOperations(); - if (edits.length > 0) { - MultiTextEdit multi = new MultiTextEdit(); - multi.addChildren(edits); + + IBaseModel editModel; + if (modification.isFullBundleModification()) + editModel = prepareBundlePluginModel(files, documents); + else + editModel = prepareAbstractEditingModel(files[0], documents[0]); + + modification.modifyModel(editModel, monitor); + + IModelTextChangeListener[] listeners = gatherListeners(editModel); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == null) + continue; + TextEdit[] currentEdits = listeners[i].getTextOperations(); + if (currentEdits.length > 0) { + MultiTextEdit multi = new MultiTextEdit(); + multi.addChildren(currentEdits); + if (performEdits) { multi.apply(documents[i]); buffers[i].commit(monitor, true); } + TextFileChange change = new TextFileChange(files[i].getName(), files[i]); + change.setEdit(multi); + change.setTextType(files[i].getFileExtension()); + edits.add(change); } - } catch (CoreException e) { - PDEPlugin.log(e); - } catch (MalformedTreeException e) { - PDEPlugin.log(e); - } catch (BadLocationException e) { - PDEPlugin.log(e); - } finally { - // don't want to over-disconnect in case we ran into an exception during connections - // dc <= sc stops this from happening - int dc = 0; - for (int i = 0; i < files.length && dc <= sc; i++) { - if (files[i] == null || !files[i].exists()) - continue; - try { - manager.disconnect(files[i].getFullPath(), monitor); - dc++; - } catch (CoreException e) { - PDEPlugin.log(e); - } + } + } catch (CoreException e) { + PDEPlugin.log(e); + } catch (MalformedTreeException e) { + PDEPlugin.log(e); + } catch (BadLocationException e) { + PDEPlugin.log(e); + } finally { + // don't want to over-disconnect in case we ran into an exception during connections + // dc <= sc stops this from happening + int dc = 0; + for (int i = 0; i < files.length && dc <= sc; i++) { + if (files[i] == null || !files[i].exists()) + continue; + try { + manager.disconnect(files[i].getFullPath(), LocationKind.IFILE, monitor); + dc++; + } catch (CoreException e) { + PDEPlugin.log(e); } } } + return (TextFileChange[])edits.toArray(new TextFileChange[edits.size()]); } private static void modifyEditorModel( Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsProcessor.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsProcessor.java diff -N src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsProcessor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsProcessor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,288 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.wizards.tools; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; +import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; +import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; +import org.eclipse.osgi.util.NLS; +import org.eclipse.pde.core.IBaseModel; +import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.ISharedExtensionsModel; +import org.eclipse.pde.internal.core.ibundle.IBundle; +import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; +import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.search.dependencies.AddNewDependenciesOperation; +import org.eclipse.pde.internal.ui.search.dependencies.CalculateUsesOperation; +import org.eclipse.pde.internal.ui.search.dependencies.GatherUnusedDependenciesOperation; +import org.eclipse.pde.internal.ui.util.ModelModification; +import org.eclipse.pde.internal.ui.util.PDEModelUtility; + +public class OrganizeManifestsProcessor extends RefactoringProcessor implements IOrganizeManifestsSettings { + + // if operation is executed without setting operations, these defaults will be used + protected boolean fAddMissing = true; // add all packages to export-package + protected boolean fMarkInternal = true; // mark export-package as internal + protected String fPackageFilter = VALUE_DEFAULT_FILTER; + protected boolean fRemoveUnresolved = true; // remove unresolved export-package + protected boolean fCalculateUses = false; // calculate the 'uses' directive for exported packages + protected boolean fModifyDep = true; // modify import-package / require-bundle + protected boolean fRemoveDependencies = true; // if true: remove, else mark optional + protected boolean fUnusedDependencies = false; // find/remove unused dependencies - long running op + protected boolean fRemoveLazy = true; // remove lazy/auto start if no activator + protected boolean fPrefixIconNL = false; // prefix icon paths with $nl$ + protected boolean fUnusedKeys = false; // remove unused .properties keys + protected boolean fAddDependencies = false; + + ArrayList fProjectList; + private IProject fCurrentProject; + + public OrganizeManifestsProcessor(ArrayList projects) { + fProjectList = projects; + } + + public RefactoringStatus checkFinalConditions(IProgressMonitor pm, + CheckConditionsContext context) throws CoreException, + OperationCanceledException { + RefactoringStatus status = new RefactoringStatus(); + for (Iterator i = fProjectList.iterator(); i.hasNext();) { + if (!(i.next() instanceof IProject)) + status.addFatalError(PDEUIMessages.OrganizeManifestsProcessor_invalidParam); + } + return status; + } + + public RefactoringStatus checkInitialConditions(IProgressMonitor pm) + throws CoreException, OperationCanceledException { + return null; + } + + public Change createChange(IProgressMonitor pm) throws CoreException, + OperationCanceledException { + CompositeChange change = new CompositeChange(""); //$NON-NLS-1$ + change.markAsSynthetic(); + pm.beginTask(PDEUIMessages.OrganizeManifestJob_taskName, fProjectList.size()); + for (Iterator i = fProjectList.iterator(); i.hasNext() && !pm.isCanceled();) + change.add(cleanProject((IProject)i.next(), new SubProgressMonitor(pm, 1))); + return change; + } + + private Change cleanProject(IProject project, IProgressMonitor monitor) { + fCurrentProject = project; + CompositeChange change = new CompositeChange(NLS.bind(PDEUIMessages.OrganizeManifestsProcessor_rootMessage, new String[] {fCurrentProject.getName()})); + monitor.beginTask(NLS.bind(PDEUIMessages.OrganizeManifestsProcessor_rootMessage, new String[] {fCurrentProject.getName()}), getTotalTicksPerProject()); + + final TextFileChange[] result = { null }; + final Exception[] ee = new Exception[1]; + ModelModification modification = new ModelModification(fCurrentProject) { + protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException { + if (model instanceof IBundlePluginModelBase) + try { + runCleanup(monitor, (IBundlePluginModelBase)model, result); + } catch (InvocationTargetException e) { + ee[0] = e; + } catch (InterruptedException e) { + ee[0] = e; + } + } + }; + TextFileChange[] changes = PDEModelUtility.changesForModelModication(modification, monitor); + for (int i = 0; i < changes.length; i++) + change.add(changes[i]); + if (result[0] != null) + change.add(result[0]); + if (ee[0] != null) + PDEPlugin.log(ee[0]); + return change; + } + + private void runCleanup(IProgressMonitor monitor, IBundlePluginModelBase modelBase, + TextFileChange[] result) throws InvocationTargetException, InterruptedException { + + IBundle currentBundle = modelBase.getBundleModel().getBundle(); + ISharedExtensionsModel sharedExtensionsModel = modelBase.getExtensionsModel(); + IPluginModelBase currentExtensionsModel = null; + if (sharedExtensionsModel instanceof IPluginModelBase) + currentExtensionsModel = (IPluginModelBase)sharedExtensionsModel; + + String projectName = fCurrentProject.getName(); + + if (fAddMissing || fRemoveUnresolved) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_export, projectName)); + if (!monitor.isCanceled()) + OrganizeManifest.organizeExportPackages(currentBundle, fCurrentProject, fAddMissing, fRemoveUnresolved); + if (fAddMissing) + monitor.worked(1); + if (fRemoveUnresolved) + monitor.worked(1); + } + + if (fMarkInternal) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_filterInternal, projectName)); + if (!monitor.isCanceled()) + OrganizeManifest.markPackagesInternal(currentBundle, fPackageFilter); + monitor.worked(1); + } + + if (fModifyDep) { + String message = fRemoveDependencies ? + NLS.bind(PDEUIMessages.OrganizeManifestsOperation_removeUnresolved, projectName) : + NLS.bind(PDEUIMessages.OrganizeManifestsOperation_markOptionalUnresolved, projectName); + monitor.subTask(message); + if (!monitor.isCanceled()) + OrganizeManifest.organizeImportPackages(currentBundle, fRemoveDependencies); + monitor.worked(1); + + if (!monitor.isCanceled()) + OrganizeManifest.organizeRequireBundles(currentBundle, fRemoveDependencies); + monitor.worked(1); + } + + if (fCalculateUses) { + // we don't set the subTask because it is done in the CalculateUsesOperation, for each package it scans + if (!monitor.isCanceled()) { + CalculateUsesOperation op = new CalculateUsesOperation(fCurrentProject, modelBase); + op.run(new SubProgressMonitor(monitor, 2)); + } + } + + if (fAddDependencies) { + monitor.subTask(NLS.bind (PDEUIMessages.OrganizeManifestsOperation_additionalDeps, projectName)); + if (!monitor.isCanceled()) { + AddNewDependenciesOperation op = new AddNewDependenciesOperation(fCurrentProject, modelBase); + op.run(new SubProgressMonitor(monitor, 4)); + } + } + + if (fUnusedDependencies) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_unusedDeps, projectName)); + if (!monitor.isCanceled()) { + SubProgressMonitor submon = new SubProgressMonitor(monitor, 4); + GatherUnusedDependenciesOperation udo = new GatherUnusedDependenciesOperation(modelBase); + udo.run(submon); + GatherUnusedDependenciesOperation.removeDependencies(modelBase, udo.getList().toArray()); + submon.done(); + } + } + + if (fRemoveLazy) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_lazyStart, fCurrentProject.getName())); + if (!monitor.isCanceled()) + OrganizeManifest.removeUnneededLazyStart(currentBundle); + monitor.worked(1); + } + + if (fPrefixIconNL) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_nlIconPath, projectName)); + if (!monitor.isCanceled()) + OrganizeManifest.prefixIconPaths(currentExtensionsModel); + monitor.worked(1); + } + + if (fUnusedKeys) { + monitor.subTask(NLS.bind(PDEUIMessages.OrganizeManifestsOperation_unusedKeys, projectName)); + if (!monitor.isCanceled()) { + TextFileChange[] results = OrganizeManifest.removeUnusedKeys(fCurrentProject, currentBundle, currentExtensionsModel); + if (results.length > 0) + result[0] = results[0]; + } + monitor.worked(1); + } + } + + public Object[] getElements() { + return fProjectList.toArray(); + } + + public String getIdentifier() { + return getClass().getName(); + } + + public String getProcessorName() { + return PDEUIMessages.OrganizeManifestsWizardPage_title; + } + + public boolean isApplicable() throws CoreException { + return true; + } + + public RefactoringParticipant[] loadParticipants(RefactoringStatus status, + SharableParticipants sharedParticipants) throws CoreException { + return new RefactoringParticipant[0]; + } + + private int getTotalTicksPerProject() { + int ticks = 0; + if (fAddMissing) ticks += 1; + if (fMarkInternal) ticks += 1; + if (fRemoveUnresolved) ticks += 1; + if (fCalculateUses) ticks += 4; + if (fModifyDep) ticks += 2; + if (fUnusedDependencies)ticks += 4; + if (fAddDependencies) ticks += 4; + if (fRemoveLazy) ticks += 1; + if (fPrefixIconNL) ticks += 1; + if (fUnusedKeys) ticks += 1; + return ticks; + } + + public void setAddMissing(boolean addMissing) { + fAddMissing = addMissing; + } + public void setMarkInternal(boolean markInternal) { + fMarkInternal = markInternal; + } + public void setPackageFilter(String packageFilter) { + fPackageFilter = packageFilter; + } + public void setRemoveUnresolved(boolean removeUnresolved) { + fRemoveUnresolved = removeUnresolved; + } + public void setCalculateUses(boolean calculateUses) { + fCalculateUses = calculateUses; + } + public void setModifyDep(boolean modifyDep) { + fModifyDep = modifyDep; + } + public void setRemoveDependencies(boolean removeDependencies) { + fRemoveDependencies = removeDependencies; + } + public void setUnusedDependencies(boolean unusedDependencies) { + fUnusedDependencies = unusedDependencies; + } + public void setRemoveLazy(boolean removeLazy) { + fRemoveLazy = removeLazy; + } + public void setPrefixIconNL(boolean prefixIconNL) { + fPrefixIconNL = prefixIconNL; + } + public void setUnusedKeys(boolean unusedKeys) { + fUnusedKeys = unusedKeys; + } + public void setAddDependencies(boolean addDependencies) { + fAddDependencies = addDependencies; + } +} Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsRefactor.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsRefactor.java diff -N src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsRefactor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsRefactor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.wizards.tools; + +import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; + +public class OrganizeManifestsRefactor extends ProcessorBasedRefactoring { + + OrganizeManifestsProcessor fProcessor; + + public OrganizeManifestsRefactor(OrganizeManifestsProcessor processor) { + super(processor); + fProcessor = processor; + } + + public RefactoringProcessor getProcessor() { + return fProcessor; + } +}