@Override public Object getItem(K itemId) { return CollectionPropertyDatasourceImpl.this.getItem(itemId); }
@Override public T getItemNN(K id) { backgroundWorker.checkUIAccess(); T it = getItem(id); if (it != null) { return it; } else { throw new IllegalStateException("Item with id=" + id + " is not found in datasource " + this.id); } }
@Override public int indexOfId(K itemId) { if (itemId == null) return -1; Collection<T> collection = getCollection(); if (CollectionUtils.isNotEmpty(collection)) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.indexOf(currentItem); } return -1; }
@Override public K prevItemId(K itemId) { if (itemId == null) return null; Collection<T> collection = getCollection(); if ((collection != null) && !collection.isEmpty() && !itemId.equals(firstItemId())) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.get(list.indexOf(currentItem) - 1).getId(); } return null; }
@Override public K nextItemId(K itemId) { if (itemId == null) return null; Collection<T> collection = getCollection(); if ((collection != null) && !collection.isEmpty() && !itemId.equals(lastItemId())) { List<T> list = new ArrayList<>(collection); T currentItem = getItem(itemId); return list.get(list.indexOf(currentItem) + 1).getId(); } return null; }
@Override public void actionPerform(Component component) { Set<CategoryAttribute> selected = categoryAttrsTable.getSelected(); if (!selected.isEmpty()) { AttributeEditor editor = (AttributeEditor) openEditor( "sys$CategoryAttribute.edit", selected.iterator().next(), OpenType.DIALOG, categoryAttrsTable.getDatasource()); editor.addCloseListener(actionId -> { categoryAttrsTable.getDatasource().refresh(); categoryAttrsTable.focus(); // restore selection from ds categoryAttrsTable.setSelected(categoryAttrsDs.getItem()); }); } } }
@Override public void actionPerform(Component component) { final CategoryAttribute attribute = metadata.create(CategoryAttribute.class); attribute.setCategory((Category) categoryDs.getItem()); assignNextOrderNo(attribute); AttributeEditor editor = (AttributeEditor) openEditor( "sys$CategoryAttribute.edit", attribute, OpenType.DIALOG, categoryAttrsTable.getDatasource()); editor.addCloseListener(actionId -> { categoryAttrsTable.getDatasource().refresh(); categoryAttrsTable.focus(); // restore selection from ds categoryAttrsTable.setSelected(categoryAttrsDs.getItem()); }); } }