Revision 36ee2736
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
19 | 19 |
import java.util.UUID; |
20 | 20 |
|
21 | 21 |
import org.eclipse.core.runtime.ICoreRunnable; |
22 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
|
22 | 23 |
import org.eclipse.core.runtime.jobs.Job; |
24 |
import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
|
23 | 25 |
import org.eclipse.jface.viewers.IStructuredSelection; |
24 | 26 |
|
25 | 27 |
import ca.odell.glazedlists.BasicEventList; |
... | ... | |
74 | 76 |
|
75 | 77 |
private Job searchJob; |
76 | 78 |
|
79 |
private volatile boolean hasSearchFinished; |
|
80 |
|
|
77 | 81 |
public AbstractBulkEditorInput() { |
78 | 82 |
super(true); |
79 | 83 |
this.conversation = CdmStore.createConversation(); |
... | ... | |
157 | 161 |
//cancel previous search job |
158 | 162 |
if(searchJob!=null && searchJob.getState()!=Job.NONE){ |
159 | 163 |
searchJob.cancel(); |
164 |
while(!hasSearchFinished){ |
|
165 |
//wait for search to finish |
|
166 |
try { |
|
167 |
Thread.sleep(100); |
|
168 |
} catch (InterruptedException e) { |
|
169 |
e.printStackTrace(); |
|
170 |
} |
|
171 |
} |
|
160 | 172 |
searchJob = null; |
161 | 173 |
} |
162 | 174 |
model.clear(); |
... | ... | |
195 | 207 |
if (monitor.isCanceled()) { |
196 | 208 |
break; |
197 | 209 |
} |
210 |
|
|
198 | 211 |
configurator.setPageNumber(pageNumber); |
199 | 212 |
entities = listEntities(configurator); |
200 | 213 |
model.addAll(entities); |
... | ... | |
211 | 224 |
monitor.done(); |
212 | 225 |
EventUtility.postAsyncEvent(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED, selection); |
213 | 226 |
}); |
227 |
searchJob.addJobChangeListener(new JobChangeAdapter(){ |
|
228 |
@Override |
|
229 |
public void done(IJobChangeEvent event) { |
|
230 |
hasSearchFinished = true; |
|
231 |
} |
|
232 |
}); |
|
233 |
hasSearchFinished = false; |
|
214 | 234 |
searchJob.schedule(); |
215 | 235 |
} |
216 | 236 |
} |
Also available in: Unified diff
ref #6321 Wait for canceled search to finish before starting new search