Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengxin Zhu2012-03-22 05:42:43 +0000
committerMengxin Zhu2012-03-22 05:47:54 +0000
commit4e22e50e855a886d2d3b2e662f17d1d50d0808d1 (patch)
tree09fef76dc013d0dd21807c0404267a764e044805
parente892b6358a25f4ba81e580b478a9a4800cef8bcd (diff)
downloadrt.equinox.p2-4e22e50e855a886d2d3b2e662f17d1d50d0808d1.tar.gz
rt.equinox.p2-4e22e50e855a886d2d3b2e662f17d1d50d0808d1.tar.xz
rt.equinox.p2-4e22e50e855a886d2d3b2e662f17d1d50d0808d1.zip
Bug 326802 [ui] Preferences allow only editing the name of existingv20120322-0547
repository. Signed-off-by: Mengxin Zhu <kane.zhu@windriver.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java42
2 files changed, 61 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
index 5a1949bc1..af9c7e542 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 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
@@ -41,6 +41,7 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
ProvisioningUI ui;
URI location;
String name;
+ String initialURL;
public RepositoryNameAndLocationDialog(Shell parentShell, ProvisioningUI ui) {
super(parentShell);
@@ -140,11 +141,17 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
else if (userLocation == null)
status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, RepositoryTracker.STATUS_INVALID_REPOSITORY_LOCATION, ProvUIMessages.AddRepositoryDialog_InvalidURL, null);
else {
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- status[0] = getRepositoryTracker().validateRepositoryLocation(ui.getSession(), userLocation, contactRepositories, null);
- }
- });
+ if (initialURL.equals(url.getText().trim()))
+ status[0] = Status.OK_STATUS;
+ else if (userLocation.equals(getOriginalLocation()))
+ // the location is reverted to the original one that has not been saved
+ status[0] = Status.OK_STATUS;
+ else
+ BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+ public void run() {
+ status[0] = getRepositoryTracker().validateRepositoryLocation(ui.getSession(), userLocation, contactRepositories, null);
+ }
+ });
}
// At this point the subclasses may have decided to opt out of
// this dialog.
@@ -175,6 +182,14 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
return ""; //$NON-NLS-1$
}
+ /**
+ * the location of repository to be changed
+ * @return the location of an existing repository
+ */
+ protected URI getOriginalLocation() {
+ return null;
+ }
+
protected Text createNameField(Composite parent) {
// Name: []
Label nameLabel = new Label(parent, SWT.NONE);
@@ -204,7 +219,8 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
validateRepositoryURL(false);
}
});
- url.setText(getInitialLocationText());
+ initialURL = getInitialLocationText();
+ url.setText(initialURL);
url.setSelection(0, url.getText().length());
return url;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index 843cfc5cd..73b63c7a8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,7 @@ package org.eclipse.equinox.p2.ui;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.ui.*;
@@ -110,6 +109,9 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
WorkbenchJob filterJob;
Button addButton, removeButton, editButton, refreshButton, disableButton, exportButton;
+ private Map<MetadataRepositoryElement, URI> originalURICache = new HashMap<MetadataRepositoryElement, URI>(2);
+ private Map<MetadataRepositoryElement, String> originalNameCache = new HashMap<MetadataRepositoryElement, String>(2);
+
class CachedMetadataRepositories extends MetadataRepositories {
private Hashtable<String, MetadataRepositoryElement> cachedElements;
@@ -541,6 +543,8 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
public boolean performOk() {
if (changed)
ElementUtils.updateRepositoryUsingElements(ui, getElements(), getShell());
+ originalNameCache.clear();
+ originalURICache.clear();
return super.performOk();
}
@@ -742,6 +746,18 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
final MetadataRepositoryElement[] selected = getSelectedElements();
if (selected.length != 1)
return;
+
+ URI originalLocation = null;
+ String originalName = null;
+ if (originalURICache.containsKey(selected[0])) {
+ originalLocation = originalURICache.get(selected[0]);
+ } else
+ originalLocation = selected[0].getLocation();
+ if (originalNameCache.containsKey(selected[0])) {
+ originalName = originalNameCache.get(selected[0]);
+ } else
+ originalName = selected[0].getName();
+ final URI existingLocation = originalLocation;
RepositoryNameAndLocationDialog dialog = new RepositoryNameAndLocationDialog(getShell(), ui) {
protected String getInitialLocationText() {
return URIUtil.toUnencodedString(selected[0].getLocation());
@@ -751,12 +767,30 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
return selected[0].getName();
}
+ @Override
+ protected URI getOriginalLocation() {
+ return existingLocation;
+ }
};
+
int retCode = dialog.open();
if (retCode == Window.OK) {
selected[0].setNickname(dialog.getName());
selected[0].setLocation(dialog.getLocation());
- changed = true;
+ if (dialog.getLocation().equals(existingLocation)) {
+ // the change is reverted
+ originalURICache.remove(selected[0]);
+ } else if (!originalURICache.containsKey(selected[0]))
+ originalURICache.put(selected[0], existingLocation);
+ if (dialog.getName().equals(originalName)) {
+ // the change is reverted
+ originalNameCache.remove(selected[0]);
+ } else if (!originalNameCache.containsKey(selected[0]))
+ originalNameCache.put(selected[0], originalName);
+ if (originalURICache.size() > 0 || originalNameCache.size() > 0)
+ changed = true;
+ else
+ changed = false;
repositoryViewer.update(selected[0], null);
setDetails();
}

Back to the top