Refine search
@Override public void mouseDragged(MouseEvent e) { if (MatchesPanel.getInstance().isEmpty()) return; if (firstMouseEvent1 != null) { e.consume(); int dx = Math.abs(e.getX() - firstMouseEvent1.getX()); int dy = Math.abs(e.getY() - firstMouseEvent1.getY()); //Arbitrarily define a 5-pixel shift as the //official beginning of a drag. if (dx > 5 || dy > 5) { //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, firstMouseEvent1, TransferHandler.COPY); firstMouseEvent1 = null; } } }
for (int i = 0; i < n; i++) { Action a = actions[i]; map.put(a.getValue(Action.NAME), a); map.put(TransferHandler.getCutAction().getValue(Action.NAME), TransferHandler.getCutAction()); map.put(TransferHandler.getCopyAction().getValue(Action.NAME), TransferHandler.getCopyAction()); map.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction());
public int getSourceActions(JComponent arg0) { return delegate.getSourceActions(arg0); }
private void setupActions() { // Mac weirdness... VK_MINUS/VK_PLUS seems to map to english key map always... bindAction(new ZoomAction("Zoom in", 2), ZOOM_IN, KeyStroke.getKeyStroke('+'), KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0)); bindAction(new ZoomAction("Zoom out", .5), ZOOM_OUT, KeyStroke.getKeyStroke('-'), KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0)); bindAction(new ZoomAction("Zoom actual"), ZOOM_ACTUAL, KeyStroke.getKeyStroke('0'), KeyStroke.getKeyStroke(KeyEvent.VK_0, 0)); bindAction(TransferHandler.getCopyAction(), (String) TransferHandler.getCopyAction().getValue(Action.NAME), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); bindAction(TransferHandler.getPasteAction(), (String) TransferHandler.getPasteAction().getValue(Action.NAME), KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); }
if (mouseEvent.isPopupTrigger()) { JList<ItemList> list = (JList<ItemList>) mouseEvent.getSource(); this.dndList.dropPasteFile( Arrays.asList(importFileDialog.getSelectedFiles()), this.dndList.locationToIndex(mouseEvent.getPoint()) ); Action action = this.dndList.getActionMap().get(TransferHandler.getCopyAction().getValue(Action.NAME)); if (action != null) { action.actionPerformed( new ActionEvent(this.dndList, ActionEvent.ACTION_PERFORMED, null) ); Action action = this.dndList.getActionMap().get(TransferHandler.getCutAction().getValue(Action.NAME)); if (action != null) { action.actionPerformed( Action action = this.dndList.getActionMap().get(TransferHandler.getPasteAction().getValue(Action.NAME)); if (action != null) { action.actionPerformed(
public JComponent makeUI() { DragPanel p1 = new DragPanel(); p1.setBorder(BorderFactory.createLineBorder(Color.BLACK)); p1.add(new JLabel(UIManager.getIcon("OptionPane.warningIcon"))); p1.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon"))); p1.addMouseListener(handler); LabelTransferHandler th = new LabelTransferHandler(); p1.setTransferHandler(th); JPanel p = new JPanel(new GridLayout(1,2)); p.add(p1); p2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); p2.addMouseListener(handler); p2.setTransferHandler(th); @Override public void mousePressed(MouseEvent e) { DragPanel p = (DragPanel)e.getSource(); Component c = SwingUtilities.getDeepestComponentAt(p, e.getX(), e.getY()); if(c!=null && c instanceof JLabel) { p.draggingLabel = (JLabel)c; p.getTransferHandler().exportAsDrag(p, e, TransferHandler.MOVE);
public void mouseClicked(MouseEvent e) { if (! e.isConsumed()) { int nclicks = e.getClickCount(); a.actionPerformed(new ActionEvent(textArea, ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); Transferable trans = buffer.getContents(null); if (trans != null) { th.importData(c, trans);
@Override public void mouseDragged(MouseEvent e) { if (e.isConsumed()) return; if (treeTable.getDragEnabled()) { if (dndArmedEvent != null) { int dx = Math.abs(e.getX() - dndArmedEvent.getX()); int dy = Math.abs(e.getY() - dndArmedEvent.getY()); if ((dx > motionThreshold) || (dy > motionThreshold)) { TransferHandler th = treeTable.getTransferHandler(); int actions = th == null ? 0 : th.getSourceActions(treeTable); if (actions != 0) { // isDragging = true; // TODO, determine action int action = TransferHandler.MOVE; th.exportAsDrag(treeTable, dndArmedEvent, action); } } } } else if (sendDragToTable) { dispatchMouseEvent(e, table); } }
@Override public void mouseDragged(MouseEvent e) { Point tabPt = e.getPoint(); // e.getDragOrigin(); if (Objects.nonNull(this.startPt) && this.startPt.distance(tabPt) > this.gestureMotionThreshold) { DnDTabbedPane src = (DnDTabbedPane) e.getComponent(); TransferHandler th = src.getTransferHandler(); DnDTabbedPane.this.dragTabIndex = src.indexAtLocation(tabPt.x, tabPt.y); th.exportAsDrag(src, e, TransferHandler.MOVE); RECT_LINE.setBounds(0, 0, 0, 0); src.getRootPane().getGlassPane().setVisible(true); src.setDropLocation(new DropLocation(tabPt, -1), null, true); this.startPt = null; } }
public synchronized JGraph cloneJGraph(IDEState ids){ DeployDiagramModelJGraph jg=new DeployDiagramModelJGraph( (DeployDiagramDataEntity) this.mde,name, ids.om, new Model(ids),new BasicMarqueeHandler(),ids.prefs); this.setSelectionCells(getGraphLayoutCache().getCells(false,true,false,false)); Action copyaction =new EventRedirectorForGraphCopy(this,this.getTransferHandler().getCopyAction(),null ); Action pasteaction =new EventRedirectorPasteForGraphCopy(jg,jg.getTransferHandler().getPasteAction(),null ); copyaction.actionPerformed(new ActionEvent(this,0,"hello")); pasteaction.actionPerformed(new ActionEvent(this,0,"hello")); jg.invalidate(); jg.doLayout(); return jg; }
@Override public void exportAsDrag(JComponent comp, InputEvent e, int action) { point = null; if (e instanceof MouseEvent) { point = ((MouseEvent) e).getPoint(); } super.exportAsDrag(comp, e, action); }
@Override public void mouseDragged(MouseEvent e) { DrawingView v = getView(); Figure f = v.findFigure(e.getPoint()); if (f != null) { if (!v.getSelectedFigures().contains(f)) { v.clearSelection(); v.addToSelection(f); } v.getComponent().getTransferHandler().exportAsDrag(v.getComponent(), e, DnDConstants.ACTION_MOVE); } fireToolDone(); }
public void mousePressed(MouseEvent e) { JComponent c = (JComponent)e.getSource(); TransferHandler handler = c.getTransferHandler(); handler.exportAsDrag(c, e, TransferHandler.COPY); } };
public void actionPerformed(ActionEvent e) { JTable table = getSelectedJTable(); Action copyAction = TransferHandler.getCopyAction(); ActionEvent actionEvent = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "copy"); copyAction.actionPerformed(actionEvent); } });
@Override public void actionPerformed(ActionEvent e) { TransferHandler.getPasteAction().actionPerformed(new ActionEvent(list, ActionEvent.ACTION_PERFORMED, "paste")); } }
@Override public void actionPerformed(ActionEvent e) { if (DnDList.this.getSelectedValuesList().isEmpty()) { return; } List<ItemList> selectedValues = DnDList.this.getSelectedValuesList(); List<ItemList> siblings = new ArrayList<>(); for (ItemList value: selectedValues) { int valueIndex = DnDList.this.listModel.indexOf(value); if (valueIndex < DnDList.this.listModel.size() - 1) { siblings.add(DnDList.this.listModel.get(valueIndex + 1)); } else if (valueIndex > 0) { siblings.add(DnDList.this.listModel.get(valueIndex - 1)); } } TransferHandler.getCutAction().actionPerformed(e); for (ItemList sibling: siblings) { DnDList.this.setSelectedValue(sibling, true); } }
copy.setActionCommand((String)TransferHandler.getCopyAction(). getValue(Action.NAME)); copy.addActionListener(new TransferActionListener()); edit.add(copy);
private int mapDragOperationFromModifiers(MouseEvent me, TransferHandler th) { if (th == null || !SwingUtilities.isLeftMouseButton(me)) { return TransferHandler.NONE; } // PENDING JW: c'p from SunDragSourceContextPeer return SwingXUtilities. convertModifiersToDropAction(me.getModifiersEx(), th.getSourceActions(component)); }
@Override public void mouseDragged(MouseEvent e) { if (first != null) { if (activeDrag(e, first)) { first = null; TransferHandler handler = this.gridCell.getTransferHandler(); handler.exportAsDrag(this.gridCell, e, TransferHandler.MOVE); e.consume(); } } }
protected int mapDragOperationFromModifiers(MouseEvent e) { int mods = e.getModifiersEx(); if ((mods & InputEvent.BUTTON1_DOWN_MASK) != InputEvent.BUTTON1_DOWN_MASK) { return TransferHandler.NONE; } JComponent c = getComponent(e); TransferHandler th = c.getTransferHandler(); // return SunDragSourceContextPeer.convertModifiersToDropAction(mods, th.getSourceActions(c)); return convertModifiersToDropAction(mods, th.getSourceActions(c)); }