Search in sources :

Example 11 with DoubleClickListener

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

the class KeymapPanel method createKeymapSettingsPanel.

private JPanel createKeymapSettingsPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    myActionsTree = new ActionsTree();
    panel.add(createToolbarPanel(), BorderLayout.NORTH);
    panel.add(myActionsTree.getComponent(), BorderLayout.CENTER);
    myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            editSelection(e, true);
            return true;
        }
    }.installOn(myActionsTree.getTree());
    myActionsTree.getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(@NotNull MouseEvent e) {
            if (e.isPopupTrigger()) {
                editSelection(e, false);
                e.consume();
            }
        }

        @Override
        public void mouseReleased(@NotNull MouseEvent e) {
            if (e.isPopupTrigger()) {
                editSelection(e, false);
                e.consume();
            }
        }
    });
    return panel;
}
Also used : DoubleClickListener(com.intellij.ui.DoubleClickListener)

Example 12 with DoubleClickListener

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

the class SelectTagDialog method createList.

private void createList(String title, Collection<String> data, String listDescription) {
    setTitle(title);
    final JList list = new JBList();
    myLists.add(list);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (list.getSelectedValue() != null)
                cancelOtherSelections(list);
            setOkEnabled();
        }
    });
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            if (isOKActionEnabled()) {
                doOKAction();
                return true;
            }
            return false;
        }
    }.installOn(list);
    fillList(data, list);
    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.add(new JLabel(listDescription, JLabel.LEFT), BorderLayout.NORTH);
    panel.add(ScrollPaneFactory.createScrollPane(list), BorderLayout.CENTER);
    myPanel.add(panel);
}
Also used : MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JBList(com.intellij.ui.components.JBList) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 13 with DoubleClickListener

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

the class AvailablePluginsManagerMain method installTableActions.

@Override
protected void installTableActions() {
    super.installTableActions();
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            if (pluginTable.columnAtPoint(e.getPoint()) < 0)
                return false;
            if (pluginTable.rowAtPoint(e.getPoint()) < 0)
                return false;
            return installSelected(pluginTable);
        }
    }.installOn(pluginTable);
    pluginTable.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            installSelected(pluginTable);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED);
}
Also used : MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 14 with DoubleClickListener

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

the class GetJPDADialog method createCenterPanel.

protected JComponent createCenterPanel() {
    final JPanel _panel1 = new JPanel(new BorderLayout());
    JPanel _panel2 = new JPanel(new BorderLayout());
    _panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    //"Debug libraries are missig from JDK home.\nIn order for debugger to start, the libraries should be installed.\nPlease visit http://java.sun.com/products/jpda"
    JLabel label1 = new JLabel(DebuggerBundle.message("label.get.jpda.dialog.prompt"));
    //label1.setForeground(Color.black);
    JLabel label2 = new JLabel(JPDA_URL);
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            BrowserUtil.browse(JPDA_URL);
            return true;
        }
    }.installOn(label2);
    label2.setForeground(JBColor.BLUE.darker());
    label2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    _panel2.add(new JLabel(DebuggerBundle.message("label.get.jpda.dialog.error.description")), BorderLayout.NORTH);
    _panel2.add(label1, BorderLayout.WEST);
    _panel2.add(label2, BorderLayout.EAST);
    _panel1.add(_panel2, BorderLayout.NORTH);
    JPanel content = new JPanel(new GridLayout(2, 1, 10, 10));
    _panel1.add(content, BorderLayout.CENTER);
    return _panel1;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener)

Example 15 with DoubleClickListener

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

the class TreeFileChooserDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
    myTree = new Tree(model);
    final ProjectAbstractTreeStructureBase treeStructure = new AbstractProjectTreeStructure(myProject) {

        @Override
        public boolean isFlattenPackages() {
            return false;
        }

        @Override
        public boolean isShowMembers() {
            return false;
        }

        @Override
        public boolean isHideEmptyMiddlePackages() {
            return true;
        }

        @Override
        public Object[] getChildElements(final Object element) {
            return filterFiles(super.getChildElements(element));
        }

        @Override
        public boolean isAbbreviatePackageNames() {
            return false;
        }

        @Override
        public boolean isShowLibraryContents() {
            return myShowLibraryContents;
        }

        @Override
        public boolean isShowModules() {
            return false;
        }

        @Override
        public List<TreeStructureProvider> getProviders() {
            return myDisableStructureProviders ? null : super.getProviders();
        }
    };
    myBuilder = new ProjectTreeBuilder(myProject, myTree, model, AlphaComparator.INSTANCE, treeStructure);
    myTree.setRootVisible(false);
    myTree.expandRow(0);
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    myTree.setCellRenderer(new NodeRenderer());
    UIUtil.setLineStyleAngled(myTree);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(JBUI.size(500, 300));
    myTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                doOKAction();
            }
        }
    });
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent e) {
            final TreePath path = myTree.getPathForLocation(e.getX(), e.getY());
            if (path != null && myTree.isPathSelected(path)) {
                doOKAction();
                return true;
            }
            return false;
        }
    }.installOn(myTree);
    myTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(final TreeSelectionEvent e) {
            handleSelectionChanged();
        }
    });
    new TreeSpeedSearch(myTree);
    myTabbedPane = new TabbedPaneWrapper(getDisposable());
    final JPanel dummyPanel = new JPanel(new BorderLayout());
    String name = null;
    if (myInitialFile != null) {
        name = myInitialFile.getName();
    }
    PsiElement context = myInitialFile == null ? null : myInitialFile;
    myGotoByNamePanel = new ChooseByNamePanel(myProject, new MyGotoFileModel(), name, true, context) {

        @Override
        protected void close(final boolean isOk) {
            super.close(isOk);
            if (isOk) {
                doOKAction();
            } else {
                doCancelAction();
            }
        }

        @Override
        protected void initUI(final ChooseByNamePopupComponent.Callback callback, final ModalityState modalityState, boolean allowMultipleSelection) {
            super.initUI(callback, modalityState, allowMultipleSelection);
            dummyPanel.add(myGotoByNamePanel.getPanel(), BorderLayout.CENTER);
            //IdeFocusTraversalPolicy.getPreferredFocusedComponent(myGotoByNamePanel.getPanel()).requestFocus();
            if (mySelectSearchByNameTab) {
                myTabbedPane.setSelectedIndex(1);
            }
        }

        @Override
        protected void showTextFieldPanel() {
        }

        @Override
        protected void chosenElementMightChange() {
            handleSelectionChanged();
        }
    };
    myTabbedPane.addTab(IdeBundle.message("tab.chooser.project"), scrollPane);
    myTabbedPane.addTab(IdeBundle.message("tab.chooser.search.by.name"), dummyPanel);
    SwingUtilities.invokeLater(() -> myGotoByNamePanel.invoke(new MyCallback(), ModalityState.stateForComponent(getRootPane()), false));
    myTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            handleSelectionChanged();
        }
    });
    return myTabbedPane.getComponent();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DoubleClickListener(com.intellij.ui.DoubleClickListener) KeyAdapter(java.awt.event.KeyAdapter) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeStructureProvider(com.intellij.ide.projectView.TreeStructureProvider) AbstractProjectTreeStructure(com.intellij.ide.projectView.impl.AbstractProjectTreeStructure) NodeRenderer(com.intellij.ide.util.treeView.NodeRenderer) KeyEvent(java.awt.event.KeyEvent) ProjectAbstractTreeStructureBase(com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase) Tree(com.intellij.ui.treeStructure.Tree) ChangeListener(javax.swing.event.ChangeListener) PsiElement(com.intellij.psi.PsiElement) MouseEvent(java.awt.event.MouseEvent) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ChooseByNamePanel(com.intellij.ide.util.gotoByName.ChooseByNamePanel) TreePath(javax.swing.tree.TreePath) ChangeEvent(javax.swing.event.ChangeEvent) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder) ProjectTreeBuilder(com.intellij.ide.projectView.impl.ProjectTreeBuilder) ModalityState(com.intellij.openapi.application.ModalityState) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) ChooseByNamePopupComponent(com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent)

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