/** * Clear the current selection, if any. */ protected void clearSelection() { grid.getRows().clearSelected(); }
/** * Displays the specified message. The list box is hidden if the message is not empty. * * @param message Message to display. */ private void showMessage(String message) { message = message == null ? null : StrUtil.getLabel(message); lblNoResultsFound.setLabel(message); lblNoResultsFound.setVisible(!StringUtils.isEmpty(message)); tblSrchResults.setVisible(!lblNoResultsFound.isVisible()); }
/** * Initializes the controller. Loads user preferences and properties. */ @Override protected void initializeController() { if (grid.getRows() == null) { grid.addChild(new Rows()); } setComponents(grid, grid.getRows()); super.initializeController(); boolean expandAll = getPropertyValue(Constants.PROPERTY_ID_EXPAND_DETAIL, Boolean.class, chkExpandAll != null && chkExpandAll.isChecked()); if (this.chkExpandAll != null) { this.chkExpandAll.setChecked(expandAll); } }
@Test public void testForm() throws Exception { BaseComponent root = PageUtil.createPage("web/org/carewebframework/ui/sharedforms/listviewForm.fsp", null).get(0); TestController controller = new TestController(); root.wireController(controller); ElementPlugin dummy = new ElementPlugin(); controller.onLoad(dummy); controller.requestData(); assertEquals(10, controller.model.size()); Grid grid = (Grid) root.findByName("grid"); Rows rows = grid.getRows(); assertEquals(10, rows.getChildCount()); assertEquals("Item #2.3", ((ILabeled) rows.getChildAt(1).getChildAt(2)).getLabel()); assertEquals("Test Title", controller.getCaption()); assertEquals("Header3", ((Column) grid.getColumns().getLastChild()).getLabel()); assertEquals(":1:false;0:33%;1:33%;2:33%", controller.getLayout()); controller.setLayout(":2:true;0:20%;1:30%;2:50%"); assertEquals(":2:true;0:20%;1:30%;2:50%", controller.getLayout()); } }
grid.getColumns().getChild(Column.class).sort();
/** * Adds a column to a grid. * * @param grid Grid. * @param label Label for column. * @param width Width for column. * @param sortBy Field for sorting. * @return Newly created column. */ public Column addColumn(Grid grid, String label, String width, String sortBy) { Column column = new Column(); grid.getColumns().addChild(column); column.setLabel(label); column.setWidth(width); column.setSortComparator(sortBy); column.setSortOrder(SortOrder.ASCENDING); return column; }
/** * Returns the last row added. * * @return The last row added. */ private Row getLastRow() { return (Row) grid.getRows().getLastChild(); }
protected void status(String message) { if (message != null) { grid.setVisible(false); status.setLabel(StrUtil.piece(message, "^")); status.setHint(StrUtil.piece(message, "^", 2, 999)); status.setVisible(true); } else { status.setVisible(false); status.setLabel(null); status.setHint(null); grid.setVisible(true); } }
Patient patient = patientListItem.getPatient(); Columns columns = grid.getColumns(); int max = columns == null ? 0 : columns.getChildCount(); String info = patientListItem.getInfo();
protected Row getSelectedRow() { return grid.getRows().getSelectedRow(); }
gridProperties.setVisible(true); setPropertyDescription("@cwf.shell.designer.property.grid.propdx.some.caption", "@cwf.shell.designer.property.grid.propdx.some.message"); } else { gridProperties.setVisible(false); setPropertyDescription("@cwf.shell.designer.property.grid.propdx.none.caption", "@cwf.shell.designer.property.grid.propdx.none.message");
/** * Returns the model from the associated grid rows. * * @return The model backing the associated grid rows. May be null. */ private IListModel<Object> getRowsModel() { Grid grid = getAncestor(Grid.class); Rows rows = grid == null ? null : grid.getRows(); return rows == null ? null : rows.getModel(Object.class); }
/** * Returns a list of rows. * * @param selectedOnly If true, only selected rows are returned. * @return List of rows. */ protected Iterable<Row> getRows(boolean selectedOnly) { Rows rows = grid.getRows(); return selectedOnly ? rows.getSelected() : rows.getChildren(Row.class); }
@Override public void afterInitialized(BaseComponent comp) { super.afterInitialized(comp); modelAndView = tblSrchResults.getRows().getModelAndView(HelpSearchHit.class); }
private IBaseResource getSelectedResource() { Row row = tblResources.getRows().getSelectedRow(); return row == null ? null : (IBaseResource) row.getData(); }
/** * Sets the currently viewed topic when a search result is selected. */ @EventHandler(value = "change", target = "@tblSrchResults") private void onSelect$tblSrchResults() { Row row = tblSrchResults.getRows().getSelectedRow(); setTopic((HelpTopic) row.getData()); }
@Override public void init(Grid grid) { grid.getRows().getModelAndView(AttributeItem.class).setRenderer(this); addColumn(grid, "Attribute", "30%", "@name"); addColumn(grid, "Value", "70%", "@value"); }
/** * Perform the search and display the results. */ @EventHandler(value = "click", target = "btnSearch") private void onClick$btnSearch() { modelAndView.setModel(null); tblSrchResults.getRows().destroyChildren(); String query = txtSearch.getValue(); showMessage(null); if (query != null && query.trim().length() > 0) { HelpUtil.getSearchService().search(query, helpSets, this); } else { showMessage("cwf.help.tab.search.noentry"); } }
/** * Returns the editor associated with the named property, or null if none found. * * @param propName The property name. * @param select If true, select editor's the containing row. * @return The associated property editor (may be null). */ public PropertyEditorBase<?> findEditor(String propName, boolean select) { for (Object child : gridProperties.getRows().getChildren()) { if (child instanceof Row) { Row row = (Row) child; PropertyEditorBase<?> editor = (PropertyEditorBase<?>) row.getAttribute(EDITOR_ATTR); if (editor != null && editor.getPropInfo().getId().equals(propName)) { if (select) { row.setSelected(true); } return editor; } } } return null; }