if (!row.isEmpty() && !selection.isEmpty()) { Dragboard db = row.startDragAndDrop(TransferMode.MOVE); db.setDragView(row.snapshot(null, null)); ClipboardContent cc = new ClipboardContent(); cc.put(DND_TABLE_SELECTION_MIME_TYPE, selection); db.setContent(cc); e.consume(); if (e.getGestureSource() != row && e.getDragboard().hasContent(DND_TABLE_SELECTION_MIME_TYPE)) { if (!((List<Integer>) e.getDragboard().getContent(DND_TABLE_SELECTION_MIME_TYPE)) .contains(row.getIndex())) { e.acceptTransferModes(TransferMode.MOVE); if (!row.isEmpty() && e.getDragboard().hasContent(DND_TABLE_SELECTION_MIME_TYPE)) { if (!((List<Integer>) e.getDragboard().getContent(DND_TABLE_SELECTION_MIME_TYPE)) .contains(row.getIndex())) { row.setOpacity(0.6); if (!row.isEmpty() && e.getDragboard().hasContent(DND_TABLE_SELECTION_MIME_TYPE)) { if (!((List<Integer>) e.getDragboard().getContent(DND_TABLE_SELECTION_MIME_TYPE)) .contains(row.getIndex())) { row.setOpacity(1); if (db.hasContent(DND_TABLE_SELECTION_MIME_TYPE)) { Optional<SelectionTableRowData> focus = ofNullable(getFocusModel().getFocusedItem()); Optional<SelectionTableRowData> toDrop = of(row).filter(r -> !r.isEmpty()) .getContent(DND_TABLE_SELECTION_MIME_TYPE); List<SelectionTableRowData> toMove = dragged.stream().map(getItems()::get)
private void dragConsume(DragEvent e, Consumer<DragEvent> c) { if (e.getDragboard().hasFiles()) { c.accept(e); } e.consume(); }
private Stream<File> getFilesFromDragboard(Dragboard board) { List<File> files = board.getFiles(); if (files.size() == 1 && files.get(0).isDirectory()) { return stream(files.get(0).listFiles()).sorted(); } return files.stream(); } }
private void onDragDropped(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasContent(EquipmentInfo.DATA_FORMAT)) { List<EquipmentInfo> infos = (List<EquipmentInfo>) db.getContent(EquipmentInfo.DATA_FORMAT); List<ContingencyElement> elements = infos.stream() .map(ContingencyStoreEditor::createContingencyElement) .filter(Objects::nonNull) .collect(Collectors.toList()); addContingencyElements(elements); success = true; } event.setDropCompleted(success); event.consume(); }
private void onDragDropped(DragEvent event) { codeArea.setShowCaret(Caret.CaretVisibility.AUTO); Dragboard db = event.getDragboard(); boolean success = false; if (db.hasContent(EquipmentInfo.DATA_FORMAT)) { List<EquipmentInfo> equipmentInfoList = (List<EquipmentInfo>) db.getContent(EquipmentInfo.DATA_FORMAT); codeArea.insertText(codeArea.getCaretPosition(), equipmentInfoList.get(0).getIdAndName().getId()); success = true; } else if (db.hasString() && event.getGestureSource() != codeArea) { codeArea.insertText(codeArea.getCaretPosition(), db.getString()); success = true; } else if (event.getGestureSource() == codeArea) { CharacterHit hit = codeArea.hit(event.getX(), event.getY()); codeArea.moveSelectedText(hit.getInsertionIndex()); success = true; } event.setDropCompleted(success); event.consume(); }
content.putString("#c" + getValue()); db.setDragView(snapshot(null, new WritableImage((int) getWidth(), (int) getHeight())), getWidth() / 2, 0); db.setContent(content); if (event.getGestureSource() != this && event.getDragboard().hasString()) event.acceptTransferModes(TransferMode.MOVE); if (event.getDragboard().hasString() && event.getDragboard().getString().startsWith("#c")) { String currentTag = getValue(); setValue(event.getDragboard().getString().replace("#c", "")); ((Tag) event.getGestureSource()).setValue(currentTag); success = true;
private void onDragDetected(MouseEvent event) { Dragboard db = substationDetailedView.startDragAndDrop(TransferMode.ANY); ClipboardContent content = new ClipboardContent(); List<EquipmentInfo> listInfo = substationDetailedView.getSelectionModel().getSelectedItems().stream().map(TreeItem :: getValue).collect(Collectors.toList()); content.put(EquipmentInfo.DATA_FORMAT, listInfo); db.setContent(content); event.consume(); }
/** * Extract the tab content * * @param e * the event * @return the content */ public static boolean hasDnDContent(Event e) { if (e instanceof DragEvent) { return ((DragEvent) e).getDragboard().hasContent(DnDTabPaneSkin.TAB_MOVE); } else if (e instanceof EFXDragEvent) { return ((EFXDragEvent) e).getDraggedContent() != null; } return false; }
private void onDragOver(DragEvent event) { Dragboard db = event.getDragboard(); if ((db.hasContent(EquipmentInfo.DATA_FORMAT) && db.getContent(EquipmentInfo.DATA_FORMAT) instanceof EquipmentInfo) || db.hasString()) { if (event.getGestureSource() == codeArea) { event.acceptTransferModes(TransferMode.MOVE); } else { event.acceptTransferModes(TransferMode.COPY); } CharacterHit hit = codeArea.hit(event.getX(), event.getY()); codeArea.displaceCaret(hit.getInsertionIndex()); } }
db.setDragView(image, image.getWidth(), image.getHeight() * -1); content.put(TAB_MOVE, data); db.setContent(content);
ClipboardContent content = new ClipboardContent(); content.putString(Integer.toString(getIndex())); dragboard.setContent(content); boolean success = false; if (db.hasString()) { ObservableList<RepositoryLocation<? extends Repository>> items = getListView().getItems(); int draggedIdx = Integer.parseInt(db.getString()); int thisIdx = items.indexOf(getItem());
if (lineIndex.get() != -1) { Dragboard db = e.getDragboard(); if (db.hasString()) { e.acceptTransferModes(TransferMode.COPY); updateInsertionMarkerIndex(lineIndex.get()); if (e.getDragboard().hasContent(DataFormat.PLAIN_TEXT)) { String insert = e.getDragboard().getString();
/** * Extract the content * * @param e * the event * @return the return value */ public static String getDnDContent(Event e) { if (e instanceof DragEvent) { return (String) ((DragEvent) e).getDragboard().getContent(DnDTabPaneSkin.TAB_MOVE); } else if (e instanceof EFXDragEvent) { return (String) ((EFXDragEvent) e).getDraggedContent(); } return null; }
/** * {@inheritDoc} */ @Override public void dragDropped(final DragEvent dragEvent) { System.out.println("drag DROPPED => " + controller().model().key()); /* data dropped */ /* if there is a string data on dragboard, read it and use it */ final Dragboard db = dragEvent.getDragboard(); boolean success = false; if (db.hasContent(CustomDataFormat.DOCKABLE)) { final Dockable serializedTab = (Dockable) db.getContent(CustomDataFormat.DOCKABLE); // final Button b = // getController().getView().getButtonByTab(serializedTab); final TabbedPaneModel model = controller().model().getModel(TabbedPaneModel.class, TabbedPaneConfig.create().id("ddddd").orientation(TabbedPaneOrientation.top)); // getController().model().addPart(model, null); success = true; } /* * let the source know whether the string was successfully transferred * and used */ dragEvent.setDropCompleted(success); dragEvent.consume(); }
@Override public void handle( MouseEvent event ) { Dragboard dragboard = tab.getGraphic().startDragAndDrop( TransferMode.MOVE ); ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.put( TAB_TYPE, 1 ); dndTab = new WeakReference<>( tab ); dragboard.setContent( clipboardContent ); event.consume(); } } );
/** * Extract the tab content * * @param e * the event * @return the content */ public static boolean hasDnDContent(Event e) { if (e instanceof DragEvent) { return ((DragEvent) e).getDragboard().hasContent(DnDTabPaneSkin.TAB_MOVE); } else if (e instanceof EFXDragEvent) { return ((EFXDragEvent) e).getDraggedContent() != null; } return false; }
db.setDragView(image, image.getWidth(), image.getHeight() * -1); content.put(TAB_MOVE, data); db.setContent(content);
/** * Extract the content * * @param e * the event * @return the return value */ public static String getDnDContent(Event e) { if (e instanceof DragEvent) { return (String) ((DragEvent) e).getDragboard().getContent(DnDTabPaneSkin.TAB_MOVE); } else if (e instanceof EFXDragEvent) { return (String) ((EFXDragEvent) e).getDraggedContent(); } return null; }