javafx.scene.input.DragEvent Java Examples
The following examples show how to use
javafx.scene.input.DragEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaterialPropertyControl.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Handle drag over events. * * @param dragEvent the drag over event. */ @FxThread private void handleDragOverEvent(@NotNull DragEvent dragEvent) { var dragboard = dragEvent.getDragboard(); var files = EditorUtil.getFiles(dragboard); if (files.size() != 1) { return; } var file = files.get(0); if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) { return; } var transferModes = dragboard.getTransferModes(); var isCopy = transferModes.contains(TransferMode.COPY); dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE); dragEvent.consume(); }
Example #2
Source File: WidgetTransfer.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** * @param event The {@link DragEvent} containing the dragged data. * @param selection_tracker Used to get the grid steps from its model to be * used in offsetting multiple widgets. * @param widgets The container of the created widgets. */ private static void installWidgetsFromString ( final DragEvent event, final SelectedWidgetUITracker selection_tracker, final List<Widget> widgets ) { final Dragboard db = event.getDragboard(); final String xmlOrText = db.getString(); try { widgets.addAll(ModelReader.parseXML(xmlOrText).getChildren()); } catch ( Exception ex ) { installWidgetsFromString(event, xmlOrText, selection_tracker, widgets); } }
Example #3
Source File: DockItem.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Handle that this tab was dragged elsewhere, or drag aborted */ private void handleDragDone(final DragEvent event) { final DockItem item = dragged_item.getAndSet(null); if (item != null && !event.isDropCompleted()) { // Would like to position new stage where the mouse was released, // but event.getX(), getSceneX(), getScreenX() are all 0.0. // --> Using MouseInfo, which is actually AWT code final Stage other = item.detach(); final PointerInfo pi = MouseInfo.getPointerInfo(); if (pi != null) { final Point loc = pi.getLocation(); other.setX(loc.getX()); other.setY(loc.getY()); } } event.consume(); }
Example #4
Source File: CardPileView.java From Solitaire with GNU General Public License v2.0 | 6 votes |
private EventHandler<DragEvent> createDragDroppedHandler(final ImageView pImageView, final Card pCard) { return new EventHandler<DragEvent>() { @Override public void handle(DragEvent pEvent) { Dragboard db = pEvent.getDragboard(); boolean success = false; if(db.hasString()) { GameModel.instance().getCardMove(new CardTransfer(db.getString()).getTop(), aIndex).perform(); success = true; } pEvent.setDropCompleted(success); pEvent.consume(); } }; }
Example #5
Source File: JaceUIController.java From jace with GNU General Public License v2.0 | 6 votes |
private void processDragEnteredEvent(DragEvent evt) { MediaEntry media = null; if (evt.getDragboard().hasFiles()) { media = MediaCache.getMediaFromFile(getDraggedFile(evt.getDragboard().getFiles())); } else if (evt.getDragboard().hasUrl()) { media = MediaCache.getMediaFromUrl(evt.getDragboard().getUrl()); } else if (evt.getDragboard().hasString()) { String path = evt.getDragboard().getString(); try { URI.create(path); media = MediaCache.getMediaFromUrl(path); } catch (IllegalArgumentException ex) { File f = new File(path); if (f.exists()) { media = MediaCache.getMediaFromFile(f); } } } if (media != null) { evt.acceptTransferModes(TransferMode.LINK, TransferMode.COPY); startDragEvent(media); } }
Example #6
Source File: CardPileView.java From Solitaire with GNU General Public License v2.0 | 6 votes |
private EventHandler<DragEvent> createDragEnteredHandler(final ImageView pImageView, final Card pCard) { return new EventHandler<DragEvent>() { @Override public void handle(DragEvent pEvent) { CardTransfer transfer = new CardTransfer(pEvent.getDragboard().getString()); if( GameModel.instance().isLegalMove(transfer.getTop(), aIndex) ) { pImageView.setEffect(new DropShadow()); } pEvent.consume(); } }; }
Example #7
Source File: ResourcePropertyEditorControl.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Handle drag over. */ @FxThread private void dragOver(@NotNull DragEvent dragEvent) { var dragboard = dragEvent.getDragboard(); var files = ClassUtils.<List<File>>unsafeCast(dragboard.getContent(DataFormat.FILES)); if (files == null || files.size() != 1) { return; } var file = files.get(0); if (!canAccept(file)) { return; } var transferModes = dragboard.getTransferModes(); var isCopy = transferModes.contains(TransferMode.COPY); dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE); dragEvent.consume(); }
Example #8
Source File: SuitStack.java From Solitaire with GNU General Public License v2.0 | 6 votes |
private EventHandler<DragEvent> createOnDragOverHandler(final ImageView pView) { return new EventHandler<DragEvent>() { public void handle(DragEvent pEvent) { if(pEvent.getGestureSource() != pView && pEvent.getDragboard().hasString()) { CardTransfer transfer = new CardTransfer(pEvent.getDragboard().getString()); if( transfer.size() == 1 && GameModel.instance().isLegalMove(transfer.getTop(), aIndex) ) { pEvent.acceptTransferModes(TransferMode.MOVE); } } pEvent.consume(); } }; }
Example #9
Source File: SuitStack.java From Solitaire with GNU General Public License v2.0 | 6 votes |
private EventHandler<DragEvent> createOnDragDroppedHandler() { return new EventHandler<DragEvent>() { public void handle(DragEvent pEvent) { Dragboard db = pEvent.getDragboard(); boolean success = false; if(db.hasString()) { CardTransfer transfer = new CardTransfer(pEvent.getDragboard().getString()); GameModel.instance().getCardMove(transfer.getTop(), aIndex).perform(); success = true; } pEvent.setDropCompleted(success); pEvent.consume(); } }; }
Example #10
Source File: FrontController.java From ns-usbloader with GNU General Public License v3.0 | 6 votes |
/** * Drag-n-drop support (drop consumer) * */ @FXML private void handleDrop(DragEvent event){ List<File> filesDropped = event.getDragboard().getFiles(); if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTfXciNszXczSupport()) filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches("(.*\\.nsp$)|(.*\\.xci$)|(.*\\.nsz$)|(.*\\.xcz$)")); else if (getSelectedProtocol().equals("GoldLeaf") && (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL())) filesDropped.removeIf(file -> (file.isDirectory() && ! file.getName().toLowerCase().matches(".*\\.nsp$"))); else filesDropped.removeIf(file -> ! file.getName().toLowerCase().matches(".*\\.nsp$")); if ( ! filesDropped.isEmpty() ) tableFilesListController.setFiles(filesDropped); event.setDropCompleted(true); event.consume(); }
Example #11
Source File: DragDropGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * @param target * The targeted {@link Node} * @param event * The original {@link DragEvent} */ protected void dragExited(final Node target, final DragEvent event) { final IViewer viewer = PartUtils.retrieveViewer(getDomain(), target); final List<? extends IOnDragDropHandler> dragDropPolicies = getHandlerResolver() .resolve(DragDropGesture.this, target, viewer, ON_DRAGDROP_HANDLER_KEY); if (dragDropPolicies != null && !dragDropPolicies.isEmpty()) { for (final IOnDragDropHandler dragDropPolicy : dragDropPolicies) { dragDropPolicy.dragExited(event); } } }
Example #12
Source File: SuitStack.java From Solitaire with GNU General Public License v2.0 | 5 votes |
private EventHandler<DragEvent> createOnDragEnteredHandler() { return new EventHandler<DragEvent>() { public void handle(DragEvent pEvent) { CardTransfer transfer = new CardTransfer(pEvent.getDragboard().getString()); if( transfer.size() == 1 && GameModel.instance().isLegalMove(transfer.getTop(), aIndex) ) { setStyle(BORDER_STYLE_DRAGGED); } pEvent.consume(); } }; }
Example #13
Source File: DockItem.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Highlight while 'drop' is possible */ private void handleDragEntered(final DragEvent event) { // Drop not possible into a 'fixed' pane if (getDockPane().isFixed()) return; final DockItem item = dragged_item.get(); if (item != null && item != this) { name_tab.setBorder(DROP_ZONE_BORDER); name_tab.setTextFill(Color.GREEN); } event.consume(); }
Example #14
Source File: MZmineGUI.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * The method activateSetOnDragDropped controlling what happens when something is dropped on window. * Implemented activateSetOnDragDropped to select the module according to the dropped file type and open dropped file * @param event - DragEvent */ public static void activateSetOnDragDropped(DragEvent event){ Dragboard dragboard = event.getDragboard(); boolean hasFileDropped = false; if (dragboard.hasFiles()) { hasFileDropped = true; for (File selectedFile:dragboard.getFiles()) { final String extension = FilenameUtils.getExtension(selectedFile.getName()); String[] rawDataFile = {"cdf","nc","mzData","mzML","mzXML","raw"}; final Boolean isRawDataFile = Arrays.asList(rawDataFile).contains(extension); final Boolean isMZmineProject = extension.equals("mzmine"); Class<? extends MZmineRunnableModule> moduleJavaClass = null; if(isMZmineProject) { moduleJavaClass = ProjectLoadModule.class; } else if(isRawDataFile){ moduleJavaClass = RawDataImportModule.class; } if(moduleJavaClass != null){ ParameterSet moduleParameters = MZmineCore.getConfiguration().getModuleParameters(moduleJavaClass); if(isMZmineProject){ moduleParameters.getParameter(projectFile).setValue(selectedFile); } else if (isRawDataFile){ File fileArray[] = { selectedFile }; moduleParameters.getParameter(fileNames).setValue(fileArray); } ParameterSet parametersCopy = moduleParameters.cloneParameterSet(); MZmineCore.runMZmineModule(moduleJavaClass, parametersCopy); } } } event.setDropCompleted(hasFileDropped); event.consume(); }
Example #15
Source File: MZmineGUI.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * The method activateSetOnDragOver controlling what happens when something is dragged over. * Implemented activateSetOnDragOver to accept when files are dragged over it. * @param event - DragEvent */ public static void activateSetOnDragOver(DragEvent event){ Dragboard dragBoard = event.getDragboard(); if (dragBoard.hasFiles()) { event.acceptTransferModes(TransferMode.COPY); } else { event.consume(); } }
Example #16
Source File: DockItem.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Remove Highlight */ private void handleDragExited(final DragEvent event) { name_tab.setBorder(Border.EMPTY); name_tab.setTextFill(Color.BLACK); event.consume(); }
Example #17
Source File: DragDropGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override protected void doHookScene(Scene scene) { // register a drag entered filter for forwarding event to drag/drop // policies scene.addEventFilter(DragEvent.DRAG_ENTERED, dragEnteredFilter); // register a drag exited filter for forwarding event to drag/drop // policies scene.addEventFilter(DragEvent.DRAG_EXITED, dragExitedFilter); // register a drag over filter for forwarding event to drag/drop // policies scene.addEventFilter(DragEvent.DRAG_OVER, dragOverFilter); // register a drag dropped filter for forwarding event to drag/drop // policies scene.addEventFilter(DragEvent.DRAG_DROPPED, dragDroppedFilter); }
Example #18
Source File: SearchBox.java From mdict-java with GNU General Public License v3.0 | 5 votes |
protected void handleDrop(DragEvent event) { Dragboard db = event.getDragboard(); if(db.hasContent(DataFormat.PLAIN_TEXT)) { String val = (String) db.getContent(DataFormat.PLAIN_TEXT); ((TextField)event.getSource()).setText(val); event.consume(); } }
Example #19
Source File: DragDropGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public void handle(final DragEvent event) { final EventTarget target = event.getTarget(); if (event.getGestureSource() != target && (target instanceof Node)) { final Node targetNode = (Node) target; dragOver(targetNode, event); } }
Example #20
Source File: FrontController.java From ns-usbloader with GNU General Public License v3.0 | 5 votes |
/** * Drag-n-drop support (dragOver consumer) * */ @FXML private void handleDragOver(DragEvent event){ if (event.getDragboard().hasFiles() && ! MediatorControl.getInstance().getTransferActive()) event.acceptTransferModes(TransferMode.ANY); event.consume(); }
Example #21
Source File: WorkspaceNavigator.java From Recaf with MIT License | 5 votes |
private void onDragDrop(DragEvent e) { // Load drag-drop files if(e.getDragboard().hasFiles()) { File file = e.getDragboard().getFiles().get(0); controller.loadWorkspace(IOUtil.toPath(file), null); } }
Example #22
Source File: BrowsableDirectoryField.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
private void dragConsume(DragEvent e, Consumer<DragEvent> c) { List<File> files = e.getDragboard().getFiles(); if (files != null && !files.isEmpty()) { c.accept(e); } e.consume(); }
Example #23
Source File: BrowsableFileField.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
private Consumer<DragEvent> onDragDropped() { return (DragEvent e) -> { e.getDragboard().getFiles().stream().filter(f -> fileType.matches(f.getName())).findFirst() .ifPresent(file -> setTextFromFile(file)); e.setDropCompleted(true); }; }
Example #24
Source File: DragDropGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public void handle(final DragEvent event) { final EventTarget target = event.getTarget(); if (target instanceof Node) { dragEntered((Node) target, event); } }
Example #25
Source File: ApkInfoPrinterActivity.java From ApkToolPlus with Apache License 2.0 | 5 votes |
public void onDragDroppedHandleFiles(DragEvent event){ Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; for (File file : db.getFiles()) { showManifest(file); break; } } event.setDropCompleted(success); event.consume(); }
Example #26
Source File: ApkInfoPrinterActivity.java From ApkToolPlus with Apache License 2.0 | 5 votes |
public void onDragOverLinkFile(DragEvent event){ Dragboard db = event.getDragboard(); if (db.hasFiles()) { event.acceptTransferModes(TransferMode.LINK); } else { event.consume(); } }
Example #27
Source File: MaterialFileEditor.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread protected void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) { super.handleDragDroppedEvent(dragEvent); UiUtils.handleDroppedFile(dragEvent, FileExtensions.TEXTURE_EXTENSIONS, this, dragEvent, this::applyTexture); }
Example #28
Source File: AbstractSceneFileEditor.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Apply a new material from an asset tree. * * @param dragEvent the drag event. * @param file the file. */ @FxThread private void applyMaterial(@NotNull final DragEvent dragEvent, @NotNull final Path file) { final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file); final String assetPath = toAssetPath(assetFile); final MA editor3DState = getEditor3DPart(); final MaterialKey materialKey = new MaterialKey(assetPath); final Camera camera = editor3DState.getCamera(); final BorderPane area = get3DArea(); final Point2D areaPoint = area.sceneToLocal(dragEvent.getSceneX(), dragEvent.getSceneY()); EXECUTOR_MANAGER.addJmeTask(() -> { final Geometry geometry = editor3DState.getGeometryByScreenPos((float) areaPoint.getX(), camera.getHeight() - (float) areaPoint.getY()); if (geometry == null) return; final Object linkNode = findParent(geometry, AssetLinkNode.class::isInstance); if (linkNode != null) return; final AssetManager assetManager = EditorUtil.getAssetManager(); final Material material = assetManager.loadAsset(materialKey); final PropertyOperation<ChangeConsumer, Geometry, Material> operation = new PropertyOperation<>(geometry, Messages.MODEL_PROPERTY_MATERIAL, material, geometry.getMaterial()); operation.setApplyHandler(Geometry::setMaterial); execute(operation); }); }
Example #29
Source File: ModulesDashboardTile.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
private Consumer<DragEvent> onDragDropped(Function<List<File>, ? extends BaseFilesDroppedEvent> provider) { return (DragEvent e) -> { eventStudio().broadcast(activeteModule(id)); eventStudio().broadcast(provider.apply(e.getDragboard().getFiles())); e.setDropCompleted(true); }; }
Example #30
Source File: CardPileView.java From Solitaire with GNU General Public License v2.0 | 5 votes |
private EventHandler<DragEvent> createDragExitedHandler(final ImageView pImageView, final Card pCard) { return new EventHandler<DragEvent>() { @Override public void handle(DragEvent pEvent) { pImageView.setEffect(null); pEvent.consume(); } }; }