blob: dcc88b7b20c014715603a9b5fbb178169da61831 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package org.eclipse.debug.internal.ui.viewers.model;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.core.commands.Request;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.progress.WorkbenchJob;
/**
* Internal implementation of the {@link IViewerInputUpdate} interface. Allows
* implementors to translate the active debug context into an appropriate viewer
* input.
*
* @since 3.4
* @see IViewerInputUpdate
*/
public class ViewerInputUpdate extends Request implements IViewerInputUpdate {
/**
* Presentation context
*/
private IPresentationContext fContext;
/**
* New viewer input
*/
private Object fSource;
/**
* Whether this update is done
*/
private boolean fDone;
/**
* Viewer input to use
*/
private Object fInput;
/**
* Client making request
*/
private IViewerInputRequestor fRequestor;
/**
* When <code>done()</code> is called, the viewer must be informed that the update is complete in the UI thread.
*/
protected WorkbenchJob fViewerInputUpdateJob = new WorkbenchJob("Asynchronous viewer input update") { //$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
fRequestor.viewerInputComplete(ViewerInputUpdate.this);
return Status.OK_STATUS;
}
};
/**
* Constructs a viewer input update request.
*
* @param context presentation context
* @param requestor client making the request
* @param source source from which to derive a viewer input
*/
public ViewerInputUpdate(IPresentationContext context, IViewerInputRequestor requestor, Object source){
fContext = context;
fSource = source;
fRequestor = requestor;
fViewerInputUpdateJob.setSystem(true);
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getPresentationContext()
*/
public IPresentationContext getPresentationContext() {
return fContext;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IProgressMonitor#done()
*/
public final void done() {
synchronized (this) {
if (isDone()) {
return;
}
fDone = true;
}
fViewerInputUpdateJob.schedule();
}
/**
* Returns whether this request is done yet.
*
* @return whether this request is done yet
*/
protected synchronized boolean isDone() {
return fDone;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getElement()
*/
public Object getElement() {
return fSource;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate#getElementPath()
*/
public TreePath getElementPath() {
return TreePath.EMPTY;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#setViewerInput(java.lang.Object)
*/
public void setViewerInput(Object element) {
fInput = element;
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate#getViewerInput()
*/
public Object getViewerInput() {
return fInput;
}
}
|