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());
}
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);
}
}
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)));
}
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();
}
}
}
});
}
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);
}
Aggregations