Search in sources :

Example 6 with SpeedSearchSupply

use of com.intellij.ui.speedSearch.SpeedSearchSupply in project intellij-community by JetBrains.

the class DebuggerTreeWithHistoryPopup method updateContainer.

@Override
protected void updateContainer(final Tree tree, String title) {
    if (myPopup != null) {
        myPopup.cancel();
    }
    tree.getModel().addTreeModelListener(createTreeListener(tree));
    myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(createMainPanel(tree), tree).setRequestFocus(true).setTitle(title).setResizable(true).setMovable(true).setDimensionServiceKey(myProject, DIMENSION_SERVICE_KEY, false).setMayBeParent(true).setKeyEventHandler(event -> {
        if (AbstractPopup.isCloseRequest(event)) {
            SpeedSearchSupply supply = SpeedSearchSupply.getSupply(tree);
            return supply != null && StringUtil.isEmpty(supply.getEnteredPrefix());
        }
        return false;
    }).addListener(new JBPopupAdapter() {

        @Override
        public void onClosed(LightweightWindowEvent event) {
            if (myHideRunnable != null) {
                myHideRunnable.run();
            }
        }
    }).setCancelCallback(() -> {
        Window parent = SwingUtilities.getWindowAncestor(tree);
        if (parent != null) {
            for (Window child : parent.getOwnedWindows()) {
                if (child.isShowing()) {
                    return false;
                }
            }
        }
        return true;
    }).createPopup();
    registerTreeDisposable(myPopup, tree);
    //Editor may be disposed before later invokator process this action
    if (myEditor.getComponent().getRootPane() == null) {
        myPopup.cancel();
        return;
    }
    myPopup.show(new RelativePoint(myEditor.getContentComponent(), myPoint));
    updateInitialBounds(tree);
}
Also used : SpeedSearchSupply(com.intellij.ui.speedSearch.SpeedSearchSupply) JBPopupAdapter(com.intellij.openapi.ui.popup.JBPopupAdapter) RelativePoint(com.intellij.ui.awt.RelativePoint) LightweightWindowEvent(com.intellij.openapi.ui.popup.LightweightWindowEvent)

Example 7 with SpeedSearchSupply

use of com.intellij.ui.speedSearch.SpeedSearchSupply in project intellij-community by JetBrains.

the class JBTable method editCellAt.

@Override
public boolean editCellAt(final int row, final int column, final EventObject e) {
    if (cellEditor != null && !cellEditor.stopCellEditing()) {
        return false;
    }
    if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) {
        return false;
    }
    if (!isCellEditable(row, column)) {
        return false;
    }
    if (e instanceof KeyEvent) {
        // do not start editing in autoStartsEdit mode on Ctrl-Z and other non-typed events
        if (!UIUtil.isReallyTypedEvent((KeyEvent) e) || ((KeyEvent) e).getKeyChar() == KeyEvent.CHAR_UNDEFINED)
            return false;
        SpeedSearchSupply supply = SpeedSearchSupply.getSupply(this);
        if (supply != null && supply.isPopupActive()) {
            return false;
        }
    }
    final TableCellEditor editor = getCellEditor(row, column);
    if (editor != null && editor.isCellEditable(e)) {
        editorComp = prepareEditor(editor, row, column);
        //((JComponent)editorComp).setBorder(null);
        if (editorComp == null) {
            removeEditor();
            return false;
        }
        editorComp.setBounds(getCellRect(row, column, false));
        add(editorComp);
        editorComp.validate();
        if (surrendersFocusOnKeyStroke()) {
            // this replaces focus request in JTable.processKeyBinding
            final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(this);
            focusManager.setTypeaheadEnabled(false);
            focusManager.requestFocus(editorComp, true).doWhenProcessed(() -> focusManager.setTypeaheadEnabled(true));
        }
        setCellEditor(editor);
        setEditingRow(row);
        setEditingColumn(column);
        editor.addCellEditorListener(this);
        return true;
    }
    return false;
}
Also used : KeyEvent(java.awt.event.KeyEvent) SpeedSearchSupply(com.intellij.ui.speedSearch.SpeedSearchSupply) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager)

Aggregations

SpeedSearchSupply (com.intellij.ui.speedSearch.SpeedSearchSupply)7 KeyEvent (java.awt.event.KeyEvent)3 AllIcons (com.intellij.icons.AllIcons)2 SplitterProportionsDataImpl (com.intellij.ide.ui.SplitterProportionsDataImpl)2 Project (com.intellij.openapi.project.Project)2 SplitterProportionsData (com.intellij.openapi.ui.SplitterProportionsData)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 com.intellij.ui (com.intellij.ui)2 CommonBundle (com.intellij.CommonBundle)1 DataManager (com.intellij.ide.DataManager)1 DeleteProvider (com.intellij.ide.DeleteProvider)1 TitledHandler (com.intellij.ide.TitledHandler)1 ProjectListBuilder (com.intellij.ide.commander.ProjectListBuilder)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Language (com.intellij.lang.Language)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1