Example #1
0
  public PaletteExample(DemoDragHandler demoDragHandler) {
    addStyleName(CSS_DEMO_PALETTE_EXAMPLE);

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

    dragController = new PickupDragController(boundaryPanel, true);
    dragController.setBehaviorMultipleSelection(false);
    dragController.setBehaviorDragProxy(false);
    dragController.setBehaviorConstrainedToBoundaryPanel(true);
    dragController.addDragHandler(demoDragHandler);

    PalettePanel palette = new PalettePanel(dragController);
    palette.add(new PaletteWidget(new Label("New Label")));
    palette.add(new PaletteWidget(new RadioButton("name", "New Radio Button")));
    palette.add(new PaletteWidget(new CheckBox("New Check Box")));
    boundaryPanel.add(palette, 10, 10);
  }
Example #2
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 {}
          });
    }
  }