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; }
@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(); } } } } }