use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OccurenceNavigatorSupport method findNode.
public DefaultMutableTreeNode findNode(@NotNull JTree tree, TreeNode selectedNode, boolean forward, Counters counters) {
boolean[] ready = { selectedNode == null };
DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
Enumeration enumeration = root.preorderEnumeration();
List<TreeNode> nodes = new ArrayList<>();
while (enumeration.hasMoreElements()) {
TreeNode node = (TreeNode) enumeration.nextElement();
nodes.add(node);
}
DefaultMutableTreeNode result = null;
if (forward) {
for (TreeNode node : nodes) {
DefaultMutableTreeNode nextNode = getNode(node, selectedNode, ready);
if (nextNode != null) {
result = nextNode;
break;
}
}
} else {
for (int i = nodes.size() - 1; i >= 0; i--) {
TreeNode node = nodes.get(i);
DefaultMutableTreeNode nextNode = getNode(node, selectedNode, ready);
if (nextNode != null) {
result = nextNode;
break;
}
}
}
if (result == null) {
return null;
}
if (counters != null) {
counters.myFoundOccurenceNumber = 0;
counters.myOccurencesCount = 0;
for (TreeNode node : nodes) {
if (!(node instanceof DefaultMutableTreeNode))
continue;
Navigatable descriptor = createDescriptorForNode((DefaultMutableTreeNode) node);
if (descriptor == null)
continue;
counters.myOccurencesCount++;
if (result == node) {
counters.myFoundOccurenceNumber = counters.myOccurencesCount;
}
}
}
return result;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OccurenceNavigatorSupport method goPreviousOccurence.
@Override
public OccurenceInfo goPreviousOccurence() {
Counters counters = new Counters();
DefaultMutableTreeNode node = findNode(myTree, false, counters);
if (node == null)
return null;
TreePath treePath = new TreePath(node.getPath());
TreeUtil.selectPath(myTree, treePath);
Navigatable editSourceDescriptor = createDescriptorForNode(node);
if (editSourceDescriptor == null)
return null;
return new OccurenceInfo(editSourceDescriptor, counters.myFoundOccurenceNumber, counters.myOccurencesCount);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class BaseNavigateToSourceAction method update.
public void update(AnActionEvent e) {
boolean inPopup = ActionPlaces.isPopupPlace(e.getPlace());
Navigatable target = findTargetForUpdate(e.getDataContext());
boolean enabled = target != null;
if (inPopup && !(this instanceof OpenModuleSettingsAction) && OpenModuleSettingsAction.isModuleInProjectViewPopup(e)) {
e.getPresentation().setVisible(false);
return;
}
//as myFocusEditor is always ignored - Main Menu|View always contains 2 actions with the same name and actually same behaviour
e.getPresentation().setVisible((enabled || !inPopup) && (myFocusEditor || !(target instanceof NavigatableWithText)));
e.getPresentation().setEnabled(enabled);
String navigateActionText = myFocusEditor && target instanceof NavigatableWithText ? ((NavigatableWithText) target).getNavigateActionText(true) : null;
e.getPresentation().setText(navigateActionText == null ? getTemplatePresentation().getText() : navigateActionText);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class SMTestRunnerResultsForm method createTestTreeView.
protected JComponent createTestTreeView() {
myTreeView = new SMTRunnerTestTreeView();
myTreeView.setLargeModel(true);
myTreeView.attachToModel(this);
myTreeView.setTestResultsViewer(this);
final SMTRunnerTreeStructure structure = new SMTRunnerTreeStructure(myProject, myTestsRootNode);
myTreeBuilder = new SMTRunnerTreeBuilder(myTreeView, structure);
myTreeBuilder.setTestsComparator(myProperties);
Disposer.register(this, myTreeBuilder);
myAnimator = new TestsProgressAnimator(myTreeBuilder);
TrackRunningTestUtil.installStopListeners(myTreeView, myProperties, new Pass<AbstractTestProxy>() {
@Override
public void pass(AbstractTestProxy testProxy) {
if (testProxy == null)
return;
final AbstractTestProxy selectedProxy = testProxy;
//drill to the first leaf
while (!testProxy.isLeaf()) {
final List<? extends AbstractTestProxy> children = testProxy.getChildren();
if (!children.isEmpty()) {
final AbstractTestProxy firstChild = children.get(0);
if (firstChild != null) {
testProxy = firstChild;
continue;
}
}
break;
}
//pretend the selection on the first leaf
//so if test would be run, tracking would be restarted
myLastSelected = testProxy;
//ensure scroll to source on explicit selection only
if (ScrollToTestSourceAction.isScrollEnabled(SMTestRunnerResultsForm.this)) {
final Navigatable descriptor = TestsUIUtil.getOpenFileDescriptor(selectedProxy, SMTestRunnerResultsForm.this);
if (descriptor != null) {
OpenSourceUtil.navigate(false, descriptor);
}
}
}
});
//myTreeView.setRootVisible(false);
return myTreeView;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class NewErrorTreeViewPanel method navigateToSource.
private void navigateToSource(final boolean focusEditor) {
NavigatableErrorTreeElement element = getSelectedNavigatableElement();
if (element == null) {
return;
}
final Navigatable navigatable = element.getNavigatable();
if (navigatable.canNavigate()) {
navigatable.navigate(focusEditor);
}
}
Aggregations