public static String getProjectName() { DataContext dataContext = DataManager.getInstance().getDataContext(); if (dataContext != null) { Project project = null; try { project = CommonDataKeys.PROJECT.getData(dataContext); } catch (NoClassDefFoundError e) { try { project = DataKeys.PROJECT.getData(dataContext); } catch (NoClassDefFoundError ex) { } } if (project != null) { return project.getName(); } } return null; }
public void setSelected(final AnActionEvent event, final boolean selected) { final Project project = DataKeys.PROJECT.getData(event.getDataContext()); if (project == null) { return; } final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class); if (checkStylePlugin == null) { throw new IllegalStateException("Couldn't get checkstyle plugin"); } final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleConstants.ID_TOOLWINDOW); final Content content = toolWindow.getContentManager().getContent(0); if (content != null) { final ToolWindowPanel panel = (ToolWindowPanel) content.getComponent(); panel.setDisplayingWarnings(selected); panel.filterDisplayedResults(); } }
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = DataKeys.PROJECT.getData(dataContext); if (project == null) { return; } final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project); final TreeClassChooser classChooser = chooserFactory.createWithInnerClassesScopeChooser( chooserTitle, GlobalSearchScope.allScope(project), myFilter, null); classChooser.showDialog(); final PsiClass selectedClass = classChooser.getSelected(); if (selectedClass == null) { return; } final String qualifiedName = selectedClass.getQualifiedName(); final ListWrappingTableModel tableModel = table.getModel(); final int index = tableModel.indexOf(qualifiedName, 0); final int rowIndex; if (index < 0) { tableModel.addRow(qualifiedName); rowIndex = tableModel.getRowCount() - 1; } else { rowIndex = index; } final ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(rowIndex, rowIndex); EventQueue.invokeLater( new Runnable() { public void run() { final Rectangle rectangle = table.getCellRect(rowIndex, 0, true); table.scrollRectToVisible(rectangle); } }); }
public void actionPerformed(AnActionEvent e) { ComparatorDialog comparatorDialog = new ComparatorDialog(DataKeys.PROJECT.getData(e.getDataContext())); comparatorDialog.show(); }