protected void doTest(final Test test) { assert myFile != null : "configure first"; final VirtualFile vFile = myFile.getVirtualFile(); assert vFile != null : "no virtual file for " + myFile; final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile); assert fileEditor != null : "editor not opened for " + vFile; final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(myFile); assert builder != null : "no builder for " + myFile; StructureViewComponent component = null; try { component = (StructureViewComponent) builder.createStructureView(fileEditor, myProject); test.test(component); } finally { if (component != null) Disposer.dispose(component); } }
@Override public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) { final StructureViewBuilder structureViewBuilder = event.getData(PlatformDataKeys.FILE_EDITOR).getStructureViewBuilder(); if (structureViewBuilder == null) { return; } StructureView structureView = structureViewBuilder.createStructureView( event.getData(PlatformDataKeys.FILE_EDITOR), event.getData(CommonDataKeys.PROJECT)); FileStructurePopup popup = new FileStructurePopup( structureView.getTreeModel(), event.getData(CommonDataKeys.PROJECT), structureView, true); if (event.getData(CommonDataKeys.VIRTUAL_FILE) != null) { // todo: look like this action is unnecessary (it's just ctrl+f12 idea action by logic and // implementation) popup.setTitle(event.getData(CommonDataKeys.VIRTUAL_FILE).getName()); } popup.show(); }