Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-07-30 19:18:14 +0000
committerMichael Valenta2007-07-30 19:18:14 +0000
commit264c9e1ba19cc16293bfc31223d9720233846aa5 (patch)
treed7d753d51f4bc948add2863a136b12d7a35d4ecc /bundles
parent7616f808f895a356944a4cdecf2a737df2735631 (diff)
downloadeclipse.platform.team-264c9e1ba19cc16293bfc31223d9720233846aa5.tar.gz
eclipse.platform.team-264c9e1ba19cc16293bfc31223d9720233846aa5.tar.xz
eclipse.platform.team-264c9e1ba19cc16293bfc31223d9720233846aa5.zip
Bug 104203 [Wizards] Allow multiple projects to be shared
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java37
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java67
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureMultipleProjectsWizard.java52
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java157
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java47
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSelectionPage.java140
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizardExtension.java44
11 files changed, 409 insertions, 154 deletions
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
index 5db655790..7406697d2 100644
--- a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.team.ui; singleton:=true
-Bundle-Version: 3.3.100.qualifier
+Bundle-Version: 3.4.0.qualifier
Bundle-Activator: org.eclipse.team.internal.ui.TeamUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
index db3782fb7..ed39608ec 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
@@ -21,6 +21,16 @@ public class TeamUIMessages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, TeamUIMessages.class);
}
+ public static String ConfigureMultipleProjectsWizard_0;
+
+ public static String ConfigureMultipleProjectsWizard_1;
+
+ public static String ProjectSelectionPage_0;
+
+ public static String ProjectSelectionPage_1;
+
+ public static String ProjectSelectionPage_2;
+
public static String TextPreferencePage_ExtensionNotCompleted;
public static String CompareInputChangeNotifier_0;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java
index 5d3674591..9a1348916 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ConfigureProjectAction.java
@@ -17,28 +17,16 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
/**
* Action for configuring a project. Configuring involves associating
* the project with a Team provider and performing any provider-specific
* configuration that is necessary.
*/
-public class ConfigureProjectAction extends TeamAction implements IWorkbenchWindowActionDelegate {
- private static class ResizeWizardDialog extends WizardDialog {
- public ResizeWizardDialog(Shell parentShell, IWizard newWizard) {
- super(parentShell, newWizard);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
- }
+public class ConfigureProjectAction extends TeamAction {
protected void execute(IAction action) throws InvocationTargetException,
InterruptedException {
@@ -47,11 +35,8 @@ public class ConfigureProjectAction extends TeamAction implements IWorkbenchWind
try {
if (!isEnabled())
return;
- IProject project = getSelectedProjects()[0];
- ConfigureProjectWizard wizard = new ConfigureProjectWizard();
- wizard.init(null, project);
- WizardDialog dialog = new ResizeWizardDialog(getShell(), wizard);
- dialog.open();
+ IProject[] projects = getSelectedProjects();
+ ConfigureProjectWizard.shareProjects(getShell(), projects);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
@@ -64,15 +49,11 @@ public class ConfigureProjectAction extends TeamAction implements IWorkbenchWind
*/
public boolean isEnabled() {
IProject[] selectedProjects = getSelectedProjects();
- if (selectedProjects.length != 1) return false;
- if (!selectedProjects[0].isAccessible()) return false;
- if (!RepositoryProvider.isShared(selectedProjects[0])) return true;
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
+ for (int i = 0; i < selectedProjects.length; i++) {
+ IProject project = selectedProjects[i];
+ if (!project.isAccessible()) return false;
+ if (!RepositoryProvider.isShared(project)) return true;
+ }
+ return true;
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index 541309b2f..eabb92aba 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -122,6 +122,9 @@ ProjectSetImportWizard_0=Projects for repository type {0} could not be loaded as
ProjectSetImportWizard_2=An error occurred while parsing the project set file: {0}
ProjectSetImportWizard_1=The following errors occurred while importing projects. Some projects may not be loaded.
ProjectSetImportWizard_3=An error occurred while performing the project set import: {0}
+ProjectSelectionPage_0={0} does not directly support multiple project sharing. Select a project and click Share Project to share each project individually
+ProjectSelectionPage_1={0} Project Selection Page
+ProjectSelectionPage_2=&Share Project...
ProjectSetImportWizard_Import_a_Project_Set_3=Import a Team Project Set
ProjectSetImportWizard_workingSetExistsTitle=Working Set Exists
ProjectSetImportWizard_workingSetExistsMessage=Working set ''{0}'' already exists. Overwrite?
@@ -224,6 +227,8 @@ RefreshCompleteDialog_6={0}: No changes found.
ConfigureRefreshScheduleDialog_0=Configure Synchronize Schedule - {0}
ConfigureRefreshScheduleDialog_1=You can allow ''{0}'' to periodically synchronize in the background.
ConfigureRefreshScheduleDialog_1a=The last synchronize occurred at: {0}
+ConfigureMultipleProjectsWizard_0=Unshared Projects
+ConfigureMultipleProjectsWizard_1=There are still projects that have not been shared. Finishing the wizard now will leave them in that state.
ConfigureRefreshScheduleDialog_2=Do not schedule the synchronize operation to run periodically.
ConfigureRefreshScheduleDialog_3=Using the following schedule:
ConfigureRefreshScheduleDialog_4=Every:
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java
index 7fcd9f9df..d2d089e41 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java
@@ -11,10 +11,15 @@
package org.eclipse.team.internal.ui.wizards;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizard;
import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.ui.IPluginContribution;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.IConfigurationWizard;
+import org.eclipse.team.ui.IConfigurationWizardExtension;
+import org.eclipse.ui.*;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchAdapter;
@@ -40,12 +45,44 @@ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAda
* Create an the instance of the object described by the configuration
* element. That is, create the instance of the class the isv supplied in
* the extension point.
+ * @return the instance of the configuration wizard of type {@link IConfigurationWizard}
*
* @throws CoreException if an error occurs creating the extension
*/
public Object createExecutableExtension() throws CoreException {
return TeamUIPlugin.createExtension(configurationElement, ConfigureProjectWizard.ATT_CLASS);
}
+
+ /**
+ * Creates the instance of the wizard and initializes with the given input.
+ * @param projects the projects being shared by this wizard
+ * @return the wizard instance of type {@link IConfigurationWizard}
+ * @throws CoreException if an error occurs creating the extension
+ */
+ public IWizard createExecutableExtension(IProject[] projects) throws CoreException {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IConfigurationWizard wizard = (IConfigurationWizard)createExecutableExtension();
+ IConfigurationWizardExtension extension = (IConfigurationWizardExtension)Utils.getAdapter(wizard, IConfigurationWizardExtension.class);
+ if (extension == null) {
+ if (projects.length == 1) {
+ wizard.init(workbench, projects[0]);
+ } else {
+ // Dispose of the created wizard, just in case
+ try {
+ wizard.dispose();
+ } catch (RuntimeException e) {
+ // If a general exception occurred here, log it and continue
+ TeamUIPlugin.log(IStatus.ERROR, "An internal error occurred", e); //$NON-NLS-1$
+ }
+ IWizard multiWizard = new ConfigureMultipleProjectsWizard(projects, this);
+ return multiWizard;
+ }
+ } else {
+ extension.init(workbench, projects);
+ }
+ return wizard;
+ }
+
/*
* Method declared on IAdaptable.
*/
@@ -108,7 +145,7 @@ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAda
/**
* Set the description parameter of this element
*
- * @param value the new desrciption
+ * @param value the new description
*/
public void setDescription(String value) {
// Not used
@@ -141,6 +178,30 @@ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAda
* @see org.eclipse.ui.IPluginContribution#getPluginId()
*/
public String getPluginId() {
- return configurationElement.getNamespace();
+ return configurationElement.getNamespaceIdentifier();
+ }
+
+ /**
+ * Return whether the wizard created for this element has pages.
+ * Unfortunately, the only way to find this out is to create the wizard.
+ * @param projects the projects being shared
+ * @return whether the resulting wizard has pages
+ */
+ public boolean wizardHasPages(IProject[] projects) {
+ try {
+ IWizard wizard = (IWizard)createExecutableExtension(projects);
+ try {
+ wizard.addPages();
+ return (wizard.getPageCount() > 0);
+ } finally {
+ wizard.dispose();
+ }
+ } catch (CoreException e) {
+ TeamUIPlugin.log(e);
+ } catch (RuntimeException e) {
+ // If a general exception occurred here, log it and continue
+ TeamUIPlugin.log(IStatus.ERROR, "An internal error occurred", e); //$NON-NLS-1$
+ }
+ return false;
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureMultipleProjectsWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureMultipleProjectsWizard.java
new file mode 100644
index 000000000..107cc421e
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureMultipleProjectsWizard.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.team.internal.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.team.internal.ui.TeamUIMessages;
+import org.eclipse.team.ui.IConfigurationWizard;
+import org.eclipse.team.ui.IConfigurationWizardExtension;
+
+/**
+ * Wizard that supports the sharing of multiple projects for those repository providers
+ * that have not adapted their {@link IConfigurationWizard} to {@link IConfigurationWizardExtension}.
+ */
+public class ConfigureMultipleProjectsWizard extends Wizard {
+
+ private final IProject[] projects;
+ private final ConfigurationWizardElement element;
+ private ProjectSelectionPage projectSelectionPage;
+
+ public ConfigureMultipleProjectsWizard(IProject[] projects, ConfigurationWizardElement element) {
+ this.projects = projects;
+ this.element = element;
+ }
+
+
+ public void addPages() {
+ projectSelectionPage = new ProjectSelectionPage(projects, element);
+ addPage(projectSelectionPage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish() {
+ // Prompt if there are still unshared projects
+ if (projectSelectionPage.hasUnsharedProjects()) {
+ return MessageDialog.openConfirm(getShell(), TeamUIMessages.ConfigureMultipleProjectsWizard_0, TeamUIMessages.ConfigureMultipleProjectsWizard_1);
+ }
+ return true;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java
index a78431d45..ce4b3370e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.wizards;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.activities.IIdentifier;
@@ -26,13 +24,9 @@ import org.eclipse.ui.model.AdaptableList;
/**
* The wizard for associating projects with team providers
*/
-public class ConfigureProjectWizard extends Wizard implements IConfigurationWizard {
- protected IWorkbench workbench;
- protected IProject project;
- protected IConfigurationWizard wizard;
-
+public class ConfigureProjectWizard extends Wizard {
+ protected IProject[] projects;
protected ConfigureProjectWizardMainPage mainPage;
- private String pluginId = TeamUIPlugin.PLUGIN_ID;
protected final static String PT_CONFIGURATION ="configurationWizards"; //$NON-NLS-1$
protected final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
@@ -42,66 +36,27 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
protected final static String ATT_ICON = "icon"; //$NON-NLS-1$
protected final static String ATT_ID = "id"; //$NON-NLS-1$
- public ConfigureProjectWizard() {
+ private ConfigureProjectWizard(IProject[] projects) {
+ this.projects = projects;
setNeedsProgressMonitor(true);
- setWindowTitle(getWizardWindowTitle());
- }
-
- protected String getExtensionPoint() {
- return PT_CONFIGURATION;
- }
-
- protected String getWizardWindowTitle() {
- return TeamUIMessages.ConfigureProjectWizard_title;
+ setWindowTitle(TeamUIMessages.ConfigureProjectWizard_title);
}
- protected String getWizardLabel() {
- return TeamUIMessages.ConfigureProjectWizard_configureProject;
- }
-
- protected String getWizardDescription() {
- return TeamUIMessages.ConfigureProjectWizard_description;
- }
-
- /*
- * @see Wizard#addPages
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
*/
public void addPages() {
AdaptableList disabledWizards = new AdaptableList();
- AdaptableList wizards = getAvailableWizards(disabledWizards);
- if (wizards.size() == 1 && disabledWizards.size() == 0) {
- // If there is only one wizard, skip the first page.
- // Only skip the first page if the one wizard has at least one page.
- ConfigurationWizardElement element = (ConfigurationWizardElement)wizards.getChildren()[0];
- try {
- this.wizard = (IConfigurationWizard)element.createExecutableExtension();
- wizard.init(workbench, project);
- wizard.addPages();
- if (wizard.getPageCount() > 0) {
- wizard.setContainer(getContainer());
- IWizardPage[] pages = wizard.getPages();
- for (int i = 0; i < pages.length; i++) {
- addPage(pages[i]);
- }
- return;
- }
- } catch (CoreException e) {
- TeamUIPlugin.log(e);
- return;
- }
- }
- mainPage = new ConfigureProjectWizardMainPage("configurePage1", getWizardLabel(), TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE), wizards, disabledWizards); //$NON-NLS-1$
- mainPage.setDescription(getWizardDescription());
- mainPage.setProject(project);
- mainPage.setWorkbench(workbench);
+ AdaptableList wizards = getAvailableWizards(disabledWizards);
+ mainPage = new ConfigureProjectWizardMainPage("configurePage1", TeamUIMessages.ConfigureProjectWizard_configureProject, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE), wizards, disabledWizards); //$NON-NLS-1$
+ mainPage.setDescription(TeamUIMessages.ConfigureProjectWizard_description);
+ mainPage.setProjects(projects);
addPage(mainPage);
}
- public IWizardPage getNextPage(IWizardPage page) {
- if (wizard != null) {
- return wizard.getNextPage(page);
- }
- return super.getNextPage(page);
- }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
public boolean canFinish() {
// If we are on the first page, never allow finish unless the selected wizard has no pages.
if (getContainer().getCurrentPage() == mainPage) {
@@ -110,44 +65,59 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
}
return false;
}
- if (wizard != null) {
- return wizard.canFinish();
- }
return super.canFinish();
}
- /*
- * @see Wizard#performFinish
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
- // There is only one wizard with at least one page
- if (wizard != null) {
- return wizard.performFinish();
- }
// If we are on the first page and the selected wizard has no pages then
// allow it to finish.
if (getContainer().getCurrentPage() == mainPage) {
- IConfigurationWizard noPageWizard = mainPage.getSelectedWizard();
+ IWizard noPageWizard = mainPage.getSelectedWizard();
if (noPageWizard != null) {
if (noPageWizard.canFinish())
{
return noPageWizard.performFinish();
}
}
- }
+ }
// If the wizard has pages and there are several
// wizards registered then the registered wizard
// will call it's own performFinish().
return true;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizard#performCancel()
- */
- public boolean performCancel() {
- if (wizard != null) {
- return wizard.performCancel();
+ private static class ResizeWizardDialog extends WizardDialog {
+ public ResizeWizardDialog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+ }
+
+ public static void shareProjects(Shell shell, IProject[] projects) {
+ IWizard wizard = null;
+ // If we only have one wizard registered, we'll just use that wizard
+ // unless it doesn't have any pages
+ AdaptableList disabledWizards = new AdaptableList();
+ AdaptableList wizards = getAvailableWizards(disabledWizards);
+ if (wizards.size() == 1 && disabledWizards.size() == 0) {
+ ConfigurationWizardElement element = (ConfigurationWizardElement)wizards.getChildren()[0];
+ if (element.wizardHasPages(projects)) {
+ try {
+ wizard = (IWizard)element.createExecutableExtension(projects);
+ } catch (CoreException e) {
+ // Log the exception and fall through to show the wizard
+ TeamUIPlugin.log(e);
+ }
+ }
+ }
+ if (wizard == null) {
+ wizard = new ConfigureProjectWizard(projects);
+ ((ConfigureProjectWizard)wizard).setForcePreviousAndNextButtons(true);
}
- return super.performCancel();
+ openWizard(shell, wizard);
}
/**
@@ -155,10 +125,10 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
*
* @return the available wizards
*/
- protected AdaptableList getAvailableWizards(AdaptableList disabledWizards) {
+ private static AdaptableList getAvailableWizards(AdaptableList disabledWizards) {
AdaptableList result = new AdaptableList();
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint(pluginId, getExtensionPoint());
+ IExtensionPoint point = registry.getExtensionPoint(TeamUIPlugin.PLUGIN_ID, PT_CONFIGURATION);
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++) {
@@ -179,9 +149,9 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
return result;
}
- private boolean filterItem(IConfigurationElement element) {
+ private static boolean filterItem(IConfigurationElement element) {
String extensionId = element.getAttribute(ATT_ID);
- String extensionPluginId = element.getNamespace();
+ String extensionPluginId = element.getNamespaceIdentifier();
IActivityManager activityMgr = PlatformUI.getWorkbench().getActivitySupport().getActivityManager();
IIdentifier id = activityMgr.getIdentifier(extensionPluginId + "/" + extensionId); //$NON-NLS-1$
return (!id.isEnabled());
@@ -197,7 +167,7 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
* @param element the element for which to create a wizard element
* @return the wizard element for the given element
*/
- protected ConfigurationWizardElement createWizardElement(IConfigurationElement element) {
+ private static ConfigurationWizardElement createWizardElement(IConfigurationElement element) {
// WizardElements must have a name attribute
String nameString = element.getAttribute(ATT_NAME);
if (nameString == null) {
@@ -220,7 +190,7 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
* @param config the registry to get properties from
* @return whether initialization was successful
*/
- protected boolean initializeWizard(ConfigurationWizardElement element, IConfigurationElement config) {
+ private static boolean initializeWizard(ConfigurationWizardElement element, IConfigurationElement config) {
element.setID(config.getAttribute(ATT_ID));
String description = ""; //$NON-NLS-1$
IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
@@ -242,14 +212,11 @@ public class ConfigureProjectWizard extends Wizard implements IConfigurationWiza
// Missing attribute
return false;
}
- setForcePreviousAndNextButtons(true);
return true;
}
- /*
- * Method declared on IConfigurationWizard
- */
- public void init(IWorkbench workbench, IProject project) {
- this.workbench = workbench;
- this.project = project;
+
+ public static void openWizard(Shell shell, IWizard wizard) {
+ WizardDialog dialog = new ResizeWizardDialog(shell, wizard);
+ dialog.open();
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java
index 33138b127..d7385288b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java
@@ -20,17 +20,15 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jface.wizard.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
+import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.ITriggerPoint;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
@@ -48,11 +46,10 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
private TableViewer viewer;
private AdaptableList wizards;
private AdaptableList disabledWizards;
- private IWorkbench workbench;
- private IProject project;
+ private IProject[] projects;
private String description;
- private IConfigurationWizard selectedWizard;
+ private IWizard selectedWizard;
/**
* Create a new ConfigureProjectWizardMainPage
@@ -84,7 +81,7 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
this.description = description;
}
- public IConfigurationWizard getSelectedWizard() {
+ public IWizard getSelectedWizard() {
return selectedWizard;
}
/*
@@ -136,8 +133,7 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
}
ConfigurationWizardElement selectedElement = (ConfigurationWizardElement)ss.getFirstElement();
try {
- selectedWizard = (IConfigurationWizard)selectedElement.createExecutableExtension();
- selectedWizard.init(workbench, project);
+ selectedWizard = (IWizard)selectedElement.createExecutableExtension(getUnsharedProjects());
} catch (CoreException e) {
return;
}
@@ -187,6 +183,17 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
}
Dialog.applyDialogFont(parent);
}
+
+ /* package */ IProject[] getUnsharedProjects() {
+ java.util.List unshared = new ArrayList();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ if (!RepositoryProvider.isShared(project))
+ unshared.add(project);
+ }
+ return (IProject[]) unshared.toArray(new IProject[unshared.size()]);
+ }
+
/**
* The <code>WizardSelectionPage</code> implementation of
* this <code>IWizardPage</code> method returns the first page
@@ -205,23 +212,11 @@ public class ConfigureProjectWizardMainPage extends WizardPage {
.getActivitySupport().getTriggerPointManager()
.getTriggerPoint(TeamUIPlugin.TRIGGER_POINT_ID);
}
-
- /**
- * Set the workbench to the argument
- *
- * @param workbench the workbench to set
- */
- public void setWorkbench(IWorkbench workbench) {
- this.workbench = workbench;
- }
- /**
- * Set the project to the argument
- *
- * @param project the project to set
- */
- public void setProject(IProject project) {
- this.project = project;
+
+ public void setProjects(IProject[] projects) {
+ this.projects = projects;
}
+
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSelectionPage.java
new file mode 100644
index 000000000..5c6fdd4e1
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSelectionPage.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * 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.team.internal.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.ui.IConfigurationWizard;
+import org.eclipse.team.ui.IConfigurationWizardExtension;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.model.*;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+/**
+ * Page that supports the sharing of multiple projects for those repository providers
+ * that have not adapted their {@link IConfigurationWizard} to {@link IConfigurationWizardExtension}.
+ */
+public class ProjectSelectionPage extends WizardPage {
+
+ private final IProject[] projects;
+ private final ConfigurationWizardElement element;
+ private Button shareButton;
+ private TableViewer projectViewer;
+ private AdaptableList projectList;
+
+ protected ProjectSelectionPage(IProject[] projects, ConfigurationWizardElement element) {
+ super("projectSelectionPage", //$NON-NLS-1$
+ NLS.bind(TeamUIMessages.ProjectSelectionPage_1, element.getLabel(null)),
+ TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE));
+ setDescription(NLS.bind(TeamUIMessages.ProjectSelectionPage_0, element.getLabel(null)));
+ this.projects = projects;
+ this.element = element;
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = SWTUtils.createHVFillComposite(parent, SWTUtils.MARGINS_DIALOG, 2);
+ createProjectList(composite);
+ createShareButton(composite);
+ updateEnablements();
+ setControl(composite);
+ }
+
+ private void createProjectList(Composite composite) {
+ projectViewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER);
+ projectViewer.getControl().setLayoutData(SWTUtils.createHVFillGridData());
+ projectList = new AdaptableList(projects);
+ projectViewer.setContentProvider(new WorkbenchContentProvider());
+ projectViewer.setLabelProvider(new WorkbenchLabelProvider());
+ projectViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
+ projectViewer.setInput(projectList);
+ projectViewer.getTable().select(0);
+ projectViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateEnablements();
+ }
+ });
+ }
+
+ private void createShareButton(Composite composite) {
+ shareButton = new Button(composite, SWT.PUSH);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.END;
+ gridData.verticalAlignment = SWT.TOP;
+ shareButton.setLayoutData(gridData);
+ shareButton.setText(TeamUIMessages.ProjectSelectionPage_2);
+ shareButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ shareSelectedProject();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Ignore
+ }
+ });
+ }
+
+ /* package */ void shareSelectedProject() {
+ IProject project = getSelectedProject();
+ if (project != null) {
+ try {
+ IConfigurationWizard wizard = (IConfigurationWizard)element.createExecutableExtension();
+ wizard.init(PlatformUI.getWorkbench(), project);
+ ConfigureProjectWizard.openWizard(getShell(), wizard);
+ updateProjectList(project);
+ if (projectList.size() == 0) {
+ // TODO: Can we close the outer wizard from here?
+ }
+ } catch (CoreException e) {
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
+ }
+ }
+ }
+
+ private void updateProjectList(IProject project) {
+ if (RepositoryProvider.isShared(project)) {
+ projectList.remove(project);
+ projectViewer.refresh();
+ if (hasUnsharedProjects()) {
+ projectViewer.getTable().select(0);
+ }
+ updateEnablements();
+ }
+ }
+
+ /* package */ void updateEnablements() {
+ shareButton.setEnabled(getSelectedProject() != null);
+ }
+
+ private IProject getSelectedProject() {
+ ISelection selection = projectViewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ return (IProject)ss.getFirstElement();
+ }
+ return null;
+ }
+
+ public boolean hasUnsharedProjects() {
+ return projectList.size() > 0;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java
index 0f164caae..eafbf8a27 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizard.java
@@ -24,7 +24,7 @@ import org.eclipse.ui.IWorkbench;
public interface IConfigurationWizard extends IWizard {
/**
* Initializes this creation wizard using the passed workbench and
- * object selection.
+ * the selected project.
* <p>
* This method is called after the no argument constructor and
* before other methods are called.
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizardExtension.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizardExtension.java
new file mode 100644
index 000000000..657f14244
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/IConfigurationWizardExtension.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.team.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Extends {@link IConfigurationWizard} to support the sharing of multiple projects.
+ * The Share Project wizard uses the "adaptable" mechanism (see {@link IAdapterManager} to obtain an
+ * <code>IConfigurationWizardExtension</code> for an <code>IConfigurationWizard</code>
+ * class so clients may choose to have their <code>IConfigurationWizard</code> class implement this
+ * interface as well or may choose to use the adaptable mechanism to provide the extension.
+ * <p>
+ * Clients may implement this interface.
+ *
+ * @see IConfigurationWizard
+ * @since 3.4
+ */
+public interface IConfigurationWizardExtension {
+
+ /**
+ * Initializes this creation wizard using the passed workbench and
+ * selected projects.
+ * <p>
+ * This method is called after the no argument constructor and
+ * before other methods are called.
+ * </p>
+ *
+ * @param workbench the current workbench
+ * TODO This parameter is useless. Should we pass the active page or part?
+ * @param projects the selected projects
+ */
+ void init(IWorkbench workbench, IProject[] projects);
+}

Back to the top