Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-07-31 20:29:50 +0000
committerMichael Valenta2007-07-31 20:29:50 +0000
commit9450f5ae0bbea919ecce148106972d1ea492d433 (patch)
treefc12ea00fbdfe48b1b4167bdd348952ca7c8e759 /bundles
parent3a7955ef929a6fd4f23fd02138fee7f0f098c59f (diff)
downloadeclipse.platform.team-9450f5ae0bbea919ecce148106972d1ea492d433.tar.gz
eclipse.platform.team-9450f5ae0bbea919ecce148106972d1ea492d433.tar.xz
eclipse.platform.team-9450f5ae0bbea919ecce148106972d1ea492d433.zip
Bug 159258 [Project Sets] Problems importing team project set
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java188
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java19
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java19
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsDialog.java232
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsTable.java397
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java38
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties18
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java155
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java11
11 files changed, 1058 insertions, 22 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
index b7d02c580..a74b44d3b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
@@ -14,16 +14,8 @@ package org.eclipse.team.internal.ccvs.core;
import java.io.File;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.*;
+import java.util.*;
+ import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
@@ -122,13 +114,36 @@ public class CVSProjectSetCapability extends ProjectSetCapability {
// Confirm the projects to be loaded
Map infoMap = new HashMap(referenceStrings.length);
- IProject[] projects = asProjects(referenceStrings, infoMap);
- projects = confirmOverwrite(context, projects);
- if (projects == null)
- throw new OperationCanceledException();
+ IProject[] projects = asProjects(referenceStrings, infoMap);
+
+ projects = confirmOverwrite(context, projects);
+ if (projects == null)
+ return new IProject[0];
+
+ Map alternativeMap = isAdditionRepositoryInformationRequired(projects, infoMap);
+ if (!alternativeMap.isEmpty()) {
+ // display the dialog
+ Map alternativeRespositoriesMap = promptForAdditionRepositoryInformation(alternativeMap);
+ // replace repository location from a project load info with one from the prompter
+ if (alternativeRespositoriesMap != null) {
+ for (Iterator iterator = infoMap.values().iterator(); iterator
+ .hasNext();) {
+ LoadInfo loadInfoForProject = (LoadInfo) iterator.next();
+ ICVSRepositoryLocation selectedAlternativeRepository = (ICVSRepositoryLocation) alternativeRespositoriesMap
+ .get(loadInfoForProject.repositoryLocation);
+ // TODO: final modifier removed for LoadInfo.repositoryLocation
+ // another solution is to create a copy (clone) of LoadInfo, and replace the whole object
+ loadInfoForProject.repositoryLocation = selectedAlternativeRepository;
+ }
+ } else {
+ // operation canceled
+ return new IProject[0];
+ }
+ }
+
+ // Load the projects
+ return checkout(projects, infoMap, monitor);
- // Load the projects
- return checkout(projects, infoMap, monitor);
}
/**
@@ -198,7 +213,8 @@ public class CVSProjectSetCapability extends ProjectSetCapability {
* Internal class for adding projects to the workspace
*/
class LoadInfo {
- private final ICVSRepositoryLocation repositoryLocation;
+ // TODO: final modifier removed in order to replace a repository location before check out
+ private ICVSRepositoryLocation repositoryLocation;
private final String module;
private final IProject project;
private final CVSTag tag;
@@ -276,7 +292,8 @@ public class CVSProjectSetCapability extends ProjectSetCapability {
}
}
// No existing location was found so add this location to the list of known repositories
- KnownRepositories.getInstance().addRepository(newLocation, true);
+ // TODO: commented out (if we add repository here we won't be able to check for alternatives)
+ // KnownRepositories.getInstance().addRepository(newLocation, true);
return newLocation;
}
@@ -578,5 +595,140 @@ public class CVSProjectSetCapability extends ProjectSetCapability {
return null;
}
}
+
+ /**
+ * Checks whether a dialog prompting for an addition repository location is
+ * required.
+ *
+ * @see org.eclipse.team.internal.ccvs.ui.AlternativeRepositoryDialog
+ * @see org.eclipse.team.internal.ccvs.ui.AlternativeRepositoryTable
+ *
+ * @param projects
+ * an array of project to check out a mapping of project to
+ * project load information
+ *
+ * @return a mapping of project to project load information
+ *
+ *
+ * When non-empty map is returned it will contain a mapping of a repository
+ * location (<code>ICVSRepositoryLocation</code>) from the project set
+ * to a list of suggested, known repositories locations (<code>ICVSRepositoryLocation</code>)
+ * to use. The list contains at least one element - a default location (same
+ * as in the project set). It's always on the first position in the list.
+ * It's possible that the repository location is known, but even then we
+ * still allow user to select a different location. So, the default location
+ * is optionally followed by compatible locations found. Finally, the last
+ * positions are held by the rest of known locations.
+ *
+ * <p>
+ * The order in which items are kept in a list also reflects the way a combo
+ * box from the Alternative Repository dialog will look like.
+ * </p>
+ * <p>
+ * Structure of the list:
+ * <ul>
+ * <li>default location form the project set</li>
+ * <li>compatible locations (if found) - no particular order here</li>
+ * <li>other known locations - no particular order here neither</li>
+ * </ul>
+ * </p>
+ * An empty map is returned when the project set file contains all required
+ * information.
+ */
+ private static Map isAdditionRepositoryInformationRequired(
+ IProject[] projects, final Map infoMap) {
+
+ List confirmedProjectsList = Arrays.asList(projects);
+
+ if (infoMap == null)
+ return Collections.EMPTY_MAP;
+ Set projectSetRepositoryLocations = new HashSet();
+ for (Iterator iterator = infoMap.keySet().iterator(); iterator
+ .hasNext();) {
+ IProject project = (IProject) iterator.next();
+ if (confirmedProjectsList.contains(project)) {
+ LoadInfo loadInfo = (LoadInfo) infoMap.get(project);
+ projectSetRepositoryLocations.add(loadInfo.repositoryLocation);
+ }
+ }
+
+ // none of projects from project sets is confirmed to overwrite
+ if (projectSetRepositoryLocations.isEmpty()) {
+ return Collections.EMPTY_MAP;
+ }
+
+ List knownRepositories = Arrays.asList(KnownRepositories.getInstance()
+ .getRepositories());
+
+ Map resultMap = new HashMap();
+
+ if (knownRepositories.isEmpty()) {
+ // there are no known repositories so use repository location from
+ // the project set
+ for (Iterator iterator = projectSetRepositoryLocations.iterator(); iterator
+ .hasNext();) {
+ ICVSRepositoryLocation projectSetRepositoryLocation = (ICVSRepositoryLocation) iterator
+ .next();
+ ArrayList alternativeList = new ArrayList(1);
+ alternativeList.add(projectSetRepositoryLocation);
+ resultMap.put(projectSetRepositoryLocation,
+ alternativeList);
+ }
+ } else if (!knownRepositories.containsAll(projectSetRepositoryLocations)) {
+ // not all repositories from the project set are known
+
+ for (Iterator iterator = projectSetRepositoryLocations.iterator(); iterator
+ .hasNext();) {
+ ICVSRepositoryLocation projectSetRepositoryLocation = (ICVSRepositoryLocation) iterator
+ .next();
+
+ ArrayList alternativeList = new ArrayList();
+ for (Iterator iterator2 = knownRepositories.iterator(); iterator2
+ .hasNext();) {
+ ICVSRepositoryLocation knownRepositoryLocation = (ICVSRepositoryLocation) iterator2
+ .next();
+ if (isCompatible(knownRepositoryLocation,
+ projectSetRepositoryLocation)) {
+ // compatible repositories first
+ alternativeList.add(0, knownRepositoryLocation);
+ } else {
+ alternativeList.add(knownRepositoryLocation);
+ }
+ }
+
+ // Always put the repository location from the project set
+ // at the beginning (as default). There is a chance that this
+ // repository is known.
+ alternativeList.add(0, projectSetRepositoryLocation);
+
+ resultMap.put(projectSetRepositoryLocation,
+ alternativeList);
+ }
+ } // else { all repositories are known, we don't need to prompt for
+ // additional information }
+
+ return resultMap;
+ }
+
+ /**
+ * Same test as in org.eclipse.team.internal.ccvs.ui.CVSProjectPropertiesPage
+ *
+ * @see org.eclipse.team.internal.ccvs.ui.CVSProjectPropertiesPage#isCompatible
+ *
+ * @param location A location from known repositories collection
+ * @param oldLocation A location to check c
+ * @return Are given locations compatible
+ */
+ public static boolean isCompatible(ICVSRepositoryLocation location, ICVSRepositoryLocation oldLocation) {
+ if (!location.getHost().equals(oldLocation.getHost())) return false;
+ if (!location.getRootDirectory().equals(oldLocation.getRootDirectory())) return false;
+ if (location.equals(oldLocation)) return false;
+ return true;
+ }
+
+ private Map promptForAdditionRepositoryInformation(Map alternativeMap) {
+ IUserAuthenticator authenticator = CVSRepositoryLocation.getAuthenticator();
+ return authenticator.promptToConfigureRepositoryLocations(alternativeMap);
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
index 9f4103285..6eb5cbc7f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core;
+import java.util.Map;
+
/**
* IUserAuthenticators are used to ensure that the user
* is validated for access to a given repository. The
@@ -130,4 +132,21 @@ public interface IUserAuthenticator {
* @return true if new host key should be accepted
*/
public boolean promptForHostKeyChange(ICVSRepositoryLocation location);
+
+ /**
+ * If the project set contains only partial repository information (some of
+ * location are unknown) we will display a dialog to associate each project
+ * set repository with a known repository location or create a new one or at
+ * last use the default locations.
+ *
+ * @param alternativeMap
+ * a map of CVS repository locations form the project set (as
+ * keys) and a list of suggested alternative (known) CVS
+ * repository locations (as values)
+ * @return a map of CVS repository locations from the project set (as keys)
+ * and confirmed CVS repository locations to be used during checkout
+ * (as values) or <code>null</code> if the operation is to be
+ * canceled
+ */
+ public abstract Map promptToConfigureRepositoryLocations(Map alternativeMap);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
index 2850be0f2..fff6803c6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
@@ -353,6 +353,16 @@ public class CVSUIMessages extends NLS {
public static String CommitWizardFileTypePage_0;
public static String CommitWizardFileTypePage_2;
public static String CommitWizardFileTypePage_3;
+
+ public static String ConfigureRepositoryLocationsWizard_title;
+ public static String ConfigureRepositoryLocationsWizard_message;
+ public static String ConfigureRepositoryLocationsWizard_createLocation;
+ public static String ConfigureRepositoryLocationsWizard_createLocationTooltip;
+ public static String ConfigureRepositoryLocationsWizard_column0;
+ public static String ConfigureRepositoryLocationsWizard_column1;
+ public static String ConfigureRepositoryLocationsWizard_showConnection;
+ public static String ConfigureRepositoryLocationsWizardDialog_finish;
+
public static String CommitSyncAction_questionRelease;
public static String CommitSyncAction_titleRelease;
@@ -508,6 +518,15 @@ public class CVSUIMessages extends NLS {
public static String NewLocationWizard_validationFailedText;
public static String NewLocationWizard_validationFailedTitle;
public static String NewLocationWizard_exception;
+
+ public static String AlternativeLocationWizard_title;
+ public static String AlternativeLocationWizard_heading;
+ public static String AlternativeLocationWizard_description;
+ public static String AlternativeLocationWizard_validationFailedText;
+ public static String AlternativeLocationWizard_validationFailedTitle;
+ public static String AlternativeLocationWizard_exception;
+
+ public static String AlternativeConfigurationWizardMainPage_0;
public static String OpenLogEntryAction_deletedTitle;
public static String OpenLogEntryAction_deleted;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsDialog.java
new file mode 100644
index 000000000..d6914f0df
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsDialog.java
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * 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.ccvs.ui;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.ui.wizards.AlternativeLocationWizard;
+import org.eclipse.ui.PlatformUI;
+
+public class ConfigureRepositoryLocationsDialog extends TitleAreaDialog {
+
+ private Image dlgTitleImage;
+ private ConfigureRepositoryLocationsTable fConfigureRepositoryLocationsTable;
+
+ /**
+ * Creates a new AlternativeRepositoryDialog.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param alternativesMap
+ * Map with a repository location (ICVSRepositoryLocation) from
+ * the Team Project Set as a key and list of alternatives found
+ * (also ICVSRepositoryLocation) as a value.
+ * @param message
+ * a message to display to the user
+ */
+ public ConfigureRepositoryLocationsDialog(Shell parentShell, Map alternativesMap) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ fConfigureRepositoryLocationsTable = new ConfigureRepositoryLocationsTable(
+ alternativesMap);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Control contents = super.createContents(parent);
+ setTitle(CVSUIMessages.ConfigureRepositoryLocationsWizard_title);
+ setMessage(CVSUIMessages.ConfigureRepositoryLocationsWizard_message);
+ dlgTitleImage = CVSUIPlugin.getPlugin().getImageDescriptor(
+ ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION).createImage();
+ setTitleImage(dlgTitleImage);
+ return contents;
+ }
+
+ public boolean close() {
+ if (dlgTitleImage != null) {
+ dlgTitleImage.dispose();
+ }
+ return super.close();
+ }
+
+ /*
+ * (non-Javadoc) Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(CVSUIMessages.ConfigureRepositoryLocationsWizard_title);
+ // set F1 help
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell,
+ IHelpContextIds.ALTERNATIVE_REPOSITORY_DIALOG);
+ }
+
+ /**
+ * @see Dialog#createDialogArea
+ */
+ protected Control createDialogArea(Composite parent) {
+ initializeDialogUnits(parent);
+
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+
+ GridData childData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(childData);
+
+ Composite table = fConfigureRepositoryLocationsTable.createControl(composite);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ table.setLayoutData(gridData);
+
+ final Button showMethodButton = new Button(composite, SWT.CHECK);
+ showMethodButton
+ .setText(CVSUIMessages.ConfigureRepositoryLocationsWizard_showConnection);
+ showMethodButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ fConfigureRepositoryLocationsTable
+ .setShowConnectionMethod(showMethodButton
+ .getSelection());
+ }
+ });
+ showMethodButton.setEnabled(fConfigureRepositoryLocationsTable
+ .noDuplicateRepositoryLocationFound());
+ showMethodButton.setSelection(!fConfigureRepositoryLocationsTable
+ .noDuplicateRepositoryLocationFound());
+ showMethodButton.setLayoutData(new GridData(
+ GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ final Button createLocationButton = new Button(composite, SWT.PUSH);
+ createLocationButton
+ .setText(CVSUIMessages.ConfigureRepositoryLocationsWizard_createLocation);
+ createLocationButton
+ .setToolTipText(CVSUIMessages.ConfigureRepositoryLocationsWizard_createLocationTooltip);
+ createLocationButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+
+ CVSRepositoryLocation selectedAlternativeRepository = fConfigureRepositoryLocationsTable
+ .getSelectedAlternativeRepository();
+
+ Properties properties = new Properties();
+ properties
+ .put(
+ "connection", selectedAlternativeRepository.getMethod().getName()); //$NON-NLS-1$
+ properties.put(
+ "user", selectedAlternativeRepository.getUsername()); //$NON-NLS-1$
+ // TODO: retrieve password (if available) and use it to prime
+ // the field
+ // properties.put("password", ""); //$NON-NLS-1$
+ properties.put("host", selectedAlternativeRepository.getHost()); //$NON-NLS-1$
+ int port = selectedAlternativeRepository.getPort();
+ if (port != ICVSRepositoryLocation.USE_DEFAULT_PORT)
+ properties.put("port", String.valueOf(port)); //$NON-NLS-1$
+ properties
+ .put(
+ "root", selectedAlternativeRepository.getRootDirectory()); //$NON-NLS-1$
+
+ AlternativeLocationWizard wizard = new AlternativeLocationWizard(
+ properties);
+ wizard.setSwitchPerspectives(false);
+ WizardDialog dialog = new ConfigureRepositoryLocationsWizardDialog(
+ getShell(), wizard);
+ dialog.open();
+
+ ICVSRepositoryLocation location = wizard.getLocation();
+ if (location != null)
+ fConfigureRepositoryLocationsTable
+ .addAlternativeRepositoryToSelection(location);
+ }
+ });
+ createLocationButton.setEnabled(fConfigureRepositoryLocationsTable
+ .getSelection().getFirstElement() != null);
+ createLocationButton.setLayoutData(new GridData(
+ GridData.HORIZONTAL_ALIGN_END));
+
+ fConfigureRepositoryLocationsTable.getViewer().addSelectionChangedListener(
+ new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection) event
+ .getSelection();
+ Object firstElement = sel.getFirstElement();
+ createLocationButton.setEnabled(firstElement != null);
+ }
+ });
+
+ return composite;
+ }
+
+ public Map getSelected() {
+ return fConfigureRepositoryLocationsTable.getSelected();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ */
+ protected IDialogSettings getDialogBoundsSettings() {
+ String sectionName = getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
+ IDialogSettings settings = CVSUIPlugin.getPlugin().getDialogSettings();
+ IDialogSettings section = settings.getSection(sectionName);
+ if (section == null) {
+ section = settings.addNewSection(sectionName);
+ section.put("DIALOG_HEIGHT", 300); //$NON-NLS-1$
+ section.put("DIALOG_WIDTH", 600); //$NON-NLS-1$
+ }
+ return section;
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsStrategy()
+ * @since 3.2
+ */
+ protected int getDialogBoundsStrategy() {
+ return DIALOG_PERSISTLOCATION | DIALOG_PERSISTSIZE;
+ }
+
+ /**
+ * This class is made only to change Wizard's default "Finish" button label
+ * to "Create".
+ */
+ private class ConfigureRepositoryLocationsWizardDialog extends WizardDialog {
+
+ public ConfigureRepositoryLocationsWizardDialog(Shell parentShell,
+ IWizard newWizard) {
+ super(parentShell, newWizard);
+ }
+
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ if (id == IDialogConstants.FINISH_ID)
+ label = CVSUIMessages.ConfigureRepositoryLocationsWizardDialog_finish;
+ return super.createButton(parent, id, label, defaultButton);
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsTable.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsTable.java
new file mode 100644
index 000000000..4a2bea411
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ConfigureRepositoryLocationsTable.java
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.ccvs.ui;
+
+import java.util.*;
+import java.util.List;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.internal.ccvs.core.CVSProjectSetCapability;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
+
+public class ConfigureRepositoryLocationsTable implements ICellModifier,
+ IStructuredContentProvider, ITableLabelProvider {
+
+ private static final class AlternativeRepositoryComparator extends
+ ViewerComparator {
+
+ public AlternativeRepositoryComparator() {
+ }
+
+ private int getCategory(Object element) {
+ if (element instanceof RepositoryLocationItem) {
+ return 0;
+ }
+ return 2;
+ }
+
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ final int compare = getCategory(e1) - getCategory(e2);
+ if (compare != 0)
+ return compare;
+ return super.compare(viewer, ((Item) e1).location,
+ ((Item) e2).location);
+ }
+ }
+
+ public abstract static class Item implements Comparable {
+ public final ICVSRepositoryLocation location;
+ public List alternativeList;
+ public int selected;
+
+ public Item(ICVSRepositoryLocation name, List alternative) {
+ this.location = name;
+ this.alternativeList = alternative;
+ this.selected = 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object o) {
+ return location.getLocation(false).compareTo(
+ ((Item) o).location.getLocation(false));
+ }
+ }
+
+ public static class RepositoryLocationItem extends Item {
+ public RepositoryLocationItem(
+ ICVSRepositoryLocation projectSetRepositoryLocation,
+ List suggestedRepositoryLocations) {
+ super(projectSetRepositoryLocation, suggestedRepositoryLocations);
+ }
+ }
+
+ protected static final String ITEM = "item"; //$NON-NLS-1$
+ protected static final String PROPERTY_ALTERNATIVE_LIST = "alternativeList"; //$NON-NLS-1$
+
+ private TableViewer fTableViewer;
+
+ private CellEditor[] cellEditors;
+
+ private TextCellEditor dummyAlternativeRepositoryEditor;
+
+ private Table table;
+
+ /**
+ * List of <code>AlternativeRepositoryTable.RepositoryLocationItem</code>
+ * used as an input to the table.
+ */
+ private List fAlternatives;
+
+ /**
+ * Indicates whether a connection method should be displayed in the first
+ * column - project set information.
+ */
+ private boolean fShowConnectionMethod;
+
+ private boolean fNoDuplicateRepositoryLocationFound;
+
+ public ConfigureRepositoryLocationsTable(Map alternativesMap) {
+ fAlternatives = new ArrayList();
+ Set checkSet = new HashSet();
+ for (Iterator iterator = alternativesMap.entrySet().iterator(); iterator
+ .hasNext();) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ fAlternatives
+ .add(new ConfigureRepositoryLocationsTable.RepositoryLocationItem(
+ (ICVSRepositoryLocation) entry.getKey(),
+ (List) entry.getValue()));
+ fNoDuplicateRepositoryLocationFound = checkSet
+ .add(excludeConnectionMethod((ICVSRepositoryLocation) entry
+ .getKey()));
+ }
+ fShowConnectionMethod = !fNoDuplicateRepositoryLocationFound;
+ // we won't need it anymore
+ checkSet = null;
+ }
+
+ public Composite createControl(final Composite composite) {
+ /**
+ * Create a table.
+ */
+ table = new Table(composite, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI
+ | SWT.FULL_SELECTION);
+ // table.setLayoutData(SWTUtils.createHVFillGridData());
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ table.addListener(SWT.MeasureItem, new Listener() {
+ public void handleEvent(Event event) {
+ // int clientWidth = table.getClientArea().width;
+ event.height = event.gc.getFontMetrics().getHeight() + 5;
+ // event.width = clientWidth * 2;
+ }
+ });
+
+ /**
+ * The 'Project Set repository location' column
+ */
+ final TableColumn projectSetRepositoryColumn = new TableColumn(table,
+ SWT.NONE, 0);
+ projectSetRepositoryColumn
+ .setText(CVSUIMessages.ConfigureRepositoryLocationsWizard_column0);
+
+ /**
+ * The 'Alternative repository locations' column
+ */
+ final TableColumn alternativeRepositoryColums = new TableColumn(table,
+ SWT.NONE, 1);
+ alternativeRepositoryColums
+ .setText(CVSUIMessages.ConfigureRepositoryLocationsWizard_column1);
+
+ composite.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ Rectangle area = composite.getClientArea();
+ Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ ScrollBar vBar = table.getVerticalBar();
+ int width = area.width - table.computeTrim(0, 0, 0, 0).width
+ - vBar.getSize().x;
+ if (size.y > area.height + table.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = vBar.getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = table.getSize();
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ projectSetRepositoryColumn.setWidth(width / 2);
+ alternativeRepositoryColums.setWidth(width
+ - projectSetRepositoryColumn.getWidth());
+ table.setSize(area.width, area.height);
+ } else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ table.setSize(area.width, area.height);
+ projectSetRepositoryColumn.setWidth(width / 2);
+ alternativeRepositoryColums.setWidth(width
+ - projectSetRepositoryColumn.getWidth());
+ }
+ }
+ });
+
+ /**
+ * Create a viewer for the table.
+ */
+ fTableViewer = new TableViewer(table);
+ fTableViewer.setContentProvider(this);
+ fTableViewer.setLabelProvider(this);
+ fTableViewer.setComparator(new AlternativeRepositoryComparator());
+
+ /**
+ * Add a cell editor in the 'Alternative repository locations' column
+ */
+ new TableEditor(table);
+
+ cellEditors = new CellEditor[2];
+ cellEditors[0] = null;
+ // to enable cell editing, create a dummy cell editor
+ cellEditors[1] = dummyAlternativeRepositoryEditor = new TextCellEditor(
+ table, SWT.READ_ONLY);
+
+ fTableViewer.setCellEditors(cellEditors);
+ fTableViewer.setColumnProperties(new String[] { ITEM,
+ PROPERTY_ALTERNATIVE_LIST });
+ fTableViewer.setCellModifier(this);
+ fTableViewer.setInput(fAlternatives);
+
+ return table;
+ }
+
+ public Object getValue(Object element, String property) {
+
+ final Item item = (Item) element;
+
+ if (PROPERTY_ALTERNATIVE_LIST.equals(property)) {
+ return new Integer(item.selected);
+ }
+ return null;
+ }
+
+ public boolean canModify(Object element, String property) {
+ // set the correct cell editor for this element
+ cellEditors[1] = getCellEditor(element);
+ // only allow modification for editable elements
+ return PROPERTY_ALTERNATIVE_LIST.equals(property);
+ }
+
+ private CellEditor getCellEditor(Object element) {
+
+ if (element instanceof RepositoryLocationItem) {
+
+ // create combo-box list of alternative repositories
+ List alternativeList = ((RepositoryLocationItem) element).alternativeList;
+ String[] alternativeNames = new String[alternativeList.size()];
+ int i = 0;
+ for (Iterator iterator = alternativeList.iterator(); iterator
+ .hasNext();) {
+ CVSRepositoryLocation repo = (CVSRepositoryLocation) iterator
+ .next();
+ alternativeNames[i++] = repo.getLocation();
+ }
+ return new ComboBoxCellEditor(table, alternativeNames,
+ SWT.READ_ONLY);
+ }
+ return dummyAlternativeRepositoryEditor;
+ }
+
+ public void modify(Object element, String property, Object value) {
+
+ final IStructuredSelection selection = (IStructuredSelection) fTableViewer
+ .getSelection();
+ final Item item = (Item) selection.getFirstElement();
+ if (item == null)
+ return;
+
+ final int comboIndex = ((Integer) value).intValue();
+
+ if (PROPERTY_ALTERNATIVE_LIST.equals(property)) {
+ item.selected = comboIndex;
+ }
+ fTableViewer.refresh(item);
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ final Item item = (Item) element;
+
+ switch (columnIndex) {
+ case 0:
+ return fShowConnectionMethod ? item.location.getLocation(false)
+ : excludeConnectionMethod(item.location);
+ case 1:
+ return ((CVSRepositoryLocation) item.alternativeList
+ .get(item.selected)).getLocation();
+ default:
+ return null;
+ }
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((Collection) inputElement).toArray();
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public IStructuredSelection getSelection() {
+ return (IStructuredSelection) fTableViewer.getSelection();
+ }
+
+ public TableViewer getViewer() {
+ return fTableViewer;
+ }
+
+ /**
+ * @return a selected (in a combo box) alternative repository location for
+ * the first selected element
+ */
+ public CVSRepositoryLocation getSelectedAlternativeRepository() {
+ RepositoryLocationItem firstElement = (RepositoryLocationItem) getSelection()
+ .getFirstElement();
+ return (CVSRepositoryLocation) firstElement.alternativeList
+ .get(firstElement.selected);
+ }
+
+ public void addAlternativeRepositoryToSelection(
+ ICVSRepositoryLocation location) {
+ // add newly created repository location to all selected elements
+ for (Iterator iterator = getSelection().iterator(); iterator.hasNext();) {
+ RepositoryLocationItem selectedItem = (RepositoryLocationItem) iterator
+ .next();
+ selectedItem.alternativeList.add(0, location);
+ selectedItem.selected = 0;
+ // fTableViewer.refresh(selectedItem);
+ }
+
+ // add newly created repository location to not-selected elements
+ // new location must be compatible with the one from the project set
+ for (int i = 0; i < fTableViewer.getTable().getItemCount(); i++) {
+ Object element = fTableViewer.getElementAt(i);
+ if (!getSelection().toList().contains(element)) {
+ RepositoryLocationItem locationItem = (RepositoryLocationItem) element;
+ if (CVSProjectSetCapability.isCompatible(location,
+ locationItem.location)) {
+ locationItem.alternativeList.add(location);
+ }
+ }
+ }
+
+ // update labels because of the first loop - first item changed
+ fTableViewer.refresh(true);
+ }
+
+ /**
+ * @return A map with repository location from the project set as a key and
+ * selected repository location from a combo box as value.
+ */
+ public Map getSelected() {
+ Map map = new HashMap();
+ for (Iterator iterator = fAlternatives.iterator(); iterator.hasNext();) {
+ ConfigureRepositoryLocationsTable.RepositoryLocationItem rli = (ConfigureRepositoryLocationsTable.RepositoryLocationItem) iterator
+ .next();
+ map.put(rli.location, rli.alternativeList.get(rli.selected));
+ }
+ return map;
+ }
+
+ public void setShowConnectionMethod(boolean show) {
+ fShowConnectionMethod = show;
+ fTableViewer.refresh(true);
+ }
+
+ private String excludeConnectionMethod(ICVSRepositoryLocation location) {
+ String user = location.getUsername();
+ String host = location.getHost();
+ int port = location.getPort();
+ String root = location.getRootDirectory();
+
+ return (user != null && !user.equals("") ? (user + CVSRepositoryLocation.HOST_SEPARATOR) //$NON-NLS-1$
+ : "") + //$NON-NLS-1$
+ host
+ + CVSRepositoryLocation.COLON
+ + ((port == CVSRepositoryLocation.USE_DEFAULT_PORT) ? "" : (new Integer(port).toString())) + //$NON-NLS-1$
+ root;
+ }
+
+ public boolean noDuplicateRepositoryLocationFound() {
+ return fNoDuplicateRepositoryLocationFound;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java
index c42d2656f..ac3ca492c 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java
@@ -33,6 +33,7 @@ public interface IHelpContextIds {
public static final String KEYBOARD_INTERACTIVE_DIALOG = PREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$
public static final String COMMIT_SET_DIALOG = PREFIX + "commit_set_dialog_context"; //$NON-NLS-1$
public static final String TAG_UNCOMMITED_PROMPT = PREFIX + "tag_uncommmited_dialog_context"; //$NON-NLS-1$
+ public static final String ALTERNATIVE_REPOSITORY_DIALOG = PREFIX + "alternative_repository_dialog_context"; //$NON-NLS-1$
// Different uses of the TagSelectionDialog
public static final String REPLACE_TAG_SELECTION_DIALOG = PREFIX + "replace_tag_selection_dialog_context"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
index 41f4f4fbd..f28cc5a59 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;
+import java.util.Map;
+
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.window.Window;
@@ -321,4 +323,40 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
}
return openConfirm[0];
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptToConfigureRepositoryLocations(java.util.Map)
+ */
+ public Map promptToConfigureRepositoryLocations(final Map alternativeMap) {
+ final Map[] result = new Map[1];
+ Display display = Display.getCurrent();
+ if (display != null) {
+ result[0] = openAlternativeRepositoryDialog(alternativeMap);
+ } else {
+ // sync exec in default thread
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ result[0] = openAlternativeRepositoryDialog(alternativeMap);
+ }
+ });
+ }
+ return result[0];
+ }
+
+ /**
+ * Opens the Alternative Repository Selection dialog.
+ *
+ * @param alternativeMap
+ * @return a map with selected repositories to use or <code>null</code>
+ * when canceled.
+ */
+ private Map openAlternativeRepositoryDialog(Map alternativeMap) {
+ ConfigureRepositoryLocationsDialog dialog = new ConfigureRepositoryLocationsDialog(
+ null, alternativeMap);
+ int result = dialog.open();
+ return result == IDialogConstants.CANCEL_ID ? null : dialog
+ .getSelected();
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 4c315468e..f4f557ecc 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -288,6 +288,15 @@ CommitWizardFileTypePage_0=Add Resources
CommitWizardFileTypePage_2=Unknown new files detected.
CommitWizardFileTypePage_3=New files with the following unknown names or extensions have been detected in the workspace. Please specify whether these files should be stored as text or binary and whether this decision should be remembered.
+ConfigureRepositoryLocationsWizard_title=Specify Repository Information
+ConfigureRepositoryLocationsWizard_message=The project set only contains partial repository information. You may use the table below to specify the complete repository information for each repository in the project set or click OK to use the default repository location.
+ConfigureRepositoryLocationsWizard_createLocation=Create Location
+ConfigureRepositoryLocationsWizard_createLocationTooltip=Creates a new repository location
+ConfigureRepositoryLocationsWizard_column0=Project set repository information
+ConfigureRepositoryLocationsWizard_column1=Repository Location
+ConfigureRepositoryLocationsWizard_showConnection=Show connection method
+ConfigureRepositoryLocationsWizardDialog_finish=Create
+
CommitSyncAction_questionRelease=You have changes that conflict with the server. Release those changes?
CommitSyncAction_titleRelease=Confirm Overwrite
CommitSyncAction_releaseAll=Release all changes, overriding any conflicting changes on the server.
@@ -452,6 +461,15 @@ NewLocationWizard_validationFailedText=Error validating location: "{0}"\n\nKeep
NewLocationWizard_validationFailedTitle=Unable to Validate
NewLocationWizard_exception=Unable to create repository location
+AlternativeLocationWizard_title=Configure CVS Repository
+AlternativeLocationWizard_heading=Configure CVS Repository
+AlternativeLocationWizard_description=Configure the repository location from the project set
+AlternativeLocationWizard_validationFailedText=Error validating location: "{0}"\n\nUse location anyway?
+AlternativeLocationWizard_validationFailedTitle=Unable to Validate
+AlternativeLocationWizard_exception=Unable to create repository location
+
+AlternativeConfigurationWizardMainPage_0=Location already exists. Close this dialog and select the location from a combo box.
+
OpenLogEntryAction_deletedTitle=Resource is Deleted
OpenLogEntryAction_deleted=The selected revision represents a deletion. It cannot be opened.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java
new file mode 100644
index 000000000..aa5c25b7a
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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.ccvs.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
+import org.eclipse.team.internal.ccvs.ui.*;
+
+public class AlternativeLocationWizard extends NewLocationWizard {
+
+ private ICVSRepositoryLocation location;
+
+ public boolean performFinish() {
+ final ICVSRepositoryLocation[] location = new ICVSRepositoryLocation[] { null };
+ boolean useLocation = true;
+ try {
+ // Create a handle to a repository location
+ location[0] = mainPage.getLocation();
+ // Add the location quitely so we can validate
+ location[0] = KnownRepositories.getInstance().addRepository(location[0], false /* don't tell anybody */);
+
+ if (mainPage.getValidate()) {
+ try {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ location[0].validateConnection(monitor);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ // Cancelled by user. Fall through to dispose of location
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ if (t instanceof TeamException) {
+ throw (TeamException)t;
+ } else if (t instanceof Exception) {
+ throw CVSException.wrapException((Exception)t);
+ } else {
+ throw CVSException.wrapException(e);
+ }
+ }
+ }
+ } catch (TeamException e) {
+ if (location[0] == null) {
+ // Exception creating the root, we cannot continue
+ CVSUIPlugin.openError(getContainer().getShell(), CVSUIMessages.AlternativeLocationWizard_exception, null, e);
+ return false;
+ } else {
+ // Exception validating. We can continue if the user wishes.
+ IStatus error = e.getStatus();
+ if (error.isMultiStatus() && error.getChildren().length == 1) {
+ error = error.getChildren()[0];
+ }
+
+ if (error.isMultiStatus()) {
+ CVSUIPlugin.openError(getContainer().getShell(), CVSUIMessages.AlternativeLocationWizard_validationFailedTitle, null, e);
+ } else {
+ useLocation = MessageDialog.openQuestion(getContainer().getShell(),
+ CVSUIMessages.AlternativeLocationWizard_validationFailedTitle,
+ NLS.bind(CVSUIMessages.AlternativeLocationWizard_validationFailedText, (new Object[] {error.getMessage()})));
+ }
+ }
+ }
+
+ if (useLocation) {
+ KnownRepositories.getInstance().addRepository(location[0], true /* let the world know */);
+ } else {
+ KnownRepositories.getInstance().disposeRepository(location[0]);
+ }
+
+ this.location = useLocation ? location[0] : null;
+ return useLocation;
+ }
+
+ public AlternativeLocationWizard(Properties initialProperties) {
+ super(initialProperties);
+ }
+
+ /**
+ * Creates the wizard pages
+ */
+ public void addPages() {
+ super.addPages();
+ }
+
+ protected ConfigurationWizardMainPage createMainPage() {
+ return new AlternativeConfigurationWizardMainPage("repositoryPage1", CVSUIMessages.AlternativeLocationWizard_heading, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); //$NON-NLS-1$
+ }
+
+ public ICVSRepositoryLocation getLocation() {
+ return location;
+ }
+
+ /**
+ * Wizard page for entering information about a CVS repository location used
+ * while working with Alternative Repository dialog.
+ *
+ * <p>
+ * Validation works slightly different. When user wants to create a
+ * location, which already exists he/she will be informed that the location
+ * can be obtained from a combo-box.
+ * </p>
+ *
+ * TODO: enable to create existing location, instead of displaying an error
+ * close the dialog and select the entry with that location in the combo box
+ */
+ private class AlternativeConfigurationWizardMainPage extends
+ ConfigurationWizardMainPage {
+
+ public AlternativeConfigurationWizardMainPage(String pageName,
+ String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage#validateFields()
+ */
+ protected void validateFields() {
+ super.validateFields();
+ if (!isPageComplete()
+ && getErrorMessage() != null
+ && getErrorMessage().equals(
+ CVSUIMessages.ConfigurationWizardMainPage_0)) {
+ // add an information that the location already exists and can
+ // be selected from a combo box
+ setErrorMessage(CVSUIMessages.AlternativeConfigurationWizardMainPage_0);
+ }
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
index d758d001d..501345049 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
@@ -525,7 +525,7 @@ public class ConfigurationWizardMainPage extends CVSWizardPage {
* Validates the contents of the editable fields and set page completion
* and error messages appropriately.
*/
- private void validateFields() {
+ protected void validateFields() {
String user = userCombo.getText();
IStatus status = validateUserName(user);
if (!isStatusOK(status)) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java
index e4b16e59d..ff7a2fbd6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java
@@ -32,8 +32,8 @@ import org.eclipse.ui.*;
public class NewLocationWizard extends Wizard implements INewWizard {
- private ConfigurationWizardMainPage mainPage;
- private Properties properties = null;
+ protected ConfigurationWizardMainPage mainPage;
+ protected Properties properties = null;
private boolean switchPerspectives = true;
/**
@@ -65,7 +65,7 @@ public class NewLocationWizard extends Wizard implements INewWizard {
* Creates the wizard pages
*/
public void addPages() {
- mainPage = new ConfigurationWizardMainPage("repositoryPage1", CVSUIMessages.NewLocationWizard_heading, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); //$NON-NLS-1$
+ mainPage = createMainPage();
if (properties != null) {
mainPage.setProperties(properties);
}
@@ -74,6 +74,11 @@ public class NewLocationWizard extends Wizard implements INewWizard {
mainPage.setDialogSettings(getDialogSettings());
addPage(mainPage);
}
+
+ protected ConfigurationWizardMainPage createMainPage() {
+ return new ConfigurationWizardMainPage("repositoryPage1", CVSUIMessages.NewLocationWizard_heading, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); //$NON-NLS-1$
+ }
+
/*
* @see IWizard#performFinish
*/

Back to the top