Here are the examples of the java api com.vaadin.flow.component.HasOrderedComponents taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
11
Source : AppToolbar.java
with Apache License 2.0
from FlowingCode
with Apache License 2.0
from FlowingCode
/**
* Component that renders the app toolbar
*
* @author mlopez
*/
@SuppressWarnings("serial")
@HtmlImport("bower_components/app-layout/app-toolbar/app-toolbar.html")
@HtmlImport("bower_components/iron-icons/iron-icons.html")
@NpmPackage(value = "@polymer/app-layout", version = AppLayout.NPM_VERSION)
@NpmPackage(value = "@polymer/iron-icons", version = "^3.0.0")
@JsModule("@polymer/app-layout/app-toolbar/app-toolbar.js")
@JsModule("@polymer/iron-icons/iron-icons.js")
@Tag("app-toolbar")
public clreplaced AppToolbar extends Component {
private ToolbarIconButton menu;
private Div divreplacedle;
private int index;
private HasOrderedComponents<AppToolbar> hasOrderedComponents = new HasOrderedComponents<AppToolbar>() {
@Override
public Element getElement() {
return AppToolbar.this.getElement();
}
@Override
public int getComponentCount() {
return (int) getChildren().count();
}
@Override
public Component getComponentAt(int index) {
if (index < 0) {
throw new IllegalArgumentException("The 'index' argument should be greater than or equal to 0. It was: " + index);
}
return getChildren().sequential().skip(index).findFirst().orElseThrow(() -> new IllegalArgumentException("The 'index' argument should not be greater than or equals to the number of children components. It was: " + index));
}
};
public AppToolbar(String replacedle, AppDrawer drawer) {
this(null, replacedle, drawer);
}
public AppToolbar(Image logo, String replacedle, AppDrawer drawer) {
menu = new ToolbarIconButton().setIcon("menu");
add(menu);
drawer.getId().ifPresent(id -> menu.getElement().setAttribute("onclick", id + ".toggle()"));
if (logo != null) {
add(logo);
}
divreplacedle = new Div();
divreplacedle.getElement().setAttribute("main-replacedle", true);
setreplacedle(replacedle);
add(divreplacedle);
index = hasOrderedComponents.getComponentCount();
}
private void add(Component... components) {
hasOrderedComponents.add(components);
}
private void addComponentAtIndex(int index, Component component) {
hasOrderedComponents.addComponentAtIndex(index, component);
}
public void setreplacedle(String replacedle) {
divreplacedle.setText(replacedle);
}
public void clearToolbarIconButtons() {
while (hasOrderedComponents.getComponentCount() > index) {
hasOrderedComponents.remove(hasOrderedComponents.getComponentAt(index));
}
}
public void setMenuIconVisible(boolean visible) {
menu.setVisible(visible);
}
public void addToolbarIconButtons(Component... components) {
this.add(components);
}
public void addToolbarIconButtonAsFirst(Component component) {
this.addComponentAtIndex(index, component);
}
}