use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class HierarchyBrowserBase method getNavigatables.
private Navigatable[] getNavigatables() {
final HierarchyNodeDescriptor[] selectedDescriptors = getSelectedDescriptors();
if (selectedDescriptors == null || selectedDescriptors.length == 0)
return null;
final ArrayList<Navigatable> result = new ArrayList<>();
for (HierarchyNodeDescriptor descriptor : selectedDescriptors) {
Navigatable navigatable = getNavigatable(descriptor);
if (navigatable != null) {
result.add(navigatable);
}
}
return result.toArray(new Navigatable[result.size()]);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class NavigatableRule method getData.
@Override
public Object getData(DataProvider dataProvider) {
final Navigatable navigatable = CommonDataKeys.NAVIGATABLE.getData(dataProvider);
if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor) navigatable;
if (openFileDescriptor.getFile().isValid()) {
return openFileDescriptor;
}
}
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataProvider);
if (element instanceof Navigatable) {
return element;
}
if (element != null) {
return EditSourceUtil.getDescriptor(element);
}
final Object selection = PlatformDataKeys.SELECTED_ITEM.getData(dataProvider);
if (selection instanceof Navigatable) {
return selection;
}
return null;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OccurenceNavigatorSupport method goNextOccurence.
@Override
public OccurenceInfo goNextOccurence() {
Counters counters = new Counters();
DefaultMutableTreeNode node = findNode(myTree, true, 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 SelectInContextImpl method createContext.
@Nullable
public static SelectInContext createContext(AnActionEvent event) {
DataContext dataContext = event.getDataContext();
SelectInContext result = createEditorContext(dataContext);
if (result != null) {
return result;
}
JComponent sourceComponent = getEventComponent(event);
if (sourceComponent == null) {
return null;
}
SelectInContext selectInContext = SelectInContext.DATA_KEY.getData(dataContext);
if (selectInContext == null) {
selectInContext = createPsiContext(event);
}
if (selectInContext == null) {
Navigatable descriptor = CommonDataKeys.NAVIGATABLE.getData(dataContext);
if (descriptor instanceof OpenFileDescriptor) {
final VirtualFile file = ((OpenFileDescriptor) descriptor).getFile();
if (file.isValid()) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
selectInContext = OpenFileDescriptorContext.create(project, file);
}
}
}
if (selectInContext == null) {
VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (virtualFile != null && project != null) {
return new VirtualFileSelectInContext(project, virtualFile);
}
}
return selectInContext;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class AbstractProjectViewPane method getData.
@Override
public Object getData(String dataId) {
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
TreePath[] paths = getSelectionPaths();
if (paths == null)
return null;
final ArrayList<Navigatable> navigatables = new ArrayList<>();
for (TreePath path : paths) {
Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) lastPathComponent;
Object userObject = node.getUserObject();
if (userObject instanceof Navigatable) {
navigatables.add((Navigatable) userObject);
} else if (node instanceof Navigatable) {
navigatables.add((Navigatable) node);
}
}
}
if (navigatables.isEmpty()) {
return null;
} else {
return navigatables.toArray(new Navigatable[navigatables.size()]);
}
}
if (myTreeStructure instanceof AbstractTreeStructureBase) {
return ((AbstractTreeStructureBase) myTreeStructure).getDataFromProviders(getSelectedNodes(AbstractTreeNode.class), dataId);
}
return null;
}
Aggregations