### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/wizards/BundleProviderHistoryUtil.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/wizards/BundleProviderHistoryUtil.java diff -N src/org/eclipse/pde/internal/ui/wizards/BundleProviderHistoryUtil.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/wizards/BundleProviderHistoryUtil.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2011 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; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.widgets.Combo; + +/** + * Provides global access to the saved list of bundle providers. Provides helper methods + * to load and save provider names from and to combo boxes. The bundle provider combo + * is used in the plug-in, feature, fragment, and feature patch wizards. + * + * @since 3.8 + */ +public class BundleProviderHistoryUtil { + /** + * Key for bundle providers list saved in dialog settings + */ + private final static String S_PROVIDERS = "providers"; //$NON-NLS-1$ + + /** + * Loads a list of providers into the provided combo control from the provided dialog settings + * + * @param combo The combo control to modify + * @param settings The dialog settings to look up the list in + */ + public static void loadHistory(Combo combo, IDialogSettings settings) { + if (null == combo || null == settings) { + return; + } + String providers[] = settings.getArray(S_PROVIDERS); + if (null != providers) { + for (int i = 0; i < providers.length; ++i) { + combo.add(providers[i]); + } + } + } + + /** + * Saves the items of the given combo to the given settings. + *

+ * If the combo text is not in the list of history items yet, it will be + * added. The combo text will be the most recent history value (saved first). + *

+ * + * @param combo The combo to get the list/text from + * @param settings The dialog settings to save the list into + */ + public static void saveHistory(Combo combo, IDialogSettings settings) { + if (null == combo) { + return; + } + // Save all providers from the combo list + the newly entered + String text = combo.getText(); + if (0 == text.length()) { + return; + } + int indexOfText = combo.indexOf(text); + // If the item was already in the list, remove it now + if (indexOfText != -1) { + combo.remove(indexOfText); + } + // And always add the entered text as the most recent one to the top of + // the list + combo.add(text, 0); + String[] items = combo.getItems(); + if (items != null && items.length > 0) { + settings.put(S_PROVIDERS, items); + } + } +} \ No newline at end of file Index: src/org/eclipse/pde/internal/ui/wizards/feature/AbstractFeatureSpecPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/AbstractFeatureSpecPage.java,v retrieving revision 1.7 diff -u -r1.7 AbstractFeatureSpecPage.java --- src/org/eclipse/pde/internal/ui/wizards/feature/AbstractFeatureSpecPage.java 27 May 2009 20:38:23 -0000 1.7 +++ src/org/eclipse/pde/internal/ui/wizards/feature/AbstractFeatureSpecPage.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -13,6 +13,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.pde.internal.core.ifeature.IFeatureModel; import org.eclipse.pde.internal.core.util.IdUtil; import org.eclipse.pde.internal.core.util.VersionUtil; @@ -61,6 +62,8 @@ protected abstract String getHelpId(); + protected abstract void saveSettings(IDialogSettings settings); + protected void createCommonInput(Composite common) { Label label = new Label(common, SWT.NULL); label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_name); Index: src/org/eclipse/pde/internal/ui/wizards/feature/AbstractNewFeatureWizard.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/AbstractNewFeatureWizard.java,v retrieving revision 1.6 diff -u -r1.6 AbstractNewFeatureWizard.java --- src/org/eclipse/pde/internal/ui/wizards/feature/AbstractNewFeatureWizard.java 27 May 2009 20:38:23 -0000 1.6 +++ src/org/eclipse/pde/internal/ui/wizards/feature/AbstractNewFeatureWizard.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -105,6 +105,7 @@ public boolean performFinish() { try { IDialogSettings settings = getDialogSettings(); + fSpecPage.saveSettings(settings); if (settings != null && fSecondPage != null) fSecondPage.saveSettings(settings); Index: src/org/eclipse/pde/internal/ui/wizards/feature/FeatureSpecPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/FeatureSpecPage.java,v retrieving revision 1.22 diff -u -r1.22 FeatureSpecPage.java --- src/org/eclipse/pde/internal/ui/wizards/feature/FeatureSpecPage.java 27 Apr 2009 14:12:08 -0000 1.22 +++ src/org/eclipse/pde/internal/ui/wizards/feature/FeatureSpecPage.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -11,9 +11,11 @@ package org.eclipse.pde.internal.ui.wizards.feature; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.pde.internal.core.util.IdUtil; import org.eclipse.pde.internal.ui.IHelpContextIds; import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.wizards.BundleProviderHistoryUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; @@ -22,7 +24,7 @@ public class FeatureSpecPage extends AbstractFeatureSpecPage { - private Text fFeatureProviderText; + private Combo fFeatureProviderCombo; private Text fFeatureIdText; public FeatureSpecPage() { @@ -45,7 +47,7 @@ FeatureData data = new FeatureData(); data.id = fFeatureIdText.getText(); data.version = fFeatureVersionText.getText(); - data.provider = fFeatureProviderText.getText(); + data.provider = fFeatureProviderCombo.getText(); data.name = fFeatureNameText.getText(); data.library = getInstallHandlerLibrary(); return data; @@ -77,14 +79,15 @@ label = new Label(group, SWT.NULL); label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_provider); - fFeatureProviderText = new Text(group, SWT.BORDER); - fFeatureProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fFeatureProviderCombo = new Combo(group, SWT.BORDER | SWT.DROP_DOWN); + fFeatureProviderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + BundleProviderHistoryUtil.loadHistory(fFeatureProviderCombo, getDialogSettings()); createInstallHandlerText(group); } protected void attachListeners(ModifyListener listener) { - fFeatureProviderText.addModifyListener(listener); + fFeatureProviderCombo.addModifyListener(listener); fFeatureIdText.addModifyListener(listener); } @@ -99,7 +102,16 @@ String id = IdUtil.getValidId(getProjectName()); fFeatureIdText.setText(id); fFeatureNameText.setText(IdUtil.getValidName(id)); - fFeatureProviderText.setText(IdUtil.getValidProvider(id)); + if (0 == fFeatureProviderCombo.getText().length()) { + fFeatureProviderCombo.setText(IdUtil.getValidProvider(id)); + } fSelfModification = false; } + + /* (non-Javadoc) + * @see org.eclipse.pde.internal.ui.wizards.feature.AbstractFeatureSpecPage#saveSettings(org.eclipse.jface.dialogs.IDialogSettings) + */ + protected void saveSettings(IDialogSettings settings) { + BundleProviderHistoryUtil.saveHistory(fFeatureProviderCombo, settings); + } } Index: src/org/eclipse/pde/internal/ui/wizards/feature/PatchSpecPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/feature/PatchSpecPage.java,v retrieving revision 1.31 diff -u -r1.31 PatchSpecPage.java --- src/org/eclipse/pde/internal/ui/wizards/feature/PatchSpecPage.java 26 Jan 2009 15:04:54 -0000 1.31 +++ src/org/eclipse/pde/internal/ui/wizards/feature/PatchSpecPage.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -11,6 +11,7 @@ package org.eclipse.pde.internal.ui.wizards.feature; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.IWizardPage; @@ -22,6 +23,7 @@ import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog; import org.eclipse.pde.internal.ui.util.SWTUtil; +import org.eclipse.pde.internal.ui.wizards.BundleProviderHistoryUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.layout.GridData; @@ -30,7 +32,7 @@ public class PatchSpecPage extends AbstractFeatureSpecPage { - private Text fPatchProviderText; + private Combo fPatchProviderCombo; private Button fBrowseButton; private Text fPatchIdText; private Text fPatchNameText; @@ -85,9 +87,9 @@ } private String getPatchProvider() { - if (fPatchProviderText == null) + if (fPatchProviderCombo == null) return ""; //$NON-NLS-1$ - return fPatchProviderText.getText(); + return fPatchProviderCombo.getText(); } public FeatureData getFeatureData() { @@ -136,8 +138,9 @@ label = new Label(patchGroup, SWT.NULL); label.setText(PDEUIMessages.NewFeaturePatch_SpecPage_provider); - fPatchProviderText = new Text(patchGroup, SWT.BORDER); - fPatchProviderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fPatchProviderCombo = new Combo(patchGroup, SWT.BORDER | SWT.DROP_DOWN); + fPatchProviderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + BundleProviderHistoryUtil.loadHistory(fPatchProviderCombo, getDialogSettings()); createInstallHandlerText(patchGroup); } @@ -197,7 +200,7 @@ protected void attachListeners(ModifyListener listener) { fPatchIdText.addModifyListener(listener); fPatchNameText.addModifyListener(listener); - fPatchProviderText.addModifyListener(listener); + fPatchProviderCombo.addModifyListener(listener); fFeatureIdText.addModifyListener(listener); } @@ -212,7 +215,13 @@ String id = IdUtil.getValidId(getProjectName()); fPatchIdText.setText(id); fPatchNameText.setText(IdUtil.getValidName(id)); - fPatchProviderText.setText(IdUtil.getValidProvider(id)); + if (0 == fPatchProviderCombo.getText().length()) { + fPatchProviderCombo.setText(IdUtil.getValidProvider(id)); + } fSelfModification = false; } + + protected void saveSettings(IDialogSettings settings) { + BundleProviderHistoryUtil.saveHistory(fPatchProviderCombo, settings); + } } Index: src/org/eclipse/pde/internal/ui/wizards/plugin/ContentPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/ContentPage.java,v retrieving revision 1.45 diff -u -r1.45 ContentPage.java --- src/org/eclipse/pde/internal/ui/wizards/plugin/ContentPage.java 10 May 2010 21:06:24 -0000 1.45 +++ src/org/eclipse/pde/internal/ui/wizards/plugin/ContentPage.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -12,6 +12,7 @@ package org.eclipse.pde.internal.ui.wizards.plugin; import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.pde.internal.core.PDECoreMessages; @@ -19,14 +20,14 @@ import org.eclipse.pde.internal.core.util.VersionUtil; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.util.PDELabelUtility; +import org.eclipse.pde.internal.ui.wizards.BundleProviderHistoryUtil; import org.eclipse.pde.internal.ui.wizards.IProjectProvider; import org.eclipse.pde.ui.IFieldData; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.*; public abstract class ContentPage extends WizardPage { @@ -34,7 +35,7 @@ protected Text fIdText; protected Text fVersionText; protected Text fNameText; - protected Text fProviderText; + protected Combo fProviderCombo; protected NewProjectCreationPage fMainPage; protected AbstractFieldData fData; @@ -75,6 +76,18 @@ return text; } + protected Combo createProviderCombo(Composite parent, ModifyListener listener, int horizSpan) { + Combo combo = new Combo(parent, SWT.BORDER | SWT.DROP_DOWN); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = horizSpan; + combo.setLayoutData(data); + BundleProviderHistoryUtil.loadHistory(combo, getDialogSettings()); + // Add listener only now, otherwise combo.select(0) would trigger it + // and cause a NPE during validation. + combo.addModifyListener(listener); + return combo; + } + protected abstract void validatePage(); protected String validateProperties() { @@ -152,7 +165,9 @@ fIdText.setText(id); fVersionText.setText("1.0.0.qualifier"); //$NON-NLS-1$ fNameText.setText(IdUtil.getValidName(id)); - fProviderText.setText(IdUtil.getValidProvider(id)); + if (0 == fProviderCombo.getText().length()) { + fProviderCombo.setText(IdUtil.getValidProvider(id)); + } fChangedGroups = oldfChanged; } if (fInitialized) @@ -167,11 +182,15 @@ return IdUtil.getValidId(fProjectProvider.getProjectName()); } + public void saveSettings(IDialogSettings settings) { + BundleProviderHistoryUtil.saveHistory(fProviderCombo, settings); + } + public void updateData() { fData.setId(fIdText.getText().trim()); fData.setVersion(fVersionText.getText().trim()); fData.setName(fNameText.getText().trim()); - fData.setProvider(fProviderText.getText().trim()); + fData.setProvider(fProviderCombo.getText().trim()); } public IFieldData getData() { Index: src/org/eclipse/pde/internal/ui/wizards/plugin/FragmentContentPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/FragmentContentPage.java,v retrieving revision 1.30 diff -u -r1.30 FragmentContentPage.java --- src/org/eclipse/pde/internal/ui/wizards/plugin/FragmentContentPage.java 26 Jan 2009 15:04:54 -0000 1.30 +++ src/org/eclipse/pde/internal/ui/wizards/plugin/FragmentContentPage.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -107,7 +107,7 @@ label = new Label(propertiesGroup, SWT.NONE); label.setText(PDEUIMessages.ContentPage_fprovider); - fProviderText = createText(propertiesGroup, propertiesListener, 2); + fProviderCombo = createProviderCombo(propertiesGroup, propertiesListener, 2); createExecutionEnvironmentControls(propertiesGroup); } Index: src/org/eclipse/pde/internal/ui/wizards/plugin/NewFragmentProjectWizard.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/NewFragmentProjectWizard.java,v retrieving revision 1.20 diff -u -r1.20 NewFragmentProjectWizard.java --- src/org/eclipse/pde/internal/ui/wizards/plugin/NewFragmentProjectWizard.java 7 Nov 2008 19:26:23 -0000 1.20 +++ src/org/eclipse/pde/internal/ui/wizards/plugin/NewFragmentProjectWizard.java 13 Jul 2011 19:07:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -13,6 +13,7 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.*; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.pde.internal.ui.*; import org.eclipse.pde.internal.ui.wizards.IProjectProvider; @@ -30,6 +31,7 @@ public NewFragmentProjectWizard() { setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFRAGPRJ_WIZ); + setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); setWindowTitle(PDEUIMessages.NewFragmentProjectWizard_title); setNeedsProgressMonitor(true); PDEPlugin.getDefault().getLabelProvider().connect(this); @@ -79,6 +81,12 @@ try { fMainPage.updateData(); fContentPage.updateData(); + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + fMainPage.saveSettings(settings); + fContentPage.saveSettings(settings); + } + BasicNewProjectResourceWizard.updatePerspective(fConfig); getContainer().run(false, true, new NewProjectCreationOperation(fFragmentData, fProjectProvider, null)); Index: src/org/eclipse/pde/internal/ui/wizards/plugin/PluginContentPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginContentPage.java,v retrieving revision 1.49 diff -u -r1.49 PluginContentPage.java --- src/org/eclipse/pde/internal/ui/wizards/plugin/PluginContentPage.java 1 Feb 2011 16:45:00 -0000 1.49 +++ src/org/eclipse/pde/internal/ui/wizards/plugin/PluginContentPage.java 13 Jul 2011 19:07:46 -0000 @@ -125,7 +125,7 @@ label = new Label(propertiesGroup, SWT.NONE); label.setText(PDEUIMessages.ContentPage_pprovider); - fProviderText = createText(propertiesGroup, propertiesListener, 2); + fProviderCombo = createProviderCombo(propertiesGroup, propertiesListener, 2); createExecutionEnvironmentControls(propertiesGroup); } @@ -367,6 +367,7 @@ * @param settings */ public void saveSettings(IDialogSettings settings) { + super.saveSettings(settings); settings.put(S_GENERATE_ACTIVATOR, !fGenerateActivator.getSelection()); if (fUIPlugin.isEnabled()) { settings.put(S_UI_PLUGIN, !fUIPlugin.getSelection());