Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123611

Gtk: Dragboard contains url escaped File paths in Linux which fail a file.exists() test

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • javafx
    • Java 1.8.0ea b92

    Backports

      Description

        In Linux (Gnome 3) if I drop files onto my JavaFX application any files that have spaces in the path are url escaped with %20 in place of any spaces. These files do not pass a Files.exists() test because of the escaped spaces.

        Please run the provided test code in Gnome and drag a group of files onto the opened Stage. Be sure to include some files that have spaces and some that do not.

        *************************************************************
        import java.io.File;
        import java.util.ArrayList;

        import javafx.application.Application;
        import javafx.event.EventHandler;
        import javafx.scene.Scene;
        import javafx.scene.control.ListView;
        import javafx.scene.input.DragEvent;
        import javafx.scene.input.Dragboard;
        import javafx.scene.input.TransferMode;
        import javafx.scene.layout.StackPane;
        import javafx.stage.Stage;

        public class DropFilesTest extends Application {

        @Override
        public void start(Stage primaryStage) throws Exception {

        primaryStage.centerOnScreen();
        primaryStage.setHeight(200);
        primaryStage.setWidth(550);

        final ListView<String> list = new ListView<>();
        list.setOnDragOver(new EventHandler<DragEvent>() {
        @Override public void handle(DragEvent event) {
        if ( event.getDragboard().hasFiles() ) {
        event.acceptTransferModes(TransferMode.COPY);
        }
        }
        });
        list.setOnDragDropped( new EventHandler<DragEvent>() {
        @Override public void handle(DragEvent event) {
        Dragboard db = event.getDragboard();
        if ( db.hasFiles() ) {
        ArrayList<String> newItems = new ArrayList<>();
        for ( File f : db.getFiles() ) {
        newItems.add("\"" + f + "\"" + " exists: " +f.exists());
        }
        list.getItems().setAll(newItems);
        event.setDropCompleted(true);
        event.consume();
        }
        event.setDropCompleted(false);
        }
        });

        primaryStage.setScene( new Scene(new StackPane(list)) );
        primaryStage.show();

        }

        public static void main(String[] args) throws Exception {
        launch(args);
        }

        }

        Attachments

          Issue Links

            Activity

              People

                azvegint Alexander Zvegintsev
                csmithjfx Charles Smith (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported: