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

Compatibility issue: ListView/TreeView drag&drop: IllegalArgumentException: DataFormat 'xxx' already exists

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 7u6
    • 7u6
    • javafx
    • None

      I just switched from 2.1 GA to 2.2 beta b15 and noticed that some things that worked in 2.1 don't work any longer in 2.2:

      I have a ListView and a TreeView with Drag & Drop. I transport my own data format. On drag detected I put the new data format in the drag board.

      On drag entered I ask the drag board if it contains "my" data format. If yes, I want to do stuff.

      In the dragentered I get the following exception:

      java.lang.IllegalArgumentException: DataFormat 'contactEntry' already exists.
      at javafx.scene.input.DataFormat.<init>(Unknown Source)
      TestApp5$1$3.handle(TestApp5.java:85)
      TestApp5$1$3.handle(TestApp5.java:82)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
      at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
      at javafx.event.Event.fireEvent(Unknown Source)
      at javafx.scene.Scene$DnDGesture.handleExitEnter(Unknown Source)
      at javafx.scene.Scene$DnDGesture.processTargetEnterOver(Unknown Source)
      at javafx.scene.Scene$DnDGesture.access$6100(Unknown Source)
      at javafx.scene.Scene$DropTargetListener.dragEnter(Unknown Source)
      at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragEnter(Unknown Source)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragEnter(Unknown Source)
      at com.sun.glass.ui.View.handleDragEnter(Unknown Source)
      at com.sun.glass.ui.View.notifyDragEnter(Unknown Source)
      at com.sun.glass.ui.win.WinDnDClipboard.push(Native Method)
      at com.sun.glass.ui.win.WinSystemClipboard.pushToSystem(Unknown Source)
      at com.sun.glass.ui.SystemClipboard.flush(Unknown Source)
      at com.sun.glass.ui.ClipboardAssistance.flush(Unknown Source)
      at com.sun.javafx.tk.quantum.QuantumClipboard.flush(Unknown Source)
      at com.sun.javafx.tk.quantum.QuantumToolkit.startDrag(Unknown Source)
      at javafx.scene.Scene$DnDGesture.dragDetectedProcessed(Unknown Source)
      at javafx.scene.Scene$DnDGesture.process(Unknown Source)
      at javafx.scene.Scene$DnDGesture.access$8700(Unknown Source)
      at javafx.scene.Scene$MouseHandler.process(Unknown Source)
      at javafx.scene.Scene$MouseHandler.process(Unknown Source)
      at javafx.scene.Scene$MouseHandler.access$1900(Unknown Source)
      at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
      at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
      at com.sun.glass.ui.View.notifyMouse(Unknown Source)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
      at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)


      I also get a COM ERROR 80de0001 in CallbackToJava(javaIDs.View.notifyDragEnter, grfKeyState, pt, pdwEffect)

      In some cases this error event causes my application to terminate!

      (I can't copy&paste it here completely due to some strange characters)


      TEST CASE (drag a listcell over another one):

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.ListCell;
      import javafx.scene.control.ListView;
      import javafx.scene.input.*;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      import java.util.HashMap;
      import java.util.Map;


      public class TestApp5 extends Application {


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

          public void start(final Stage stage) throws Exception {

              VBox root = new VBox();

              ListView<String> listView = new ListView<String>();

              listView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
                  @Override
                  public ListCell<String> call(ListView<String> stringListView) {

                      final ListCell<String> listCell = new ListCell<String>() {

                          protected void updateItem(String item, boolean empty) {
                              super.updateItem(item, empty);
                              if (item != null) {
                                  setText(item);
                              }
                          }

                      };

                      listCell.setOnDragDetected(new EventHandler<MouseEvent>() {
                          @Override
                          public void handle(MouseEvent mouseEvent) {
                              Dragboard db;
                                  try {
                                      db = listCell.startDragAndDrop(TransferMode.MOVE);

                                      String[] contactEntryInfo = new String[2];
                                      contactEntryInfo[0] = "Some data";
                                      contactEntryInfo[1] = "I want to drag";

                                      DataFormat dataFormat = new DataFormat("contactEntry");
                                      Map<DataFormat, Object> map = new HashMap<DataFormat, Object>();
                                      map.put(dataFormat, contactEntryInfo);

                                      db.setContent(map);
                                      mouseEvent.consume();
                                  } catch (Exception e) {
                                      //e.printStackTrace();
                                  }
                          }
                      });

                      listCell.setOnDragEntered(new EventHandler<DragEvent>() {
                          @Override
                          public void handle(DragEvent dragEvent) {
                              if (dragEvent.getDragboard().hasContent(new DataFormat("contactEntry")))
                              {
                                  // add some CSS class, so that the user knows that he can drop.
                              }
                          }
                      });

                      return listCell;
                  }
              });

              listView.setItems(FXCollections.observableArrayList("Test1", "Test2"));
              root.getChildren().add(listView);

              Scene scene = new Scene(root);
              stage.setScene(scene);

              stage.show();
          }
      }

            psafrata Pavel Ĺ afrata
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: