Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2010-05-11 14:01:06 +0000
committerJohn Arthorne2010-05-11 14:01:06 +0000
commitfb92b58c719290e6abfbf11a415973a8e4118381 (patch)
tree92dfd79f6c931d9df99211fdc771204736da8546
parentb97cbfa23c44be465c406d15167062b854b07ae4 (diff)
downloadrt.equinox.p2-fb92b58c719290e6abfbf11a415973a8e4118381.tar.gz
rt.equinox.p2-fb92b58c719290e6abfbf11a415973a8e4118381.tar.xz
rt.equinox.p2-fb92b58c719290e6abfbf11a415973a8e4118381.zip
Bug 310507 - [ui] Work with combo intermittently misses changes made in pref dialog
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java116
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java54
4 files changed, 93 insertions, 79 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
index 3c864f7f3..ad3b69a56 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
@@ -187,7 +187,6 @@ public class ProvUIMessages extends NLS {
public static String AvailableIUsPage_Title;
public static String AvailableIUWrapper_AllAreInstalled;
public static String IUViewQueryContext_AllAreInstalledDescription;
- public static String ElementUtils_UpdateJobTitle;
public static String Label_Profiles;
public static String Label_Repositories;
public static String LaunchUpdateManagerButton;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
index bd9605027..929652ea0 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
@@ -206,7 +206,6 @@ AvailableIUsPage_SingleSelectionCount={0} item selected
AvailableIUsPage_Title=Available Software
AvailableIUWrapper_AllAreInstalled=All items are installed
IUViewQueryContext_AllAreInstalledDescription=You can uncheck the 'Hide items that are already installed' check box to see all items.
-ElementUtils_UpdateJobTitle=Updating Repository Information
Label_Profiles=All Software Profiles
Label_Repositories=Known Repositories
LaunchUpdateManagerButton=Launch...
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
index bde26b247..f6a5ab2f8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
@@ -14,9 +14,9 @@ package org.eclipse.equinox.internal.p2.ui.model;
import java.net.URI;
import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.equinox.internal.p2.ui.*;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
@@ -34,68 +34,62 @@ import org.eclipse.swt.widgets.Shell;
public class ElementUtils {
public static void updateRepositoryUsingElements(final MetadataRepositoryElement[] elements, final Shell shell) {
- Job job = new Job(ProvUIMessages.ElementUtils_UpdateJobTitle) {
- public IStatus run(IProgressMonitor monitor) {
- final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
- ui.signalRepositoryOperationStart();
- IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
- IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
- try {
- int visibilityFlags = ui.getRepositoryTracker().getMetadataRepositoryFlags();
- URI[] currentlyEnabled = metaManager.getKnownRepositories(visibilityFlags);
- URI[] currentlyDisabled = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED | visibilityFlags);
- for (int i = 0; i < elements.length; i++) {
- URI location = elements[i].getLocation();
- if (elements[i].isEnabled()) {
- if (containsURI(currentlyDisabled, location))
- // It should be enabled and is not currently
- setColocatedRepositoryEnablement(ui, location, true);
- else if (!containsURI(currentlyEnabled, location)) {
- // It is not known as enabled or disabled. Add it.
- metaManager.addRepository(location);
- artManager.addRepository(location);
- }
- } else {
- if (containsURI(currentlyEnabled, location))
- // It should be disabled, and is currently enabled
- setColocatedRepositoryEnablement(ui, location, false);
- else if (!containsURI(currentlyDisabled, location)) {
- // It is not known as enabled or disabled. Add it and then disable it.
- metaManager.addRepository(location);
- artManager.addRepository(location);
- setColocatedRepositoryEnablement(ui, location, false);
- }
- }
- String name = elements[i].getName();
- if (name != null && name.length() > 0) {
- metaManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
- artManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
- }
+ final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
+ ui.signalRepositoryOperationStart();
+ IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
+ IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
+ try {
+ int visibilityFlags = ui.getRepositoryTracker().getMetadataRepositoryFlags();
+ URI[] currentlyEnabled = metaManager.getKnownRepositories(visibilityFlags);
+ URI[] currentlyDisabled = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED | visibilityFlags);
+ for (int i = 0; i < elements.length; i++) {
+ URI location = elements[i].getLocation();
+ if (elements[i].isEnabled()) {
+ if (containsURI(currentlyDisabled, location))
+ // It should be enabled and is not currently
+ setColocatedRepositoryEnablement(ui, location, true);
+ else if (!containsURI(currentlyEnabled, location)) {
+ // It is not known as enabled or disabled. Add it.
+ metaManager.addRepository(location);
+ artManager.addRepository(location);
}
- // Are there any elements that need to be deleted? Go over the original state
- // and remove any elements that weren't in the elements we were given
- Set<String> nowKnown = new HashSet<String>();
- for (int i = 0; i < elements.length; i++)
- nowKnown.add(URIUtil.toUnencodedString(elements[i].getLocation()));
- for (int i = 0; i < currentlyEnabled.length; i++) {
- if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyEnabled[i]))) {
- metaManager.removeRepository(currentlyEnabled[i]);
- artManager.removeRepository(currentlyEnabled[i]);
- }
+ } else {
+ if (containsURI(currentlyEnabled, location))
+ // It should be disabled, and is currently enabled
+ setColocatedRepositoryEnablement(ui, location, false);
+ else if (!containsURI(currentlyDisabled, location)) {
+ // It is not known as enabled or disabled. Add it and then disable it.
+ metaManager.addRepository(location);
+ artManager.addRepository(location);
+ setColocatedRepositoryEnablement(ui, location, false);
}
- for (int i = 0; i < currentlyDisabled.length; i++) {
- if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyDisabled[i]))) {
- metaManager.removeRepository(currentlyDisabled[i]);
- artManager.removeRepository(currentlyDisabled[i]);
- }
- }
- } finally {
- ui.signalRepositoryOperationComplete(null, true);
}
- return Status.OK_STATUS;
+ String name = elements[i].getName();
+ if (name != null && name.length() > 0) {
+ metaManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
+ artManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
+ }
+ }
+ // Are there any elements that need to be deleted? Go over the original state
+ // and remove any elements that weren't in the elements we were given
+ Set<String> nowKnown = new HashSet<String>();
+ for (int i = 0; i < elements.length; i++)
+ nowKnown.add(URIUtil.toUnencodedString(elements[i].getLocation()));
+ for (int i = 0; i < currentlyEnabled.length; i++) {
+ if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyEnabled[i]))) {
+ metaManager.removeRepository(currentlyEnabled[i]);
+ artManager.removeRepository(currentlyEnabled[i]);
+ }
}
- };
- job.schedule();
+ for (int i = 0; i < currentlyDisabled.length; i++) {
+ if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyDisabled[i]))) {
+ metaManager.removeRepository(currentlyDisabled[i]);
+ artManager.removeRepository(currentlyDisabled[i]);
+ }
+ }
+ } finally {
+ ui.signalRepositoryOperationComplete(null, true);
+ }
}
private static void setColocatedRepositoryEnablement(ProvisioningUI ui, URI location, boolean enable) {
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 52409dfcf..23af132de 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
@@ -100,6 +100,9 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
RepositoryDetailsLabelProvider labelProvider;
RepositoryTracker tracker;
RepositoryTracker localCacheRepoManipulator;
+ /**
+ * The input field is initialized lazily and should only be accessed via the {@link #getInput()} method.
+ */
CachedMetadataRepositories input;
Text pattern, details;
PatternFilter filter;
@@ -107,7 +110,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
Button addButton, removeButton, editButton, refreshButton, disableButton, exportButton;
class CachedMetadataRepositories extends MetadataRepositories {
- Hashtable<String, Object> cachedElements;
+ private Hashtable<String, MetadataRepositoryElement> cachedElements;
CachedMetadataRepositories() {
super(ui);
@@ -121,21 +124,41 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
public Object[] fetchChildren(Object o, IProgressMonitor monitor) {
if (cachedElements == null) {
Object[] children = super.fetchChildren(o, monitor);
- cachedElements = new Hashtable<String, Object>(children.length);
+ cachedElements = new Hashtable<String, MetadataRepositoryElement>(children.length);
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof MetadataRepositoryElement) {
- String key = URIUtil.toUnencodedString(((MetadataRepositoryElement) children[i]).getLocation());
- int length = key.length();
- if (length > 0 && key.charAt(length - 1) == '/') {
- key = key.substring(0, length - 1);
- }
- cachedElements.put(key, children[i]);
+ put((MetadataRepositoryElement) children[i]);
}
}
}
return cachedElements.values().toArray();
}
+ MetadataRepositoryElement[] getElements() {
+ return cachedElements.values().toArray(new MetadataRepositoryElement[cachedElements.size()]);
+ }
+
+ void remove(MetadataRepositoryElement element) {
+ cachedElements.remove(getKey(element.getLocation()));
+ }
+
+ void put(MetadataRepositoryElement element) {
+ cachedElements.put(getKey(element.getLocation()), element);
+ }
+
+ MetadataRepositoryElement get(URI location) {
+ return cachedElements.get(getKey(location));
+ }
+
+ String getKey(URI location) {
+ String key = URIUtil.toUnencodedString(location);
+ int length = key.length();
+ if (length > 0 && key.charAt(length - 1) == '/') {
+ key = key.substring(0, length - 1);
+ }
+ return key;
+ }
+
}
class MetadataRepositoryPatternFilter extends PatternFilter {
@@ -322,7 +345,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
element.setEnabled(event.getChecked());
// paranoid that an equal but not identical element was passed in as the selection.
// update the cache map just in case.
- input.cachedElements.put(URIUtil.toUnencodedString(element.getLocation()), element);
+ getInput().put(element);
// update the viewer to show the change
updateForEnablementChange(new MetadataRepositoryElement[] {element});
}
@@ -533,7 +556,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
}
MetadataRepositoryElement[] getElements() {
- return getInput().cachedElements.values().toArray(new MetadataRepositoryElement[getInput().cachedElements.size()]);
+ return getInput().getElements();
}
MetadataRepositoryElement[] getSelectedElements() {
@@ -651,7 +674,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
boolean enableSites = !toggleMeansDisable(selected);
for (int i = 0; i < selected.length; i++) {
selected[i].setEnabled(enableSites);
- input.cachedElements.put(URIUtil.toUnencodedString(selected[i].getLocation()), selected[i]);
+ getInput().put(selected[i]);
}
updateForEnablementChange(selected);
}
@@ -672,10 +695,9 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
public void run() {
MetadataRepositoryElement[] imported = UpdateManagerCompatibility.importSites(getShell());
if (imported.length > 0) {
- Hashtable<String, Object> repos = getInput().cachedElements;
changed = true;
for (int i = 0; i < imported.length; i++)
- repos.put(URIUtil.toUnencodedString(imported[i].getLocation()), imported[i]);
+ getInput().put(imported[i]);
safeRefresh(null);
}
}
@@ -808,7 +830,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
changed = true;
for (int i = 0; i < selections.length; i++) {
- getInput().cachedElements.remove(URIUtil.toUnencodedString(selections[i].getLocation()));
+ getInput().remove(selections[i]);
}
safeRefresh(null);
}
@@ -821,10 +843,10 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
if (localCacheRepoManipulator == null)
localCacheRepoManipulator = new RepositoryTracker() {
public void addRepository(URI location, String nickname, ProvisioningSession session) {
- MetadataRepositoryElement element = (MetadataRepositoryElement) getInput().cachedElements.get(URIUtil.toUnencodedString(location));
+ MetadataRepositoryElement element = getInput().get(location);
if (element == null) {
element = new MetadataRepositoryElement(getInput(), location, true);
- getInput().cachedElements.put(URIUtil.toUnencodedString(location), element);
+ getInput().put(element);
}
if (nickname != null)
element.setNickname(nickname);

Back to the top