Example usage for org.apache.wicket.markup.html.list LoopItem setVisible

List of usage examples for org.apache.wicket.markup.html.list LoopItem setVisible

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list LoopItem setVisible.

Prototype

public final Component setVisible(final boolean visible) 

Source Link

Document

Sets whether this component and any children are visible.

Usage

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  w w  .  j  ava 2s .c om
        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// ww w  .j a va2 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:com.googlecode.wicket.kendo.ui.widget.accordion.AccordionPanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    final WebMarkupContainer root = new WebMarkupContainer("root");
    this.add(root);

    root.add(new Loop("tabs", this.getCountModel()) {

        private static final long serialVersionUID = 1L;

        @Override//from w  w  w .ja v  a2  s  .c om
        protected LoopItem newItem(final int index) {
            ITab tab = AccordionPanel.this.getModelObject().get(index);

            LoopItem item = super.newItem(index);
            item.setVisible(tab.isVisible());

            return item;
        }

        @Override
        protected void populateItem(LoopItem item) {
            int index = item.getIndex();
            final ITab tab = AccordionPanel.this.getModelObject().get(index);

            item.add(AccordionPanel.this.newTitleLabel("title", tab.getTitle()));
            item.add(tab.getPanel("panel"));
        }
    });

    this.widgetBehavior = JQueryWidget.newWidgetBehavior(this, root);
    this.add(this.widgetBehavior);
}