List of usage examples for org.apache.wicket.markup.html.list LoopItem add
public MarkupContainer add(final Component... children)
From source file:au.org.theark.core.web.component.tabbedPanel.DynamicTabbedPanel.java
License:Open Source License
public DynamicTabbedPanel(final String id, final IModel<List<ITab>> tabModel) { super(id, new Model<Integer>(-1)); this.tabModel = tabModel; final IModel<Integer> tabCount = new AbstractReadOnlyModel<Integer>() { private static final long serialVersionUID = 1L; @Override/* ww w. j ava 2s . co m*/ public Integer getObject() { return tabModel.getObject().size(); } }; WebMarkupContainer tabsContainer = newTabsContainer("tabs-container"); add(tabsContainer); // add the loop used to generate tab names tabsContainer.add(new Loop("tabs", tabCount) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final LoopItem item) { final int index = item.getIndex(); final ITab tab = tabModel.getObject().get(index); final WebMarkupContainer titleLink = newLink("link", index); titleLink.add(newTitle("title", tab.getTitle(), index)); item.add(titleLink); } @Override protected LoopItem newItem(final int iteration) { return newTabContainer(iteration); } public boolean isVisible() { return tabCount.getObject() > 0; } }); }
From source file:au.org.theark.core.web.component.worksheet.ArkExcelWorkSheetAsGrid.java
License:Open Source License
@SuppressWarnings({ "unchecked" })
private Loop createHeadings() {
return new Loop("heading", new PropertyModel(sheetMetaData, "cols")) {
private static final long serialVersionUID = -7027878243061138904L;
public void populateItem(LoopItem item) {
final int col = item.getIndex();
/*//from w w w . j a va 2 s . c om
* this model used for Label component gets data from cell instance Because we are interacting directly with the sheet instance which gets
* updated each time we upload a new Excel File, the value for each cell is automatically updated
*/
IModel<Object> model = new Model() {
private static final long serialVersionUID = 1144128566137457199L;
@Override
public Serializable getObject() {
Cell cell = sheet.getCell(col, 0);
return cell.getContents();
}
};
Label cellData = new Label("cellHead", model);
item.add(cellData);
}
};
}
From source file:au.org.theark.core.web.component.worksheet.ArkExcelWorkSheetAsGrid.java
License:Open Source License
private Loop createEmptyHeadings() { return new Loop("heading", new PropertyModel(sheetMetaData, "cols")) { private static final long serialVersionUID = -7027878243061138904L; public void populateItem(LoopItem item) { Label cellData = new Label("cellHead", ""); item.add(cellData); }/* w ww. j av a 2 s. c o m*/ }; }
From source file:au.org.theark.core.web.component.worksheet.ArkExcelWorkSheetAsGrid.java
License:Open Source License
@SuppressWarnings({ "serial", "unchecked" })
private Loop createMainGrid() {
// We create a Loop instance and uses PropertyModel to bind the Loop iteration to ExcelMetaData "rows" value
return new Loop("rows", new PropertyModel(sheetMetaData, "rows")) {
@Override//from w ww . j a v a2 s. c o m
public void populateItem(LoopItem item) {
final int row = item.getIndex();
if (!insertRows.isEmpty() || !updateRows.isEmpty() || !warningRows.isEmpty()) {
setRowCssStyle(row, item);
}
if (row > 0 && row <= rowsToDisplay) {
// creates the row numbers
item.add(new Label("rowNo", new Model(String.valueOf(row))));
// We create an inner Loop instance and uses PropertyModel to bind the Loop iteration to ExcelMetaData "cols" value
item.add(new Loop("cols", new PropertyModel<Integer>(sheetMetaData, "cols")) {
@Override
public void populateItem(LoopItem item) {
final int col = item.getIndex();
/*
* this model used for Label component gets data from cell instance Because we are interacting directly with the sheet instance
* which gets updated each time we upload a new Excel File, the value for each cell is automatically updated
*/
IModel<Object> model = new Model() {
/**
*
*/
private static final long serialVersionUID = 1144128566137457199L;
@Override
public Serializable getObject() {
Cell cell = sheet.getCell(col, row);
if (cell instanceof DateCell) {
DateCell dc = (DateCell) cell;
Date d = dc.getDate();
return (sdf.format(d));
}
return cell.getContents();
}
};
Label cellData = new Label("cellData", model);
item.add(cellData);
ArkGridCell cell = new ArkGridCell(col, row);
if (errorCells.contains(cell)) {
item.add(errorCellBehavior);
} else if (warningCells.contains(cell)) {
item.add(warningCellBehavior);
} else if (updateCells.contains(cell)) {
item.add(updateCellBehavior);
} else if (insertCells.contains(cell)) {
item.add(insertCellBehavior);
}
}
});
} else {
item.add(new Label("rowNo", new Model("")));
item.setVisible(false);
item.add(new Loop("cols", new PropertyModel(sheetMetaData, "cols")) {
@Override
protected void populateItem(LoopItem item) {
Label cellData = new Label("cellData", new Model(""));
item.add(cellData);
}
});
item.setVisible(false);
}
}
/**
* Determines whether row data is an insert or an update and amends the css of the
* accordingly
* <tr>
* @param cell
*/
private void setRowCssStyle(Integer row, LoopItem item) {
if (updateRows.contains(row)) {
item.add(updateCellBehavior);
} else if (warningRows.contains(row)) {
item.add(warningCellBehavior);
} else if (insertRows.contains(row)) {
item.add(insertCellBehavior);
}
}
};
}
From source file:au.org.theark.core.web.component.worksheet.ArkExcelWorkSheetAsGrid.java
License:Open Source License
@SuppressWarnings({ "serial", "unchecked" })
private Loop createMainGrid(final boolean header) {
// We create a Loop instance and uses PropertyModel to bind the Loop iteration to ExcelMetaData "rows" value
return new Loop("rows", new PropertyModel(sheetMetaData, "rows")) {
@Override//from w ww. j ava 2 s .c o m
public void populateItem(LoopItem item) {
final int row = item.getIndex();
if (!insertRows.isEmpty() || !updateRows.isEmpty() || !warningRows.isEmpty()) {
setRowCssStyle(row, item);
}
if ((header && row > 0 && row <= rowsToDisplay) || (!header && row <= rowsToDisplay)) {
// creates the row numbers
item.add(new Label("rowNo", new Model(String.valueOf(row))));
// We create an inner Loop instance and uses PropertyModel to bind the Loop iteration to ExcelMetaData "cols" value
item.add(new Loop("cols", new PropertyModel<Integer>(sheetMetaData, "cols")) {
@Override
public void populateItem(LoopItem item) {
final int col = item.getIndex();
/*
* this model used for Label component gets data from cell instance Because we are interacting directly with the sheet instance
* which gets updated each time we upload a new Excel File, the value for each cell is automatically updated
*/
IModel<Object> model = new Model() {
/**
*
*/
private static final long serialVersionUID = 1144128566137457199L;
@Override
public Serializable getObject() {
Cell cell = sheet.getCell(col, row);
if (cell instanceof DateCell) {
DateCell dc = (DateCell) cell;
Date d = dc.getDate();
return (sdf.format(d));
}
return cell.getContents();
}
};
Label cellData = new Label("cellData", model);
item.add(cellData);
ArkGridCell cell = new ArkGridCell(col, row);
if (errorCells.contains(cell)) {
item.add(errorCellBehavior);
} else if (warningCells.contains(cell)) {
item.add(warningCellBehavior);
} else if (updateCells.contains(cell)) {
item.add(updateCellBehavior);
} else if (insertCells.contains(cell)) {
item.add(insertCellBehavior);
}
}
});
} else {
item.add(new Label("rowNo", new Model("")));
item.setVisible(false);
item.add(new Loop("cols", new PropertyModel(sheetMetaData, "cols")) {
@Override
protected void populateItem(LoopItem item) {
Label cellData = new Label("cellData", new Model(""));
item.add(cellData);
}
});
item.setVisible(false);
}
}
/**
* Determines whether row data is an insert or an update and amends the css of the
* accordingly
* <tr>
* @param cell
*/
private void setRowCssStyle(Integer row, LoopItem item) {
if (updateRows.contains(row)) {
item.add(updateCellBehavior);
} else if (warningRows.contains(row)) {
item.add(warningCellBehavior);
} else if (insertRows.contains(row)) {
item.add(insertCellBehavior);
}
}
};
}
From source file:au.org.theark.lims.web.component.inventory.panel.box.display.GridBoxPanel.java
License:Open Source License
/** * Creates the header of the table for the represented InvBox in question * @param invBox/* ww w . j a va2 s .c o m*/ * @return */ @SuppressWarnings({ "unchecked" }) private Loop createHeadings(final InvBox invBox) { String colRowNoType = ""; if (invBox.getId() != null) { colRowNoType = invBox.getColnotype().getName(); } else { // handle for null invBox (eg when backend list of cells corrupted) return new Loop("heading", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { Label colLabel = new Label("cellHead", ""); item.add(colLabel.setVisible(false)); } @Override public boolean isVisible() { return false; } }; } final String colNoType = colRowNoType; // Outer Loop instance, using a PropertyModel to bind the Loop iteration to invBox "noofcol" value return new Loop("heading", new PropertyModel(invBox, "noofcol")) { private static final long serialVersionUID = -7027878243061138904L; public void populateItem(LoopItem item) { final int col = item.getIndex(); IModel<String> colModel = new Model() { private static final long serialVersionUID = 1144128566137457199L; @Override public Serializable getObject() { String label = new String(); if (colNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (col + 65); label = new Character(character).toString(); } else { label = new Integer(col + 1).toString(); } return label; } }; // Create the col number/label Label colLabel = new Label("cellHead", colModel); item.add(colLabel); } }; }
From source file:au.org.theark.lims.web.component.inventory.panel.box.display.GridBoxPanel.java
License:Open Source License
/** * Creates the table data that represents the cells of the InvBox in question * @param invBox/*from ww w . j av a 2 s . co m*/ * @param invCellList * @return */ @SuppressWarnings({ "unchecked" }) private Loop createMainGrid(final InvBox invBox, final List<InvCell> invCellList) { String colRowNoType = ""; if (invBox.getId() != null) { colRowNoType = invBox.getRownotype().getName(); } else { // handle for null invBox (eg when backend list of cells corrupted) return new Loop("rows", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { item.add(new Loop("cols", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { item.add(new EmptyPanel("cell")); } }.setVisible(false)); } @Override public boolean isVisible() { return false; } }; } final String rowNoType = colRowNoType; final int noOfCols = invBox.getNoofcol(); // Outer Loop instance, using a PropertyModel to bind the Loop iteration to invBox "noofrow" value Loop loop = new Loop("rows", new PropertyModel(invBox, "noofrow")) { private static final long serialVersionUID = 1L; public void populateItem(LoopItem item) { final int row = item.getIndex(); // Create the row number/label String label = new String(); if (rowNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (row + 65); label = new Character(character).toString(); } else { label = new Integer(row + 1).toString(); } Label rowLabel = new Label("rowNo", new Model(label)); rowLabel.add(new Behavior() { private static final long serialVersionUID = 1L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("style", "background: none repeat scroll 0 0 #FFFFFF; color: black; font-weight: bold; padding: 1px;"); }; }); rowLabel.setOutputMarkupId(true); item.add(rowLabel); // We create an inner Loop instance and uses PropertyModel to bind the Loop iteration to invBox "noofcol" value item.add(new Loop("cols", new PropertyModel(invBox, "noofcol")) { private static final long serialVersionUID = 1L; public void populateItem(LoopItem item) { final int col = item.getIndex(); final int index = (row * noOfCols) + col; InvCell invCell = invCellList.get(index); GridCellContentPanel gridCellContentPanel; // add the gridCell if (allocating) { gridCellContentPanel = new GridCellContentPanel("cell", limsVo, invCell, modalWindow, true); } else { gridCellContentPanel = new GridCellContentPanel("cell", limsVo, invCell, modalWindow, false); } gridCellContentPanel.setOutputMarkupId(true); gridCellContentPanel.setMarkupId("invCell" + invCell.getId().toString()); item.add(gridCellContentPanel); } }); } }; return loop; }
From source file:com.bt.menu.MenuTabs.java
public void createComponent() { Loop loop = new Loop("tabs_content", new PropertyModel(this, "size")) { @Override/*w w w . j av a 2 s . co m*/ protected void populateItem(LoopItem li) { // WebMarkupContainer wmc=new WebMarkupContainer("tab"); // li.add(wmc); final WindowPack pck = lst.get(li.getIndex()); if (pck.isVisible()) { li.add(new Label("tab_name", textMenu(pck.getTitle()))); } else { TLinkAsPanel lnk = new TLinkAsPanel("tab_name", textMenu(pck.getTitle())) { @Override public void onClick(AjaxRequestTarget art) { onSelected(art, pck); } }; li.add(lnk); } } }; add(loop); }
From source file:com.evolveum.midpoint.web.component.data.paging.NavigatorPanel.java
License:Apache License
private void initNavigation() { IModel<Integer> model = new AbstractReadOnlyModel<Integer>() { @Override//from w w w .jav a 2 s .c om public Integer getObject() { int count = (int) pageable.getPageCount(); if (count < PAGING_SIZE) { return count; } return PAGING_SIZE; } }; Loop navigation = new Loop(ID_NAVIGATION, model) { @Override protected void populateItem(final LoopItem item) { final NavigatorPageLink pageLink = new NavigatorPageLink(ID_PAGE_LINK, computePageNumber(item.getIndex())) { @Override public void onClick(AjaxRequestTarget target) { pageLinkPerformed(target, getPageNumber()); } }; item.add(pageLink); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return pageable.getCurrentPage() == pageLink.getPageNumber() ? "active" : ""; } })); } }; navigation.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return showPageListing; } }); add(navigation); }
From source file:com.evolveum.midpoint.web.component.TabbedPanel.java
License:Apache License
/** * Constructor/*from w ww. jav a 2 s .c om*/ * * @param id component id * @param tabs list of ITab objects used to represent tabs * @param model model holding the index of the selected tab */ public TabbedPanel(final String id, final IModel<List<T>> tabs, IModel<Integer> model) { super(id, model); this.tabs = Args.notNull(tabs, "tabs"); final IModel<Integer> tabCount = new AbstractReadOnlyModel<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { return tabs.getObject().size(); } }; WebMarkupContainer tabsContainer = newTabsContainer("tabs-container"); add(tabsContainer); // add the loop used to generate tab names tabsContainer.add(new Loop("tabs", tabCount) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final LoopItem item) { final int index = item.getIndex(); final T tab = TabbedPanel.this.tabs.getObject().get(index); final WebMarkupContainer titleLink = newLink("link", index); titleLink.add(newTitle("title", tab.getTitle(), index)); item.add(titleLink); } @Override protected LoopItem newItem(final int iteration) { return newTabContainer(iteration); } }); add(newPanel()); }