Exemplo n.º 1
0
 public void setTimelineDefinition(
     final TimelineDefinition timelineDefinition, final boolean fireEvents) {
   if (timelineDefinition.equals(_timelineDefinition) && _timelineData != null) {
     return;
   }
   _timelineDefinition = timelineDefinition;
   if (fireEvents) {
     if (timelineDefinition.isChanged()) {
       setTimelineDefinitionChanged();
     }
     setLoading();
     _service.getTimelineData(
         _tenant,
         timelineDefinition,
         new DCAsyncCallback<TimelineData>() {
           @Override
           public void onSuccess(TimelineData data) {
             setTimelineData(data);
           }
         });
   }
 }
Exemplo n.º 2
0
  public TimelinePanel(
      TenantIdentifier tenant,
      DashboardServiceAsync service,
      TimelineIdentifier timelineIdentifier,
      DashboardGroupPanel timelineGroupPanel,
      boolean isDashboardEditor) {
    super();
    _tenant = tenant;
    _service = service;
    _timelineIdentifier = timelineIdentifier;
    _timelineGroupPanel = timelineGroupPanel;
    _isDashboardEditor = isDashboardEditor;
    _header = new HeadingLabel("");

    _loadingIndicator = new LoadingIndicator();
    _loadingIndicator.setHeight((DefaultVAxisOption.DEFAULT_HEIGHT + 4) + "px");

    _saveButton = new Button("");
    _saveButton.setVisible(isDashboardEditor);
    _saveButton.addStyleDependentName("ImageButton");
    _saveButton.setTitle("Save timeline");
    _saveButton.addStyleName("SaveButton");
    _saveButton.addClickHandler(new SaveTimelineClickHandler(_service, _tenant, this));

    if (_timelineIdentifier != null) {
      // initially does not make sense to save an (unchanged) and
      // identifyable timeline.
      setTimelineDefinitionUnchanged();
    }

    _deleteButton = new Button();
    _deleteButton.setVisible(isDashboardEditor);
    _deleteButton.addStyleDependentName("ImageButton");
    _deleteButton.setTitle("Delete timeline");
    _deleteButton.addStyleName("DeleteButton");
    _deleteButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            final boolean confirmation =
                Window.confirm("Are you sure you wish to delete this timeline?");
            if (confirmation) {
              if (_timelineIdentifier != null) {
                _service.removeTimeline(
                    _tenant,
                    _timelineIdentifier,
                    new DCAsyncCallback<Boolean>() {
                      @Override
                      public void onSuccess(Boolean result) {
                        // do nothing
                      }
                    });
              }
              _timelineGroupPanel.removeTimelinePanel(TimelinePanel.this);
            }
          }
        });

    addStyleName("TimelinePanel");
    add(createButtonPanel());
    updateHeader();
    setLoading();

    if (_timelineIdentifier != null) {
      _service.getTimelineDefinition(
          _tenant,
          _timelineIdentifier,
          new DCAsyncCallback<TimelineDefinition>() {
            @Override
            public void onSuccess(final TimelineDefinition definition) {
              setTimelineDefinition(definition);
            }
          });
    }
  }