mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Include Browser: improved handling of running indexer.
This commit is contained in:
parent
9b349bc02e
commit
46c5ad0339
3 changed files with 83 additions and 19 deletions
|
@ -697,7 +697,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
|
|
||||||
public boolean joinIndexer(final int waitMaxMillis, final IProgressMonitor monitor) {
|
public boolean joinIndexer(final int waitMaxMillis, final IProgressMonitor monitor) {
|
||||||
assert monitor != null;
|
assert monitor != null;
|
||||||
Thread th= new Thread() {
|
Thread th= null;
|
||||||
|
if (waitMaxMillis != FOREVER) {
|
||||||
|
th= new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(waitMaxMillis);
|
Thread.sleep(waitMaxMillis);
|
||||||
|
@ -709,6 +711,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
};
|
};
|
||||||
th.setDaemon(true);
|
th.setDaemon(true);
|
||||||
th.start();
|
th.start();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
Job.getJobManager().join(this, monitor);
|
Job.getJobManager().join(this, monitor);
|
||||||
|
@ -719,9 +722,11 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
return Job.getJobManager().find(this).length == 0;
|
return Job.getJobManager().find(this).length == 0;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
if (th != null) {
|
||||||
th.interrupt();
|
th.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean joinIndexerOld(int waitMaxMillis, IProgressMonitor monitor) {
|
public boolean joinIndexerOld(int waitMaxMillis, IProgressMonitor monitor) {
|
||||||
final int totalTicks = 1000;
|
final int totalTicks = 1000;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -137,6 +137,7 @@ public class IBViewPart extends ViewPart
|
||||||
private Action fHistoryAction;
|
private Action fHistoryAction;
|
||||||
private IContextActivation fContextActivation;
|
private IContextActivation fContextActivation;
|
||||||
private WorkingSetFilterUI fWorkingSetFilterUI;
|
private WorkingSetFilterUI fWorkingSetFilterUI;
|
||||||
|
private IBSetInputJob fSetInputJob;
|
||||||
|
|
||||||
|
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
|
@ -152,6 +153,10 @@ public class IBViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInput(final ITranslationUnit input) {
|
public void setInput(final ITranslationUnit input) {
|
||||||
|
if (fPagebook.isDisposed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fSetInputJob.cancel();
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
setMessage(IBMessages.IBViewPart_instructionMessage);
|
setMessage(IBMessages.IBViewPart_instructionMessage);
|
||||||
fTreeViewer.setInput(null);
|
fTreeViewer.setInput(null);
|
||||||
|
@ -163,13 +168,8 @@ public class IBViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
|
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
|
||||||
Display disp= Display.getCurrent();
|
fSetInputJob.setInput(input);
|
||||||
if (disp != null && !disp.isDisposed()) {
|
fSetInputJob.schedule();
|
||||||
disp.timerExec(500, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
setInput(input);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,8 @@ public class IBViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPartControl(Composite parent) {
|
public void createPartControl(Composite parent) {
|
||||||
|
fSetInputJob= new IBSetInputJob(this, Display.getCurrent());
|
||||||
|
|
||||||
fPagebook = new PageBook(parent, SWT.NULL);
|
fPagebook = new PageBook(parent, SWT.NULL);
|
||||||
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
|
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
createInfoPage();
|
createInfoPage();
|
||||||
|
|
Loading…
Add table
Reference in a new issue