Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    EventDialogCustomizer sample

    I have to create a Timeline with a customized EventDialog :
    • No Description Text Area Item,
    • Name field read-only,
    • endDate not mandatory,
    • extra fields, ...
    Do you have any EventDialogCustomizer sample, please ?

    #2
    There's no sample for this API, as it's purpose is to allow you to show your own replacement dialog - a very simple API.

    However, it's not clear whether you want your own complete replacement event dialog, or whether you could just customize the existing dialog - see this sample, which suppresses default fields and adds additional fields, as you want.

    Comment


      #3

      I have already studied this sample : http://www.smartclient.com/smartgwt/...endar_category
      and it is not useful for the use case I have to develop.
      I have to create a CustomizedBannerSlotDialog class which replaces the default dialog box of the Timeline class.
      But the setEventDialogCustomizer method doen't seem to work : the default dialog box still appears.

      Any suggestion, please?

      Code:
       public class BannersForMosaicViewImpl extends AbstractFormLayout implements BannersForMosaicView {
          ...
         
        /**
      * Initializing planning timeline widget
      */
      protected void createTimeline() {
        
      this.planning = new Timeline();
      this.planning.setID("BannerFormViewImpl_planning");
      this.planning.setHeight(354);
      this.planning.setWidth100();
      Date today = new Date();
      this.planning.setStartDate(today);
      CalendarUtil.addDaysToDate(today, Constant.PLANNING_DURATION_IN_DAYS);
      this.planning.setEndDate(today);
      this.planning.setCanEditLane(false);
      this.planning.setShowEventDescriptions(false);
      this.planning.setShowControlsBar(false);
      this.planning.setCanAcceptDrop(true);
      this.planning.setAutoFetchData(false);
      this.planning.setCanEditEvents(false);
      this.planning.setCanCreateEvents(false);
      this.planning.setEventOverlap(false);
      
      BannersForMosaicViewImpl.this.planning.setEventDialogCustomizer(new EventDialogCustomizer() {
        
      @Override
      public boolean showEventDialog(CalendarEvent event, Boolean isNew) {
         new CustomizedBannerSlotDialog(BannersForMosaicViewImpl.this.planning, event, isNew).show();
         return false;
      }
        
      });
      
      HeaderLevel[] headerLevels = new HeaderLevel[] {
          new HeaderLevel(TimeUnit.WEEK), new HeaderLevel(TimeUnit.DAY)
      };
        
      this.planning.setHeaderLevels(headerLevels);
      this.planning.setLaneFields(new ListGridField[] {
           new ListGridField("title", "Page", 80)
      });
         
        this.planning.setLanes(TimelineLaneData.getRecords());
        }
        }
          public class CustomizedBannerSlotDialog extends Dialog {
        
      public CustomizedBannerSlotDialog(final Timeline planning, final CalendarEvent event, final Boolean isNew) {
        
      if (isNew) {
      this.setTitle("Create a banner slot");
      } else {
      this.setTitle("Update a banner slot");
      }
      this.setIsModal(true);
      this.setCanDragResize(true);
      this.setCanDragReposition(true);
      this.addItem(new VLayout(4) {
      {
      final DynamicForm form = new DynamicForm() {
      {
      
      TextItem externalId = new TextItem("externalId", "External ID");
      externalId.setDisabled(true);
      TextItem name = new TextItem("name", "Name");
      name.setDisabled(true);
      TextAreaItem description = new TextAreaItem("description", "Description");
      description.setDisabled(true);
      TextItem page = new TextItem("lane", "Page");
      page.setDisabled(true);
      DateTimeItem startDate = new DateTimeItem("startDate", "Start Time");
      DateTimeItem endDate = new DateTimeItem("endDate", "End Time");
      this.setFields(externalId, name, page, description, startDate, endDate);
      this.editRecord(event);
      }
      };
      this.addMember(form);
      this.addMember(new HLayout(4) {
      {
      this.setAlign(Alignment.RIGHT);
      this.addMember(new Button("Save") {
      {
      this.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent clickEvent) {
      boolean isOverlapping = false;
      Record record = form.getValuesAsRecord();
      String externalId = record.getAttribute("externalId");
      String name = record.getAttribute("name");
      String description = record.getAttribute("description");
      Date startDate = record.getAttributeAsDate("startDate");
      Date endDate = record.getAttributeAsDate("endDate");
      // TODO check if the slot created or update overlaps an existing slot in the
      // lane
      
      if (!isOverlapping) {
      if (isNew) {
      planning.addEvent(startDate, endDate, name, description);
      } else {
      event.setStartDate(startDate);
      event.setEndDate(endDate);
      event.setName(name);
      event.setDescription(description);
      event.setAttribute("externalId", externalId);
      }
      planning.markForRedraw();
      CustomizedBannerSlotDialog.this.close();
      } else {
      SC.say("Your slot overlaps an existing slot. Please modify your start and /or en date(s)");
      }
      }
      });
      }
      });
      this.addMember(new Button("Cancel") {
      {
      this.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
      CustomizedBannerSlotDialog.this.close();
      }
      });
      }
      });
      }
      });
      }
      });
        
      }
        
      }

      Comment


        #4
        What is your exact version of SmartGWT, and on what browser(s) are you having this issue?

        Comment


          #5
          Also, are you saying that you see both the built-in dialog and your replacement dialog?

          Also, are you aware that Calendar / Timeline has two types of pop-up editing interface - the EventDialog and the EventEditor. It looks like you mean to customize the EventEditor as well - for this you need the EventEditorCustomizer, but you're using EventDialogCustomizer.

          Comment

          Working...
          X