Package com.allen_sauer.gwt.dnd.client

Examples of com.allen_sauer.gwt.dnd.client.DragHandlerAdapter


 
    /**
     * initialize drag and drop function
     */
  private void initializeDragAndDrop() {
    graphics.initializeDragging(new DragHandlerAdapter() {
      @Override
      public void onDragStart(DragStartEvent event) {
      }
    });

View Full Code Here


    shapeDragController = new ShapePickupDragController(boundaryPanel, true, Diagram.this);
    shapeDragController.setBehaviorDragStartSensitivity(2);
    shapeDragController.setBehaviorConstrainedToBoundaryPanel(true);
    shapeDragController.setBehaviorMultipleSelection(true);

    shapeDragController.addDragHandler(new DragHandlerAdapter() {

      @Override
      public void onDragStart(DragStartEvent event) {
        int startX =
            Diagram.this.boundaryPanel.getWidgetLeft(event.getContext().draggable)
                - Diagram.this.boundaryPanel.getAbsoluteLeft();
        int startY =
            Diagram.this.boundaryPanel.getWidgetTop(event.getContext().draggable)
                - Diagram.this.boundaryPanel.getAbsoluteTop();
        Diagram.this.onElementDrag(new ElementDragEvent(event.getContext().draggable, startX, startY,
            ElementDragEvent.DragEventType.DRAG_START));
      }

      @Override
      public void onDragEnd(DragEndEvent event) {

        Widget widget = event.getContext().draggable;
        if (event.getContext().vetoException != null) {
          if (event.getContext().draggable instanceof Shape) {
            Shape draggable = (Shape) event.getContext().draggable;
            draggable.updateConnectors();
          }
        }
        if (widget instanceof Shape) {
          Shape shape = (Shape) event.getContext().draggable;
          if (!ctrlPressed) {
            fixShapePosition(shape);

            for (ConnectionPoint cp : shape.connectionPoints) {
              for (EndPoint ep : cp.gluedEndPoints) {
                // connector between two dragged shapes
                if (ep.connector.startEndPoint.gluedConnectionPoint != null
                    && ep.connector.endEndPoint.gluedConnectionPoint != null
                    && ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget() != null
                    && ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget() != null
                    && selectedWidgets.contains(ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget())
                    && selectedWidgets.contains(ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget())) {
                  ep.connector.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
                } else {
                  ep.connector.updateCornerPoints();
                }
              }
            }

            fixLineSections(shape);
          } else {
            fixShapePosition(shape);
            for (Connector c : shape.getConnectedConnectors()) {
              if (c.startEndPoint.gluedConnectionPoint != null && c.endEndPoint.gluedConnectionPoint != null
                  && c.startEndPoint.gluedConnectionPoint.getParentWidget() != null
                  && c.endEndPoint.gluedConnectionPoint.getParentWidget() != null
                  && selectedWidgets.contains(c.startEndPoint.gluedConnectionPoint.getParentWidget())
                  && selectedWidgets.contains(c.endEndPoint.gluedConnectionPoint.getParentWidget())) {
                c.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
              } else {
                c.fixEndSectionDirection(c.endEndPoint);
                c.fixEndSectionDirection(c.startEndPoint);
                c.fixLineSections(c.getCorners());
                c.drawSections();
              }
            }
          }
        }

        int endX =
            Diagram.this.boundaryPanel.getWidgetLeft(event.getContext().draggable)
                - Diagram.this.boundaryPanel.getAbsoluteLeft();
        int endY =
            Diagram.this.boundaryPanel.getWidgetTop(event.getContext().draggable)
                - Diagram.this.boundaryPanel.getAbsoluteTop();

        Diagram.this.onElementDrag(new ElementDragEvent(event.getContext().draggable, endX, endY,
            ElementDragEvent.DragEventType.DRAG_END));
      }

    });

    // Create drag controller to control end point dragging
    endPointDragController = new EndPointDragController(this.boundaryPanel, true, Diagram.this);
    endPointDragController.setBehaviorConstrainedToBoundaryPanel(true);
    endPointDragController.setBehaviorDragStartSensitivity(4);
    endPointDragController.addDragHandler(new DragHandlerAdapter() {

      @Override
      public void onDragStart(DragStartEvent event) {
        endPointDragging = true;
        if (event != null) {
View Full Code Here

    super(boundaryPanel, allowDroppingOnBoundaryPanel);
    dragableWidgets = new ArrayList<Widget>();
    this.diagram = diagram;

    addDragHandler(new DragHandlerAdapter() {

      @Override
      public void onPreviewDragStart(DragStartEvent event) {
        if (event.getContext().draggable instanceof Shape) {
          Shape shape = (Shape) event.getContext().draggable;
View Full Code Here

    panel.add(this, Math.min(this.startPoint.getLeft(), this.endPoint.getLeft()), Math.min(this.startPoint.getTop(),
        this.endPoint.getTop()));
    this.sectionDragController.makeDraggable(this);
    this.sectionDragController.setBehaviorDragStartSensitivity(5);

    this.sectionDragController.addDragHandler(new DragHandlerAdapter() {

      @Override
      public void onPreviewDragStart(DragStartEvent event) {
        if (event.getContext().draggable != null) {
          event.getContext().draggable.getElement().scrollIntoView();
View Full Code Here

    @Override
    public ResourceSetAvatar createAvatar(ResourceSet resources) {
        final ResourceSetAvatar avatar = super.createAvatar(resources);

        /**
         * Removes the hover at the end of a drag and drop operation. Because
         * the resource set is already hovered, this saves the effort of
         * highlighting the resources again.
         */
        final DragHandlerAdapter dragHandler = new DragHandlerAdapter() {
            @Override
            public void onDragEnd(DragEndEvent event) {
                removeFromHover();
            }

View Full Code Here

        this.dragController = dragController;
        this.dragController.registerDropController(new DisposeDropController(this));
       
        this.dragController.setBehaviorMultipleSelection(false);
        this.dragController.setConstrainWidgetToBoundaryPanel(false);
        this.dragController.addDragHandler(new DragHandlerAdapter());
    }
View Full Code Here

    protected void createStyles() {
        final FBFormItem item = getItem();
        final Widget actualWidget = item.getWidget();
        MovablePanel movable = new MovablePanel(actualWidget, item);
        dragController.makeDraggable(movable);
        dragController.addDragHandler(new DragHandlerAdapter() {
            @Override
            public void onDragEnd(DragEndEvent event) {
                item.clear();
                item.setWidget(actualWidget);
            }
View Full Code Here

TOP

Related Classes of com.allen_sauer.gwt.dnd.client.DragHandlerAdapter

Copyright © 2018 www.massapicom. 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.