Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
  // 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;
  }
Ejemplo n.º 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();
          }
        }
      }
    }
  }