Search in sources :

Example 36 with MouseEvent

use of java.awt.event.MouseEvent in project EnrichmentMapApp by BaderLab.

the class SettingsPopupPanel method popup.

public void popup(Component parent) {
    JPopupMenu menu = new JPopupMenu();
    menu.add(this);
    menu.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                menu.setVisible(false);
            }
        }
    });
    menu.show(parent, 0, parent.getHeight());
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JPopupMenu(javax.swing.JPopupMenu)

Example 37 with MouseEvent

use of java.awt.event.MouseEvent in project intellij-community by JetBrains.

the class MainProcessor method processMouseEvent.

protected void processMouseEvent(final MouseEvent e) {
    myLastMousePosition = e.getPoint();
    if (myCurrentProcessor != null && myCurrentProcessor.isDragActive()) {
        return;
    }
    // motion events should go further
    if (e.isPopupTrigger()) {
        RadComponent component = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(), e.getY());
        if (component != null && !component.isSelected()) {
            FormEditingUtil.selectSingleComponent(myEditor, component);
        }
        final ActionManager actionManager = ActionManager.getInstance();
        final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(ActionPlaces.GUI_DESIGNER_EDITOR_POPUP, (ActionGroup) actionManager.getAction(IdeActions.GROUP_GUI_DESIGNER_EDITOR_POPUP));
        popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY());
        return;
    }
    final int id = e.getID();
    if ((MouseEvent.BUTTON2 == e.getButton() || MouseEvent.BUTTON3 == e.getButton()) && (MouseEvent.MOUSE_PRESSED == id || MouseEvent.MOUSE_RELEASED == id || MouseEvent.MOUSE_CLICKED == id)) {
        return;
    }
    // Handle all left mouse events and all motion events
    final RadComponent componentAt = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(), e.getY());
    if (componentAt != null) {
        final Point p1 = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), componentAt.getDelegee());
        final Component deepestComponentAt = SwingUtilities.getDeepestComponentAt(componentAt.getDelegee(), p1.x, p1.y);
        final Point p2 = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), deepestComponentAt);
        EventProcessor processor = componentAt.getEventProcessor(e);
        if (processor != null) {
            myCurrentProcessor = processor;
        } else {
            final Component source = deepestComponentAt != null ? deepestComponentAt : componentAt.getDelegee();
            componentAt.processMouseEvent(new MouseEvent(source, id, e.getWhen(), e.getModifiers(), p2.x, p2.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()));
        }
    }
    Cursor cursor = Cursor.getDefaultCursor();
    if (id == MouseEvent.MOUSE_MOVED) {
        if (PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class) != null) {
            if (myInsertFeedbackEnabled) {
                cursor = myInsertComponentProcessor.processMouseMoveEvent(e);
            }
        } else if (myCurrentProcessor != null) {
            myCurrentProcessor.processMouseEvent(e);
        } else {
            final RadComponent component = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(), e.getY());
            if (component != null) {
                final Point point = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), component.getDelegee());
                final int resizeMask = Painter.getResizeMask(component, point.x, point.y);
                if (resizeMask != 0) {
                    cursor = Cursor.getPredefinedCursor(Painter.getResizeCursor(resizeMask));
                }
                updateDragger(e);
            }
        }
    } else if (id == MouseEvent.MOUSE_PRESSED) {
        processMousePressed(e);
    } else if (id == MouseEvent.MOUSE_RELEASED) {
        // not every press sets processor so its not a redundant 'if'
        if (myCurrentProcessor != null) {
            myCurrentProcessor.processMouseEvent(e);
            myCurrentProcessor = null;
        }
    } else if (id == MouseEvent.MOUSE_CLICKED) {
        processMouseClicked(e);
    } else if (id == MouseEvent.MOUSE_EXITED) {
        myEditor.getActiveDecorationLayer().removeFeedback();
    }
    if (!e.isConsumed() && myCurrentProcessor != null) {
        myCurrentProcessor.processMouseEvent(e);
    }
    if (myCurrentProcessor != null && myCurrentProcessor.isDragActive()) {
        myEditor.getLayeredPane().setCursor(null);
    } else {
        if (myCurrentProcessor != null && myCurrentProcessor.getCursor() != null) {
            cursor = myCurrentProcessor.getCursor();
        }
        myEditor.getLayeredPane().setCursor(cursor);
    }
}
Also used : ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) MouseEvent(java.awt.event.MouseEvent) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Example 38 with MouseEvent

use of java.awt.event.MouseEvent in project intellij-community by JetBrains.

the class PyiRelatedItemLineMarkerProvider method createLineMarkerInfo.

@NotNull
private static RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element, @NotNull PsiElement relatedElement, @NotNull String itemTitle) {
    final SmartPointerManager pointerManager = SmartPointerManager.getInstance(element.getProject());
    final SmartPsiElementPointer<PsiElement> relatedElementPointer = pointerManager.createSmartPsiElementPointer(relatedElement);
    final String stubFileName = relatedElement.getContainingFile().getName();
    return new RelatedItemLineMarkerInfo<>(element, element.getTextRange(), ICON, Pass.LINE_MARKERS, element1 -> itemTitle + " in " + stubFileName, new GutterIconNavigationHandler<PsiElement>() {

        @Override
        public void navigate(MouseEvent e, PsiElement elt) {
            final PsiElement restoredRelatedElement = relatedElementPointer.getElement();
            if (restoredRelatedElement == null) {
                return;
            }
            final int offset = restoredRelatedElement instanceof PsiFile ? -1 : restoredRelatedElement.getTextOffset();
            final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(restoredRelatedElement);
            if (virtualFile != null && virtualFile.isValid()) {
                new OpenFileDescriptor(restoredRelatedElement.getProject(), virtualFile, offset).navigate(true);
            }
        }
    }, GutterIconRenderer.Alignment.RIGHT, GotoRelatedItem.createItems(Collections.singletonList(relatedElement)));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SmartPointerManager(com.intellij.psi.SmartPointerManager) MouseEvent(java.awt.event.MouseEvent) RelatedItemLineMarkerInfo(com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo) PsiFile(com.intellij.psi.PsiFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with MouseEvent

use of java.awt.event.MouseEvent in project intellij-community by JetBrains.

the class ToBeMergedDialog method addRevisionListListeners.

private void addRevisionListListeners() {
    final int checkboxWidth = new JCheckBox().getPreferredSize().width;
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            final int idx = myRevisionsList.rowAtPoint(e.getPoint());
            if (idx >= 0) {
                final Rectangle baseRect = myRevisionsList.getCellRect(idx, 0, false);
                baseRect.setSize(checkboxWidth, baseRect.height);
                if (baseRect.contains(e.getPoint())) {
                    toggleInclusion(myRevisionsModel.getRowValue(idx));
                    myRevisionsList.repaint(baseRect);
                }
            }
            return true;
        }
    }.installOn(myRevisionsList);
    myRevisionsList.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (KeyEvent.VK_SPACE == e.getKeyCode()) {
                List<SvnChangeList> selected = myRevisionsList.getSelectedObjects();
                if (!selected.isEmpty()) {
                    selected.forEach(ToBeMergedDialog.this::toggleInclusion);
                    myRevisionsList.repaint();
                    e.consume();
                }
            }
        }
    });
}
Also used : KeyEvent(java.awt.event.KeyEvent) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) Collections.singletonList(java.util.Collections.singletonList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList)

Example 40 with MouseEvent

use of java.awt.event.MouseEvent in project intellij-community by JetBrains.

the class ToBeMergedDialog method initUI.

private void initUI() {
    final ListSelectionListener selectionListener = e -> {
        List<SvnChangeList> changeLists = myRevisionsList.getSelectedObjects();
        myAlreadyMerged.clear();
        for (SvnChangeList changeList : changeLists) {
            myAlreadyMerged.addAll(getAlreadyMergedPaths(changeList));
        }
        myRepositoryChangesBrowser.setChangesToDisplay(collectChanges(changeLists, false));
        mySplitter.doLayout();
        myRepositoryChangesBrowser.repaint();
    };
    final MyListCellRenderer listCellRenderer = new MyListCellRenderer();
    myRevisionsList = new TableView<SvnChangeList>() {

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            return listCellRenderer;
        }

        @Override
        public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            selectionListener.valueChanged(e);
        }
    };
    myRevisionsList.setExpandableItemsEnabled(false);
    new TableViewSpeedSearch<SvnChangeList>(myRevisionsList) {

        @Override
        protected String getItemText(@NotNull SvnChangeList element) {
            return element.getComment();
        }
    };
    myRevisionsList.setModelAndUpdateColumns(myRevisionsModel);
    myRevisionsList.setTableHeader(null);
    myRevisionsList.setShowGrid(false);
    final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {

        @Override
        public Object getTagAt(@NotNull MouseEvent e) {
            JTable table = (JTable) e.getSource();
            int row = table.rowAtPoint(e.getPoint());
            int column = table.columnAtPoint(e.getPoint());
            if (row == -1 || column == -1)
                return null;
            listCellRenderer.customizeCellRenderer(table, table.getValueAt(row, column), table.isRowSelected(row));
            return listCellRenderer.myRenderer.getFragmentTagAt(e.getPoint().x - table.getCellRect(row, column, false).x);
        }
    };
    mouseListener.installOn(myRevisionsList);
    myMore100Action = new MoreXAction(100);
    myMore500Action = new MoreXAction(500);
    BorderLayoutPanel panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(myRevisionsList)).addToTop(createToolbar().getComponent());
    mySplitter = new Splitter(false, 0.7f);
    mySplitter.setFirstComponent(panel);
    myRepositoryChangesBrowser = new RepositoryChangesBrowser(myMergeContext.getProject(), Collections.<SvnChangeList>emptyList(), emptyList(), null);
    myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
    setChangesDecorator();
    mySplitter.setSecondComponent(myRepositoryChangesBrowser);
    mySplitter.setDividerWidth(2);
    addRevisionListListeners();
    myPanel.add(mySplitter, BorderLayout.CENTER);
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) MessageType(com.intellij.openapi.ui.MessageType) CommittedChangesTreeBrowser.collectChanges(com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser.collectChanges) Change(com.intellij.openapi.vcs.changes.Change) MergeChecker(org.jetbrains.idea.svn.mergeinfo.MergeChecker) ColumnInfo(com.intellij.util.ui.ColumnInfo) MergeCalculatorTask.getBunchSize(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.getBunchSize) TableCellRenderer(javax.swing.table.TableCellRenderer) Collections.singletonList(java.util.Collections.singletonList) Task(com.intellij.openapi.progress.Task) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) JBUI(com.intellij.util.ui.JBUI) Collections.synchronizedMap(java.util.Collections.synchronizedMap) CommittedChangeListRenderer(com.intellij.openapi.vcs.changes.committed.CommittedChangeListRenderer) VcsException(com.intellij.openapi.vcs.VcsException) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ContainerUtilRt.newHashSet(com.intellij.util.containers.ContainerUtilRt.newHashSet) TableView(com.intellij.ui.table.TableView) KeyEvent(java.awt.event.KeyEvent) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) java.util(java.util) KeyAdapter(java.awt.event.KeyAdapter) ContainerUtil(com.intellij.util.containers.ContainerUtil) MergeCalculatorTask.loadChangeLists(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.loadChangeLists) SvnMergeInfoCache(org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) ListTableModel(com.intellij.util.ui.ListTableModel) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList) Splitter(com.intellij.openapi.ui.Splitter) ListMergeStatus(org.jetbrains.idea.svn.mergeinfo.ListMergeStatus) ChangeNodeDecorator(com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator) PopupUtil(com.intellij.openapi.ui.popup.util.PopupUtil) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ChangesBrowserNodeRenderer(com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) Pair(com.intellij.openapi.util.Pair) ObjectUtils(com.intellij.util.ObjectUtils) ListSelectionListener(javax.swing.event.ListSelectionListener) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) TableCellRenderer(javax.swing.table.TableCellRenderer) MouseEvent(java.awt.event.MouseEvent) Splitter(com.intellij.openapi.ui.Splitter) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) NotNull(org.jetbrains.annotations.NotNull) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) Collections.singletonList(java.util.Collections.singletonList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList)

Aggregations

MouseEvent (java.awt.event.MouseEvent)407 MouseAdapter (java.awt.event.MouseAdapter)201 JLabel (javax.swing.JLabel)78 JPanel (javax.swing.JPanel)71 ActionEvent (java.awt.event.ActionEvent)60 JScrollPane (javax.swing.JScrollPane)53 ActionListener (java.awt.event.ActionListener)52 Dimension (java.awt.Dimension)51 BorderLayout (java.awt.BorderLayout)46 JButton (javax.swing.JButton)45 Point (java.awt.Point)44 MouseListener (java.awt.event.MouseListener)41 Insets (java.awt.Insets)40 KeyEvent (java.awt.event.KeyEvent)36 JTable (javax.swing.JTable)34 GridBagConstraints (java.awt.GridBagConstraints)33 KeyAdapter (java.awt.event.KeyAdapter)30 JTextField (javax.swing.JTextField)30 GridBagLayout (java.awt.GridBagLayout)27 ListSelectionEvent (javax.swing.event.ListSelectionEvent)26