Exemple #1
0
  private JsTimeLineEvent[] getTimeLineEvents(LightweightCollection<VisualItem> resourceItems) {

    JsTimeLineEvent[] events = new JsTimeLineEvent[resourceItems.size()];
    int counter = 0;
    for (VisualItem item : resourceItems) {
      TimeLineItem timelineItem = (TimeLineItem) item.getDisplayObject();
      events[counter++] = timelineItem.getTimeLineEvent();
    }
    return events;
  }
  // XXX VisualItems should not be referenced here.
  public static List<String> getSharedPropertiesOfDataType(
      LightweightCollection<VisualItem> visualItems, DataType dataType) {

    List<String> properties = new ArrayList<String>();

    if (visualItems.isEmpty()) {
      return properties;
    }

    // get all valid properties from the first visualItem
    for (String property : getProperties(visualItems.getFirstElement().getResources(), dataType)) {
      properties.add(property);
    }

    // only keep properties that are shared by all of the resource
    for (VisualItem visualItem : visualItems) {
      ResourceSet resources = visualItem.getResources();
      properties.retainAll(getProperties(resources, dataType).toList());
    }

    return properties;
  }
Exemple #3
0
  @Override
  public void update(Delta<VisualItem> delta, LightweightCollection<Slot> updatedSlots) {

    // TODO pull up
    if (!timelineWidget.isAttached()) {
      return;
    }

    LightweightCollection<VisualItem> addedVisualItems = delta.getAddedElements();
    if (!addedVisualItems.isEmpty()) {
      createTimeLineItems(addedVisualItems);
      addEventsToTimeline(addedVisualItems);
      updateStatusStyling(addedVisualItems);
    }

    LightweightCollection<VisualItem> updatedVisualItems = delta.getUpdatedElements();
    if (!updatedVisualItems.isEmpty()) {
      updateStatusStyling(updatedVisualItems);
    }

    LightweightCollection<VisualItem> removedVisualItems = delta.getRemovedElements();
    if (!removedVisualItems.isEmpty()) {
      removeEventsFromTimeline(removedVisualItems);
    }

    // TODO refactor
    if (!updatedSlots.isEmpty()) {
      for (VisualItem visualItem : getVisualItems()) {
        TimeLineItem timelineItem = (TimeLineItem) visualItem.getDisplayObject();
        for (Slot slot : updatedSlots) {
          if (slot.equals(BORDER_COLOR)) {
            timelineItem.updateBorderColor();
          } else if (slot.equals(COLOR)) {
            timelineItem.updateColor();
          }
        }
      }
    }
  }
Exemple #4
0
  private void createTimeLineItems(LightweightCollection<VisualItem> addedVisualItems) {

    for (VisualItem visualItem : addedVisualItems) {
      visualItem.setDisplayObject(new TimeLineItem(visualItem, this));
    }
  }
Exemple #5
0
  private void updateStatusStyling(LightweightCollection<VisualItem> visualItems) {

    for (VisualItem visualItem : visualItems) {
      visualItem.<TimeLineItem>getDisplayObject().setStatusStyling();
    }
  }