Example usage for com.intellij.openapi MnemonicHelper MnemonicHelper

List of usage examples for com.intellij.openapi MnemonicHelper MnemonicHelper

Introduction

In this page you can find the example usage for com.intellij.openapi MnemonicHelper MnemonicHelper.

Prototype

@Deprecated
public MnemonicHelper() 

Source Link

Usage

From source file:com.intellij.ide.util.FileStructurePopup.java

License:Apache License

public void show() {
    //final long time = System.currentTimeMillis();
    JComponent panel = createCenterPanel();
    new MnemonicHelper().register(panel);
    boolean shouldSetWidth = DimensionService.getInstance().getSize(getDimensionServiceKey(),
            myProject) == null;//from w  w w.j a  v  a 2 s .c  om
    myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, null).setTitle(myTitle)
            .setResizable(true).setModalContext(false).setFocusable(true).setRequestFocus(true).setMovable(true)
            .setBelongsToGlobalPopupStack(true)
            //.setCancelOnClickOutside(false) //for debug and snapshots
            .setCancelKeyEnabled(false).setDimensionServiceKey(null, getDimensionServiceKey(), false)
            .setCancelCallback(new Computable<Boolean>() {
                @Override
                public Boolean compute() {
                    DimensionService.getInstance().setLocation(getDimensionServiceKey(),
                            myPopup.getLocationOnScreen(), myProject);
                    return true;
                }
            }).createPopup();

    myTree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            if (myPopup.isVisible()) {
                final PopupUpdateProcessor updateProcessor = myPopup.getUserData(PopupUpdateProcessor.class);
                if (updateProcessor != null) {
                    final AbstractTreeNode node = getSelectedNode();
                    updateProcessor.updatePopup(node);
                }
            }
        }
    });
    Disposer.register(myPopup, this);
    Disposer.register(myPopup, new Disposable() {
        @Override
        public void dispose() {
            if (!myTreeHasBuilt.isDone()) {
                myTreeHasBuilt.setRejected();
            }
        }
    });
    myTree.getEmptyText().setText("Loading...");
    final Point location = DimensionService.getInstance().getLocation(getDimensionServiceKey(), myProject);
    if (location != null) {
        myPopup.showInScreenCoordinates(myFileEditor.getComponent(), location);
    } else {
        myPopup.showCenteredInCurrentWindow(myProject);
    }

    ((AbstractPopup) myPopup).setShowHints(true);
    if (shouldSetWidth) {
        myPopup.setSize(new Dimension(myPreferredWidth + 10, myPopup.getSize().height));
    }

    IdeFocusManager.getInstance(myProject).requestFocus(myTree, true);
    SwingUtilities.windowForComponent(myPopup.getContent()).addWindowFocusListener(new WindowFocusListener() {
        @Override
        public void windowGainedFocus(WindowEvent e) {
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            myPopup.cancel();
        }
    });
    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().runReadAction(new Runnable() {
                @Override
                public void run() {
                    myFilteringStructure.rebuild();
                }
            });

            //noinspection SSBasedInspection
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
                        @Override
                        public void run() {
                            myTreeHasBuilt.setDone();
                            //noinspection SSBasedInspection
                            SwingUtilities.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    if (myAbstractTreeBuilder.isDisposed())
                                        return;
                                    if (selectPsiElement(myInitialPsiElement) == null) {
                                        TreeUtil.ensureSelection(myAbstractTreeBuilder.getTree());
                                        myAbstractTreeBuilder.revalidateTree();
                                    }
                                }
                            });
                        }
                    });
                    installUpdater();
                }
            });
        }
    });
}

From source file:com.intellij.ide.util.gotoByName.ChooseByNameBase.java

License:Apache License

protected void showTextFieldPanel() {
    final JLayeredPane layeredPane = getLayeredPane();
    final Dimension preferredTextFieldPanelSize = myTextFieldPanel.getPreferredSize();
    final int x = (layeredPane.getWidth() - preferredTextFieldPanelSize.width) / 2;
    final int paneHeight = layeredPane.getHeight();
    final int y = paneHeight / 3 - preferredTextFieldPanelSize.height / 2;

    VISIBLE_LIST_SIZE_LIMIT = Math.max(10,
            (paneHeight - (y + preferredTextFieldPanelSize.height)) / (preferredTextFieldPanelSize.height / 2)
                    - 1);/* w  w  w  . java  2 s  .  co  m*/

    ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(myTextFieldPanel,
            myTextField);
    builder.setCancelCallback(new Computable<Boolean>() {
        @Override
        public Boolean compute() {
            myTextPopup = null;
            close(false);
            return Boolean.TRUE;
        }
    }).setFocusable(true).setRequestFocus(true).setModalContext(false).setCancelOnClickOutside(false);

    Point point = new Point(x, y);
    SwingUtilities.convertPointToScreen(point, layeredPane);
    Rectangle bounds = new Rectangle(point,
            new Dimension(preferredTextFieldPanelSize.width + 20, preferredTextFieldPanelSize.height));
    myTextPopup = builder.createPopup();
    myTextPopup.setSize(bounds.getSize());
    myTextPopup.setLocation(bounds.getLocation());

    new MnemonicHelper().register(myTextFieldPanel);
    if (myProject != null && !myProject.isDefault()) {
        DaemonCodeAnalyzer.getInstance(myProject).disableUpdateByTimer(myTextPopup);
    }

    Disposer.register(myTextPopup, new Disposable() {
        @Override
        public void dispose() {
            cancelListUpdater();
        }
    });
    myTextPopup.show(layeredPane);
    if (myTextPopup instanceof AbstractPopup) {
        Window window = ((AbstractPopup) myTextPopup).getPopupWindow();
        if (window instanceof JDialog) {
            ((JDialog) window).getRootPane().putClientProperty(WindowAction.NO_WINDOW_ACTIONS, Boolean.TRUE);
        }
    }
}

From source file:com.intellij.util.net.AuthenticationDialog.java

License:Apache License

public AuthenticationDialog(@NotNull Component component, String title, String description, final String login,
        final String password, final boolean rememberPassword) {
    super(component, true);
    setTitle(title);//from w ww .j  a v a  2s.  c  o m

    new MnemonicHelper().register(getContentPane());
    panel = new AuthenticationPanel(description, login, password, rememberPassword);

    final Window window = getWindow();
    if (window instanceof JDialog) {
        ((JDialog) window).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    }

    init();
}

From source file:com.intellij.util.net.AuthenticationDialog.java

License:Apache License

public AuthenticationDialog(String title, String description, final String login, final String password,
        final boolean rememberPassword) {
    super(JOptionPane.getRootFrame(), true);
    setTitle(title);/*from  w  w w.ja va  2 s  . c o m*/

    new MnemonicHelper().register(getContentPane());
    panel = new AuthenticationPanel(description, login, password, rememberPassword);

    final Window window = getWindow();
    if (window instanceof JDialog) {
        ((JDialog) window).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    }

    init();
}

From source file:com.intellij.util.xml.ui.DomFileEditor.java

License:Apache License

@Nonnull
protected JComponent createCustomComponent() {
    new MnemonicHelper().register(getComponent());
    myComponent = myComponentFactory.create();
    DomUIFactory.getDomUIFactory().setupErrorOutdatingUserActivityWatcher(this, getDomElement());
    DomManager.getDomManager(getProject()).addDomEventListener(new DomEventListener() {
        public void eventOccured(DomEvent event) {
            checkIsValid();/* w ww.j av  a 2s  .  com*/
        }
    }, this);
    Disposer.register(this, myComponent);
    return myComponent.getComponent();
}