@PostConstruct
  public void init() {
    CommonGlobals.getInstance().registerI18n((I18NConstants) GWT.create(I18NConstants.class));
    PickupDragController dragController =
        new PickupDragController(dndController.getBoundaryPanel(), true);
    dragController.registerDropController(new DisposeDropController(view.getPanel()));
    CommonGlobals.getInstance().registerDragController(dragController);
    try {
      formServices
          .call(
              new RemoteCallback<Map<String, String>>() {
                @Override
                public void callback(Map<String, String> properties) {
                  for (String key : properties.keySet()) {
                    RepresentationFactory.registerItemClassName(key, properties.get(key));
                  }
                }
              })
          .getFormBuilderProperties();

      formServices
          .call(
              new RemoteCallback<Void>() {
                @Override
                public void callback(Void nothing) {}
              })
          .listMenuItems();

    } catch (MenuServiceException ex) {
      Logger.getLogger(FormBuilderPalettePresenter.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
예제 #2
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);
 }
예제 #3
0
  WindowController(AbsolutePanel boundaryPanel) {
    this.boundaryPanel = boundaryPanel;

    pickupDragController = new PickupDragController(boundaryPanel, true);
    pickupDragController.setBehaviorConstrainedToBoundaryPanel(true);
    pickupDragController.setBehaviorMultipleSelection(false);

    resizeDragController = new ResizeDragController(boundaryPanel);
    resizeDragController.setBehaviorConstrainedToBoundaryPanel(true);
    resizeDragController.setBehaviorMultipleSelection(false);
  }
예제 #4
0
 @Override
 protected void gwtSetUp() throws Exception {
   stepDelayMillis = 0;
   RootPanel rootPanel = RootPanel.get();
   rootPanel.getElement().getStyle().setHeight(800, Unit.PX);
   PickupDragController dragController = new PickupDragController(rootPanel, true);
   for (int i = 0; i < 8; i++) {
     FocusPanel panel = newRedFocusPanel(i);
     rootPanel.add(panel, i * 125, 0);
     dragController.makeDraggable(panel);
   }
 }
예제 #5
0
  private void clearView() {
    PickupDragController pdc = m_Container.getDragController();
    if (m_DropZones.size() > 0) {
      for (DropZoneController dropController : m_DropZones) {
        pdc.unregisterDropController(dropController);
      }
      m_DropZones.clear();
    }

    for (Widget widget : getChildren()) {
      if (widget instanceof Item) {
        ((Item) widget).hidding();
      }
    }
    pdc.clearSelection();
    clear();
  }
예제 #6
0
  /** Main entry point method. */
  public void onModuleLoad() {
    // ensure the document BODY has dimensions in standards mode
    RootPanel.get().setPixelSize(600, 600);

    // workaround for GWT issue 1813
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=1813
    RootPanel.get().getElement().getStyle().setProperty("position", "relative");

    // create a DragController to manage drag-n-drop actions
    // note: This creates an implicit DropController for the boundary panel
    PickupDragController dragController = new PickupDragController(RootPanel.get(), true);

    // add a new image to the boundary panel and make it draggable
    Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
    RootPanel.get().add(img, 40, 30);
    dragController.makeDraggable(img);
  }
예제 #7
0
  @Override
  public void draw() {
    // Create the elements
    Widget labelHello = new BoxLabel("Hello");
    controller.addWidget(labelHello, 25, 115);

    Widget labelWorld = new BoxLabel("World");
    controller.addWidget(labelWorld, 200, 115);

    // Add DnD logic
    PickupDragController dragController = new PickupDragController(controller.getView(), true);
    dragController.makeDraggable(labelHello);
    dragController.makeDraggable(labelWorld);
    controller.registerDragController(dragController);

    // Add the logic
    controller.drawStraightArrowConnection(labelHello, labelWorld);
  }
예제 #8
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);
  }
예제 #9
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);
  }
 @Override
 public void startDropController(PickupDragController controller, IsWidget layout) {
   controller.registerDropController(new DropFormItemController(layout.asWidget(), this));
 }
예제 #11
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 {}
          });
    }
  }