1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-07 02:23:18 +02:00

Include Browser: improved handling of running indexer.

This commit is contained in:
Markus Schorn 2007-03-20 09:41:28 +00:00
parent 9b349bc02e
commit 46c5ad0339
3 changed files with 83 additions and 19 deletions

View file

@ -697,18 +697,21 @@ public class PDOMManager implements IWritableIndexManager, IListener {
public boolean joinIndexer(final int waitMaxMillis, final IProgressMonitor monitor) {
assert monitor != null;
Thread th= new Thread() {
public void run() {
try {
Thread.sleep(waitMaxMillis);
monitor.setCanceled(true);
Thread th= null;
if (waitMaxMillis != FOREVER) {
th= new Thread() {
public void run() {
try {
Thread.sleep(waitMaxMillis);
monitor.setCanceled(true);
}
catch (InterruptedException e) {
}
}
catch (InterruptedException e) {
}
}
};
th.setDaemon(true);
th.start();
};
th.setDaemon(true);
th.start();
}
try {
try {
Job.getJobManager().join(this, monitor);
@ -719,7 +722,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
return Job.getJobManager().find(this).length == 0;
}
finally {
th.interrupt();
if (th != null) {
th.interrupt();
}
}
}

View file

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.ITranslationUnit;
public class IBSetInputJob extends Job {
private ITranslationUnit fInput;
private Display fDisplay;
private IBViewPart fViewPart;
public IBSetInputJob(IBViewPart viewPart, Display disp) {
super(IBMessages.IBViewPart_waitingOnIndexerMessage);
setSystem(true);
fViewPart= viewPart;
fDisplay= disp;
}
protected IStatus run(IProgressMonitor monitor) {
if (CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, monitor)) {
try {
fDisplay.asyncExec(new Runnable() {
public void run() {
fViewPart.setInput(fInput);
}
});
} catch (SWTException e) {
// display may be disposed
}
}
return Status.OK_STATUS;
}
public void setInput(ITranslationUnit input) {
fInput= input;
}
}

View file

@ -137,6 +137,7 @@ public class IBViewPart extends ViewPart
private Action fHistoryAction;
private IContextActivation fContextActivation;
private WorkingSetFilterUI fWorkingSetFilterUI;
private IBSetInputJob fSetInputJob;
public void setFocus() {
@ -152,6 +153,10 @@ public class IBViewPart extends ViewPart
}
public void setInput(final ITranslationUnit input) {
if (fPagebook.isDisposed()) {
return;
}
fSetInputJob.cancel();
if (input == null) {
setMessage(IBMessages.IBViewPart_instructionMessage);
fTreeViewer.setInput(null);
@ -163,13 +168,8 @@ public class IBViewPart extends ViewPart
}
else {
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
Display disp= Display.getCurrent();
if (disp != null && !disp.isDisposed()) {
disp.timerExec(500, new Runnable() {
public void run() {
setInput(input);
}});
}
fSetInputJob.setInput(input);
fSetInputJob.schedule();
}
}
@ -204,6 +204,8 @@ public class IBViewPart extends ViewPart
}
public void createPartControl(Composite parent) {
fSetInputJob= new IBSetInputJob(this, Display.getCurrent());
fPagebook = new PageBook(parent, SWT.NULL);
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
createInfoPage();