@Override protected Container createOrderedWrapper(Container newDataSource) { ContainerOrderedWrapper wrapper = new ContainerOrderedWrapper(newDataSource); wrapper.setResetOnItemSetChange(true); return wrapper; }
/** * @deprecated As of 7.0, replaced by * {@link #addItemSetChangeListener(Container.ItemSetChangeListener)} */ @Override @Deprecated public void addListener(Container.ItemSetChangeListener listener) { addItemSetChangeListener(listener); }
/** * @deprecated As of 7.0, replaced by * {@link #addPropertySetChangeListener(Container.PropertySetChangeListener)} */ @Override @Deprecated public void addListener(Container.PropertySetChangeListener listener) { addPropertySetChangeListener(listener); }
@Override public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // If the previous item is not in the container, fail if (previousItemId != null && !containsId(previousItemId)) { return null; } // Adds the item to container final Item item = container.addItem(newItemId); // Puts the new item to its correct place if (!ordered && item != null) { addToOrderWrapper(newItemId, previousItemId); } return item; }
/** * Constructs a Switcher by a given {@link Container} and colorVariant ("green" or "black", "green" is default). * @param container * @param colorVariation */ public Switcher(Container container, String colorVariation) { this.colorVariation = colorVariation; // instantiate the combobox with the container if (!(container instanceof Container.Ordered)) { container = new ContainerOrderedWrapper(container); } combobox = new ComboBox("", container); combobox.setTextInputAllowed(false); }
for (final Object id : l) { if (!container.containsId(id)) { removeFromOrderWrapper(id); addToOrderWrapper(id);
/** * Registers a new Item by its ID to the underlying container and to the * ordering. * * @param itemId * the ID of the Item to be created. * @return the added Item or <code>null</code> if the operation failed * @throws UnsupportedOperationException * if the addItem is not supported. */ @Override public Item addItem(Object itemId) throws UnsupportedOperationException { final Item item = container.addItem(itemId); if (!ordered && item != null) { addToOrderWrapper(itemId); } return item; }
/** * @deprecated As of 7.0, replaced by * {@link #removePropertySetChangeListener(Container.PropertySetChangeListener)} */ @Override @Deprecated public void removeListener(Container.PropertySetChangeListener listener) { removePropertySetChangeListener(listener); }
/** * @deprecated As of 7.0, replaced by * {@link #removeItemSetChangeListener(Container.ItemSetChangeListener)} */ @Override @Deprecated public void removeListener(Container.ItemSetChangeListener listener) { removeItemSetChangeListener(listener); }
/** * Removes an Item specified by the itemId from the underlying container and * from the ordering. * * @param itemId * the ID of the Item to be removed. * @return <code>true</code> if the operation succeeded, <code>false</code> * if not * @throws UnsupportedOperationException * if the removeItem is not supported. */ @Override public boolean removeItem(Object itemId) throws UnsupportedOperationException { final boolean success = container.removeItem(itemId); if (!ordered && success) { removeFromOrderWrapper(itemId); } return success; }
} else { super.setContainerDataSource( new ContainerOrderedWrapper(newDataSource));
@Override public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { // If the previous item is not in the container, fail if (previousItemId != null && !containsId(previousItemId)) { return null; } // Adds the item to container final Object id = container.addItem(); // Puts the new item to its correct place if (!ordered && id != null) { addToOrderWrapper(id, previousItemId); } return id; }
/** * Creates a new Item into the Container, assigns it an automatic ID, and * adds it to the ordering. * * @return the autogenerated ID of the new Item or <code>null</code> if the * operation failed * @throws UnsupportedOperationException * if the addItem is not supported. */ @Override public Object addItem() throws UnsupportedOperationException { final Object id = container.addItem(); if (!ordered && id != null) { addToOrderWrapper(id); } return id; }
@Override protected Container createOrderedWrapper(Container newDataSource) { ContainerOrderedWrapper wrapper = new ContainerOrderedWrapper(newDataSource); wrapper.setResetOnItemSetChange(true); return wrapper; }
/** * Registers the specified Item after the specified itemId in the wrapper's * internal ordering. The underlying container is not modified. Given item * id must be in the container, or must be null. * * @param id * the ID of the Item to be added to the ordering. * @param previousItemId * the Id of the previous item. */ private void addToOrderWrapper(Object id, Object previousItemId) { if (last == previousItemId || last == null) { addToOrderWrapper(id); } else { if (previousItemId == null) { next.put(id, first); prev.put(first, id); first = id; } else { prev.put(id, previousItemId); next.put(id, next.get(previousItemId)); prev.put(next.get(previousItemId), id); next.put(previousItemId, id); } } }