예제 #1
0
 /**
  * Make the tabs draggable. Just give me a draghandler so I know what to do when its over.
  *
  * @param dragHandler the draghandler.
  * @param dropController the drop controller.
  */
 public void makeTabsDraggable(
     final DragHandler dragHandler, final DropController dropController) {
   draggable = true;
   tabDragController = new PickupDragController(tabBoundaryPanel, false);
   tabDragController.setBehaviorConstrainedToBoundaryPanel(true);
   tabDragController.setBehaviorMultipleSelection(false);
   tabDragController.setBehaviorDragStartSensitivity(DRAG_SENSITIVITY);
   tabDragController.addDragHandler(dragHandler);
   tabDragController.registerDropController(dropController);
 }
예제 #2
0
  public DragHandleExample(DemoDragHandler demoDragHandler) {
    addStyleName(CSS_DEMO_DRAG_HANDLE_EXAMPLE);

    // use the boundary panel as this composite's widget
    final AbsolutePanel boundaryPanel = new AbsolutePanel();
    boundaryPanel.setPixelSize(600, 400);
    setWidget(boundaryPanel);

    // create the title bar
    HTML header =
        new HTML(
            "Title/Header (Drag Handle) with <a href='http://google.com/' target='_blank'>link</a>");
    header.addStyleName(CSS_DEMO_DRAG_HANDLE_EXAMPLE_HEADER);

    // add some text
    HTML content =
        new HTML(
            "This is a <code>VerticalPanel</code> which can be dragged by its header,"
                + " i.e. the title/header widget.");

    // add an editable text area
    final TextArea textArea = new TextArea();
    textArea.addStyleName(CSS_DEMO_DRAG_HANDLE_EXAMPLE_TEXTAREA);
    // textArea.setSize("20em", "5em");
    textArea.setText(
        "You can click in this TextArea to get focus without causing the panel to be dragged.");

    // add a clickable button
    Button button = new Button("Click me");
    button.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            textArea.setText(textArea.getText() + " Click!");
          }
        });

    // create a panel to hold all our widgets
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(2);
    verticalPanel.addStyleName(CSS_DEMO_DRAG_HANDLE_EXAMPLE_PANEL);
    verticalPanel.add(header);
    verticalPanel.add(content);
    verticalPanel.add(textArea);
    verticalPanel.add(button);
    boundaryPanel.add(verticalPanel, 20, 20);

    // instantiate our drag controller
    dragController = new PickupDragController(boundaryPanel, true);
    dragController.addDragHandler(demoDragHandler);
    dragController.setBehaviorConstrainedToBoundaryPanel(true);
    dragController.setBehaviorMultipleSelection(false);
    dragController.setBehaviorDragStartSensitivity(5);

    // instantiate our drop controller
    AbsolutePositionDropController dropController =
        new AbsolutePositionDropController(boundaryPanel);
    dragController.registerDropController(dropController);

    // make the panel draggable by its header
    dragController.makeDraggable(verticalPanel, header);
  }
예제 #3
0
  @Override
  public void attach(CalendarWidget widget) {
    super.attach(widget);

    if (dayViewBody == null) {
      dayViewBody = new DayViewBody(this);
      dayViewHeader = new DayViewHeader(this);
      layoutStrategy = new DayViewLayoutStrategy(this);
      multiViewBody = new DayViewMultiDayBody(this);
    }

    calendarWidget.getRootPanel().add(dayViewHeader);
    calendarWidget.getRootPanel().add(multiViewBody);
    calendarWidget.getRootPanel().add(dayViewBody);

    if (getSettings() != null) scrollToHour(getSettings().getScrollToHour());

    if (dragController == null) {
      dragController = new DayViewPickupDragController(dayViewBody.getGrid().grid, false);
      dragController.setBehaviorDragProxy(true);
      dragController.setBehaviorDragStartSensitivity(1);
      dragController.setBehaviorConstrainedToBoundaryPanel(true); // do I need these?
      dragController.setConstrainWidgetToBoundaryPanel(true); // do I need these?
      dragController.setBehaviorMultipleSelection(false);
      dragController.addDragHandler(
          new DragHandler() {

            public void onDragEnd(DragEndEvent event) {
              Appointment appt =
                  ((AppointmentWidget) event.getContext().draggable).getAppointment();
              calendarWidget.setCommittedAppointment(appt);
              calendarWidget.fireUpdateEvent(appt);
            }

            public void onDragStart(DragStartEvent event) {
              Appointment appt =
                  ((AppointmentWidget) event.getContext().draggable).getAppointment();
              calendarWidget.setRollbackAppointment(appt.clone());
            }

            public void onPreviewDragEnd(DragEndEvent event) throws VetoDragException {}

            public void onPreviewDragStart(DragStartEvent event) throws VetoDragException {}
          });
    }

    if (dropController == null) {
      dropController = new DayViewDropController(dayViewBody.getGrid().grid);
      dragController.registerDropController(dropController);
    }

    if (resizeController == null) {
      resizeController = new DayViewResizeController(dayViewBody.getGrid().grid);
      resizeController.addDragHandler(
          new DragHandler() {

            public void onDragEnd(DragEndEvent event) {
              Appointment appt =
                  ((AppointmentWidget) event.getContext().draggable.getParent()).getAppointment();

              calendarWidget.setCommittedAppointment(appt);
              calendarWidget.fireUpdateEvent(appt);
            }

            public void onDragStart(DragStartEvent event) {
              Appointment appt =
                  ((AppointmentWidget) event.getContext().draggable.getParent()).getAppointment();
              // AppointmentWidget appointment = (AppointmentWidget)event.getContext().draggable;
              calendarWidget.setRollbackAppointment(
                  ((AppointmentWidget) event.getContext().draggable.getParent())
                      .getAppointment()
                      .clone());
            }

            public void onPreviewDragEnd(DragEndEvent event) throws VetoDragException {}

            public void onPreviewDragStart(DragStartEvent event) throws VetoDragException {}
          });
    }
  }