Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Migrating Drag and Drop From GWT-Ext to Smart GWT

    I'm migrating a large GWT-Ext web application to Smart GWT. The initial component migrated to Smart GWT is a tree panel that resides on the left side of the application. Double-clicking a tree node on the tree opens it in a GWT-Ext workspace editor to the right. This is working fine. I also need to be able to support dragging tree nodes to these open editors. Can anyone make a suggestion as to the best way to do this? I'd like to make the Smart GWT tree/tree node a valid GWT-Ext drag source so I don't have to alter the editors at this point, but so far I have not had success. Thanks!

    #2
    When you drag a tree node what do you expect to show up in the workspace editor? In other words is a tree node really a form/grid/mix/etc.. Likely you'll need to capture the drop event on the workspace canvas and do the logic from there, but this isn't necessarily straight forward either a node->canvas. If you have more details on exactly what you want can give you more specific help.

    Comment


      #3
      Hi, the original implementation (GWT-Ext TreeNode to GWT-Ext Panel) allowed the DragData to be decomposed so that the NodeModel that was contained within the TreeNode was extracted and used to construct a thumbnail in a panel. I'll provide a sample of the data extraction below. I'd like to do the same except with the Smart GWT TreeNode if possible, the data is the same (a custom NodeModel can be constructed on the fly when the drag begins with the model (which is a Java object). Once the data is extracted, the visual representation will be handled exactly as before, the only important matter is getting the data across and be able to detect it from the GWT-Ext DropZone.

      Code:
          public boolean notifyDrop(DragSource dragSource, EventObject eventObject, DragData dragData)
          {
              notifyOut(dragSource, eventObject, dragData);
      
              if (isValidDragSource(dragData))
              {
                  if (dragData instanceof TreeDragData)
                  {
                      TreeDragData treeDragData = (TreeDragData) dragData;
      
                      TreeNode treeNode = treeDragData.getTreeNode();
      
                      if (treeNode != null)
                      {
                          NodeModel nodeModel = treeNode.getNodeModel();
      
                          if (nodeModel instanceof ODSNodeModel)
                          {
                              return (nodeModelAdded((ODSNodeModel) nodeModel, true));
                          }
                      }
                  }
              }
      
              return (false);
          }

      Comment


        #4
        You'll have to do something similiar to the following. The drop event on the canvas will be the TreeGrid, not the TreeGrid node your dragging, but dragging requires selecting a node, so you can always get the dragged node as I showed. Similiar to your code, just a few changes needed.
        Code:
        TreeGrid grid = new TreeGrid();
        grid .setCanDragRecordsOut(true);
        grid.setID("MyTree");
        ..
        Canvas c = new Canvas();
        c.setCanAcceptDrop(true);
        c.addDropHandler(new DropHandler() {
          @Override
          public void onDrop(DropEvent event) {
            if (EventHandler.getDragTarget().getID().equals("MyTree")) {
              TreeGrid grid = (TreeGrid)EventHandler.getDragTarget();
              SC.say("Name: " + grid.getSelectedRecord().getAttribute("Name"));
            }
          }
        });

        Comment


          #5
          Thanks for the info. This would only work though if I used a Smart GWT Canvas as the drop zone, which I was trying to avoid as the number of editors and drop zones within them are extensive and they're purely GWT-Ext panels and widgets at this point. It sounds like there's no way to make the Smart GWT TreeGrid a GWT-Ext DragSource then, correct? Thanks!

          Comment


            #6
            Two very different APIs your mixing, I won't say absolutely no way, but unlikely and definitely not supported.

            Comment

            Working...
            X