@Override public boolean isActive() { return !CollectionUtility.isEmpty(m_remoteUrls); }
public boolean containsNode(ITreeNode nodeToFind) { if (CollectionUtility.isEmpty(m_nodes)) { return false; } for (ITreeNode node : m_nodes) { if (ObjectUtility.equals(node, nodeToFind)) { return true; } } return false; }
public static TreeVisitResult visitNodes(Collection<ITreeNode> nodes, IDepthFirstTreeVisitor<ITreeNode> v, Function<ITreeNode, Collection<? extends ITreeNode>> childrenSupplier) { if (CollectionUtility.isEmpty(nodes)) { return TreeVisitResult.CONTINUE; } for (ITreeNode node : nodes) { if (node == null) { continue; } TreeVisitResult result = visitNode(node, v, childrenSupplier); if (result == TreeVisitResult.TERMINATE || result == TreeVisitResult.SKIP_SIBLINGS) { return result; } } return TreeVisitResult.CONTINUE; }
/** * Removes all occurrences of the given rows. Removed rows are added to the optional row collector. * * @return Returns <code>true</code> if any of the given rows has been deleted. Otherwise <code>false</code>. */ public boolean removeRows(Collection<ITableRow> rowsToRemove, Set<ITableRow> removedRowsCollector) { if (CollectionUtility.isEmpty(rowsToRemove) || m_rows.isEmpty()) { return false; } boolean removed = false; for (Iterator<? extends ITableRow> it = m_rows.iterator(); it.hasNext();) { final ITableRow row = it.next(); if (rowsToRemove.contains(row)) { it.remove(); removed = true; if (removedRowsCollector != null) { removedRowsCollector.add(row); } } } return removed; }
public void complete() { if (CollectionUtility.isEmpty(m_removedNodesCollector)) { // the original delete event must not be modified return; } List<ITreeNode> remainingNodes = new ArrayList<>(); for (ITreeNode node : m_deleteEvent.getNodes()) { if (!m_removedNodesCollector.contains(node)) { remainingNodes.add(node); } } m_deleteEvent.setNodes(remainingNodes); } }
public void complete() { if (CollectionUtility.isEmpty(m_removedRowsCollector)) { // the original delete event must not be modified return; } List<ITableRow> remainingRows = new ArrayList<>(); for (ITableRow row : m_deleteEvent.getRows()) { if (!m_removedRowsCollector.contains(row)) { remainingRows.add(row); } } m_deleteEvent.setRows(remainingRows); } }
/** * If every given node has the same parent, that common parent node will be returned, else null. */ public static ITreeNode calculateCommonParentNode(Collection<? extends ITreeNode> nodes) { if (CollectionUtility.isEmpty(nodes)) { return null; } Iterator<? extends ITreeNode> nodeIt = nodes.iterator(); final ITreeNode commonParent = nodeIt.next().getParentNode(); while (nodeIt.hasNext()) { if (nodeIt.next().getParentNode() != commonParent) { return null; } } return commonParent; }
protected Set<PlannerMenuType> getMenuTypesForSelection(List<? extends Resource<?>> selectedResources, Activity<?, ?> selectedActivity, Range<Date> selectionRange) { if (CollectionUtility.isEmpty(selectedResources)) { return CollectionUtility.hashSet(PlannerMenuType.EmptySpace); } Set<PlannerMenuType> menuTypes = new HashSet<>(); if (CollectionUtility.size(selectedResources) > 0) { menuTypes.add(PlannerMenuType.Resource); } if (selectedActivity != null) { menuTypes.add(PlannerMenuType.Activity); } else if (selectionRange.getFrom() != null || selectionRange.getTo() != null) { menuTypes.add(PlannerMenuType.Range); } return menuTypes; }
@Override public void consumeBinaryResource(List<BinaryResource> binaryResources, Map<String, String> uploadProperties) { if (!CollectionUtility.isEmpty(binaryResources)) { getModel().setValue(CollectionUtility.firstElement(binaryResources)); } }
@Override public void consumeBinaryResource(List<BinaryResource> binaryResources, Map<String, String> uploadProperties) { if (!CollectionUtility.isEmpty(binaryResources)) { getModel().setValue(CollectionUtility.firstElement(binaryResources)); } }
protected boolean calcHasVisibleFieldsInternal() { if (CollectionUtility.isEmpty(getFieldsInternal())) { return false; } for (IFormField field : getFieldsInternal()) { if (field.isVisible()) { return true; } } return false; }
@Override public void setExpandedRowsFromUI(List<? extends ITableRow> rows, boolean expanded) { if (CollectionUtility.isEmpty(rows)) { return; } try { pushUIProcessor(); expandRowsInternal(rows, expanded); } finally { popUIProcessor(); } }
/** * override this method to perform detailed validation in subclasses */ protected Set<T> doValidateValueInternal(Set<T> rawValue) { if (CollectionUtility.isEmpty(rawValue)) { // fast return return rawValue; } ITree tree = getTree(); if (tree != null && ((tree.isCheckable() && !tree.isMultiCheck()) || (!tree.isCheckable() && !tree.isMultiSelect())) && rawValue.size() > 1) { LOG.warn("{} only accepts a single value. Got {}. Using only first value.", getClass().getName(), rawValue); return CollectionUtility.hashSet(CollectionUtility.firstElement(rawValue)); } return rawValue; }
/** * override this method to perform detailed validation in subclasses */ protected Set<KEY> doValidateValueInternal(Set<KEY> rawValue) { if (CollectionUtility.isEmpty(rawValue)) { // fast return empty set return rawValue; } ITable table = getTable(); if (table != null && ((table.isCheckable() && !table.isMultiCheck()) || (!table.isCheckable() && !table.isMultiSelect())) && rawValue.size() > 1) { LOG.warn("{} only accepts a single value. Got {}. Using only first value.", getClass().getName(), rawValue); return CollectionUtility.hashSet(CollectionUtility.firstElement(rawValue)); } return rawValue; }
protected Set<TreeMenuType> getMenuTypesForSelection(Set<? extends ITreeNode> selection) { if (CollectionUtility.isEmpty(selection)) { return CollectionUtility.hashSet(TreeMenuType.EmptySpace); } else if (CollectionUtility.size(selection) == 1) { return CollectionUtility.hashSet(TreeMenuType.SingleSelection); } else { return CollectionUtility.hashSet(TreeMenuType.MultiSelection); } } }
protected Set<TileGridMenuType> getMenuTypesForSelection(List<? extends ITile> selection) { if (CollectionUtility.isEmpty(selection)) { return CollectionUtility.hashSet(TileGridMenuType.EmptySpace); } else if (CollectionUtility.size(selection) == 1) { return CollectionUtility.hashSet(TileGridMenuType.SingleSelection); } else { return CollectionUtility.hashSet(TileGridMenuType.MultiSelection); } } }
protected Set<TableMenuType> getMenuTypesForSelection(List<? extends ITableRow> selection) { if (CollectionUtility.isEmpty(selection)) { return CollectionUtility.hashSet(TableMenuType.EmptySpace); } else if (CollectionUtility.size(selection) == 1) { return CollectionUtility.hashSet(TableMenuType.SingleSelection); } else { return CollectionUtility.hashSet(TableMenuType.MultiSelection); } } }
@Override public void exportFormFieldData(AbstractFormFieldData target) { @SuppressWarnings("unchecked") AbstractValueFieldData<Set<T>> v = (AbstractValueFieldData<Set<T>>) target; Set<T> value = getValue(); if (CollectionUtility.isEmpty(value)) { v.setValue(null); } else { v.setValue(CollectionUtility.hashSet(this.getValue())); } }
@Override public void exportFormFieldData(AbstractFormFieldData target) { @SuppressWarnings("unchecked") AbstractValueFieldData<Set<KEY>> v = (AbstractValueFieldData<Set<KEY>>) target; Set<KEY> value = getValue(); if (CollectionUtility.isEmpty(value)) { v.setValue(null); } else { v.setValue(CollectionUtility.hashSet(this.getValue())); } }
/** * dispatch notifications in a client job and ensure to wait for dispatched notifications * * @param notifications * the notifications to dispatch */ protected void dispatchClientNotifications(final List<ClientNotificationMessage> notifications) { if (CollectionUtility.isEmpty(notifications)) { return; } final IBlockingCondition cond = Jobs.newBlockingCondition(true); Jobs.schedule(() -> { ClientNotificationDispatcher notificationDispatcher = BEANS.get(ClientNotificationDispatcher.class); notificationDispatcher.dispatchNotifications(notifications); }, Jobs.newInput() .withRunContext(ClientRunContexts.copyCurrent())) .whenDone(event -> cond.setBlocking(false), null); cond.waitFor(); } }