Examples of DragSource


Examples of org.eclipse.swt.dnd.DragSource

            // setup drag source
            Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
            // This example will allow the text to be copied or moved to the drop target
            int operations = DND.DROP_COPY;

            DragSource source = new DragSource(table, operations);
            source.setTransfer(types);
            source.addDragListener(new DragSourceListener() {
                public void dragStart(DragSourceEvent event) {
                    logger.debug("drag start: " + event);
                    // // Only start the drag if there is actually text in the
                    // // label - this text will be what is dropped on the target.
                    // if (label.getText().length() == 0) {
View Full Code Here

Examples of org.eclipse.swt.dnd.DragSource

        context.getODOMSelectionManager().
                addSelectionListener(dndListener, filter);

        int operations = DND.DROP_COPY | DND.DROP_MOVE;

        DragSource source = new DragSource(formatComposite, operations);
        DropTarget target = new DropTarget(formatComposite, operations);

        source.addDragListener(
            new LayoutDragSourceListener(transfer[0], actionDetails));
        source.setTransfer(transfer);
        target.addDropListener(new LayoutDropTargetListener(
                actionDetails, context.getODOMSelectionManager(),
            ((LayoutODOMEditorContext) context).getLayoutEditorContext()) {

            protected ODOMElement getCurrentTarget(DropTargetEvent event) {
View Full Code Here

Examples of org.eclipse.swt.dnd.DragSource

     */
    private void configureLeftDND() {
        final StringArrayTransfer transfer =
                StringArrayTransfer.getInstance();

        DragSource leftDragSource;

        // Provide data in Text format
        Transfer[] types = new Transfer[]{
            transfer,
        };

        if (duplicatesAllowed) {
            // This controller does not modify the list's contents because
            // duplicates are allowed.
            leftDragSource = new DragSource(leftListController.list,
                    DND.DROP_COPY);
        } else {
            leftDragSource = new DragSource(leftListController.list,
                    DND.DROP_MOVE);

            // Since move is allowed we need a drop target for the left list
            DropTarget leftDropTarget = new DropTarget(leftListController.list,
                    DND.DROP_MOVE);
            leftDropTarget.setTransfer(types);
            leftDropTarget.addDropListener(new DropTargetAdapter() {
                public void dragOver(DropTargetEvent event) {
                    event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
                }

                public void drop(DropTargetEvent event) {
                    if (event.data == null) {
                        event.detail = DND.DROP_NONE;
                    } else {
                        leftListController.add((String[]) event.data);
                        // Update the current selection.
                        currentSelection = selectedItemsList.getItems();
                    }
                }
            });
        }

        leftDragSource.setTransfer(types);

        leftDragSource.addDragListener(new DragSourceListener() {
            public void dragStart(DragSourceEvent event) {
                // Only start the drag if there is something selected
                event.doit = leftListController.list.getSelectionCount() > 0;
            }

View Full Code Here

Examples of org.eclipse.swt.dnd.DragSource

        Transfer[] types = new Transfer[]{
            transfer
        };

        if (!duplicatesAllowed) {
            DragSource rightDragSource =
                    new DragSource(rightListController.list, DND.DROP_MOVE);

            // Provide data in Text format
            rightDragSource.setTransfer(types);

            rightDragSource.addDragListener(new DragSourceListener() {
                public void dragStart(DragSourceEvent event) {
                    // Only start the drag if there is a selection
                    event.doit =
                            rightListController.list.getSelectionCount() > 0;
                }
View Full Code Here

Examples of org.olat.core.gui.control.dragdrop.DragSource

      if (di != null) {
        String dropid = ureq.getParameter("v");
        List accDrags = di.getAccepted();
        for (Iterator it_accdrags = accDrags.iterator(); it_accdrags.hasNext();) {
          Draggable dr = (Draggable) it_accdrags.next();
          DragSource ds = dr.find(dropid);
          if (ds != null) {
            // found!
            fireEvent(ureq, new DropEvent(ds, null));
            return;
          }
View Full Code Here

Examples of org.olat.core.gui.control.dragdrop.DragSource

   * @param dragElementId
   * @return
   */
  protected DragSource draggableFind(String dragElementId) {
    Component toRender = getContent();
    DragSource ds = null;
    if (toRender != null) {
      String id = "o_c"+toRender.getDispatchID();
      if (dragElementId.equals(id)) {
        ds = new DragSource() {
 
          public Object getSource() {
            return Panel.this;
          }
 
View Full Code Here

Examples of pivot.wtk.DragSource

    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
        bind();

        // Text
        label.setDragSource(new DragSource() {
            private LocalManifest content = null;

            public boolean beginDrag(Component component, int x, int y) {
                String text = label.getText();
                if (text != null) {
                    content = new LocalManifest();
                    content.putText(label.getText());
                }

                return (content != null);
            }

            public void endDrag(Component component, DropAction dropAction) {
                content = null;
            }

            public boolean isNative() {
                return true;
            }

            public LocalManifest getContent() {
                return content;
            }

            public Visual getRepresentation() {
                return null;
            }

            public Point getOffset() {
                return null;
            }

            public int getSupportedDropActions() {
                return DropAction.COPY.getMask();
            }
        });

        label.setDropTarget(new DropTarget() {
            public DropAction dragEnter(Component component, Manifest dragContent,
                int supportedDropActions, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsText()
                    && DropAction.COPY.isSelected(supportedDropActions)) {
                    dropAction = DropAction.COPY;
                }

                return dropAction;
            }

            public void dragExit(Component component) {
            }

            public DropAction dragMove(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsText() ? DropAction.COPY : null);
            }

            public DropAction userDropActionChange(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsText() ? DropAction.COPY : null);
            }

            public DropAction drop(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsText()) {
                    try {
                        label.setText(dragContent.getText());
                        dropAction = DropAction.COPY;
                    } catch(IOException exception) {
                        System.err.println(exception);
                    }
                }

                dragExit(component);

                return dropAction;
            }
        });

        copyTextButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                String text = label.getText();
                LocalManifest clipboardContent = new LocalManifest();
                clipboardContent.putText(text);
                Clipboard.setContent(clipboardContent);
            }
        });

        pasteTextButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Manifest clipboardContent = Clipboard.getContent();

                if (clipboardContent != null
                    && clipboardContent.containsText()) {
                    try {
                        label.setText(clipboardContent.getText());
                    } catch(IOException exception) {
                        System.err.println(exception);
                    }
                }
            }
        });

        // Images
        imageView.setDragSource(new DragSource() {
            private LocalManifest content = null;

            public boolean beginDrag(Component component, int x, int y) {
                Image image = imageView.getImage();

                if (image != null) {
                    content = new LocalManifest();
                    content.putImage(image);
                }

                return (content != null);
            }

            public void endDrag(Component component, DropAction dropAction) {
                content = null;
            }

            public boolean isNative() {
                return true;
            }

            public LocalManifest getContent() {
                return content;
            }

            public Visual getRepresentation() {
                return null;
            }

            public Point getOffset() {
                return null;
            }

            public int getSupportedDropActions() {
                return DropAction.COPY.getMask();
            }
        });

        imageView.setDropTarget(new DropTarget() {
            public DropAction dragEnter(Component component, Manifest dragContent,
                int supportedDropActions, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsImage()
                    && DropAction.COPY.isSelected(supportedDropActions)) {
                    dropAction = DropAction.COPY;
                }

                return dropAction;
            }

            public void dragExit(Component component) {
            }

            public DropAction dragMove(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsImage() ? DropAction.COPY : null);
            }

            public DropAction userDropActionChange(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsImage() ? DropAction.COPY : null);
            }

            public DropAction drop(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsImage()) {
                    try {
                        imageView.setImage(dragContent.getImage());
                        dropAction = DropAction.COPY;
                    } catch(IOException exception) {
                        System.err.println(exception);
                    }
                }

                dragExit(component);

                return dropAction;
            }
        });

        copyImageButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Image image = imageView.getImage();
                if (image != null) {
                    LocalManifest clipboardContent = new LocalManifest();
                    clipboardContent.putImage(image);
                    Clipboard.setContent(clipboardContent);
                }
            }
        });

        pasteImageButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Manifest clipboardContent = Clipboard.getContent();

                if (clipboardContent != null
                    && clipboardContent.containsImage()) {
                    try {
                        imageView.setImage(clipboardContent.getImage());
                    } catch(IOException exception) {
                        System.err.println(exception);
                    }
                }
            }
        });

        // Files
        listView.setListData(new FileList());

        listView.setDragSource(new DragSource() {
            private LocalManifest content = null;

            public boolean beginDrag(Component component, int x, int y) {
                ListView listView = (ListView)component;
                FileList fileList = (FileList)listView.getListData();
View Full Code Here

Examples of wicketdnd.DragSource

        Item<Foo> item = super.newRowItem(id, index, model);
        item.setOutputMarkupId(true);
        return item;
      }
    };
    table.add(new DragSource()
    {
      @Override
      public Set<Operation> getOperations()
      {
        return dragOperations();
View Full Code Here

Examples of wicketdnd.DragSource

        Component component = super.newContentComponent(arg0, arg1);
        component.setOutputMarkupId(true);
        return component;
      }
    };
    tree.add(new DragSource()
    {
      @Override
      public Set<Operation> getOperations()
      {
        return dragOperations();
View Full Code Here

Examples of wicketdnd.DragSource

  {
    super(id);

    final WebMarkupContainer container = new WebMarkupContainer("container");
    add(container);
    container.add(new DragSource()
    {
      @Override
      public Set<Operation> getOperations()
      {
        return dragOperations();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.