1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Include Browser: wait for indexer before computing tree.

This commit is contained in:
Markus Schorn 2006-11-10 12:12:52 +00:00
parent 9350190911
commit 665fdd2ca8
5 changed files with 60 additions and 36 deletions

View file

@ -102,4 +102,9 @@ public interface IIndexManager {
* @return <code>true</code>, if the indexer went idle in the given time.
*/
boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor);
/**
* Checks whether the indexer is currently idle
*/
boolean isIndexerIdle();
}

View file

@ -481,7 +481,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
}
}
private boolean isIndexerIdle() {
public boolean isIndexerIdle() {
synchronized (fTaskQueueMutex) {
return fCurrentTask == null && fTaskQueue.isEmpty();
}

View file

@ -46,6 +46,8 @@ public class IBMessages extends NLS {
public static String IBViewPart_showIncludesTo_label;
public static String IBViewPart_showIncludesTo_tooltip;
public static String IBViewPart_ShowInMenu_label;
public static String IBViewPart_waitingOnIndexerMessage;
public static String IBViewPart_workspaceScope;
static {

View file

@ -18,6 +18,7 @@ IBViewPart_showFolders_label=Show Folders
IBViewPart_showFolders_tooltip=Show Folders
IBViewPart_previousMatch_label=Previous Include
IBViewPart_showIncludesTo_tooltip=Show Files Included
IBViewPart_waitingOnIndexerMessage=Waiting for indexer to complete.
IBViewPart_IncludedByContentDescription=Files including ''{0}'' - in {1}
IBViewPart_IncludesToContentDescription=Files included by ''{0}'' - in {1}
IBViewPart_hideInactive_tooltip=Hide Includes from Inactive Code

View file

@ -68,6 +68,7 @@ import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
@ -92,7 +93,7 @@ public class IBViewPart extends ViewPart
private static final String TRUE = String.valueOf(true);
private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
private static final String KEY_FILTER_SYSTEM = "systemFilter"; //$NON-NLS-1$
private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
// private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
private static final String KEY_INPUT_PATH= "inputPath"; //$NON-NLS-1$
private IMemento fMemento;
@ -113,7 +114,7 @@ public class IBViewPart extends ViewPart
// filters, sorter
private IBWorkingSetFilter fWorkingSetFilter;
private ViewerFilter fInactiveFilter;
// private ViewerFilter fInactiveFilter;
private ViewerFilter fSystemFilter;
private ViewerComparator fSorterAlphaNumeric;
private ViewerComparator fSorterReferencePosition;
@ -121,7 +122,7 @@ public class IBViewPart extends ViewPart
// actions
private Action fIncludedByAction;
private Action fIncludesToAction;
private Action fFilterInactiveAction;
// private Action fFilterInactiveAction;
private Action fFilterSystemAction;
private Action fShowFolderInLabelsAction;
private Action fNextAction;
@ -142,14 +143,30 @@ public class IBViewPart extends ViewPart
updateDescription();
}
public void setInput(ITranslationUnit input) {
public void setInput(final ITranslationUnit input) {
if (input == null) {
setMessage(IBMessages.IBViewPart_instructionMessage);
fTreeViewer.setInput(null);
return;
}
fShowsMessage= false;
if (CCorePlugin.getIndexManager().isIndexerIdle()) {
setInputIndexerIdle(input);
}
else {
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
Display disp= Display.getCurrent();
if (disp != null && !disp.isDisposed()) {
disp.timerExec(500, new Runnable() {
public void run() {
setInput(input);
}});
}
}
}
private void setInputIndexerIdle(ITranslationUnit input) {
fShowsMessage= false;
boolean isHeader= input.isHeaderUnit();
fTreeViewer.setInput(null);
@ -165,7 +182,7 @@ public class IBViewPart extends ViewPart
updateActionEnablement();
updateDescription();
}
}
private void updateActionEnablement() {
fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
@ -195,19 +212,19 @@ public class IBViewPart extends ViewPart
private void initializeActionStates() {
boolean includedBy= true;
boolean filterSystem= false;
boolean filterInactive= false;
// boolean filterInactive= false;
if (fMemento != null) {
filterSystem= TRUE.equals(fMemento.getString(KEY_FILTER_SYSTEM));
filterInactive= TRUE.equals(fMemento.getString(KEY_FILTER_INACTIVE));
// filterInactive= TRUE.equals(fMemento.getString(KEY_FILTER_INACTIVE));
}
fIncludedByAction.setChecked(includedBy);
fIncludesToAction.setChecked(!includedBy);
fContentProvider.setComputeIncludedBy(includedBy);
fFilterInactiveAction.setChecked(filterInactive);
fFilterInactiveAction.run();
// fFilterInactiveAction.setChecked(filterInactive);
// fFilterInactiveAction.run();
fFilterSystemAction.setChecked(filterSystem);
fFilterSystemAction.run();
updateSorter();
@ -248,7 +265,7 @@ public class IBViewPart extends ViewPart
if (fWorkingSetFilter != null) {
fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
}
memento.putString(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
// memento.putString(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
memento.putString(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
ITranslationUnit input= getInput();
if (input != null) {
@ -354,27 +371,27 @@ public class IBViewPart extends ViewPart
fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
fInactiveFilter= new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
return node.isActiveCode();
}
return true;
}
};
fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
public void run() {
if (isChecked()) {
fTreeViewer.addFilter(fInactiveFilter);
}
else {
fTreeViewer.removeFilter(fInactiveFilter);
}
}
};
fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
// fInactiveFilter= new ViewerFilter() {
// public boolean select(Viewer viewer, Object parentElement, Object element) {
// if (element instanceof IBNode) {
// IBNode node= (IBNode) element;
// return node.isActiveCode();
// }
// return true;
// }
// };
// fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
// public void run() {
// if (isChecked()) {
// fTreeViewer.addFilter(fInactiveFilter);
// }
// else {
// fTreeViewer.removeFilter(fInactiveFilter);
// }
// }
// };
// fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
// CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
fSystemFilter= new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
@ -468,7 +485,7 @@ public class IBViewPart extends ViewPart
tm.add(fPreviousAction);
tm.add(new Separator());
tm.add(fFilterSystemAction);
tm.add(fFilterInactiveAction);
// tm.add(fFilterInactiveAction);
tm.add(new Separator());
tm.add(fIncludedByAction);
tm.add(fIncludesToAction);
@ -488,7 +505,7 @@ public class IBViewPart extends ViewPart
mm.add(fShowFolderInLabelsAction);
mm.add(new Separator());
mm.add(fFilterSystemAction);
mm.add(fFilterInactiveAction);
// mm.add(fFilterInactiveAction);
}
private IBNode getNextNode(boolean forward) {
@ -569,7 +586,6 @@ public class IBViewPart extends ViewPart
}
}
}
message= "The Include Browser is work in progress! - " + message; //$NON-NLS-1$
setContentDescription(message);
}