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:
parent
9350190911
commit
665fdd2ca8
5 changed files with 60 additions and 36 deletions
|
@ -102,4 +102,9 @@ public interface IIndexManager {
|
||||||
* @return <code>true</code>, if the indexer went idle in the given time.
|
* @return <code>true</code>, if the indexer went idle in the given time.
|
||||||
*/
|
*/
|
||||||
boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor);
|
boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the indexer is currently idle
|
||||||
|
*/
|
||||||
|
boolean isIndexerIdle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,7 +481,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIndexerIdle() {
|
public boolean isIndexerIdle() {
|
||||||
synchronized (fTaskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
return fCurrentTask == null && fTaskQueue.isEmpty();
|
return fCurrentTask == null && fTaskQueue.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class IBMessages extends NLS {
|
||||||
public static String IBViewPart_showIncludesTo_label;
|
public static String IBViewPart_showIncludesTo_label;
|
||||||
public static String IBViewPart_showIncludesTo_tooltip;
|
public static String IBViewPart_showIncludesTo_tooltip;
|
||||||
public static String IBViewPart_ShowInMenu_label;
|
public static String IBViewPart_ShowInMenu_label;
|
||||||
|
|
||||||
|
public static String IBViewPart_waitingOnIndexerMessage;
|
||||||
public static String IBViewPart_workspaceScope;
|
public static String IBViewPart_workspaceScope;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -18,6 +18,7 @@ IBViewPart_showFolders_label=Show Folders
|
||||||
IBViewPart_showFolders_tooltip=Show Folders
|
IBViewPart_showFolders_tooltip=Show Folders
|
||||||
IBViewPart_previousMatch_label=Previous Include
|
IBViewPart_previousMatch_label=Previous Include
|
||||||
IBViewPart_showIncludesTo_tooltip=Show Files Included
|
IBViewPart_showIncludesTo_tooltip=Show Files Included
|
||||||
|
IBViewPart_waitingOnIndexerMessage=Waiting for indexer to complete.
|
||||||
IBViewPart_IncludedByContentDescription=Files including ''{0}'' - in {1}
|
IBViewPart_IncludedByContentDescription=Files including ''{0}'' - in {1}
|
||||||
IBViewPart_IncludesToContentDescription=Files included by ''{0}'' - in {1}
|
IBViewPart_IncludesToContentDescription=Files included by ''{0}'' - in {1}
|
||||||
IBViewPart_hideInactive_tooltip=Hide Includes from Inactive Code
|
IBViewPart_hideInactive_tooltip=Hide Includes from Inactive Code
|
||||||
|
|
|
@ -68,6 +68,7 @@ import org.eclipse.ui.part.ResourceTransfer;
|
||||||
import org.eclipse.ui.part.ShowInContext;
|
import org.eclipse.ui.part.ShowInContext;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
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.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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 TRUE = String.valueOf(true);
|
||||||
private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
|
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_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 static final String KEY_INPUT_PATH= "inputPath"; //$NON-NLS-1$
|
||||||
|
|
||||||
private IMemento fMemento;
|
private IMemento fMemento;
|
||||||
|
@ -113,7 +114,7 @@ public class IBViewPart extends ViewPart
|
||||||
|
|
||||||
// filters, sorter
|
// filters, sorter
|
||||||
private IBWorkingSetFilter fWorkingSetFilter;
|
private IBWorkingSetFilter fWorkingSetFilter;
|
||||||
private ViewerFilter fInactiveFilter;
|
// private ViewerFilter fInactiveFilter;
|
||||||
private ViewerFilter fSystemFilter;
|
private ViewerFilter fSystemFilter;
|
||||||
private ViewerComparator fSorterAlphaNumeric;
|
private ViewerComparator fSorterAlphaNumeric;
|
||||||
private ViewerComparator fSorterReferencePosition;
|
private ViewerComparator fSorterReferencePosition;
|
||||||
|
@ -121,7 +122,7 @@ public class IBViewPart extends ViewPart
|
||||||
// actions
|
// actions
|
||||||
private Action fIncludedByAction;
|
private Action fIncludedByAction;
|
||||||
private Action fIncludesToAction;
|
private Action fIncludesToAction;
|
||||||
private Action fFilterInactiveAction;
|
// private Action fFilterInactiveAction;
|
||||||
private Action fFilterSystemAction;
|
private Action fFilterSystemAction;
|
||||||
private Action fShowFolderInLabelsAction;
|
private Action fShowFolderInLabelsAction;
|
||||||
private Action fNextAction;
|
private Action fNextAction;
|
||||||
|
@ -142,14 +143,30 @@ public class IBViewPart extends ViewPart
|
||||||
updateDescription();
|
updateDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInput(ITranslationUnit input) {
|
public void setInput(final ITranslationUnit input) {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
setMessage(IBMessages.IBViewPart_instructionMessage);
|
setMessage(IBMessages.IBViewPart_instructionMessage);
|
||||||
fTreeViewer.setInput(null);
|
fTreeViewer.setInput(null);
|
||||||
return;
|
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();
|
boolean isHeader= input.isHeaderUnit();
|
||||||
|
|
||||||
fTreeViewer.setInput(null);
|
fTreeViewer.setInput(null);
|
||||||
|
@ -165,7 +182,7 @@ public class IBViewPart extends ViewPart
|
||||||
|
|
||||||
updateActionEnablement();
|
updateActionEnablement();
|
||||||
updateDescription();
|
updateDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateActionEnablement() {
|
private void updateActionEnablement() {
|
||||||
fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
|
fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
|
||||||
|
@ -195,19 +212,19 @@ public class IBViewPart extends ViewPart
|
||||||
private void initializeActionStates() {
|
private void initializeActionStates() {
|
||||||
boolean includedBy= true;
|
boolean includedBy= true;
|
||||||
boolean filterSystem= false;
|
boolean filterSystem= false;
|
||||||
boolean filterInactive= false;
|
// boolean filterInactive= false;
|
||||||
|
|
||||||
if (fMemento != null) {
|
if (fMemento != null) {
|
||||||
filterSystem= TRUE.equals(fMemento.getString(KEY_FILTER_SYSTEM));
|
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);
|
fIncludedByAction.setChecked(includedBy);
|
||||||
fIncludesToAction.setChecked(!includedBy);
|
fIncludesToAction.setChecked(!includedBy);
|
||||||
fContentProvider.setComputeIncludedBy(includedBy);
|
fContentProvider.setComputeIncludedBy(includedBy);
|
||||||
|
|
||||||
fFilterInactiveAction.setChecked(filterInactive);
|
// fFilterInactiveAction.setChecked(filterInactive);
|
||||||
fFilterInactiveAction.run();
|
// fFilterInactiveAction.run();
|
||||||
fFilterSystemAction.setChecked(filterSystem);
|
fFilterSystemAction.setChecked(filterSystem);
|
||||||
fFilterSystemAction.run();
|
fFilterSystemAction.run();
|
||||||
updateSorter();
|
updateSorter();
|
||||||
|
@ -248,7 +265,7 @@ public class IBViewPart extends ViewPart
|
||||||
if (fWorkingSetFilter != null) {
|
if (fWorkingSetFilter != null) {
|
||||||
fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
|
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()));
|
memento.putString(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
|
||||||
ITranslationUnit input= getInput();
|
ITranslationUnit input= getInput();
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
|
@ -354,27 +371,27 @@ public class IBViewPart extends ViewPart
|
||||||
fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
|
fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
|
||||||
CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
|
CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
|
||||||
|
|
||||||
fInactiveFilter= new ViewerFilter() {
|
// fInactiveFilter= new ViewerFilter() {
|
||||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
// public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
if (element instanceof IBNode) {
|
// if (element instanceof IBNode) {
|
||||||
IBNode node= (IBNode) element;
|
// IBNode node= (IBNode) element;
|
||||||
return node.isActiveCode();
|
// return node.isActiveCode();
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
|
// fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
|
||||||
public void run() {
|
// public void run() {
|
||||||
if (isChecked()) {
|
// if (isChecked()) {
|
||||||
fTreeViewer.addFilter(fInactiveFilter);
|
// fTreeViewer.addFilter(fInactiveFilter);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
fTreeViewer.removeFilter(fInactiveFilter);
|
// fTreeViewer.removeFilter(fInactiveFilter);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
|
// fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
|
||||||
CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
|
// CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
|
||||||
|
|
||||||
fSystemFilter= new ViewerFilter() {
|
fSystemFilter= new ViewerFilter() {
|
||||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
@ -468,7 +485,7 @@ public class IBViewPart extends ViewPart
|
||||||
tm.add(fPreviousAction);
|
tm.add(fPreviousAction);
|
||||||
tm.add(new Separator());
|
tm.add(new Separator());
|
||||||
tm.add(fFilterSystemAction);
|
tm.add(fFilterSystemAction);
|
||||||
tm.add(fFilterInactiveAction);
|
// tm.add(fFilterInactiveAction);
|
||||||
tm.add(new Separator());
|
tm.add(new Separator());
|
||||||
tm.add(fIncludedByAction);
|
tm.add(fIncludedByAction);
|
||||||
tm.add(fIncludesToAction);
|
tm.add(fIncludesToAction);
|
||||||
|
@ -488,7 +505,7 @@ public class IBViewPart extends ViewPart
|
||||||
mm.add(fShowFolderInLabelsAction);
|
mm.add(fShowFolderInLabelsAction);
|
||||||
mm.add(new Separator());
|
mm.add(new Separator());
|
||||||
mm.add(fFilterSystemAction);
|
mm.add(fFilterSystemAction);
|
||||||
mm.add(fFilterInactiveAction);
|
// mm.add(fFilterInactiveAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBNode getNextNode(boolean forward) {
|
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);
|
setContentDescription(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue