use of com.intellij.openapi.actionSystem.DataProvider in project intellij-community by JetBrains.
the class MavenDomTestCase method search.
protected List<PsiElement> search(VirtualFile file) throws IOException {
final MapDataContext context = createDataContext(file);
UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return context.getData(dataId);
}
});
PsiElement target = ((PsiElement2UsageTargetAdapter) targets[0]).getElement();
List<PsiReference> result = new ArrayList<>(ReferencesSearch.search(target).findAll());
return ContainerUtil.map(result, psiReference -> psiReference.getElement());
}
use of com.intellij.openapi.actionSystem.DataProvider in project intellij-community by JetBrains.
the class NavBarPopup method createPopupContent.
private static JComponent createPopupContent(final NavBarPanel panel, Object[] siblings) {
final JBList list = new NavbarPopupList(panel, siblings);
list.setDataProvider(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return panel.getData(dataId);
}
});
final List<Disposable> disposables = new ArrayList<>();
list.putClientProperty(DISPOSED_OBJECTS, disposables);
list.installCellRenderer(obj -> {
final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
disposables.add(navBarItem);
return navBarItem;
});
list.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
installEnterAction(list, panel, KeyEvent.VK_ENTER);
installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
final JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), o -> panel.getPresentation().getPresentableText(o));
component.putClientProperty(JBLIST_KEY, list);
return component;
}
use of com.intellij.openapi.actionSystem.DataProvider in project intellij-community by JetBrains.
the class DockableEditorTabbedContainer method add.
@Override
public void add(@NotNull DockableContent content, RelativePoint dropTarget) {
EditorWindow window = null;
if (myCurrentOver != null) {
final DataProvider provider = myCurrentOver.getDataProvider();
if (provider != null) {
window = EditorWindow.DATA_KEY.getData(provider);
}
}
final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor) content;
VirtualFile file = dockableEditor.getFile();
if (window == null || window.isDisposed()) {
window = mySplitters.getOrCreateCurrentWindow(file);
}
if (myCurrentOver != null) {
int index = ((JBTabsImpl) myCurrentOver).getDropInfoIndex();
file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index);
}
((FileEditorManagerImpl) FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true);
window.setFilePinned(file, dockableEditor.isPinned());
}
use of com.intellij.openapi.actionSystem.DataProvider in project android by JetBrains.
the class AndroidFindUsagesTest method findUsages.
private static Collection<UsageInfo> findUsages(String fileName, final JavaCodeInsightTestFixture fixture, String newFilePath) throws Throwable {
VirtualFile file = fixture.copyFileToProject(BASE_PATH + fileName, newFilePath);
fixture.configureFromExistingVirtualFile(file);
final UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return ((EditorEx) fixture.getEditor()).getDataContext().getData(dataId);
}
});
assert targets != null && targets.length > 0 && targets[0] instanceof PsiElementUsageTarget;
return fixture.findUsages(((PsiElementUsageTarget) targets[0]).getElement());
}
use of com.intellij.openapi.actionSystem.DataProvider in project intellij-community by JetBrains.
the class RunContentManagerImpl method registerToolWindow.
private void registerToolWindow(@NotNull final Executor executor, @NotNull ToolWindowManagerEx toolWindowManager) {
final String toolWindowId = executor.getToolWindowId();
if (toolWindowManager.getToolWindow(toolWindowId) != null) {
return;
}
final ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true);
final ContentManager contentManager = toolWindow.getContentManager();
contentManager.addDataProvider(new DataProvider() {
private int myInsideGetData = 0;
@Override
public Object getData(String dataId) {
myInsideGetData++;
try {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return executor.getHelpId();
} else {
return myInsideGetData == 1 ? DataManager.getInstance().getDataContext(contentManager.getComponent()).getData(dataId) : null;
}
} finally {
myInsideGetData--;
}
}
});
toolWindow.setIcon(executor.getToolWindowIcon());
new ContentManagerWatcher(toolWindow, contentManager);
initToolWindow(executor, toolWindowId, executor.getToolWindowIcon(), contentManager);
}
Aggregations