List of usage examples for java.awt.event MouseEvent consume
public void consume()
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java
@Override public void mouseReleased(final MouseEvent event) { if (event.getButton() != MouseEvent.BUTTON1) return;//from w w w. j av a 2 s . c o m event.consume(); if (m_edit && m_lineEditor != null) { final GM_Curve curve = m_lineEditor.finish(); if (curve != null) finishLine(curve); } }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java
@Override public void mouseClicked(final MouseEvent event) { if (event.getButton() != MouseEvent.BUTTON1) return;// w w w .j a v a2 s .com if (event.getClickCount() < 2) return; event.consume(); if (m_edit && event.isShiftDown()) { // TODO: insert points into current line } if (m_lineBuilder != null) { try { final GM_Curve curve = (GM_Curve) m_lineBuilder.finish(); finishLine(curve); } catch (final Exception e) { e.printStackTrace(); reinit(); } } }
From source file:org.kuali.test.ui.components.sqlquerytree.SqlQueryTree.java
@Override public void mousePressed(MouseEvent e) { TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (node != null) { if (node.getUserObject() instanceof ColumnData) { ColumnData cd = (ColumnData) node.getUserObject(); if (cd.isSelected()) { columnsSelected--;//from w ww. j a v a2 s .c o m } else { columnsSelected++; } cd.setSelected(!cd.isSelected()); getComponentAt(e.getPoint()).repaint(); e.consume(); } } } }
From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
private void initJResPlan() { resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel); resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem()); resPlan.addMouseListener(new AbstractJPopupMenuListener() { @Override/*from w w w . jav a 2s . com*/ protected JPopupMenu getJPopupMenu(MouseEvent evt) { JPopupMenu popupMenu = new JPopupMenu(); Point pt = evt.getPoint(); Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea(); if (blankSelection != null) { popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval())); } else { popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt))); } List<Collectable> selectedEntries = selectEntriesForEvent(pt); List<Collectable> selectedRelations = selectRelationsForEvent(pt); if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) { JMenuItem menuItem = popupMenu.add(removeAction); boolean enabled = true; for (Collectable clct : selectedEntries) { if (!resPlanModel.isRemoveEntryAllowed(clct)) { enabled = false; break; } } for (Collectable clct : selectedRelations) { if (!resPlanModel.isRemoveRelationAllowed(clct)) { enabled = false; break; } } // Note: just change the state of the menu item (and leave the action as is) menuItem.setEnabled(enabled); } if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) { popupMenu.add(detailsAction); } if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null && resPlanModel.isCreateRelationAllowed()) { popupMenu.addSeparator(); if (resPlan.getRelateBegin() != null) { Collectable to = selectedEntries.get(0); if (to != resPlan.getRelateBegin()) { popupMenu.add(relateFinishAction); } } popupMenu.add(relateBeginAction); } return popupMenu; } private List<Collectable> selectEntriesForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedEntries(); Collectable entryAt = resPlan.getEntryAt(pt); if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) { selection = Collections.singletonList(entryAt); resPlan.setSelectedEntries(selection); } return selection; } private List<Collectable> selectRelationsForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedRelations(); Collectable relAt = resPlan.getRelationAt(pt); if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) { selection = Collections.singletonList(relAt); resPlan.setSelectedRelations(selection); } return selection; } @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getEntryAt(evt.getPoint()); if (clct == null) { clct = resPlan.getRelationAt(evt.getPoint()); if (clct != null) { runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct); } } else { runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct); } evt.consume(); } } }); resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); evt.consume(); } } @Override protected JPopupMenu getJPopupMenu(MouseEvent evt) { final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); if (clct != null) { JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new AbstractAction( SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) { @Override public void actionPerformed(ActionEvent e) { runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); } }); return popupMenu; } return null; } }); Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5); Date end = DateUtils.addDays(start, 30); resPlan.setTimeHorizon(new Interval<Date>(start, end)); }
From source file:org.openmicroscopy.shoola.agents.measurement.view.ObjectInspector.java
/** Initializes the component composing the display. */ private void initComponents() { infoLabel = new JLabel(MAGNIFICATION + " is " + model.getDrawingView().getScaleFactor()); //create the table fieldTable = new FigureTable(new FigureTableModel(attributeFields, COLUMN_NAMES)); fieldTable.getTableHeader().setReorderingAllowed(false); fieldTable.setRowHeight(26);/*w w w . ja v a2 s .c o m*/ fieldTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fieldTable.setCellSelectionEnabled(true); fieldTable.setColumnSelectionAllowed(true); fieldTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int col = fieldTable.getSelectedColumn(); int row = fieldTable.getSelectedRow(); Object value = fieldTable.getValueAt(row, col); if (e.getClickCount() == 1) { if (value instanceof Boolean) { toggleValue(); } } else if (e.getClickCount() > 1) { e.consume(); if (value instanceof Color) { //Only if the figure is not read only. FigureTableModel ftm = (FigureTableModel) fieldTable.getModel(); ROIFigure figure = ftm.getFigure(); if (figure != null && !figure.isReadOnly()) if (figure.canEdit()) controller.showColorPicker((Color) value); } else if (value instanceof Boolean) { toggleValue(); } } } }); fieldTable.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FigureTable.VALUE_CHANGED_PROPERTY.equals(name)) { handleValueChanged((String) evt.getNewValue()); } } }); }
From source file:org.photovault.swingui.PhotoCollectionThumbView.java
protected void handleDnDDragEvent(MouseEvent e) { //Don't bother to drag if no photo is selected if (selection.isEmpty()) { return;// w w w. ja va 2 s. c o m } if (firstMouseEvent != null) { log.debug("considering drag"); e.consume(); //If they are holding down the control key, COPY rather than MOVE int ctrlMask = InputEvent.CTRL_DOWN_MASK; int action = e.isControlDown() ? TransferHandler.COPY : TransferHandler.MOVE; int dx = Math.abs(e.getX() - firstMouseEvent.getX()); int dy = Math.abs(e.getY() - firstMouseEvent.getY()); //Arbitrarily define a 5-pixel shift as the //official beginning of a drag. if (dx > 5 || dy > 5) { log.debug("Start a drag"); //This is a drag, not a click. JComponent c = (JComponent) e.getSource(); //Tell the transfer handler to initiate the drag. TransferHandler handler = c.getTransferHandler(); handler.exportAsDrag(c, firstMouseEvent, action); firstMouseEvent = null; } } }