public TemplateKindCombo() { //noinspection unchecked getComboBox().setRenderer(new ListCellRendererWrapper() { @Override public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean cellHasFocus) { if (value instanceof Trinity) { setText((String)((Trinity)value).first); setIcon ((Icon)((Trinity)value).second); } } }); new ComboboxSpeedSearch(getComboBox()) { @Override protected String getElementText(Object element) { if (element instanceof Trinity) { return (String)((Trinity)element).first; } return null; } }.setComparator(new SpeedSearchComparator(true)); setButtonListener(null); }
private void createComponent() { setLayout(new BorderLayout()); myRepositoryTree = new Tree(); myRepositoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myRepositoryTree.setRootVisible(false); myRepositoryTree.setShowsRootHandles(true); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myRepositoryTree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(scrollPane, BorderLayout.CENTER); myRepositoryTree.setCellRenderer(new SvnRepositoryTreeCellRenderer()); TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, new Convertor<TreePath, String>() { @Override public String convert(TreePath o) { Object component = o.getLastPathComponent(); if (component instanceof RepositoryTreeNode) { return ((RepositoryTreeNode)component).getURL().toDecodedString(); } return null; } }); search.setComparator(new SpeedSearchComparator(false, true)); EditSourceOnDoubleClickHandler.install(myRepositoryTree); }
public ThreadDumpPanel(Project project, final ConsoleView consoleView, final DefaultActionGroup toolbarActions, final List<ThreadState> threadDump) { super(new BorderLayout()); final ThreadState[] data = threadDump.toArray(new ThreadState[threadDump.size()]); DefaultListModel model = new DefaultListModel(); for (ThreadState threadState : data) { model.addElement(threadState); } myThreadList = new JBList(model); myThreadList.setCellRenderer(new ThreadListCellRenderer()); myThreadList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myThreadList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { int index = myThreadList.getSelectedIndex(); if (index >= 0) { ThreadState selection = (ThreadState)myThreadList.getModel().getElementAt(index); AnalyzeStacktraceUtil.printStacktrace(consoleView, selection.getStackTrace()); } else { AnalyzeStacktraceUtil.printStacktrace(consoleView, ""); } myThreadList.repaint(); } }); toolbarActions.add(new CopyToClipboardAction(threadDump, project)); toolbarActions.add(new SortThreadsAction()); //toolbarActions.add(new ShowRecentlyChanged()); add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false).getComponent(), BorderLayout.WEST); final Splitter splitter = new Splitter(false, 0.3f); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myThreadList, SideBorder.LEFT | SideBorder.RIGHT)); splitter.setSecondComponent(consoleView.getComponent()); add(splitter, BorderLayout.CENTER); new ListSpeedSearch(myThreadList).setComparator(new SpeedSearchComparator(false, true)); }
public static void chooseAndOverrideOrImplementMethods(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PyClass pyClass, @NotNull final Collection<PyFunction> superFunctions, @NotNull final String title, final boolean implement) { List<PyMethodMember> elements = new ArrayList<PyMethodMember>(); for (PyFunction function : superFunctions) { final String name = function.getName(); if (name == null || PyUtil.isClassPrivateName(name)) { continue; } if (pyClass.findMethodByName(name, false) == null) { final PyMethodMember member = new PyMethodMember(function); elements.add(member); } } if (elements.size() == 0) { return; } final MemberChooser<PyMethodMember> chooser = new MemberChooser<PyMethodMember>(elements.toArray(new PyMethodMember[elements.size()]), false, true, project) { @Override protected SpeedSearchComparator getSpeedSearchComparator() { return new SpeedSearchComparator(false) { @Nullable @Override public Iterable<TextRange> matchingFragments(@NotNull String pattern, @NotNull String text) { return super.matchingFragments(PyMethodMember.trimUnderscores(pattern), text); } }; } }; chooser.setTitle(title); chooser.setCopyJavadocVisible(false); chooser.show(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) { return; } List<PyMethodMember> membersToOverride = chooser.getSelectedElements(); overrideMethods(editor, pyClass, membersToOverride, implement); }
@Nullable @Override protected JComponent createCenterPanel() { final TestFindResult closest = jasmineFile.getClosestTestFromCaret(caretOffset); // Build the tree. TreeNode root = jasmineFile.getTreeNode(); tree = new Tree(root); tree.setVisibleRowCount(VISIBLE_ROW_COUNT); tree.setCellRenderer(new CustomTreeCellRenderer()); // Check if there are multiple describes in the file. if (root.getUserObject() instanceof String) { tree.setRootVisible(false); } TreeUtil.expandAll(tree); // Add search, make it case insensitive. new TreeSpeedSearch(tree) { @Override protected boolean compare(String text, String pattern) { return super.compare(text.toLowerCase(), pattern.toLowerCase()); } }.setComparator(new SpeedSearchComparator(false)); // Perform the OK action on enter. tree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { // Set the selected node when you click OK. DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); selectedTest = (TestFindResult) lastPathComponent.getUserObject(); doOKAction(); } } }); // Jump to code on double click. tree.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX(), e.getY()); if (selRow != -1 && e.getClickCount() == 2) { goToTest(tree.getPathForLocation(e.getX(), e.getY())); } } }); JBScrollPane scrollPane = new JBScrollPane(tree); selectClosestTest(root, closest); JPanel panel = new JPanel(new BorderLayout()); panel.add(BorderLayout.CENTER, scrollPane); panel.add(BorderLayout.SOUTH, createPanelWithLabels()); return panel; }