List of usage examples for javafx.scene.input DragEvent consume
public void consume()
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.GridViewImpl.java
private void handleDragDropped(DragEvent event) { LOGGER.debug("drag dropped"); Dragboard dragboard = event.getDragboard(); boolean success = dragboard.hasFiles(); if (success) { dragboard.getFiles().forEach(f -> LOGGER.debug("dropped file {}", f)); for (File file : dragboard.getFiles()) { try { workspaceService.addDirectory(file.toPath()); } catch (ServiceException ex) { LOGGER.error("Couldn't add directory {}"); }/*ww w . j a v a 2s . co m*/ } } event.setDropCompleted(success); event.consume(); }
From source file:com.rockhoppertech.symchords.fx.SymChordsController.java
protected void setupDragonDrop() { Image image = new Image(getClass().getResourceAsStream("/images/rocky-32-trans.png")); dragImageView = new ImageView(image); dragImageView.setFitHeight(32);/*from www . ja v a 2s. c om*/ dragImageView.setFitWidth(32); grandStaff.setOnDragDetected(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { if (!root.getChildren().contains(dragImageView)) { root.getChildren().add(dragImageView); } // dragImageView.setOpacity(0.5); dragImageView.toFront(); dragImageView.setMouseTransparent(true); dragImageView.setVisible(true); dragImageView.relocate((int) (me.getSceneX() - dragImageView.getBoundsInLocal().getWidth() / 2), (int) (me.getSceneY() - dragImageView.getBoundsInLocal().getHeight() / 2)); Dragboard db = grandStaff.startDragAndDrop(TransferMode.ANY); // TODO remove the custom image nonsense in javafx 8 // javafx 8 // db.setDragView(dragImageView); ClipboardContent content = new ClipboardContent(); // MIDITrack track = grandStaff.getMIDITrack(); MIDITrack track = model.getMIDITrack(); content.put(midiTrackDataFormat, track); db.setContent(content); me.consume(); } }); grandStaff.setOnDragDone(new EventHandler<DragEvent>() { public void handle(DragEvent e) { dragImageView.setVisible(false); e.consume(); } }); // Parent root = grandStaff.getScene().getRoot(); // stage.getScene().getRoot(); if (root != null) { root.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent e) { Point2D localPoint = grandStaff.getScene().getRoot() .sceneToLocal(new Point2D(e.getSceneX(), e.getSceneY())); dragImageView.relocate( (int) (localPoint.getX() - dragImageView.getBoundsInLocal().getWidth() / 2), (int) (localPoint.getY() - dragImageView.getBoundsInLocal().getHeight() / 2)); e.consume(); } }); } trackList.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* * data is dragged over the target; accept it only if it is not * dragged from the same node and if it has MIDITrack data */ if (event.getGestureSource() != trackList && event.getDragboard().hasContent(midiTrackDataFormat)) { logger.debug("drag over"); /* allow for both copying and moving, whatever user chooses */ event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } // Don't consume the event. Let the layers below process the // DragOver event as well so that the // translucent container image will follow the cursor. // event.consume(); } }); trackList.setOnDragEntered(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* the drag-and-drop gesture entered the target */ /* show to the user that it is an actual gesture target */ logger.debug("drag entered"); if (event.getGestureSource() != trackList && event.getDragboard().hasContent(midiTrackDataFormat)) { DropShadow dropShadow = new DropShadow(); dropShadow.setRadius(5.0); dropShadow.setOffsetX(3.0); dropShadow.setOffsetY(3.0); dropShadow.setColor(Color.color(0.4, 0.5, 0.5)); trackList.setEffect(dropShadow); } event.consume(); } }); trackList.setOnDragExited(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* mouse moved away, remove the graphical cues */ trackList.setEffect(null); event.consume(); } }); trackList.setOnDragDropped(new EventHandler<DragEvent>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasContent(midiTrackDataFormat)) { MIDITrack track = (MIDITrack) db.getContent(midiTrackDataFormat); trackList.getItems().add(track); success = true; } /* * let the source know whether the data was successfully * transferred and used */ event.setDropCompleted(success); event.consume(); } }); logger.debug("jvm mime {}", DataFlavor.javaJVMLocalObjectMimeType); }
From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignView.java
/** * Drag and drop input/*from w w w. j a va 2 s .c o m*/ */ @FXML protected void onDragDroppedInput(DragEvent event) throws Exception { // Files dropped Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; String filePath = ""; for (File file : db.getFiles()) { if (!filePath.isEmpty()) { filePath += ";"; } filePath += file.getAbsolutePath(); } String currentText = inputText.getText(); if (!currentText.isEmpty() && !currentText.equals(bundle.getString("inputText"))) { inputText.setText(currentText + ";" + filePath); } else { inputText.setText(filePath); } } event.setDropCompleted(success); event.consume(); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *///from w w w .java 2 s . c o m private void projetsNouveau() { Action reponse = null; Localization.setLocale(locale); if (!dejaSauve) { reponse = Dialogs.create().owner(null).title("Nouveau projet") .masthead("Vous n'avez pas sauvegard votre projet").message("Voulez vous le sauver ?") .showConfirm(); } if (reponse == Dialog.Actions.YES) { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } if ((reponse == Dialog.Actions.YES) || (reponse == Dialog.Actions.NO) || (reponse == null)) { panoEntree = ""; deleteDirectory(repertTemp); String repertPanovisu = repertTemp + File.separator + "panovisu"; File rptPanovisu = new File(repertPanovisu); rptPanovisu.mkdirs(); copieDirectory(repertAppli + File.separator + "panovisu", repertPanovisu); menuPanoramique.setDisable(false); imgAjouterPano.setDisable(false); imgAjouterPano.setOpacity(1.0); imgSauveProjet.setDisable(false); imgSauveProjet.setOpacity(1.0); sauveProjet.setDisable(false); sauveSousProjet.setDisable(false); visiteGenere.setDisable(false); fichProjet = null; paneChoixPanoramique.setVisible(false); panoramiquesProjet = new Panoramique[50]; nombrePanoramiques = 0; retireAffichageLigne(); retireAffichageHotSpots(); retireAffichagePointsHotSpots(); numPoints = 0; numImages = 0; numHTML = 0; gestionnaireInterface.nombreImagesFond = 0; gestionnairePlan.planActuel = -1; imagePanoramique.setImage(null); listeChoixPanoramique.getItems().clear(); listeChoixPanoramiqueEntree.getItems().clear(); lblDragDrop.setVisible(true); Node ancNord = (Node) pano.lookup("#Nord"); if (ancNord != null) { pano.getChildren().remove(ancNord); } Node ancPoV = (Node) pano.lookup("#PoV"); if (ancPoV != null) { pano.getChildren().remove(ancPoV); } gestionnairePlan.lblDragDropPlan.setVisible(true); nombrePlans = 0; plans = new Plan[100]; gestionnairePlan.creeInterface(largeurInterface, hauteurInterface - 60); Pane panneauPlan = gestionnairePlan.tabInterface; affichagePlan.setDisable(true); tabPlan.setDisable(true); tabPlan.setContent(panneauPlan); vuePanoramique.setOnDragOver((DragEvent event) -> { Dragboard db = event.getDragboard(); if (db.hasFiles()) { event.acceptTransferModes(TransferMode.ANY); } else { event.consume(); } }); // Dropping over surface vuePanoramique.setOnDragDropped((DragEvent event) -> { Platform.runLater(() -> { paneAttends.setVisible(true); }); Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; String filePath = null; File[] list = new File[100]; int i = 0; for (File file1 : db.getFiles()) { filePath = file1.getAbsolutePath(); list[i] = file1; i++; } int nb = i; if (list != null) { i = 0; File[] lstFich1 = new File[list.length]; String[] typeFich1 = new String[list.length]; for (int jj = 0; jj < nb; jj++) { File file = list[jj]; String nomfich = file.getAbsolutePath(); String extension = nomfich.substring(nomfich.lastIndexOf(".") + 1, nomfich.length()) .toLowerCase(); // if (extension.equals("bmp") || extension.equals("jpg")) { if (extension.equals("jpg") || extension.equals("bmp") || extension.equals("tif")) { Image img = null; if (extension.equals("tif")) { try { img = ReadWriteImage.readTiff(file.getAbsolutePath()); } catch (ImageReadException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } else { img = new Image("file:" + file.getAbsolutePath()); } typeFich1[i] = ""; if (img.getWidth() == 2 * img.getHeight()) { lstFich1[i] = file; typeFich1[i] = Panoramique.SPHERE; i++; } if (img.getWidth() == img.getHeight()) { String nom = file.getAbsolutePath().substring(0, file.getAbsolutePath().length() - 6); boolean trouve = false; for (int j = 0; j < i; j++) { String nom1 = ""; if (lstFich1[j].getAbsolutePath().length() == file.getAbsolutePath() .length()) { nom1 = lstFich1[j].getAbsolutePath().substring(0, file.getAbsolutePath().length() - 6); } if (nom.equals(nom1)) { trouve = true; } } if (!trouve) { lstFich1[i] = file; typeFich1[i] = Panoramique.CUBE; i++; } } } } File[] lstFich = new File[i]; System.arraycopy(lstFich1, 0, lstFich, 0, i); for (int ii = 0; ii < lstFich.length; ii++) { File file1 = lstFich[ii]; dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); sauveProjet.setDisable(false); currentDir = file1.getParent(); File imageRepert = new File(repertTemp + File.separator + "panos"); if (!imageRepert.exists()) { imageRepert.mkdirs(); } repertPanos = imageRepert.getAbsolutePath(); try { // try { // if (typeFich1[ii].equals(Panoramique.SPHERE)) { // copieFichierRepertoire(file1.getPath(), repertPanos); // } else { // String nom = file1.getAbsolutePath().substring(0, file1.getAbsolutePath().length() - 6); // copieFichierRepertoire(nom + "_u.jpg", repertPanos); // copieFichierRepertoire(nom + "_d.jpg", repertPanos); // copieFichierRepertoire(nom + "_f.jpg", repertPanos); // copieFichierRepertoire(nom + "_b.jpg", repertPanos); // copieFichierRepertoire(nom + "_r.jpg", repertPanos); // copieFichierRepertoire(nom + "_l.jpg", repertPanos); // } // } catch (IOException ex) { // Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); // } if (typeFich1[ii] == Panoramique.CUBE || typeFich1[ii] == Panoramique.SPHERE) { ajoutePanoramiqueProjet(file1.getPath(), typeFich1[ii]); } } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } installeEvenements(); imgVisiteGenere.setOpacity(1.0); imgVisiteGenere.setDisable(false); lblDragDrop.setVisible(false); } } Platform.runLater(() -> { paneAttends.setVisible(false); }); event.setDropCompleted(success); event.consume(); }); } }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void initPostProcessTab() { //initialize voxel file merging panel listViewVoxMergingVoxelFiles.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); listViewVoxMergingVoxelFiles.setOnDragOver(DragAndDropHelper.dragOverEvent); listViewVoxMergingVoxelFiles.setOnDragDropped(new EventHandler<DragEvent>() { @Override/* w w w.ja v a 2 s . c o m*/ public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; for (File file : db.getFiles()) { addVoxelFileToMergingList(file); } } event.setDropCompleted(success); event.consume(); } }); fileChooserVoxMergingList = new FileChooserContext(); fileChooserOpenInputFileButterflyRemover = new FileChooserContext(); fileChooserOpenOutputFileButterflyRemover = new FileChooserContext(); fileChooserChooseOutputCfgFileButterflyRemover = new FileChooserContext(); }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void setDragDroppedSingleFileEvent(final TextField textField) { textField.setOnDragDropped(new EventHandler<DragEvent>() { @Override//from w ww.j ava 2 s . c o m public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles() && db.getFiles().size() == 1) { success = true; for (File file : db.getFiles()) { if (file != null) { textField.setText(file.getAbsolutePath()); } } } event.setDropCompleted(success); event.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *//*from w w w .j a v a2 s . c o m*/ private static void projetsNouveau() { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); ButtonType buttonTypeAnnule = new ButtonType(rbLocalisation.getString("main.annuler")); if (!isbDejaSauve()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("main.dialog.nouveauProjet")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("main.dialog.chargeProjetMessage")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon, buttonTypeAnnule); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } if ((reponse == buttonTypeOui) || (reponse == buttonTypeNon) || (reponse == null)) { apVignettesPano.getChildren().clear(); strPanoEntree = ""; deleteDirectory(getStrRepertTemp()); String strRepertPanovisu = getStrRepertTemp() + File.separator + "panovisu"; File fileRptPanovisu = new File(strRepertPanovisu); fileRptPanovisu.mkdirs(); copieRepertoire(getStrRepertAppli() + File.separator + "panovisu", strRepertPanovisu); mnuPanoramique.setDisable(false); btnMnuPanoramique.setDisable(false); ivAjouterPano.setDisable(false); ivAjouterPano.setOpacity(1.0); ivSauveProjet.setDisable(false); ivSauveProjet.setOpacity(1.0); mniSauveProjet.setDisable(false); mniSauveSousProjet.setDisable(false); mniVisiteGenere.setDisable(false); fileProjet = null; getVbChoixPanoramique().setVisible(false); setPanoramiquesProjet(new Panoramique[50]); setiNombrePanoramiques(0); retireAffichageLigne(); dejaCharge = false; retireAffichageHotSpots(); retireAffichagePointsHotSpots(); setiNumPoints(0); setiNumImages(0); setiNumHTML(0); getGestionnaireInterface().setiNombreImagesFond(0); getGestionnairePlan().setiPlanActuel(-1); ivImagePanoramique.setImage(null); cbListeChoixPanoramique.getItems().clear(); lblDragDrop.setVisible(true); Node nodAncienNord = (Node) panePanoramique.lookup("#Nord"); if (nodAncienNord != null) { panePanoramique.getChildren().remove(nodAncienNord); } Node nodAncienPoV = (Node) panePanoramique.lookup("#PoV"); if (nodAncienPoV != null) { panePanoramique.getChildren().remove(nodAncienPoV); } getGestionnairePlan().getLblDragDropPlan().setVisible(true); setiNombrePlans(0); setPlans(new Plan[100]); getGestionnairePlan().creeInterface(iLargeurInterface, iHauteurInterface - 60); Pane panePanneauPlan = getGestionnairePlan().getPaneInterface(); getMniAffichagePlan().setDisable(true); getTabPlan().setDisable(true); getTabPlan().setContent(panePanneauPlan); spVuePanoramique.setOnDragOver((DragEvent event) -> { Dragboard dbFichiersPanoramiques = event.getDragboard(); if (dbFichiersPanoramiques.hasFiles()) { event.acceptTransferModes(TransferMode.ANY); } else { event.consume(); } }); spVuePanoramique.setOnDragDropped((DragEvent event) -> { Platform.runLater(() -> { getApAttends().setVisible(true); }); Dragboard dbFichiersPanoramiques = event.getDragboard(); boolean bSucces = false; if (dbFichiersPanoramiques.hasFiles()) { getApAttends().setVisible(true); mbarPrincipal.setDisable(true); bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); tpEnvironnement.setDisable(true); pbarAvanceChargement.setProgress(-1); bSucces = true; String strFichierPath = null; File[] fileList = new File[100]; int i = 0; for (File filePano : dbFichiersPanoramiques.getFiles()) { strFichierPath = filePano.getAbsolutePath(); fileList[i] = filePano; i++; } int iNb = i; if (fileList != null) { lblDragDrop.setVisible(false); Task taskChargeFichiers; taskChargeFichiers = tskChargeListeFichiers(fileList, iNb); Thread thChargeFichiers = new Thread(taskChargeFichiers); thChargeFichiers.setDaemon(true); thChargeFichiers.start(); } } event.setDropCompleted(bSucces); event.consume(); }); apVignettesPano.getChildren().add(rectVignettePano); rectVignettePano.setVisible(false); } }
From source file:org.pdfsam.ui.io.BrowsableDirectoryField.java
private void dragConsume(DragEvent e, Consumer<DragEvent> c) { List<File> files = e.getDragboard().getFiles(); if (files != null && !files.isEmpty()) { c.accept(e);/*from w ww . jav a2s.c o m*/ } e.consume(); }
From source file:org.pdfsam.ui.selection.multiple.SelectionTable.java
private void onDragExited(DragEvent e) { placeHolder.setDisable(true); e.consume(); }
From source file:org.ykc.usbcx.MainWindowController.java
@FXML void openOnDragOver(DragEvent event) { Dragboard db = event.getDragboard(); if (db.hasFiles()) { event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } else {//from w w w. ja v a2 s . c om event.consume(); } }