@Override public void closeTab(String key) { final Component tab = keyMapper.get(key); if (tab != null) { closeHandler.onTabClose(TabSheet.this, tab); } } }
/** * Merge Objects into the mapper. * <p> * This method will add the new objects to the mapper and remove inactive * objects from it. * * @param objects * new objects set needs to be merged. * @since 8.7 */ public void merge(Set<V> objects) { final Set<String> keys = new HashSet<>(keyObjectMap.size()); for (V object : objects) { if (object == null) { continue; } String key = key(object); keys.add(key); } keyObjectMap.entrySet() .removeIf(entry -> !keys.contains(entry.getKey())); objectIdKeyMap.entrySet() .removeIf(entry -> !keys.contains(entry.getValue())); }
keyMapper.remove(component); components.remove(component);
@Override public void onWindowContextMenu() { Collection<Action> actions = getContextActions(CubaWindow.this); if (!actions.isEmpty()) { contextActionMapper = new KeyMapper<>(); List<ClientAction> actionsList = new ArrayList<>(actions.size()); for (Action action : actions) { ClientAction clientAction = new ClientAction(action.getCaption()); clientAction.setActionId(contextActionMapper.key(action)); actionsList.add(clientAction); } ClientAction[] clientActions = actionsList.toArray(new ClientAction[actions.size()]); getRpcProxy(CubaWindowClientRpc.class).showTabContextMenu(clientActions); } }
protected void markMenuStructureAsDirty() { markAsDirty(); this.structureChanged = true; for (String menuIconsKey : menuIconResourceKeys) { Resource resource = getResource(menuIconsKey); menuIconsKeyMapper.remove(resource); setResource(menuIconsKey, null); } menuItemIdMapper.removeAll(); menuIconsKeyMapper.removeAll(); // all badges will be sent to client with items badgeUpdates.clear(); }
/** * Creates a {@link DataKeyMapper} to use with this DataCommunicator. * <p> * This method is called from the constructor. * * @param identifierGetter * has to return a unique key for every bean, and the returned * key has to follow general {@code hashCode()} and * {@code equals()} contract, see {@link Object#hashCode()} for * details. * @return key mapper * * @since 8.1 * */ protected DataKeyMapper<T> createKeyMapper( ValueProvider<T, Object> identifierGetter) { return new KeyMapper<T>(identifierGetter); }
/** * Lets the listener know a Containers Item set has changed. * * @see Container.ItemSetChangeListener#containerItemSetChange(Container.ItemSetChangeEvent) */ @Override public void containerItemSetChange(Container.ItemSetChangeEvent event) { // Clears the item id mapping table itemIdMapper.removeAll(); // Notify all listeners fireItemSetChange(); }
@Override public void onTabContextMenu(int tabIndex) { Tab tab = getTab(tabIndex); if (tab != null) { Set<Action> actions = getActions(CubaMainTabSheet.this.getActionTarget(tab)); if (!actions.isEmpty()) { actionMapper = new KeyMapper<>(); List<ClientAction> actionsList = new ArrayList<>(actions.size()); for (Action action : actions) { ClientAction clientAction = new ClientAction(action.getCaption()); clientAction.setActionId(actionMapper.key(action)); actionsList.add(clientAction); } ClientAction[] clientActions = actionsList.toArray(new ClientAction[actions.size()]); getRpcProxy(CubaMainTabSheetClientRpc.class).showTabContextMenu(tabIndex, clientActions); } } }
/** * Adds an action handler. * * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { if (actionHandlers == null) { actionHandlers = new LinkedList<Action.Handler>(); actionMapper = new KeyMapper<Action>(); } if (!actionHandlers.contains(actionHandler)) { actionHandlers.add(actionHandler); markAsDirty(); } } }
/** * Removes all items from the container. * * This functionality is optional. If the function is unsupported, it always * returns false. * * @return True if the operation succeeded. * @see Container#removeAllItems() */ @Override public boolean removeAllItems() throws UnsupportedOperationException { final boolean retval = items.removeAllItems(); itemIdMapper.removeAll(); if (retval) { setValue(null); if (!(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); } } return retval; }
public void handleActions(Map<String, Object> variables, Container sender) { if (variables.containsKey("action") && actionMapper != null) { final String key = (String) variables.get("action"); final Action action = actionMapper.get(key); final Object target = variables.get("actiontarget"); if (action != null) { handleAction(action, sender, target); } } }
keyMapper.key(tabComponent), caption, icon);
@Override public void destroyData(Object itemId) { keyMapper.remove(itemId); removeListener(itemId); }
/** * Registers a new action handler for this container. * * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { if (actionHandlers == null) { actionHandlers = new LinkedList<Handler>(); actionMapper = new KeyMapper<Action>(); } if (!actionHandlers.contains(actionHandler)) { actionHandlers.add(actionHandler); // Assures the visual refresh. No need to reset the page buffer // before as the content has not changed, only the action // handlers. refreshRenderedCells(); } } }
itemIdMapper.removeAll();