View | Details | Raw Unified | Return to bug 232413 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/provisional/p2/ui/model/ProfileElement.java (+7 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.provisional.p2.ui.model;
11
package org.eclipse.equinox.internal.provisional.p2.ui.model;
12
12
13
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
14
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
14
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
15
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
15
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
16
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
Lines 83-86 Link Here
83
	public boolean isContainer() {
84
	public boolean isContainer() {
84
		return super.getChildren(this).length > 0;
85
		return super.getChildren(this).length > 0;
85
	}
86
	}
87
88
	// Make this public to fix
89
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=232413
90
	public Object[] fetchChildren(Object o, IProgressMonitor monitor) {
91
		return super.fetchChildren(o, monitor);
92
	}
86
}
93
}
(-)src/org/eclipse/equinox/internal/p2/ui/messages.properties (+2 lines)
Lines 139-144 Link Here
139
AvailableIUGroup_RefreshOperationLabel=Refresh
139
AvailableIUGroup_RefreshOperationLabel=Refresh
140
AvailableIUGroup_ViewByToolTipText=View by
140
AvailableIUGroup_ViewByToolTipText=View by
141
DeferredFetchFilteredTree_RetrievingList=Retrieving List
141
DeferredFetchFilteredTree_RetrievingList=Retrieving List
142
DeferredQueryContentProvider_FetchJobName=Fetching install information
143
DeferredQueryContentProvider_Pending=Pending...
142
Label_Profiles=All Software Profiles
144
Label_Profiles=All Software Profiles
143
Label_Repositories=Known Repositories
145
Label_Repositories=Known Repositories
144
MetadataRepositoryElement_NotFound=This repository is currently not available.
146
MetadataRepositoryElement_NotFound=This repository is currently not available.
(-)src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java (+2 lines)
Lines 123-128 Link Here
123
	public static String AvailableIUGroup_RefreshOperationLabel;
123
	public static String AvailableIUGroup_RefreshOperationLabel;
124
	public static String AvailableIUGroup_ViewByToolTipText;
124
	public static String AvailableIUGroup_ViewByToolTipText;
125
	public static String DeferredFetchFilteredTree_RetrievingList;
125
	public static String DeferredFetchFilteredTree_RetrievingList;
126
	public static String DeferredQueryContentProvider_FetchJobName;
127
	public static String DeferredQueryContentProvider_Pending;
126
	public static String Label_Profiles;
128
	public static String Label_Profiles;
127
	public static String Label_Repositories;
129
	public static String Label_Repositories;
128
	public static String MetadataRepositoryElement_NotFound;
130
	public static String MetadataRepositoryElement_NotFound;
(-)src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java (-1 / +5 lines)
Lines 38-45 Link Here
38
	public boolean accept(Object match) {
38
	public boolean accept(Object match) {
39
		if (!(match instanceof IInstallableUnit))
39
		if (!(match instanceof IInstallableUnit))
40
			return true;
40
			return true;
41
		if (queryable instanceof IProfile)
41
		if (queryable instanceof IProfile) {
42
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=232413
43
			// access the IU's name while collecting to prevent a later lockup in the UI thread.
44
			IUPropertyUtils.getIUProperty((IInstallableUnit) match, IInstallableUnit.PROP_NAME);
42
			return super.accept(new InstalledIUElement(((IProfile) queryable).getProfileId(), (IInstallableUnit) match));
45
			return super.accept(new InstalledIUElement(((IProfile) queryable).getProfileId(), (IInstallableUnit) match));
46
		}
43
		// shouldn't happen, but is possible if a client reset the queryable to a non-profile.
47
		// shouldn't happen, but is possible if a client reset the queryable to a non-profile.
44
		return super.accept(match);
48
		return super.accept(match);
45
	}
49
	}
(-)src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/DeferredQueryContentProvider.java (-3 / +66 lines)
Lines 13-26 Link Here
13
13
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.HashSet;
15
import java.util.HashSet;
16
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.*;
18
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
17
import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
19
import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
18
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
20
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
19
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryTreeContentManager;
21
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryTreeContentManager;
20
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryTreeListener;
22
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryTreeListener;
23
import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
21
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
24
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
22
import org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement;
25
import org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement;
23
import org.eclipse.jface.viewers.*;
26
import org.eclipse.jface.viewers.*;
27
import org.eclipse.swt.widgets.Display;
24
28
25
/**
29
/**
26
 * Content provider that retrieves children asynchronously where
30
 * Content provider that retrieves children asynchronously where
Lines 40-45 Link Here
40
	AbstractTreeViewer viewer = null;
44
	AbstractTreeViewer viewer = null;
41
	ListenerList listeners = new ListenerList();
45
	ListenerList listeners = new ListenerList();
42
	boolean synchronous = false;
46
	boolean synchronous = false;
47
	TableViewer tableViewer = null;
48
	Job profileFetchJob = null;
49
	Display display = null;
50
	String placeholder;
51
	Object[] realChildren;
43
52
44
	public DeferredQueryContentProvider(IQueryProvider queryProvider) {
53
	public DeferredQueryContentProvider(IQueryProvider queryProvider) {
45
		this.queryProvider = queryProvider;
54
		this.queryProvider = queryProvider;
Lines 54-61 Link Here
54
	}
63
	}
55
64
56
	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
65
	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
66
		// cache display while in UI thread
67
		display = v.getControl().getDisplay();
57
		if (manager != null)
68
		if (manager != null)
58
			manager.cancel(oldInput);
69
			manager.cancel(oldInput);
70
		if (profileFetchJob != null) {
71
			profileFetchJob.cancel();
72
			profileFetchJob = null;
73
		}
59
		if (v instanceof AbstractTreeViewer) {
74
		if (v instanceof AbstractTreeViewer) {
60
			manager = new DeferredQueryTreeContentManager((AbstractTreeViewer) v);
75
			manager = new DeferredQueryTreeContentManager((AbstractTreeViewer) v);
61
			viewer = (AbstractTreeViewer) v;
76
			viewer = (AbstractTreeViewer) v;
Lines 69-76 Link Here
69
					queryCompleted.add(parent);
84
					queryCompleted.add(parent);
70
				}
85
				}
71
			});
86
			});
72
		} else
87
		} else {
73
			viewer = null;
88
			viewer = null;
89
			if (v instanceof TableViewer)
90
				tableViewer = (TableViewer) v;
91
		}
74
		alreadyQueried = new HashMap();
92
		alreadyQueried = new HashMap();
75
		queryCompleted = new HashSet();
93
		queryCompleted = new HashSet();
76
		currentInput = newInput;
94
		currentInput = newInput;
Lines 81-87 Link Here
81
99
82
	}
100
	}
83
101
84
	public Object[] getElements(Object input) {
102
	public Object[] getElements(final Object input) {
103
		if (input instanceof ProfileElement) {
104
			if (profileFetchJob == null && tableViewer != null) {
105
				final ProfileElement element = (ProfileElement) input;
106
				element.setQueryProvider(queryProvider);
107
				placeholder = ProvUIMessages.DeferredQueryContentProvider_Pending;
108
				profileFetchJob = new Job(ProvUIMessages.DeferredQueryContentProvider_FetchJobName) {
109
					public IStatus run(IProgressMonitor monitor) {
110
						if (monitor.isCanceled())
111
							return Status.CANCEL_STATUS;
112
						realChildren = element.fetchChildren(input, monitor);
113
						return Status.OK_STATUS;
114
					}
115
				};
116
				profileFetchJob.addJobChangeListener(new JobChangeAdapter() {
117
					public void done(IJobChangeEvent event) {
118
						// whether finished or cancelled, get rid of the placeholder.
119
						if (display == null || placeholder == null)
120
							return;
121
						final boolean addChildren = event.getResult().isOK();
122
						display.asyncExec(new Runnable() {
123
							public void run() {
124
								if (!tableViewer.getControl().isDisposed()) {
125
									tableViewer.remove(placeholder);
126
									if (addChildren) {
127
										tableViewer.add(realChildren);
128
										// Set the selection explicitly so listeners can
129
										// change their validation
130
										tableViewer.setSelection(StructuredSelection.EMPTY);
131
									}
132
								}
133
								placeholder = null;
134
							}
135
						});
136
					}
137
				});
138
				profileFetchJob.schedule();
139
				realChildren = new Object[] {placeholder};
140
			}
141
			// realChildren could contain the placeholder or the real stuff
142
			return realChildren;
143
		}
85
		if (input instanceof QueriedElement) {
144
		if (input instanceof QueriedElement) {
86
			QueriedElement element = (QueriedElement) input;
145
			QueriedElement element = (QueriedElement) input;
87
			element.setQueryProvider(queryProvider);
146
			element.setQueryProvider(queryProvider);
Lines 94-99 Link Here
94
		if (manager != null) {
153
		if (manager != null) {
95
			manager.cancel(currentInput);
154
			manager.cancel(currentInput);
96
		}
155
		}
156
		if (profileFetchJob != null) {
157
			profileFetchJob.cancel();
158
			profileFetchJob = null;
159
		}
97
	}
160
	}
98
161
99
	public Object getParent(Object child) {
162
	public Object getParent(Object child) {

Return to bug 232413