for (LocatorStrategy strategy : locatorStrategies) { | for (LocatorStrategy strategy : locatorStrategies) { | ||||
if (strategy.validatePath(path)) { | if (strategy.validatePath(path)) { | ||||
List<Element> elements = strategy.getElementsByPath(path); | List<Element> elements = strategy.getElementsByPath(path); | ||||
if (elements.size() > 0) { | |||||
if (!elements.isEmpty()) { | |||||
for (Element e : elements) { | for (Element e : elements) { | ||||
jsElements.push(e); | jsElements.push(e); | ||||
} | } | ||||
if (strategy.validatePath(path)) { | if (strategy.validatePath(path)) { | ||||
List<Element> elements = strategy | List<Element> elements = strategy | ||||
.getElementsByPathStartingAt(path, root); | .getElementsByPathStartingAt(path, root); | ||||
if (elements.size() > 0) { | |||||
if (!elements.isEmpty()) { | |||||
for (Element e : elements) { | for (Element e : elements) { | ||||
jsElements.push(e); | jsElements.push(e); | ||||
} | } |
path.add(pathFragment); | path.add(pathFragment); | ||||
} | } | ||||
if (path.size() == 0) { | |||||
if (path.isEmpty()) { | |||||
// If we didn't find a single element, return null.. | // If we didn't find a single element, return null.. | ||||
return null; | return null; | ||||
} | } | ||||
public List<Element> getElementsByPath(String path) { | public List<Element> getElementsByPath(String path) { | ||||
List<SelectorPredicate> postFilters = SelectorPredicate | List<SelectorPredicate> postFilters = SelectorPredicate | ||||
.extractPostFilterPredicates(path); | .extractPostFilterPredicates(path); | ||||
if (postFilters.size() > 0) { | |||||
if (!postFilters.isEmpty()) { | |||||
path = path.substring(1, path.lastIndexOf(')')); | path = path.substring(1, path.lastIndexOf(')')); | ||||
} | } | ||||
Element root) { | Element root) { | ||||
List<SelectorPredicate> postFilters = SelectorPredicate | List<SelectorPredicate> postFilters = SelectorPredicate | ||||
.extractPostFilterPredicates(path); | .extractPostFilterPredicates(path); | ||||
if (postFilters.size() > 0) { | |||||
if (!postFilters.isEmpty()) { | |||||
path = path.substring(1, path.lastIndexOf(')')); | path = path.substring(1, path.lastIndexOf(')')); | ||||
} | } | ||||
List<Integer> widgetTags = new ArrayList<>(); | List<Integer> widgetTags = new ArrayList<>(); | ||||
widgetTags.addAll(getTags(widgetName)); | widgetTags.addAll(getTags(widgetName)); | ||||
if (widgetTags.size() == 0) { | |||||
if (widgetTags.isEmpty()) { | |||||
widgetTags.addAll(getTags("com.vaadin.ui." + widgetName)); | widgetTags.addAll(getTags("com.vaadin.ui." + widgetName)); | ||||
} | } | ||||
final String simpleName = getSimpleClassName(name); | final String simpleName = getSimpleClassName(name); | ||||
final String fullName = getFullClassName(name); | final String fullName = getFullClassName(name); | ||||
if (widgetTags.size() > 0) { | |||||
if (!widgetTags.isEmpty()) { | |||||
Integer[] foundTags = client.getConfiguration() | Integer[] foundTags = client.getConfiguration() | ||||
.getTagsForServerSideClassName(fullName); | .getTagsForServerSideClassName(fullName); | ||||
for (int tag : foundTags) { | for (int tag : foundTags) { |
draggedItems = getDraggedRows(nativeEvent); | draggedItems = getDraggedRows(nativeEvent); | ||||
// Ignore event if there are no items dragged | // Ignore event if there are no items dragged | ||||
if (draggedItems.size() == 0) { | |||||
if (draggedItems.isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
final Element selectionColumnCell = getGrid().getSelectionColumn() | final Element selectionColumnCell = getGrid().getSelectionColumn() | ||||
.isPresent() | .isPresent() | ||||
// -1 is used when even selection column is not frozen | // -1 is used when even selection column is not frozen | ||||
&& frozenColumnCount != -1 ? draggedRowElement | |||||
.removeChild(draggedRowElement.getFirstChild()) | |||||
.cast() : null; | |||||
&& frozenColumnCount != -1 | |||||
? draggedRowElement | |||||
.removeChild( | |||||
draggedRowElement.getFirstChild()) | |||||
.cast() | |||||
: null; | |||||
final List<String> frozenCellsTransforms = new ArrayList<>(); | final List<String> frozenCellsTransforms = new ArrayList<>(); | ||||
for (int i = 0; i < getGrid().getColumnCount(); i++) { | for (int i = 0; i < getGrid().getColumnCount(); i++) { | ||||
return; | return; | ||||
} | } | ||||
// Ignore event if there are no items dragged | // Ignore event if there are no items dragged | ||||
if (draggedItems != null && draggedItems.size() > 0) { | |||||
if (draggedItems != null && !draggedItems.isEmpty()) { | |||||
super.onDragEnd(event); | super.onDragEnd(event); | ||||
} | } | ||||
* @return Stream of dragged table row elements. | * @return Stream of dragged table row elements. | ||||
*/ | */ | ||||
private Stream<TableRowElement> getDraggedRowElementStream() { | private Stream<TableRowElement> getDraggedRowElementStream() { | ||||
return draggedItems.stream() | |||||
.map(row -> ((AbstractRemoteDataSource<JsonObject>) gridConnector | |||||
return draggedItems.stream().map( | |||||
row -> ((AbstractRemoteDataSource<JsonObject>) gridConnector | |||||
.getDataSource()).indexOf(row)) | .getDataSource()).indexOf(row)) | ||||
.map(getGridBody()::getRowElement); | .map(getGridBody()::getRowElement); | ||||
} | } |
Set<ComponentConnector> zeroWidthComponents = new HashSet<>(); | Set<ComponentConnector> zeroWidthComponents = new HashSet<>(); | ||||
findZeroSizeComponents(zeroHeightComponents, zeroWidthComponents, | findZeroSizeComponents(zeroHeightComponents, zeroWidthComponents, | ||||
ac.getUIConnector()); | ac.getUIConnector()); | ||||
if (zeroHeightComponents.size() > 0 || zeroWidthComponents.size() > 0) { | |||||
if (!zeroHeightComponents.isEmpty() || !zeroWidthComponents.isEmpty()) { | |||||
add(new HTML("<h4> Client side notifications</h4>" | add(new HTML("<h4> Client side notifications</h4>" | ||||
+ " <em>The following relative sized components were " | + " <em>The following relative sized components were " | ||||
+ "rendered to a zero size container on the client side." | + "rendered to a zero size container on the client side." | ||||
+ " Note that these are not necessarily invalid " | + " Note that these are not necessarily invalid " | ||||
+ "states, but reported here as they might be.</em>")); | + "states, but reported here as they might be.</em>")); | ||||
if (zeroHeightComponents.size() > 0) { | |||||
if (!zeroHeightComponents.isEmpty()) { | |||||
add(new HTML("<p><strong>Vertically zero size:</strong></p>")); | add(new HTML("<p><strong>Vertically zero size:</strong></p>")); | ||||
printClientSideDetectedIssues(zeroHeightComponents, ac); | printClientSideDetectedIssues(zeroHeightComponents, ac); | ||||
} | } | ||||
if (zeroWidthComponents.size() > 0) { | |||||
if (!zeroWidthComponents.isEmpty()) { | |||||
add(new HTML( | add(new HTML( | ||||
"<p><strong>Horizontally zero size:</strong></p>")); | "<p><strong>Horizontally zero size:</strong></p>")); | ||||
printClientSideDetectedIssues(zeroWidthComponents, ac); | printClientSideDetectedIssues(zeroWidthComponents, ac); |
clear(); | clear(); | ||||
List<ApplicationConnection> apps = ApplicationConfiguration | List<ApplicationConnection> apps = ApplicationConfiguration | ||||
.getRunningApplications(); | .getRunningApplications(); | ||||
if (apps.size() == 0) { | |||||
if (apps.isEmpty()) { | |||||
// try again in a while | // try again in a while | ||||
refresher.schedule(1000); | refresher.schedule(1000); | ||||
} else { | } else { |
String tmpPath = path; | String tmpPath = path; | ||||
List<SelectorPredicate> postFilters = SelectorPredicate | List<SelectorPredicate> postFilters = SelectorPredicate | ||||
.extractPostFilterPredicates(path); | .extractPostFilterPredicates(path); | ||||
if (postFilters.size() > 0) { | |||||
if (!postFilters.isEmpty()) { | |||||
tmpPath = tmpPath.substring(1, tmpPath.lastIndexOf(')')); | tmpPath = tmpPath.substring(1, tmpPath.lastIndexOf(')')); | ||||
if (tmpPath.contains("#")) { | if (tmpPath.contains("#")) { | ||||
// FIXME: SubParts should be handled. | // FIXME: SubParts should be handled. |
*/ | */ | ||||
private void uploadNextFile() { | private void uploadNextFile() { | ||||
Scheduler.get().scheduleDeferred(() -> { | Scheduler.get().scheduleDeferred(() -> { | ||||
if (!uploading && uploadUrls.size() > 0) { | |||||
if (!uploading && !uploadUrls.isEmpty()) { | |||||
uploading = true; | uploading = true; | ||||
String nextId = uploadUrls.keySet().stream().findAny().get(); | String nextId = uploadUrls.keySet().stream().findAny().get(); | ||||
} | } | ||||
// Request a list of upload URLs for the dropped files | // Request a list of upload URLs for the dropped files | ||||
if (fileParams.size() > 0) { | |||||
if (!fileParams.isEmpty()) { | |||||
getRpcProxy(FileDropTargetRpc.class).drop(fileParams); | getRpcProxy(FileDropTargetRpc.class).drop(fileParams); | ||||
} | } | ||||
protected FileUploadXHR() { | protected FileUploadXHR() { | ||||
} | } | ||||
public final native void postFile(File file) /*-{ | |||||
public final native void postFile(File file) | |||||
/*-{ | |||||
this.setRequestHeader('Content-Type', 'multipart/form-data'); | this.setRequestHeader('Content-Type', 'multipart/form-data'); | ||||
this.send(file); | this.send(file); | ||||
}-*/; | }-*/; |
selectors.append('.').append(primaryStyle); | selectors.append('.').append(primaryStyle); | ||||
if (target.getState().styles != null | if (target.getState().styles != null | ||||
&& target.getState().styles.size() > 0) { | |||||
&& !target.getState().styles.isEmpty()) { | |||||
for (String style : target.getState().styles) { | for (String style : target.getState().styles) { | ||||
selectors.append(",.").append(style); | selectors.append(",.").append(style); | ||||
selectors.append(",.").append(primaryStyle).append('.') | selectors.append(",.").append(primaryStyle).append('.') |
* Gets the preferred height of the menu including pageItemsCount items. | * Gets the preferred height of the menu including pageItemsCount items. | ||||
*/ | */ | ||||
String getPreferredHeight(int pageItemsCount) { | String getPreferredHeight(int pageItemsCount) { | ||||
if (currentSuggestions.size() > 0) { | |||||
if (!currentSuggestions.isEmpty()) { | |||||
final int pixels = getPreferredHeight() | final int pixels = getPreferredHeight() | ||||
/ currentSuggestions.size() * pageItemsCount; | / currentSuggestions.size() * pageItemsCount; | ||||
return pixels + "px"; | return pixels + "px"; | ||||
*/ | */ | ||||
int getItemOffsetHeight() { | int getItemOffsetHeight() { | ||||
List<MenuItem> items = getItems(); | List<MenuItem> items = getItems(); | ||||
return items != null && items.size() > 0 | |||||
return items != null && !items.isEmpty() | |||||
? items.get(0).getOffsetHeight() | ? items.get(0).getOffsetHeight() | ||||
: 0; | : 0; | ||||
} | } | ||||
*/ | */ | ||||
int getItemOffsetWidth() { | int getItemOffsetWidth() { | ||||
List<MenuItem> items = getItems(); | List<MenuItem> items = getItems(); | ||||
return items != null && items.size() > 0 | |||||
return items != null && !items.isEmpty() | |||||
? items.get(0).getOffsetWidth() | ? items.get(0).getOffsetWidth() | ||||
: 0; | : 0; | ||||
} | } |
@Override | @Override | ||||
public void execute() { | public void execute() { | ||||
if (!uploading) { | if (!uploading) { | ||||
if (fileIds.size() > 0) { | |||||
if (!fileIds.isEmpty()) { | |||||
uploading = true; | uploading = true; | ||||
final Integer fileId = fileIds.remove(0); | final Integer fileId = fileIds.remove(0); |
// Only collapse if there is more than one item in the root menu and the | // Only collapse if there is more than one item in the root menu and the | ||||
// menu has an explicit size | // menu has an explicit size | ||||
if ((getItems().size() > 1 || (collapsedRootItems != null | if ((getItems().size() > 1 || (collapsedRootItems != null | ||||
&& collapsedRootItems.getItems().size() > 0)) | |||||
&& !collapsedRootItems.getItems().isEmpty())) | |||||
&& getElement().getStyle().getProperty("width") != null | && getElement().getStyle().getProperty("width") != null | ||||
&& moreItem != null) { | && moreItem != null) { | ||||
} | } | ||||
int widthReduced = 0; | int widthReduced = 0; | ||||
while (widthReduced < widthNeeded && getItems().size() > 0) { | |||||
while (widthReduced < widthNeeded && !getItems().isEmpty()) { | |||||
// Move last root menu item to collapsed menu | // Move last root menu item to collapsed menu | ||||
CustomMenuItem collapse = getItems() | CustomMenuItem collapse = getItems() | ||||
.get(getItems().size() - 1); | .get(getItems().size() - 1); | ||||
removeItem(collapse); | removeItem(collapse); | ||||
collapsedRootItems.addItem(collapse, 0); | collapsedRootItems.addItem(collapse, 0); | ||||
} | } | ||||
} else if (collapsedRootItems.getItems().size() > 0) { | |||||
} else if (!collapsedRootItems.getItems().isEmpty()) { | |||||
// Space available for items: expand first items from collapsed | // Space available for items: expand first items from collapsed | ||||
// menu | // menu | ||||
int widthAvailable = diff + moreItemWidth; | int widthAvailable = diff + moreItemWidth; | ||||
int widthGrowth = 0; | int widthGrowth = 0; | ||||
while (widthAvailable > widthGrowth | while (widthAvailable > widthGrowth | ||||
&& collapsedRootItems.getItems().size() > 0) { | |||||
&& !collapsedRootItems.getItems().isEmpty()) { | |||||
// Move first item from collapsed menu to the root menu | // Move first item from collapsed menu to the root menu | ||||
CustomMenuItem expand = collapsedRootItems.getItems() | CustomMenuItem expand = collapsedRootItems.getItems() | ||||
.get(0); | .get(0); | ||||
collapsedRootItems.removeItem(expand); | collapsedRootItems.removeItem(expand); | ||||
addItem(expand); | addItem(expand); | ||||
widthGrowth += expand.getOffsetWidth(); | widthGrowth += expand.getOffsetWidth(); | ||||
if (collapsedRootItems.getItems().size() > 0) { | |||||
if (!collapsedRootItems.getItems().isEmpty()) { | |||||
widthAvailable -= moreItemWidth; | widthAvailable -= moreItemWidth; | ||||
} | } | ||||
if (widthGrowth > widthAvailable) { | if (widthGrowth > widthAvailable) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (collapsedRootItems.getItems().size() > 0) { | |||||
if (!collapsedRootItems.getItems().isEmpty()) { | |||||
addItem(moreItem); | addItem(moreItem); | ||||
} | } | ||||
} | } |
} | } | ||||
private static VWindow getTopmostWindow() { | private static VWindow getTopmostWindow() { | ||||
if (windowOrder.size() > 0) { | |||||
if (!windowOrder.isEmpty()) { | |||||
return windowOrder.get(windowOrder.size() - 1); | return windowOrder.get(windowOrder.size() - 1); | ||||
} | } | ||||
return null; | return null; |
* @return the first item from the menu or null if no items. | * @return the first item from the menu or null if no items. | ||||
*/ | */ | ||||
public MenuItem getFirstItem() { | public MenuItem getFirstItem() { | ||||
return items != null && items.size() > 0 ? items.get(0) : null; | |||||
return items != null && !items.isEmpty() ? items.get(0) : null; | |||||
} | } | ||||
/** | /** | ||||
* @return the last item from the menu or null if no items. | * @return the last item from the menu or null if no items. | ||||
*/ | */ | ||||
public MenuItem getLastItem() { | public MenuItem getLastItem() { | ||||
return items != null && items.size() > 0 ? items.get(items.size() - 1) | |||||
return items != null && !items.isEmpty() ? items.get(items.size() - 1) | |||||
: null; | : null; | ||||
} | } | ||||
*/ | */ | ||||
private void onShow() { | private void onShow() { | ||||
// Select the first item when a menu is shown. | // Select the first item when a menu is shown. | ||||
if (items.size() > 0) { | |||||
if (!items.isEmpty()) { | |||||
selectItem(items.get(0)); | selectItem(items.get(0)); | ||||
} | } | ||||
} | } |
if (result != 0) { | if (result != 0) { | ||||
return o.getDirection() == SortDirection.ASCENDING | return o.getDirection() == SortDirection.ASCENDING | ||||
? result : -result; | |||||
? result | |||||
: -result; | |||||
} | } | ||||
} | } | ||||
if (order.size() > 0) { | |||||
if (!order.isEmpty()) { | |||||
return order.get(0) | return order.get(0) | ||||
.getDirection() == SortDirection.ASCENDING | .getDirection() == SortDirection.ASCENDING | ||||
? a.hashCode() - b.hashCode() | ? a.hashCode() - b.hashCode() |
velocity = delta / ellapsed; | velocity = delta / ellapsed; | ||||
// if last speed was so low, reset speeds and start | // if last speed was so low, reset speeds and start | ||||
// storing again | // storing again | ||||
if (speeds.size() > 0 && !validSpeed(speeds.get(0))) { | |||||
if (!speeds.isEmpty() && !validSpeed(speeds.get(0))) { | |||||
speeds.clear(); | speeds.clear(); | ||||
run = true; | run = true; | ||||
} | } |
* Gets the preferred height of the menu including pageItemsCount items. | * Gets the preferred height of the menu including pageItemsCount items. | ||||
*/ | */ | ||||
String getPreferredHeight(int pageItemsCount) { | String getPreferredHeight(int pageItemsCount) { | ||||
if (currentSuggestions.size() > 0) { | |||||
if (!currentSuggestions.isEmpty()) { | |||||
final int pixels = (getPreferredHeight() | final int pixels = (getPreferredHeight() | ||||
/ currentSuggestions.size()) * pageItemsCount; | / currentSuggestions.size()) * pageItemsCount; | ||||
return pixels + "px"; | return pixels + "px"; | ||||
*/ | */ | ||||
int getItemOffsetHeight() { | int getItemOffsetHeight() { | ||||
List<MenuItem> items = getItems(); | List<MenuItem> items = getItems(); | ||||
return items != null && items.size() > 0 | |||||
return items != null && !items.isEmpty() | |||||
? items.get(0).getOffsetHeight() | ? items.get(0).getOffsetHeight() | ||||
: 0; | : 0; | ||||
} | } | ||||
*/ | */ | ||||
int getItemOffsetWidth() { | int getItemOffsetWidth() { | ||||
List<MenuItem> items = getItems(); | List<MenuItem> items = getItems(); | ||||
return items != null && items.size() > 0 | |||||
return items != null && !items.isEmpty() | |||||
? items.get(0).getOffsetWidth() | ? items.get(0).getOffsetWidth() | ||||
: 0; | : 0; | ||||
} | } |
// that is the same as the previous selection. This prevents | // that is the same as the previous selection. This prevents | ||||
// unwanted scrolling (#18247). | // unwanted scrolling (#18247). | ||||
boolean rowsUnSelected = removeUnselectedRowKeys(selectedKeys); | boolean rowsUnSelected = removeUnselectedRowKeys(selectedKeys); | ||||
boolean updateFocus = rowsUnSelected || selectedRowKeys.size() == 0 | |||||
boolean updateFocus = rowsUnSelected || selectedRowKeys.isEmpty() | |||||
|| focusedRow == null; | || focusedRow == null; | ||||
if (scrollBody != null) { | if (scrollBody != null) { | ||||
for (Widget w : scrollBody) { | for (Widget w : scrollBody) { |
public void setSelected(TreeNode treeNode, boolean selected) { | public void setSelected(TreeNode treeNode, boolean selected) { | ||||
if (selected) { | if (selected) { | ||||
if (!isMultiselect) { | if (!isMultiselect) { | ||||
while (selectedIds.size() > 0) { | |||||
while (!selectedIds.isEmpty()) { | |||||
final String id = selectedIds.iterator().next(); | final String id = selectedIds.iterator().next(); | ||||
final TreeNode oldSelection = getNodeByKey(id); | final TreeNode oldSelection = getNodeByKey(id); | ||||
if (oldSelection != null) { | if (oldSelection != null) { | ||||
TreeNode node = null; | TreeNode node = null; | ||||
// If node is open and has children then move in to the children | // If node is open and has children then move in to the children | ||||
if (!focusedNode.isLeaf() && focusedNode.getState() | if (!focusedNode.isLeaf() && focusedNode.getState() | ||||
&& focusedNode.getChildren().size() > 0) { | |||||
&& !focusedNode.getChildren().isEmpty()) { | |||||
node = focusedNode.getChildren().get(0); | node = focusedNode.getChildren().get(0); | ||||
} else { | } else { | ||||
// Move down to the next sibling | // Move down to the next sibling | ||||
* @return The bottom most child | * @return The bottom most child | ||||
*/ | */ | ||||
private TreeNode getLastVisibleChildInTree(TreeNode root) { | private TreeNode getLastVisibleChildInTree(TreeNode root) { | ||||
if (root.isLeaf() || !root.getState() | |||||
|| root.getChildren().size() == 0) { | |||||
if (root.isLeaf() || !root.getState() || root.getChildren().isEmpty()) { | |||||
return root; | return root; | ||||
} | } | ||||
List<TreeNode> children = root.getChildren(); | List<TreeNode> children = root.getChildren(); |
// in selection and exists with same index | // in selection and exists with same index | ||||
getWidget().setRowFocus(getWidget().getRenderedRowByKey( | getWidget().setRowFocus(getWidget().getRenderedRowByKey( | ||||
getWidget().focusedRow.getKey())); | getWidget().focusedRow.getKey())); | ||||
} else if (getWidget().selectedRowKeys.size() > 0) { | |||||
} else if (!getWidget().selectedRowKeys.isEmpty()) { | |||||
// try to focus any row in selection | // try to focus any row in selection | ||||
getWidget().setRowFocus(getWidget().getRenderedRowByKey( | getWidget().setRowFocus(getWidget().getRenderedRowByKey( | ||||
getWidget().selectedRowKeys.iterator().next())); | getWidget().selectedRowKeys.iterator().next())); |
if (result != 0) { | if (result != 0) { | ||||
return o.getDirection() == SortDirection.ASCENDING | return o.getDirection() == SortDirection.ASCENDING | ||||
? result : -result; | |||||
? result | |||||
: -result; | |||||
} | } | ||||
} | } | ||||
if (order.size() > 0) { | |||||
if (!order.isEmpty()) { | |||||
return order.get(0) | return order.get(0) | ||||
.getDirection() == SortDirection.ASCENDING | .getDirection() == SortDirection.ASCENDING | ||||
? a.hashCode() - b.hashCode() | ? a.hashCode() - b.hashCode() |
@Override | @Override | ||||
public boolean deselectAll() { | public boolean deselectAll() { | ||||
if (selectedRows.size() > 0) { | |||||
if (!selectedRows.isEmpty()) { | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
final LinkedHashSet<RowHandle<T>> selectedRowsClone = (LinkedHashSet<RowHandle<T>>) selectedRows | final LinkedHashSet<RowHandle<T>> selectedRowsClone = (LinkedHashSet<RowHandle<T>>) selectedRows | ||||
} | } | ||||
} | } | ||||
if (added.size() > 0) { | |||||
if (!added.isEmpty()) { | |||||
grid.fireEvent(new SelectionEvent<T>(grid, added, null, | grid.fireEvent(new SelectionEvent<T>(grid, added, null, | ||||
isBeingBatchSelected())); | isBeingBatchSelected())); | ||||
} | } | ||||
} | } | ||||
if (removed.size() > 0) { | |||||
if (!removed.isEmpty()) { | |||||
grid.fireEvent(new SelectionEvent<T>(grid, null, removed, | grid.fireEvent(new SelectionEvent<T>(grid, null, removed, | ||||
isBeingBatchSelected())); | isBeingBatchSelected())); | ||||
return true; | return true; |
velocity = delta / ellapsed; | velocity = delta / ellapsed; | ||||
// if last speed was so low, reset speeds and start | // if last speed was so low, reset speeds and start | ||||
// storing again | // storing again | ||||
if (speeds.size() > 0 && !validSpeed(speeds.get(0))) { | |||||
if (!speeds.isEmpty() && !validSpeed(speeds.get(0))) { | |||||
speeds.clear(); | speeds.clear(); | ||||
run = true; | run = true; | ||||
} | } |
* @author Petri Hakala | * @author Petri Hakala | ||||
* @author Henri Sara | * @author Henri Sara | ||||
* | * | ||||
* @deprecated See {@link BeanValidationBinder} and {@link com.vaadin.data.validator.BeanValidator} | |||||
* @deprecated See {@link BeanValidationBinder} and | |||||
* {@link com.vaadin.data.validator.BeanValidator} | |||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
public class BeanValidator implements Validator { | public class BeanValidator implements Validator { | ||||
public void validate(final Object value) throws InvalidValueException { | public void validate(final Object value) throws InvalidValueException { | ||||
Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, | Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, | ||||
propertyName, value); | propertyName, value); | ||||
if (violations.size() > 0) { | |||||
if (!violations.isEmpty()) { | |||||
InvalidValueException[] causes = new InvalidValueException[violations | InvalidValueException[] causes = new InvalidValueException[violations | ||||
.size()]; | .size()]; | ||||
int i = 0; | int i = 0; |
} | } | ||||
} | } | ||||
if (!isNullSelectionAllowed() | |||||
&& acceptedSelections.size() < 1) { | |||||
if (!isNullSelectionAllowed() && acceptedSelections.isEmpty()) { | |||||
// empty selection not allowed, keep old value | // empty selection not allowed, keep old value | ||||
markAsDirty(); | markAsDirty(); | ||||
return; | return; |
*/ | */ | ||||
private Field<?> getFirstFocusableField() { | private Field<?> getFirstFocusableField() { | ||||
Collection<?> itemPropertyIds = getItemPropertyIds(); | Collection<?> itemPropertyIds = getItemPropertyIds(); | ||||
if (itemPropertyIds != null && itemPropertyIds.size() > 0) { | |||||
if (itemPropertyIds != null && !itemPropertyIds.isEmpty()) { | |||||
for (Object id : itemPropertyIds) { | for (Object id : itemPropertyIds) { | ||||
if (id != null) { | if (id != null) { | ||||
Field<?> field = getField(id); | Field<?> field = getField(id); |
protected void readDesign(Element cellElement, | protected void readDesign(Element cellElement, | ||||
DesignContext designContext) { | DesignContext designContext) { | ||||
if (!cellElement.hasAttr("plain-text")) { | if (!cellElement.hasAttr("plain-text")) { | ||||
if (cellElement.children().size() > 0 | |||||
if (!cellElement.children().isEmpty() | |||||
&& cellElement.child(0).tagName().contains("-")) { | && cellElement.child(0).tagName().contains("-")) { | ||||
setComponent( | setComponent( | ||||
designContext.readDesign(cellElement.child(0))); | designContext.readDesign(cellElement.child(0))); | ||||
*/ | */ | ||||
protected void readDesign(Element tableSectionElement, | protected void readDesign(Element tableSectionElement, | ||||
DesignContext designContext) throws DesignException { | DesignContext designContext) throws DesignException { | ||||
while (rows.size() > 0) { | |||||
while (!rows.isEmpty()) { | |||||
removeRow(0); | removeRow(0); | ||||
} | } | ||||
"selection-mode", attrs, SelectionMode.class)); | "selection-mode", attrs, SelectionMode.class)); | ||||
} | } | ||||
if (design.children().size() > 0) { | |||||
if (!design.children().isEmpty()) { | |||||
if (design.children().size() > 1 | if (design.children().size() > 1 | ||||
|| !design.child(0).tagName().equals("table")) { | || !design.child(0).tagName().equals("table")) { | ||||
throw new DesignException( | throw new DesignException( |
} | } | ||||
} | } | ||||
if (!isNullSelectionAllowed() && s.size() < 1) { | |||||
if (!isNullSelectionAllowed() && s.isEmpty()) { | |||||
// empty selection not allowed, keep old value | // empty selection not allowed, keep old value | ||||
markAsDirty(); | markAsDirty(); | ||||
return; | return; |
@Override | @Override | ||||
public Object lastItemId() { | public Object lastItemId() { | ||||
if (getPreOrder().size() > 0) { | |||||
if (!getPreOrder().isEmpty()) { | |||||
return getPreOrder().get(getPreOrder().size() - 1); | return getPreOrder().get(getPreOrder().size() - 1); | ||||
} else { | } else { | ||||
return null; | return null; |
Collection<?> children = container.getChildren(rootId); | Collection<?> children = container.getChildren(rootId); | ||||
assertNotNull(rootId + " should have children", children); | assertNotNull(rootId + " should have children", children); | ||||
assertTrue(rootId + " should have children", | assertTrue(rootId + " should have children", | ||||
(children.size() > 0)); | |||||
!children.isEmpty()); | |||||
// getParent | // getParent | ||||
for (Object childId : children) { | for (Object childId : children) { | ||||
assertEquals(container.getParent(childId), rootId); | assertEquals(container.getParent(childId), rootId); | ||||
if (!container.areChildrenAllowed(itemId)) { | if (!container.areChildrenAllowed(itemId)) { | ||||
// If no children is allowed the item should have no children | // If no children is allowed the item should have no children | ||||
assertFalse(container.hasChildren(itemId)); | assertFalse(container.hasChildren(itemId)); | ||||
assertTrue(children == null || children.size() == 0); | |||||
assertTrue(children == null || children.isEmpty()); | |||||
return; | return; | ||||
} | } |
@Test | @Test | ||||
public void testRemovePropertyId() { | public void testRemovePropertyId() { | ||||
Collection<Object> converters = table.getCurrentConverters(); | Collection<Object> converters = table.getCurrentConverters(); | ||||
assertTrue("Set of converters was empty at the start.", | |||||
converters.size() > 0); | |||||
assertFalse("Set of converters was empty at the start.", | |||||
converters.isEmpty()); | |||||
Object firstId = converters.iterator().next(); | Object firstId = converters.iterator().next(); | ||||
} | } | ||||
}); | }); | ||||
Set<Object> converters = customTable.getCurrentConverters(); | Set<Object> converters = customTable.getCurrentConverters(); | ||||
assertTrue("Converter was not set.", converters.size() > 0); | |||||
assertFalse("Converter was not set.", converters.isEmpty()); | |||||
} | } | ||||
@Test | @Test |
List<T> rowsToPush = fetchItemsWithRange(offset, limit); | List<T> rowsToPush = fetchItemsWithRange(offset, limit); | ||||
if (!initial && !reset && rowsToPush.size() == 0) { | |||||
if (!initial && !reset && rowsToPush.isEmpty()) { | |||||
triggerReset = true; | triggerReset = true; | ||||
} | } | ||||
Collection<Extension> extensions = connector.getExtensions(); | Collection<Extension> extensions = connector.getExtensions(); | ||||
boolean hasComponents = connector instanceof HasComponents; | boolean hasComponents = connector instanceof HasComponents; | ||||
boolean hasExtensions = extensions.size() > 0; | |||||
boolean hasExtensions = !extensions.isEmpty(); | |||||
if (!hasComponents && !hasExtensions) { | if (!hasComponents && !hasExtensions) { | ||||
// If has neither component nor extensions, return immutable empty | // If has neither component nor extensions, return immutable empty | ||||
// list as iterable. | // list as iterable. |
break; | break; | ||||
} | } | ||||
// if no message, combine the messages of all children | // if no message, combine the messages of all children | ||||
if (null == result && null != getCauses() && getCauses().size() > 0) { | |||||
if (null == result && null != getCauses() && !getCauses().isEmpty()) { | |||||
StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
for (ErrorMessage cause : getCauses()) { | for (ErrorMessage cause : getCauses()) { | ||||
String childMessage = cause.getFormattedHtmlMessage(); | String childMessage = cause.getFormattedHtmlMessage(); |
clientJSON.append(",\"widthMsg\":\"").append(msg).append("\""); | clientJSON.append(",\"widthMsg\":\"").append(msg).append("\""); | ||||
printServerError(msg, attributes, true, serverErrorStream); | printServerError(msg, attributes, true, serverErrorStream); | ||||
} | } | ||||
if (subErrors.size() > 0) { | |||||
if (!subErrors.isEmpty()) { | |||||
serverErrorStream.println("Sub errors >>"); | serverErrorStream.println("Sub errors >>"); | ||||
clientJSON.append(", \"subErrors\" : ["); | clientJSON.append(", \"subErrors\" : ["); | ||||
boolean first = true; | boolean first = true; |
"Attempted to write to a closed PaintTarget."); | "Attempted to write to a closed PaintTarget."); | ||||
} | } | ||||
if (openJsonTags.size() > 0) { | |||||
if (!openJsonTags.isEmpty()) { | |||||
final JsonTag parent = openJsonTags.pop(); | final JsonTag parent = openJsonTags.pop(); | ||||
String lastTag = ""; | String lastTag = ""; |
if (getDropHandler() != null) { | if (getDropHandler() != null) { | ||||
getDropHandler().getAcceptCriterion().paint(target); | getDropHandler().getAcceptCriterion().paint(target); | ||||
} | } | ||||
if (receivers != null && receivers.size() > 0) { | |||||
if (receivers != null && !receivers.isEmpty()) { | |||||
for (Iterator<Entry<String, ProxyReceiver>> it = receivers | for (Iterator<Entry<String, ProxyReceiver>> it = receivers | ||||
.entrySet().iterator(); it.hasNext();) { | .entrySet().iterator(); it.hasNext();) { | ||||
Entry<String, ProxyReceiver> entry = it.next(); | Entry<String, ProxyReceiver> entry = it.next(); |
Element col = cols.get(column); | Element col = cols.get(column); | ||||
Component child = null; | Component child = null; | ||||
if (col.children().size() > 0) { | |||||
if (!col.children().isEmpty()) { | |||||
Element childElement = col.child(0); | Element childElement = col.child(0); | ||||
child = designContext.readDesign(childElement); | child = designContext.readDesign(childElement); | ||||
alignments.put(child, DesignAttributeHandler | alignments.put(child, DesignAttributeHandler |
protected void readDesign(Element cellElement, | protected void readDesign(Element cellElement, | ||||
DesignContext designContext) { | DesignContext designContext) { | ||||
if (!cellElement.hasAttr("plain-text")) { | if (!cellElement.hasAttr("plain-text")) { | ||||
if (cellElement.children().size() > 0 | |||||
if (!cellElement.children().isEmpty() | |||||
&& cellElement.child(0).tagName().contains("-")) { | && cellElement.child(0).tagName().contains("-")) { | ||||
setComponent( | setComponent( | ||||
designContext.readDesign(cellElement.child(0))); | designContext.readDesign(cellElement.child(0))); |
throw new FieldBindingException("Could not get field value", e); | throw new FieldBindingException("Could not get field value", e); | ||||
} | } | ||||
} | } | ||||
if (unboundFields.size() > 0) { | |||||
if (!unboundFields.isEmpty()) { | |||||
getLogger().severe( | getLogger().severe( | ||||
"Found unbound fields in component root :" + unboundFields); | "Found unbound fields in component root :" + unboundFields); | ||||
} | } |
// Send upload URLs to the client if there are files to be | // Send upload URLs to the client if there are files to be | ||||
// uploaded | // uploaded | ||||
if (urls.size() > 0) { | |||||
if (!urls.isEmpty()) { | |||||
getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls); | getRpcProxy(FileDropTargetClientRpc.class).sendUploadUrl(urls); | ||||
} | } | ||||
} | } |
package com.vaadin.tests.server.componentcontainer; | package com.vaadin.tests.server.componentcontainer; | ||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assert.assertFalse; | |||||
import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
List<Class<? extends ComponentContainer>> containerClasses = VaadinClasses | List<Class<? extends ComponentContainer>> containerClasses = VaadinClasses | ||||
.getComponentContainersSupportingAddRemoveComponent(); | .getComponentContainersSupportingAddRemoveComponent(); | ||||
assertTrue(containerClasses.size() > 0); | |||||
assertFalse(containerClasses.isEmpty()); | |||||
// No default constructor, special case | // No default constructor, special case | ||||
containerClasses.remove(CustomLayout.class); | containerClasses.remove(CustomLayout.class); |
} | } | ||||
private void verifyValueChangeEvents() { | private void verifyValueChangeEvents() { | ||||
if (oldValues.size() > 0) { | |||||
if (!oldValues.isEmpty()) { | |||||
assertTrue(oldValues.get(0).isEmpty()); | assertTrue(oldValues.get(0).isEmpty()); | ||||
assertEquals(values.size(), oldValues.size()); | assertEquals(values.size(), oldValues.size()); | ||||
for (int i = 0; i < oldValues.size() - 1; i++) { | for (int i = 0; i < oldValues.size() - 1; i++) { |
} | } | ||||
private void verifyValueChanges() { | private void verifyValueChanges() { | ||||
if (oldSelections.size() > 0) { | |||||
if (!oldSelections.isEmpty()) { | |||||
assertEquals(null, oldSelections.get(0)); | assertEquals(null, oldSelections.get(0)); | ||||
assertEquals(selectionChanges.size(), oldSelections.size()); | assertEquals(selectionChanges.size(), oldSelections.size()); | ||||
for (int i = 0; i < oldSelections.size() - 1; i++) { | for (int i = 0; i < oldSelections.size() - 1; i++) { |
private WebElement getSelectedTopLevelItem() { | private WebElement getSelectedTopLevelItem() { | ||||
List<WebElement> selectedItems = findElements( | List<WebElement> selectedItems = findElements( | ||||
By.className("v-menubar-menuitem-selected")); | By.className("v-menubar-menuitem-selected")); | ||||
if (selectedItems.size() == 0) { | |||||
if (selectedItems.isEmpty()) { | |||||
return null; | return null; | ||||
} | } | ||||
return selectedItems.get(0); | return selectedItems.get(0); |
// a locator that does not lead to selecting tabs from a contained inner | // a locator that does not lead to selecting tabs from a contained inner | ||||
// TabSheet (#13735) | // TabSheet (#13735) | ||||
protected org.openqa.selenium.By byTabCell = By | |||||
.xpath("./div/table/tbody/tr/td[contains(normalize-space(concat(' ', @class, ' '))," | |||||
protected org.openqa.selenium.By byTabCell = By.xpath( | |||||
"./div/table/tbody/tr/td[contains(normalize-space(concat(' ', @class, ' '))," | |||||
+ "normalize-space(' v-tabsheet-tabitem '))]"); | + "normalize-space(' v-tabsheet-tabitem '))]"); | ||||
private static org.openqa.selenium.By byCaption = By | private static org.openqa.selenium.By byCaption = By | ||||
.className("v-captiontext"); | .className("v-captiontext"); | ||||
private void openTab(WebElement tabCell) { | private void openTab(WebElement tabCell) { | ||||
// Open the tab by clicking its caption text if it exists. | // Open the tab by clicking its caption text if it exists. | ||||
List<WebElement> tabCaptions = tabCell.findElements(byCaption); | List<WebElement> tabCaptions = tabCell.findElements(byCaption); | ||||
if (tabCaptions.size() > 0) { | |||||
if (!tabCaptions.isEmpty()) { | |||||
tabCaptions.get(0).click(); | tabCaptions.get(0).click(); | ||||
return; | return; | ||||
} | } | ||||
// If no caption text was found, click the icon of the tab. | // If no caption text was found, click the icon of the tab. | ||||
List<WebElement> tabIcons = tabCell | List<WebElement> tabIcons = tabCell | ||||
.findElements(By.className("v-icon")); | .findElements(By.className("v-icon")); | ||||
if (tabIcons.size() > 0) { | |||||
if (!tabIcons.isEmpty()) { | |||||
tabIcons.get(0).click(); | tabIcons.get(0).click(); | ||||
return; | return; | ||||
} | } | ||||
*/ | */ | ||||
private String getTabCaption(WebElement tabCell) { | private String getTabCaption(WebElement tabCell) { | ||||
List<WebElement> captionElements = tabCell.findElements(byCaption); | List<WebElement> captionElements = tabCell.findElements(byCaption); | ||||
if (captionElements.size() == 0) { | |||||
if (captionElements.isEmpty()) { | |||||
return null; | return null; | ||||
} else { | } else { | ||||
return captionElements.get(0).getText(); | return captionElements.get(0).getText(); |
public void toggleExpanded() { | public void toggleExpanded() { | ||||
List<WebElement> expandButtons = getWrappedElement() | List<WebElement> expandButtons = getWrappedElement() | ||||
.findElements(By.className("v-treetable-treespacer")); | .findElements(By.className("v-treetable-treespacer")); | ||||
if (expandButtons.size() > 0) { | |||||
if (!expandButtons.isEmpty()) { | |||||
expandButtons.get(0).click(); | expandButtons.get(0).click(); | ||||
} | } | ||||
} | } |
} | } | ||||
deselButton.click(); | deselButton.click(); | ||||
} | } | ||||
while (selectedOptions.getOptions().size() > 0) { | |||||
while (!selectedOptions.getOptions().isEmpty()) { | |||||
selectedOptions.selectByIndex(0); | selectedOptions.selectByIndex(0); | ||||
deselButton.click(); | deselButton.click(); | ||||
} | } |
public void valueChange(ValueChangeEvent event) { | public void valueChange(ValueChangeEvent event) { | ||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
Set<String> value = (Set<String>) table3.getValue(); | Set<String> value = (Set<String>) table3.getValue(); | ||||
selected3.setValue(value.size() == 0 ? "No selected items" | |||||
selected3.setValue(value.isEmpty() ? "No selected items" | |||||
: value + ": Total " + value.size() + " items"); | : value + ": Total " + value.size() + " items"); | ||||
} | } | ||||
}); | }); |
// in multiselect mode, a Set of itemIds is returned, | // in multiselect mode, a Set of itemIds is returned, | ||||
// in singleselect mode the itemId is returned directly | // in singleselect mode the itemId is returned directly | ||||
Set<?> value = (Set<?>) event.getProperty().getValue(); | Set<?> value = (Set<?>) event.getProperty().getValue(); | ||||
if (null == value || value.size() == 0) { | |||||
if (null == value || value.isEmpty()) { | |||||
selected.setValue("No selection"); | selected.setValue("No selection"); | ||||
} else { | } else { | ||||
selected.setValue("Selected: " + table.getValue()); | selected.setValue("Selected: " + table.getValue()); |
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
// safe cast after instanceof check | // safe cast after instanceof check | ||||
Set<Object> itemIds = (Set<Object>) tree.getValue(); | Set<Object> itemIds = (Set<Object>) tree.getValue(); | ||||
if (itemIds.size() == 0) { | |||||
if (itemIds.isEmpty()) { | |||||
valueLbl.setValue("No selection"); | valueLbl.setValue("No selection"); | ||||
} else { | } else { | ||||
valueLbl.setValue(itemIds.toString()); | valueLbl.setValue(itemIds.toString()); |
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
// safe cast after instanceof check | // safe cast after instanceof check | ||||
Set<Object> itemIds = (Set<Object>) tree.getValue(); | Set<Object> itemIds = (Set<Object>) tree.getValue(); | ||||
if (itemIds.size() == 0) { | |||||
if (itemIds.isEmpty()) { | |||||
valueLbl.setValue("No selection"); | valueLbl.setValue("No selection"); | ||||
} else { | } else { | ||||
valueLbl.setValue(itemIds.toString()); | valueLbl.setValue(itemIds.toString()); |
*/ | */ | ||||
package com.vaadin.tests.components; | package com.vaadin.tests.components; | ||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import java.util.List; | import java.util.List; | ||||
public void requiredIndicatorVisible() { | public void requiredIndicatorVisible() { | ||||
openTestURL(); | openTestURL(); | ||||
List<WebElement> layouts = findElements(By.className("vaadin-layout")); | List<WebElement> layouts = findElements(By.className("vaadin-layout")); | ||||
assertTrue(layouts.size() > 0); | |||||
assertFalse(layouts.isEmpty()); | |||||
layouts.stream().forEach(this::checkRequiredIndicator); | layouts.stream().forEach(this::checkRequiredIndicator); | ||||
} | } | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import org.junit.Assert; | |||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.openqa.selenium.By; | import org.openqa.selenium.By; | ||||
assertItemSuffices(20); | assertItemSuffices(20); | ||||
List<WebElement> icons = getSelect() | List<WebElement> icons = getSelect() | ||||
.findElements(By.cssSelector(".v-select-optiongroup .v-icon")); | .findElements(By.cssSelector(".v-select-optiongroup .v-icon")); | ||||
assertTrue(icons.size() > 0); | |||||
assertFalse(icons.isEmpty()); | |||||
for (int i = 0; i < icons.size(); i++) { | for (int i = 0; i < icons.size(); i++) { | ||||
assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), | assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), | ||||
icons.get(i).getText().charAt(0)); | icons.get(i).getText().charAt(0)); | ||||
} | } | ||||
private void assertSelected(String... expectedSelection) { | private void assertSelected(String... expectedSelection) { | ||||
assertEquals(Arrays.asList(expectedSelection), | |||||
getSelect().getValue()); | |||||
assertEquals(Arrays.asList(expectedSelection), getSelect().getValue()); | |||||
} | } | ||||
@Override | @Override | ||||
List<String> optionsIcons = new ArrayList<>(); | List<String> optionsIcons = new ArrayList<>(); | ||||
for (WebElement option : getSelect().getOptionElements()) { | for (WebElement option : getSelect().getOptionElements()) { | ||||
List<WebElement> images = option.findElements(By.tagName("img")); | List<WebElement> images = option.findElements(By.tagName("img")); | ||||
if (images.size() > 0) { | |||||
if (!images.isEmpty()) { | |||||
optionsIcons.add(images.get(0).getAttribute("src")); | optionsIcons.add(images.get(0).getAttribute("src")); | ||||
} else { | } else { | ||||
optionsIcons.add(null); | optionsIcons.add(null); |
int col) { | int col) { | ||||
GridCellElement cell = grid.getHeaderCell(row, col); | GridCellElement cell = grid.getHeaderCell(row, col); | ||||
List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); | List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); | ||||
if (all.size() == 0) { | |||||
if (all.isEmpty()) { | |||||
return null; | return null; | ||||
} else if (all.size() == 1) { | } else if (all.size() == 1) { | ||||
return all.get(0); | return all.get(0); | ||||
int col) { | int col) { | ||||
GridCellElement cell = grid.getFooterCell(row, col); | GridCellElement cell = grid.getFooterCell(row, col); | ||||
List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); | List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); | ||||
if (all.size() == 0) { | |||||
if (all.isEmpty()) { | |||||
return null; | return null; | ||||
} else if (all.size() == 1) { | } else if (all.size() == 1) { | ||||
return all.get(0); | return all.get(0); |
package com.vaadin.tests.components.table; | package com.vaadin.tests.components.table; | ||||
import static org.hamcrest.MatcherAssert.assertThat; | import static org.hamcrest.MatcherAssert.assertThat; | ||||
import static org.junit.Assert.assertFalse; | |||||
import java.util.List; | import java.util.List; | ||||
import org.openqa.selenium.WebElement; | import org.openqa.selenium.WebElement; | ||||
import com.vaadin.testbench.By; | import com.vaadin.testbench.By; | ||||
import com.vaadin.testbench.elements.TableElement; | |||||
import com.vaadin.testbench.elements.ButtonElement; | import com.vaadin.testbench.elements.ButtonElement; | ||||
import com.vaadin.testbench.elements.TableElement; | |||||
import com.vaadin.tests.tb3.MultiBrowserTest; | import com.vaadin.tests.tb3.MultiBrowserTest; | ||||
/** | /** | ||||
public void switchIntoIframe() { | public void switchIntoIframe() { | ||||
List<WebElement> frames = driver.findElements(By.tagName("iframe")); | List<WebElement> frames = driver.findElements(By.tagName("iframe")); | ||||
assertThat("No frames was found", frames.size() > 0); | |||||
assertFalse("No frames was found", frames.isEmpty()); | |||||
driver.switchTo().frame(frames.get(0)); | driver.switchTo().frame(frames.get(0)); | ||||
} | } | ||||
package com.vaadin.tests.components.table; | package com.vaadin.tests.components.table; | ||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
assertTrue("Column header text should be custom", | assertTrue("Column header text should be custom", | ||||
headerCell.getText().equalsIgnoreCase("Hello World")); | headerCell.getText().equalsIgnoreCase("Hello World")); | ||||
assertTrue("Column should have an icon", | |||||
headerCell.findElements(By.className("v-icon")).size() > 0); | |||||
assertFalse("Column should have an icon", | |||||
headerCell.findElements(By.className("v-icon")).isEmpty()); | |||||
assertTrue("Column should have alignment to the right", headerCell | |||||
assertFalse("Column should have alignment to the right", headerCell | |||||
.findElements( | .findElements( | ||||
By.className("v-table-caption-container-align-right")) | By.className("v-table-caption-container-align-right")) | ||||
.size() > 0); | |||||
.isEmpty()); | |||||
} | } | ||||
} | } |
List<WebElement> openTabCaptionElements = tab | List<WebElement> openTabCaptionElements = tab | ||||
.findElement(By.className("v-caption")) | .findElement(By.className("v-caption")) | ||||
.findElements(By.className("v-captiontext")); | .findElements(By.className("v-captiontext")); | ||||
if (openTabCaptionElements.size() > 0) { | |||||
if (!openTabCaptionElements.isEmpty()) { | |||||
String openTabCaption = openTabCaptionElements.get(0).getText(); | String openTabCaption = openTabCaptionElements.get(0).getText(); | ||||
assertEquals("Wrong tab is open.", caption, openTabCaption); | assertEquals("Wrong tab is open.", caption, openTabCaption); | ||||
} else { | } else { | ||||
boolean tabsOpen = false; | boolean tabsOpen = false; | ||||
for (int i = 0; i < tabs.size(); i++) { | for (int i = 0; i < tabs.size(); i++) { | ||||
WebElement tab = tabs.get(i); | WebElement tab = tabs.get(i); | ||||
boolean isOpened = tab | |||||
boolean isOpened = !tab | |||||
.findElements(By.className("v-tabsheet-tabitem-selected")) | .findElements(By.className("v-tabsheet-tabitem-selected")) | ||||
.size() > 0; | |||||
.isEmpty(); | |||||
if (isOpened) { | if (isOpened) { | ||||
tabsOpen = true; | tabsOpen = true; | ||||
assertEquals("The wrong tab is open.", index, i); | assertEquals("The wrong tab is open.", index, i); | ||||
+ " should be open."); | + " should be open."); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
private WebElement getFirstDayWithEvents() { | private WebElement getFirstDayWithEvents() { | ||||
for (WebElement monthDay : getCalendar().getMonthDays()) { | for (WebElement monthDay : getCalendar().getMonthDays()) { | ||||
if (getVisibleEvents(monthDay).size() > 0) { | |||||
if (!getVisibleEvents(monthDay).isEmpty()) { | |||||
return monthDay; | return monthDay; | ||||
} | } | ||||
} | } |
parameters.add("restartApplication"); | parameters.add("restartApplication"); | ||||
} | } | ||||
if (parameters.size() > 0) { | |||||
if (!parameters.isEmpty()) { | |||||
url += "?" + StringUtils.join(parameters, "&"); | url += "?" + StringUtils.join(parameters, "&"); | ||||
} | } | ||||