Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2009-03-02 20:08:02 +0000
committerSusan Franklin2009-03-02 20:08:02 +0000
commit394a3854ba5aa39cba223ecfe162890315513b74 (patch)
treebef7fa5896dcf079884f3a6017555918f9a04fd2 /bundles
parent2aeb0797e3ec6721ecfca8866eb56033dfdce7b2 (diff)
downloadrt.equinox.p2-394a3854ba5aa39cba223ecfe162890315513b74.tar.gz
rt.equinox.p2-394a3854ba5aa39cba223ecfe162890315513b74.tar.xz
rt.equinox.p2-394a3854ba5aa39cba223ecfe162890315513b74.zip
Bug 263546 - [ui] Unable to remove site
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java97
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUI.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUIProvisioningListener.java195
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AddRepositoryDialog.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddRepositoryOperation.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/RepositoryOperation.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java68
11 files changed, 282 insertions, 147 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
index bac3364d8..2eed3dcca 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
@@ -83,7 +83,7 @@ abstract class RepositoriesView extends ProvView {
protected void addListeners() {
super.addListeners();
listener = new StructuredViewerProvisioningListener(viewer, getListenerEventTypes()) {
- protected void refreshAll() {
+ protected void refreshViewer() {
RepositoriesView.this.refreshAll(false);
}
};
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
index 6a76b19fe..651d68553 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
@@ -20,7 +20,6 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningLis
import org.eclipse.equinox.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.ui.*;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.internal.provisional.p2.ui.viewers.StructuredViewerProvisioningListener;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -140,7 +139,7 @@ public class ProvUIActivator extends AbstractUIPlugin {
}
}
- public void addProvisioningListener(StructuredViewerProvisioningListener listener) {
+ public void addProvisioningListener(ProvUIProvisioningListener listener) {
getProvisioningEventBus().addListener(listener);
}
@@ -148,8 +147,8 @@ public class ProvUIActivator extends AbstractUIPlugin {
getProvisioningEventBus().publishEvent(new BatchChangeBeginningEvent(this));
}
- public void signalBatchOperationComplete() {
- getProvisioningEventBus().publishEvent(new BatchChangeCompleteEvent(this));
+ public void signalBatchOperationComplete(boolean notify) {
+ getProvisioningEventBus().publishEvent(new BatchChangeCompleteEvent(this, notify));
}
public IProvisioningEventBus getProvisioningEventBus() {
@@ -159,7 +158,7 @@ public class ProvUIActivator extends AbstractUIPlugin {
return (IProvisioningEventBus) context.getService(busReference);
}
- public void removeProvisioningListener(StructuredViewerProvisioningListener listener) {
+ public void removeProvisioningListener(ProvUIProvisioningListener listener) {
getProvisioningEventBus().removeListener(listener);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
index 068b34748..fc19042dd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
@@ -14,14 +14,10 @@ package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.EventObject;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.*;
import org.eclipse.equinox.internal.p2.ui.viewers.IUDetailsLabelProvider;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener;
-import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.ui.*;
@@ -72,7 +68,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
Button useCategoriesCheckbox, hideInstalledCheckbox, showLatestVersionsCheckbox;
Text detailsArea;
StructuredViewerProvisioningListener profileListener;
- ProvisioningListener repoListener;
+ ProvUIProvisioningListener comboRepoListener;
Display display;
ControlDecoration repoDec;
Image info, warning, error;
@@ -129,7 +125,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
}
});
- addProvisioningListeners();
+ addViewerProvisioningListeners();
availableIUGroup.setUseBoldFontForFilteredItems(queryContext.getViewType() != IUViewQueryContext.AVAILABLE_VIEW_FLAT);
setDropTarget(availableIUGroup.getStructuredViewer().getControl());
@@ -327,6 +323,8 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
gd = new GridData(SWT.END, SWT.FILL, true, false);
gd.horizontalSpan = 3;
repoLink.setLayoutData(gd);
+
+ addComboProvisioningListeners();
}
}
@@ -544,6 +542,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
// select that item.
if (!alwaysPrompt && !isNewText && selectionIndex != repoCombo.getSelectionIndex()) {
repoCombo.select(selectionIndex);
+
} else if (alwaysPrompt) {
AddRepositoryDialog dialog = new AddRepositoryDialog(getShell(), policy) {
protected AddRepositoryOperation getOperation(URI repositoryLocation) {
@@ -561,6 +560,9 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
};
dialog.setTitle(repoMan.getAddOperationLabel());
dialog.open();
+ URI location = dialog.getAddedLocation();
+ if (location != null)
+ fillRepoCombo(location.toString());
} else if (isNewText) {
try {
getContainer().run(false, false, new IRunnableWithProgress() {
@@ -579,6 +581,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
RepositoryOperation op = repoMan.getAddOperation(location);
op.setNotify(false);
op.execute(monitor);
+ fillRepoCombo(location.toString());
} catch (ProvisionException e) {
// TODO Auto-generated catch block
ProvUI.handleException(e, null, StatusManager.SHOW);
@@ -649,10 +652,11 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
}
}
- void addProvisioningListeners() {
- // We might need to adjust the content of this viewer according to installation
- // changes. We want to be very selective about refreshing.
- profileListener = new StructuredViewerProvisioningListener(availableIUGroup.getStructuredViewer(), StructuredViewerProvisioningListener.PROV_EVENT_PROFILE) {
+ void addViewerProvisioningListeners() {
+ // We might need to adjust the content of the available IU group's viewer
+ // according to installation changes. We want to be very selective about refreshing,
+ // because the viewer has its own listeners installed.
+ profileListener = new StructuredViewerProvisioningListener(availableIUGroup.getStructuredViewer(), ProvUIProvisioningListener.PROV_EVENT_PROFILE) {
protected void profileAdded(String id) {
// do nothing
}
@@ -663,57 +667,33 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
protected void profileChanged(String id) {
if (id.equals(profileId)) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (isClosing())
- return;
- refreshAll();
- }
- });
+ asyncRefresh();
}
}
};
+
ProvUI.addProvisioningListener(profileListener);
- repoListener = new ProvisioningListener() {
-
- public void notify(EventObject o) {
- if (o instanceof BatchChangeBeginningEvent) {
- batchCount++;
- } else if (o instanceof BatchChangeCompleteEvent) {
- batchCount--;
- if (batchCount <= 0)
- if (policy.getRepositoryManipulator() != null)
- fillRepoCombo(null);
- else
- display.asyncExec(new Runnable() {
- public void run() {
- availableIUGroup.updateAvailableViewState();
- }
- });
- } else if (batchCount > 0) {
- // We are in the middle of a batch operation
- return;
- } else if (o instanceof RepositoryEvent) {
- final RepositoryEvent event = (RepositoryEvent) o;
- // Do not refresh unless this is the type of repo that we are interested in
- if (event.getRepositoryType() == IRepository.TYPE_METADATA) {
- if (event.getKind() == RepositoryEvent.ADDED && event.isRepositoryEnabled()) {
- fillRepoCombo(event.getRepositoryLocation().toString());
- } else if (event.getKind() == RepositoryEvent.REMOVED) {
- fillRepoCombo(null);
- } else if (event.getKind() == RepositoryEvent.ENABLEMENT) {
- if (event.isRepositoryEnabled())
- fillRepoCombo(event.getRepositoryLocation().toString());
- else
- fillRepoCombo(null);
- }
- }
+ }
+
+ void addComboProvisioningListeners() {
+ // We need to monitor repository events so that we can adjust the repo combo.
+ comboRepoListener = new ProvUIProvisioningListener(ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY) {
+ protected void repositoryAdded(RepositoryEvent e) {
+ if (e instanceof UIRepositoryEvent) {
+ fillRepoCombo(e.getRepositoryLocation().toString());
}
}
+
+ protected void repositoryRemoved(RepositoryEvent e) {
+ fillRepoCombo(null);
+ }
+
+ protected void refreshAll() {
+ fillRepoCombo(null);
+ }
};
- IProvisioningEventBus bus = ProvUIActivator.getDefault().getProvisioningEventBus();
- if (bus != null)
- bus.addListener(repoListener);
+ ProvUI.addProvisioningListener(comboRepoListener);
+
}
void removeProvisioningListeners() {
@@ -721,12 +701,11 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
ProvUI.removeProvisioningListener(profileListener);
profileListener = null;
}
- if (repoListener != null) {
- IProvisioningEventBus bus = ProvUIActivator.getDefault().getProvisioningEventBus();
- if (bus != null)
- bus.removeListener(repoListener);
- repoListener = null;
+ if (comboRepoListener != null) {
+ ProvUI.removeProvisioningListener(comboRepoListener);
+ comboRepoListener = null;
}
+
}
void setRepoComboDecoration(IStatus status) {
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 444028829..3b870eeae 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
@@ -84,7 +84,7 @@ public class ElementUtils {
} catch (ProvisionException e) {
return e.getStatus();
} finally {
- ProvUI.endBatchOperation();
+ ProvUI.endBatchOperation(true);
}
return Status.OK_STATUS;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUI.java
index d116e4031..29a50409e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUI.java
@@ -21,7 +21,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.ui.viewers.IUColumnConfig;
-import org.eclipse.equinox.internal.provisional.p2.ui.viewers.StructuredViewerProvisioningListener;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -277,11 +276,11 @@ public class ProvUI {
}
- public static void addProvisioningListener(StructuredViewerProvisioningListener listener) {
+ public static void addProvisioningListener(ProvUIProvisioningListener listener) {
ProvUIActivator.getDefault().addProvisioningListener(listener);
}
- public static void removeProvisioningListener(StructuredViewerProvisioningListener listener) {
+ public static void removeProvisioningListener(ProvUIProvisioningListener listener) {
ProvUIActivator.getDefault().removeProvisioningListener(listener);
}
@@ -289,8 +288,8 @@ public class ProvUI {
ProvUIActivator.getDefault().signalBatchOperationStart();
}
- public static void endBatchOperation() {
- ProvUIActivator.getDefault().signalBatchOperationComplete();
+ public static void endBatchOperation(boolean notify) {
+ ProvUIActivator.getDefault().signalBatchOperationComplete(notify);
}
public static void openUpdateManagerInstaller(Event event) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUIProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUIProvisioningListener.java
new file mode 100644
index 000000000..645c6a773
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/ProvUIProvisioningListener.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.equinox.internal.provisional.p2.ui;
+
+import org.eclipse.equinox.internal.p2.ui.BatchChangeBeginningEvent;
+import org.eclipse.equinox.internal.p2.ui.BatchChangeCompleteEvent;
+
+import java.util.EventObject;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener;
+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent;
+import org.eclipse.equinox.internal.provisional.p2.engine.ProfileEvent;
+
+/**
+ * ProvisioningListener which handles event batching and other
+ * extensions to the provisioning event framework that are used by
+ * the UI.
+ *
+ * @since 3.5
+ */
+public abstract class ProvUIProvisioningListener implements ProvisioningListener {
+
+ public static final int PROV_EVENT_METADATA_REPOSITORY = 0x0001;
+ public static final int PROV_EVENT_IU = 0x0002;
+ public static final int PROV_EVENT_PROFILE = 0x0004;
+ public static final int PROV_EVENT_ARTIFACT_REPOSITORY = 0x0008;
+
+ int eventTypes = 0;
+ int batchCount = 0;
+
+ public ProvUIProvisioningListener(int eventTypes) {
+ this.eventTypes = eventTypes;
+ }
+
+ public void notify(EventObject o) {
+ if (o instanceof BatchChangeBeginningEvent) {
+ batchCount++;
+ } else if (o instanceof BatchChangeCompleteEvent) {
+ batchCount--;
+ // A batch operation completed. Refresh if we are
+ // to honor it.
+ if (batchCount <= 0 && ((BatchChangeCompleteEvent) o).notify)
+ refreshAll();
+ } else if (batchCount > 0) {
+ // We are in the middle of a batch operation
+ return;
+ } else if (o instanceof ProfileEvent && (((eventTypes & PROV_EVENT_IU) == PROV_EVENT_IU) || ((eventTypes & PROV_EVENT_PROFILE) == PROV_EVENT_PROFILE))) {
+ ProfileEvent event = (ProfileEvent) o;
+ if (event.getReason() == ProfileEvent.CHANGED) {
+ profileChanged(event.getProfileId());
+ } else if (event.getReason() == ProfileEvent.ADDED) {
+ profileAdded(event.getProfileId());
+ } else if (event.getReason() == ProfileEvent.REMOVED) {
+ profileRemoved(event.getProfileId());
+ }
+ } else if (o instanceof RepositoryEvent) {
+ RepositoryEvent event = (RepositoryEvent) o;
+ // Do not handle unless this is the type of repo that we are interested in
+ if ((event.getRepositoryType() == IRepository.TYPE_METADATA && (eventTypes & PROV_EVENT_METADATA_REPOSITORY) == PROV_EVENT_METADATA_REPOSITORY) || (event.getRepositoryType() == IRepository.TYPE_ARTIFACT && (eventTypes & PROV_EVENT_ARTIFACT_REPOSITORY) == PROV_EVENT_ARTIFACT_REPOSITORY)) {
+ if (event.getKind() == RepositoryEvent.ADDED) {
+ repositoryAdded(event);
+ } else if (event.getKind() == RepositoryEvent.REMOVED) {
+ repositoryRemoved(event);
+ } else if (event.getKind() == RepositoryEvent.DISCOVERED) {
+ repositoryDiscovered(event);
+ } else if (event.getKind() == RepositoryEvent.CHANGED) {
+ repositoryChanged(event);
+ } else if (event.getKind() == RepositoryEvent.ENABLEMENT) {
+ repositoryEnablement(event);
+ }
+ }
+ }
+ }
+
+ /**
+ * A repository has been added. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param event the RepositoryEvent describing the details
+ */
+ protected void repositoryAdded(RepositoryEvent event) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in repository events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * A repository has been removed. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param event the RepositoryEvent describing the details
+ */
+ protected void repositoryRemoved(RepositoryEvent event) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in repository events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * A repository has been discovered. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param event the RepositoryEvent describing the details
+ */
+ protected void repositoryDiscovered(RepositoryEvent event) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in repository events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * A repository has changed. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param event the RepositoryEvent describing the details
+ */
+ protected void repositoryChanged(RepositoryEvent event) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in repository events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * A repository's enablement state has changed. This is treated
+ * as repository addition or removal by default. Subclasses may
+ * override. May be called from a non-UI thread.
+ * @param event
+ */
+ protected void repositoryEnablement(RepositoryEvent event) {
+ // We treat enablement of a repository as if one were added.
+ if (event.isRepositoryEnabled())
+ repositoryAdded(event);
+ else
+ repositoryRemoved(event);
+ }
+
+ /**
+ * The specified profile has changed. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param profileId the id of the profile that changed.
+ */
+ protected void profileChanged(final String profileId) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in profile events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * The specified profile has been added. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param profileId the id of the profile that has been added.
+ */
+ protected void profileAdded(final String profileId) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in profile events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * The specified profile has been removed. Subclasses may override. May be called
+ * from a non-UI thread.
+ *
+ * @param profileId the id of the profile that has been removed.
+ */
+ protected void profileRemoved(final String profileId) {
+ // Do nothing. This method is not abstract because subclasses
+ // may not be interested in profile events at all and should
+ // not have to implement it.
+ }
+
+ /**
+ * An event requiring a complete refresh of the listener's state has
+ * been received. This is used, for example, when a batch change has
+ * completed. Subclasses may override. May be called from a non-UI
+ * thread.
+ */
+ protected void refreshAll() {
+ // Do nothing by default.
+ }
+
+ public int getEventTypes() {
+ return eventTypes;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AddRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AddRepositoryDialog.java
index 86aef1c73..1aabb36dd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AddRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AddRepositoryDialog.java
@@ -44,6 +44,7 @@ public abstract class AddRepositoryDialog extends StatusDialog {
Button okButton;
Text url, nickname;
+ URI addedLocation;
static final String[] ARCHIVE_EXTENSIONS = new String[] {"*.jar;*.zip"}; //$NON-NLS-1$
static String lastLocalLocation = null;
static String lastArchiveLocation = null;
@@ -198,10 +199,22 @@ public abstract class AddRepositoryDialog extends StatusDialog {
return userLocation;
}
+ /**
+ * Get the location of the repository that was added by this dialog. Return <code>null</code>
+ * if the dialog has not yet added a repository location.
+ *
+ * @return the location of the repository that has been added by this dialog, or <code>null</code>
+ * if no repository has been added.
+ */
+ public URI getAddedLocation() {
+ return addedLocation;
+ }
+
protected IStatus addRepository() {
IStatus status = validateRepositoryURL(false);
if (status.isOK()) {
- AddRepositoryOperation op = getOperation(getUserLocation());
+ addedLocation = getUserLocation();
+ AddRepositoryOperation op = getOperation(addedLocation);
String nick = nickname.getText().trim();
if (nick.length() > 0)
op.setNicknames(new String[] {nick});
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
index f8c3e0ce1..2f9ed49e6 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
@@ -155,24 +155,22 @@ public class AvailableIUGroup extends StructuredIUGroup {
// well as recognize specifically a user-add that resulted in
// the enablement of a repository.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=248989
- if (!(event instanceof UIRepositoryEvent))
+ if (!(event instanceof UIRepositoryEvent)) {
return;
+ }
makeRepositoryVisible(event.getRepositoryLocation());
}
- protected void refreshAll() {
- display.asyncExec(new Runnable() {
- public void run() {
- final TreeViewer treeViewer = filteredTree.getViewer();
- final Tree tree = treeViewer.getTree();
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench.isClosing())
- return;
- if (tree != null && !tree.isDisposed()) {
- treeViewer.setInput(getNewInput());
- }
- }
- });
+ protected void refreshViewer() {
+ final TreeViewer treeViewer = filteredTree.getViewer();
+ final Tree tree = treeViewer.getTree();
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench.isClosing())
+ return;
+ if (tree != null && !tree.isDisposed()) {
+ treeViewer.setInput(getNewInput());
+ }
+
}
};
ProvUIActivator.getDefault().addProvisioningListener(listener);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddRepositoryOperation.java
index 37c311261..ebcd683cc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/AddRepositoryOperation.java
@@ -50,8 +50,8 @@ public abstract class AddRepositoryOperation extends RepositoryOperation {
setNickname(locations[i], nicknames[i]);
}
}
- if (batched && notify)
- ProvUI.endBatchOperation();
+ if (batched)
+ ProvUI.endBatchOperation(notify);
return status;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/RepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/RepositoryOperation.java
index 2d47b6865..358b94533 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/RepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/RepositoryOperation.java
@@ -43,7 +43,7 @@ public abstract class RepositoryOperation extends ProvisioningOperation {
}
IStatus status = doBatchedExecute(monitor);
if (batched && notify)
- ProvUI.endBatchOperation();
+ ProvUI.endBatchOperation(notify);
return status;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
index b137d46a8..9d6bfe228 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
@@ -11,13 +11,9 @@
package org.eclipse.equinox.internal.provisional.p2.ui.viewers;
-import java.util.EventObject;
-import org.eclipse.equinox.internal.p2.ui.BatchChangeBeginningEvent;
-import org.eclipse.equinox.internal.p2.ui.BatchChangeCompleteEvent;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener;
-import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
+import org.eclipse.equinox.internal.provisional.p2.ui.ProvUIProvisioningListener;
+
import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProfileEvent;
import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.widgets.Display;
@@ -33,61 +29,17 @@ import org.eclipse.ui.PlatformUI;
*
* @since 3.4
*/
-public class StructuredViewerProvisioningListener implements ProvisioningListener {
-
- public static final int PROV_EVENT_METADATA_REPOSITORY = 0x0001;
- public static final int PROV_EVENT_IU = 0x0002;
- public static final int PROV_EVENT_PROFILE = 0x0004;
- public static final int PROV_EVENT_ARTIFACT_REPOSITORY = 0x0008;
+public class StructuredViewerProvisioningListener extends ProvUIProvisioningListener {
- int eventTypes = 0;
- int batchCount = 0;
StructuredViewer viewer;
Display display;
public StructuredViewerProvisioningListener(StructuredViewer viewer, int eventTypes) {
+ super(eventTypes);
this.viewer = viewer;
- this.eventTypes = eventTypes;
this.display = viewer.getControl().getDisplay();
}
- public void notify(EventObject o) {
- if (o instanceof BatchChangeBeginningEvent) {
- batchCount++;
- } else if (o instanceof BatchChangeCompleteEvent) {
- batchCount--;
- if (batchCount <= 0)
- asyncRefresh();
- } else if (batchCount > 0) {
- // We are in the middle of a batch operation
- return;
- } else if (o instanceof ProfileEvent && (((eventTypes & PROV_EVENT_IU) == PROV_EVENT_IU) || ((eventTypes & PROV_EVENT_PROFILE) == PROV_EVENT_PROFILE))) {
- ProfileEvent event = (ProfileEvent) o;
- if (event.getReason() == ProfileEvent.CHANGED) {
- profileChanged(event.getProfileId());
- } else if (event.getReason() == ProfileEvent.ADDED) {
- profileAdded(event.getProfileId());
- } else if (event.getReason() == ProfileEvent.REMOVED) {
- profileRemoved(event.getProfileId());
- }
- } else if (o instanceof RepositoryEvent) {
- RepositoryEvent event = (RepositoryEvent) o;
- // Do not refresh unless this is the type of repo that we are interested in
- if ((event.getRepositoryType() == IRepository.TYPE_METADATA && (eventTypes & PROV_EVENT_METADATA_REPOSITORY) == PROV_EVENT_METADATA_REPOSITORY) || (event.getRepositoryType() == IRepository.TYPE_ARTIFACT && (eventTypes & PROV_EVENT_ARTIFACT_REPOSITORY) == PROV_EVENT_ARTIFACT_REPOSITORY)) {
- if (event.getKind() == RepositoryEvent.ADDED) {
- repositoryAdded(event);
- } else if (event.getKind() == RepositoryEvent.REMOVED) {
- repositoryRemoved(event);
-
- } else if (event.getKind() == RepositoryEvent.DISCOVERED) {
- repositoryDiscovered(event);
- } else if (event.getKind() == RepositoryEvent.CHANGED) {
- repositoryChanged(event);
- }
- }
- }
- }
-
/**
* A repository has been added. The default behavior is to
* refresh the viewer. Subclasses may override. May be called
@@ -179,25 +131,25 @@ public class StructuredViewerProvisioningListener implements ProvisioningListene
public void run() {
if (isClosing())
return;
- refreshAll();
+ refreshViewer();
}
});
}
+ protected void refreshAll() {
+ asyncRefresh();
+ }
+
/**
* Refresh the entire structure of the viewer. Subclasses may
* override to ensure that any caching done in content providers or
* model elements is refreshed before the viewer is refreshed. This will
* always be called from the UI thread.
*/
- protected void refreshAll() {
+ protected void refreshViewer() {
viewer.refresh();
}
- public int getEventTypes() {
- return eventTypes;
- }
-
/**
* Return whether the viewer is closing or shutting down.
* This method should be used in async execs to ensure that

Back to the top