Search in sources :

Example 16 with DoubleClickListener

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

the class FileTypeChooser method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    myTitleLabel.setText(FileTypesBundle.message("filetype.chooser.prompt", myFileName));
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myList.setCellRenderer(new FileTypeRenderer());
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            doOKAction();
            return true;
        }
    }.installOn(myList);
    myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateButtonsState();
        }
    });
    ScrollingUtil.selectItem(myList, FileTypes.PLAIN_TEXT);
    return myPanel;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) FileTypeRenderer(com.intellij.openapi.fileTypes.impl.FileTypeRenderer) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 17 with DoubleClickListener

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

the class SimpleFieldChooser method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    final DefaultListModel model = new DefaultListModel();
    for (PsiField member : myFields) {
        model.addElement(member);
    }
    myList = new JBList(model);
    myList.setCellRenderer(new MyListCellRenderer());
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            if (myList.getSelectedValues().length > 0) {
                doOKAction();
                return true;
            }
            return false;
        }
    }.installOn(myList);
    myList.setPreferredSize(JBUI.size(300, 400));
    return myList;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) PsiField(com.intellij.psi.PsiField) JBList(com.intellij.ui.components.JBList)

Aggregations

DoubleClickListener (com.intellij.ui.DoubleClickListener)17 MouseEvent (java.awt.event.MouseEvent)16 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)4 TreeSelectionListener (javax.swing.event.TreeSelectionListener)4 ListSelectionEvent (javax.swing.event.ListSelectionEvent)3 ListSelectionListener (javax.swing.event.ListSelectionListener)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)3 Nullable (org.jetbrains.annotations.Nullable)3 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)2 AbstractProjectTreeStructure (com.intellij.ide.projectView.impl.AbstractProjectTreeStructure)2 ProjectAbstractTreeStructureBase (com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase)2 ProjectTreeBuilder (com.intellij.ide.projectView.impl.ProjectTreeBuilder)2 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)2 Disposable (com.intellij.openapi.Disposable)2 ModalityState (com.intellij.openapi.application.ModalityState)2 TabbedPaneWrapper (com.intellij.ui.TabbedPaneWrapper)2 TreeSpeedSearch (com.intellij.ui.TreeSpeedSearch)2 JBList (com.intellij.ui.components.JBList)2 Tree (com.intellij.ui.treeStructure.Tree)2