Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-11-01 20:08:20 +0000
committerMichael Valenta2002-11-01 20:08:20 +0000
commitd2fb3b5d2d8f19f6b0a69e5a10f81b8d926cf7ea (patch)
treed7ebacd672eb9fdbc32cbe1d15aba928cc01456d
parent631e27d322dd7990c1ca4caf08f7b96268505477 (diff)
downloadeclipse.platform.team-d2fb3b5d2d8f19f6b0a69e5a10f81b8d926cf7ea.tar.gz
eclipse.platform.team-d2fb3b5d2d8f19f6b0a69e5a10f81b8d926cf7ea.tar.xz
eclipse.platform.team-d2fb3b5d2d8f19f6b0a69e5a10f81b8d926cf7ea.zip
20955: [CVS UI] Would like to name repository locations
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java95
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java53
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java8
4 files changed, 157 insertions, 11 deletions
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 1f02c6638..c6a1ffaf0 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
@@ -141,9 +141,9 @@ CVSLocalCompareEditorInput.title=CVS Compare [{0}]
CVSOperationCancelledException.operationCancelled=Operation Cancelled
-CVSPropertiesPage.connectionType=Connection type:
-CVSPropertiesPage.user=User:
-CVSPropertiesPage.password=Password:
+CVSPropertiesPage.connectionType=&Connection type:
+CVSPropertiesPage.user=&User:
+CVSPropertiesPage.password=&Password:
CVSPropertiesPage.host=Host:
CVSPropertiesPage.port=Port:
CVSPropertiesPage.path=Repository path:
@@ -725,8 +725,10 @@ CVSProjectPropertiesPage.fetchAbsentDirectoriesOnUpdate=Fetch absent or new dire
CVSRepositoryPropertiesPage.Confirm_Project_Sharing_Changes_1=Confirm Project Sharing Changes
CVSRepositoryPropertiesPage.There_are_projects_in_the_workspace_shared_with_this_repository_2=There are projects in the workspace shared with this repository. The projects will be updated with the new information that you have entered
CVSRepositoryPropertiesPage.sharedProject=The projects that are shared with {0} are:
-CVSRepositoryPropertiesPage.useDefaultProgramName=Expect the default program name "cvs" in text message prefixes from this server
-CVSRepositoryPropertiesPage.useProgramName=Expect a custom program name:
+CVSRepositoryPropertiesPage.useDefaultProgramName=Expect the &default program name "cvs" in text message prefixes from this server
+CVSRepositoryPropertiesPage.useProgramName=Expect a custom &program name:
+CVSRepositoryPropertiesPage.useLocationAsLabel=Use the &repository identification string as the label
+CVSRepositoryPropertiesPage.useCustomLabel=Use a custom &label:
CVSProjectSetSerializer.Confirm_Overwrite_Project_8=Confirm Overwrite Project
CVSProjectSetSerializer.The_project_{0}_already_exists._Do_you_wish_to_overwrite_it__9=The project {0} already exists. Do you wish to overwrite it?
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
index 1942ea3d4..a31c71ec4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
@@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
@@ -62,6 +63,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
boolean passwordChanged;
boolean connectionInfoChanged;
boolean programNameChanged;
+ boolean labelChanged;
IUserInfo info;
@@ -69,6 +71,10 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
private Text programNameText;
private Button useDefaultProgramName;
private Button useCustomProgramName;
+ // Label
+ private Button useLocationAsLabel;
+ private Button useCustomLabel;
+ private Text labelText;
/*
* @see PreferencesPage#createContents
@@ -81,6 +87,32 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
GridLayout layout = new GridLayout();
layout.numColumns = 3;
composite.setLayout(layout);
+
+ // Repository Label
+ // create a composite to ensure the radio buttons come in the correct order
+ Composite labelGroup = new Composite(composite, SWT.NONE);
+ GridData data = new GridData();
+ data.horizontalSpan = 3;
+ labelGroup.setLayoutData(data);
+ layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ labelGroup.setLayout(layout);
+ Listener labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ labelChanged = true;
+ updateWidgetEnablements();
+ }
+ };
+ useLocationAsLabel = createRadioButton(labelGroup, Policy.bind("CVSRepositoryPropertiesPage.useLocationAsLabel"), 3); //$NON-NLS-1$
+ useCustomLabel = createRadioButton(labelGroup, Policy.bind("CVSRepositoryPropertiesPage.useCustomLabel"), 1); //$NON-NLS-1$
+ useCustomLabel.addListener(SWT.Selection, labelListener);
+ labelText = createTextField(labelGroup);
+ labelText.addListener(SWT.Modify, labelListener);
+
+ // Add some extra space
+ createLabel(composite, "", 3); //$NON-NLS-1$
Label label = createLabel(composite, Policy.bind("CVSPropertiesPage.connectionType"), 1); //$NON-NLS-1$
methodType = createCombo(composite);
@@ -107,7 +139,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
// Remote CVS program name
// create a composite to ensure the radio buttons come in the correct order
Composite programNameGroup = new Composite(composite, SWT.NONE);
- GridData data = new GridData();
+ data = new GridData();
data.horizontalSpan = 3;
programNameGroup.setLayoutData(data);
layout = new GridLayout();
@@ -115,7 +147,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
layout.marginHeight = 0;
layout.marginWidth = 0;
programNameGroup.setLayout(layout);
- Listener listener = new Listener() {
+ Listener programNameListener = new Listener() {
public void handleEvent(Event event) {
programNameChanged = true;
updateWidgetEnablements();
@@ -123,9 +155,9 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
};
useDefaultProgramName = createRadioButton(programNameGroup, Policy.bind("CVSRepositoryPropertiesPage.useDefaultProgramName"), 3); //$NON-NLS-1$
useCustomProgramName = createRadioButton(programNameGroup, Policy.bind("CVSRepositoryPropertiesPage.useProgramName"), 1); //$NON-NLS-1$
- useCustomProgramName.addListener(SWT.Selection, listener);
+ useCustomProgramName.addListener(SWT.Selection, programNameListener);
programNameText = createTextField(programNameGroup);
- programNameText.addListener(SWT.Modify, listener);
+ programNameText.addListener(SWT.Modify, programNameListener);
initializeValues();
updateWidgetEnablements();
@@ -248,10 +280,27 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
portLabel.setText("" + port); //$NON-NLS-1$
}
pathLabel.setText(location.getRootDirectory());
+
+ // get the program name
String programName = ((CVSRepositoryLocation)location).getRemoteCVSProgramName();
programNameText.setText(programName);
useDefaultProgramName.setSelection(programName == CVSRepositoryLocation.DEFAULT_REMOTE_CVS_PROGRAM_NAME);
useCustomProgramName.setSelection(!useDefaultProgramName.getSelection());
+
+ // get the repository label
+ String label = null;
+ try {
+ RepositoryRoot root = CVSUIPlugin.getPlugin().getRepositoryManager().getRepositoryRootFor(location);
+ label = root.getName();
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e);
+ }
+ useLocationAsLabel.setSelection(label == null);
+ useCustomLabel.setSelection(!useLocationAsLabel.getSelection());
+ if (label == null) {
+ label = location.getLocation();
+ }
+ labelText.setText(label);
}
/*
@@ -262,6 +311,9 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
if (programNameChanged) {
recordNewProgramName((CVSRepositoryLocation)location);
}
+ if (labelChanged) {
+ recordNewLabel((CVSRepositoryLocation)location);
+ }
return true;
}
info.setUsername(userText.getText());
@@ -333,7 +385,8 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
}
// Dispose the old repository location
- CVSProviderPlugin.getPlugin().disposeRepository(location);
+ CVSUIPlugin.getPlugin().getRepositoryManager().replaceRepositoryLocation(location, newLocation);
+
} finally {
// Even if we failed, ensure that the new location appears in the repo view.
newLocation = (CVSRepositoryLocation)CVSProviderPlugin.getPlugin().getRepository(newLocation.getLocation());
@@ -347,7 +400,10 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
if (programNameChanged) {
recordNewProgramName((CVSRepositoryLocation)location);
}
-
+ if (labelChanged) {
+ recordNewLabel((CVSRepositoryLocation)location);
+ }
+
connectionInfoChanged = false;
passwordChanged = false;
programNameChanged = false;
@@ -380,6 +436,11 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
} else {
programNameText.setEnabled(true);
}
+ if (useLocationAsLabel.getSelection()) {
+ labelText.setEnabled(false);
+ } else {
+ labelText.setEnabled(true);
+ }
validateFields();
}
@@ -390,6 +451,13 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
return;
}
}
+ if (labelText.isEnabled()) {
+ if (labelText.getText().length() == 0) {
+ setValid(false);
+ return;
+ }
+ }
+ setValid(true);
}
private void recordNewProgramName(CVSRepositoryLocation location) {
@@ -404,5 +472,20 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
CVSProviderPlugin.getPlugin().setCVSProgramName(location, newProgramName);
}
}
+
+ private void recordNewLabel(CVSRepositoryLocation location) {
+ String label = null;
+ if (useCustomLabel.getSelection()) {
+ label = labelText.getText();
+ if (label.equals(location.getLocation())) {
+ label = null;
+ }
+ }
+ try {
+ CVSUIPlugin.getPlugin().getRepositoryManager().setLabel(location, label);
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e);
+ }
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
index 57fc7fe46..96ecc56d8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
@@ -872,4 +872,57 @@ public class RepositoryManager {
root.clearCache();
}
}
+ /**
+ * Method setLabel.
+ * @param location
+ * @param label
+ */
+ public void setLabel(CVSRepositoryLocation location, String label) throws CVSException {
+ RepositoryRoot root = getRepositoryRootFor(location);
+ String oldLabel = root.getName();
+ if (oldLabel == null) {
+ if (label == null) return;
+ root.setName(label);
+ } else if (label == null) {
+ root.setName(label);
+ } else if (label.equals(oldLabel)) {
+ return;
+ } else {
+ root.setName(label);
+ }
+ broadcastRepositoryChange(root);
+ }
+
+ /**
+ * Replace the old repository location with the new one assuming that they
+ * are the same location with different authentication informations
+ * @param location
+ * @param newLocation
+ */
+ public void replaceRepositoryLocation(
+ final ICVSRepositoryLocation oldLocation,
+ final CVSRepositoryLocation newLocation) throws CVSException {
+
+ try {
+ run(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ RepositoryRoot root = getRepositoryRootFor(oldLocation);
+ // Disposing of the old location will result in the deletion of the
+ // cached root through a listener callback
+ CVSProviderPlugin.getPlugin().disposeRepository(oldLocation);
+
+ newLocation.updateCache();
+ root.setRepositoryLocation(newLocation);
+ add(root);
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ }, Policy.monitorFor(null));
+ } catch (InvocationTargetException e) {
+ CVSException.wrapException(e);
+ } catch (InterruptedException e) {
+ }
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
index a3bdc560b..41ebeceac 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
@@ -415,4 +415,12 @@ public class RepositoryRoot extends PlatformObject {
modulesCache = null;
}
+ /**
+ * Sets the root.
+ * @param root The root to set
+ */
+ void setRepositoryLocation(ICVSRepositoryLocation root) {
+ this.root = root;
+ }
+
}

Back to the top