### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java,v retrieving revision 1.43 diff -u -r1.43 CategorySection.java --- src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java 15 Aug 2007 20:12:52 -0000 1.43 +++ src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java 4 Sep 2007 15:37:29 -0000 @@ -12,6 +12,8 @@ import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.Action; @@ -87,6 +89,10 @@ private LabelProvider fSiteLabelProvider; + private ISiteFeature[] cachedFeatures; + + private IStructuredSelection cachedSelection; + class CategoryContentProvider extends DefaultContentProvider implements ITreeContentProvider { public Object[] getElements(Object inputElement) { @@ -171,7 +177,7 @@ fModel.addModelChangedListener(this); Composite container = createClientContainer(section, 2, toolkit); - createViewerPartControl(container, SWT.SINGLE, 2, toolkit); + createViewerPartControl(container, SWT.MULTI, 2, toolkit); fCategoryTreePart = getTreePart(); fCategoryViewer = fCategoryTreePart.getTreeViewer(); fCategoryViewer.setContentProvider(new CategoryContentProvider()); @@ -418,13 +424,27 @@ private boolean handleRemove() { IStructuredSelection ssel = (IStructuredSelection) fCategoryViewer .getSelection(); - Object object = ssel.getFirstElement(); - if (object == null) - return true; - if (object instanceof ISiteCategoryDefinition) { - return handleRemoveCategoryDefinition((ISiteCategoryDefinition) object); + Iterator iterator = ssel.iterator(); + boolean success = true; + Set removedCategories = new HashSet(); + while(iterator.hasNext()) { + Object object = iterator.next(); + if (object == null) continue; + if (object instanceof ISiteCategoryDefinition) { + if(! handleRemoveCategoryDefinition((ISiteCategoryDefinition) object)) { + success = false; + } + } else { + //check if some of features was not removed during category removal + SiteFeatureAdapter fa = (SiteFeatureAdapter) object; + if(removedCategories.contains(fa.category)) continue; + + if(!handleRemoveSiteFeatureAdapter(fa)) { + success = false; + } + } } - return handleRemoveSiteFeatureAdapter((SiteFeatureAdapter) object); + return success; } private boolean handleRemoveCategoryDefinition( @@ -517,28 +537,21 @@ manager); ISelection selection = fCategoryViewer.getSelection(); - if (!selection.isEmpty() && selection instanceof IStructuredSelection) { - Object o = ((IStructuredSelection) selection) - .getFirstElement(); - if (o instanceof SiteFeatureAdapter) { - final SiteFeatureAdapter adapter = (SiteFeatureAdapter)o; + if(!selection.isEmpty() && selection instanceof IStructuredSelection) { + final ISiteFeature[] features = getFeaturesFromSelection((IStructuredSelection) selection); + if(features.length > 0) { manager.add(new Separator()); - - Action synchronizeAction = new SynchronizePropertiesAction(adapter.feature, fModel); + Action synchronizeAction = new SynchronizePropertiesAction(features, fModel); manager.add(synchronizeAction); - synchronizeAction.setEnabled(isEditable()); - Action buildAction = new Action(PDEUIMessages.CategorySection_build) { - public void run() { - ((SiteEditor)getPage().getPDEEditor()).handleBuild(new ISiteFeature[] { adapter.feature }); - } - }; + public void run() { + ((SiteEditor)getPage().getPDEEditor()).handleBuild(features); + } + }; + buildAction.setEnabled(isEditable()); manager.add(buildAction); - buildAction.setEnabled(isEditable()&& findFeature(adapter.feature) != null ); - } } - } public boolean doGlobalAction(String actionId) { @@ -553,6 +566,10 @@ if (actionId.equals(ActionFactory.DELETE.getId())) { return handleRemove(); } + if (actionId.equals(ActionFactory.SELECT_ALL.getId())) { + fCategoryViewer.getTree().selectAll(); + refresh(); + } return false; } @@ -568,11 +585,7 @@ } IStructuredSelection sel = (IStructuredSelection) fCategoryViewer .getSelection(); - fCategoryTreePart.setButtonEnabled(BUTTON_BUILD_FEATURE, - !sel.isEmpty() - && sel.getFirstElement() instanceof SiteFeatureAdapter - && findFeature(((SiteFeatureAdapter) sel - .getFirstElement()).feature) != null); + fCategoryTreePart.setButtonEnabled(BUTTON_BUILD_FEATURE, getFeaturesFromSelection(sel).length > 0); int featureCount = fModel.getSite().getFeatures().length; fCategoryTreePart.setButtonEnabled(BUTTON_BUILD_ALL, featureCount > 0); fCategoryTreePart.setButtonEnabled(BUTTON_IMPORT_ENVIRONMENT, featureCount > 0); @@ -642,11 +655,25 @@ private void handleBuild() { IStructuredSelection sel = (IStructuredSelection) fCategoryViewer .getSelection(); - if (!sel.isEmpty() - && sel.getFirstElement() instanceof SiteFeatureAdapter) { - ISiteFeature feature = ((SiteFeatureAdapter) sel.getFirstElement()).feature; - ((SiteEditor)getPage().getPDEEditor()).handleBuild(new ISiteFeature[] { feature }); + ((SiteEditor)getPage().getPDEEditor()).handleBuild(getFeaturesFromSelection(sel)); + } + + private ISiteFeature[] getFeaturesFromSelection(IStructuredSelection sel) { + if(sel.isEmpty()) return new ISiteFeature[0]; + if(cachedSelection == sel) return cachedFeatures; + cachedSelection = sel; + ArrayList features = new ArrayList(sel.size()); + Iterator iterator = sel.iterator(); + while(iterator.hasNext()) { + Object next = iterator.next(); + if(next instanceof SiteFeatureAdapter) { + if((((SiteFeatureAdapter) next).feature) != null) { + features.add(((SiteFeatureAdapter) next).feature); + } + } } + cachedFeatures = (ISiteFeature[]) features.toArray(new ISiteFeature[features.size()]); + return cachedFeatures; } /** @@ -669,16 +696,11 @@ private void handleImportEnvironment() { IStructuredSelection sel = (IStructuredSelection) fCategoryViewer .getSelection(); - ISiteFeature feature = null; - if (!sel.isEmpty() - && sel.getFirstElement() instanceof SiteFeatureAdapter) { - feature = ((SiteFeatureAdapter) sel.getFirstElement()).feature; - } - final ISiteFeature selectedFeature = feature; + final ISiteFeature[] selectedFeatures = getFeaturesFromSelection(sel); BusyIndicator.showWhile(fCategoryTreePart.getControl().getDisplay(), new Runnable() { public void run() { - new SynchronizePropertiesAction(selectedFeature, + new SynchronizePropertiesAction(selectedFeatures, getModel()).run(); } }); Index: src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesAction.java,v retrieving revision 1.5 diff -u -r1.5 SynchronizePropertiesAction.java --- src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesAction.java 3 May 2006 13:31:06 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesAction.java 4 Sep 2007 15:37:29 -0000 @@ -20,18 +20,18 @@ public class SynchronizePropertiesAction extends Action { private ISiteModel fModel; - private ISiteFeature fSiteFeature; + private ISiteFeature[] fSiteFeatures; - public SynchronizePropertiesAction(ISiteFeature siteFeature, + public SynchronizePropertiesAction(ISiteFeature[] siteFeatures, ISiteModel model) { setText(PDEUIMessages.SynchronizePropertiesAction_label); - fSiteFeature = siteFeature; + fSiteFeatures = siteFeatures; fModel = model; } public void run() { SynchronizePropertiesWizard wizard = new SynchronizePropertiesWizard( - fSiteFeature, fModel); + fSiteFeatures, fModel); WizardDialog dialog = new WizardDialog(PDEPlugin .getActiveWorkbenchShell(), wizard); dialog.open(); Index: src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizardPage.java,v retrieving revision 1.5 diff -u -r1.5 SynchronizePropertiesWizardPage.java --- src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizardPage.java 13 Apr 2005 18:51:49 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizardPage.java 4 Sep 2007 15:37:29 -0000 @@ -40,7 +40,7 @@ public static final int ALL_FEATURES = 2; - public static final int ONE_FEATURE = 1; + public static final int SELECTED_FEATURES = 1; private static final String PREFIX = PDEPlugin.getPluginId() + ".synchronizeFeatueEnvironment."; //$NON-NLS-1$ @@ -51,22 +51,21 @@ private ISiteModel fModel; - private Button fOneFeatureButton; + private Button fSelectedFeaturesButton; - private ISiteFeature fSiteFeature; + private ISiteFeature[] fSiteFeatures; /** * - * @param siteFeature + * @param siteFeatures * selected feature or null */ - public SynchronizePropertiesWizardPage(ISiteFeature siteFeature, + public SynchronizePropertiesWizardPage(ISiteFeature[] siteFeatures, ISiteModel model) { super("featureSelection"); //$NON-NLS-1$ setTitle(PDEUIMessages.SynchronizePropertiesWizardPage_title); setDescription(PDEUIMessages.SynchronizePropertiesWizardPage_desc); - fSiteFeature = siteFeature != null && getFeature(siteFeature) != null ? siteFeature - : null; + fSiteFeatures = siteFeatures != null ? siteFeatures : new ISiteFeature[0]; fModel = model; } @@ -82,10 +81,10 @@ group.setLayoutData(gd); group.setText(PDEUIMessages.SynchronizePropertiesWizardPage_group); - fOneFeatureButton = new Button(group, SWT.RADIO); - fOneFeatureButton.setText(PDEUIMessages.SynchronizePropertiesWizardPage_oneFeature); + fSelectedFeaturesButton = new Button(group, SWT.RADIO); + fSelectedFeaturesButton.setText(PDEUIMessages.SynchronizePropertiesWizardPage_oneFeature); gd = new GridData(GridData.FILL_HORIZONTAL); - fOneFeatureButton.setLayoutData(gd); + fSelectedFeaturesButton.setLayoutData(gd); fAllFeaturesButton = new Button(group, SWT.RADIO); fAllFeaturesButton.setText(PDEUIMessages.SynchronizePropertiesWizardPage_allFeatures); @@ -185,24 +184,24 @@ } private void loadSettings() { - if (fSiteFeature != null) { + if (fSiteFeatures != null) { IDialogSettings settings = getDialogSettings(); if (settings.get(PROP_SYNCHRO_MODE) != null) { int mode = settings.getInt(PROP_SYNCHRO_MODE); switch (mode) { - case ONE_FEATURE: - fOneFeatureButton.setSelection(true); + case SELECTED_FEATURES: + fSelectedFeaturesButton.setSelection(true); break; case ALL_FEATURES: fAllFeaturesButton.setSelection(true); break; default: - fOneFeatureButton.setSelection(true); + fSelectedFeaturesButton.setSelection(true); } } else - fOneFeatureButton.setSelection(true); + fSelectedFeaturesButton.setSelection(true); } else { - fOneFeatureButton.setEnabled(false); + fSelectedFeaturesButton.setEnabled(false); fAllFeaturesButton.setSelection(true); } } @@ -210,8 +209,8 @@ private void runOperation(int mode, IProgressMonitor monitor) throws CoreException, InvocationTargetException { ISiteFeature[] siteFeatures; - if (mode == ONE_FEATURE) { - siteFeatures = new ISiteFeature[] { fSiteFeature }; + if (mode == SELECTED_FEATURES) { + siteFeatures = fSiteFeatures; } else { siteFeatures = fModel.getSite().getFeatures(); } @@ -223,7 +222,7 @@ private int saveSettings() { IDialogSettings settings = getDialogSettings(); - int mode = ONE_FEATURE; + int mode = SELECTED_FEATURES; if (fAllFeaturesButton.getSelection()) mode = ALL_FEATURES; Index: src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizard.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizard.java,v retrieving revision 1.5 diff -u -r1.5 SynchronizePropertiesWizard.java --- src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizard.java 3 May 2006 13:31:06 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/editor/site/SynchronizePropertiesWizard.java 4 Sep 2007 15:37:29 -0000 @@ -22,21 +22,21 @@ private ISiteModel fModel; - private ISiteFeature fSiteFeature; + private ISiteFeature[] fSiteFeatures; - public SynchronizePropertiesWizard(ISiteFeature siteFeature, + public SynchronizePropertiesWizard(ISiteFeature[] siteFeatures, ISiteModel model) { super(); setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFTRPRJ_WIZ); setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); setNeedsProgressMonitor(true); setWindowTitle(PDEUIMessages.SynchronizePropertiesWizard_wtitle); - fSiteFeature = siteFeature; + fSiteFeatures = siteFeatures; fModel = model; } public void addPages() { - fMainPage = new SynchronizePropertiesWizardPage(fSiteFeature, fModel); + fMainPage = new SynchronizePropertiesWizardPage(fSiteFeatures, fModel); addPage(fMainPage); }