use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class GridTabRowRenderer method render.
/**
* @param row
* @param data
* @see RowRenderer#render(Row, Object)
*/
public void render(Row row, Object[] data, int index) throws Exception {
//don't render if not visible
if (gridPanel != null && !gridPanel.isVisible()) {
return;
}
if (grid == null)
grid = (Grid) row.getParent().getParent();
if (rowListener == null)
rowListener = new RowListener((Grid) row.getParent().getParent());
currentValues = data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
Grid grid = (Grid) row.getParent().getParent();
org.zkoss.zul.Columns columns = grid.getColumns();
int rowIndex = row.getParent().getChildren().indexOf(row);
if (paging != null && paging.getPageSize() > 0) {
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
int colIndex = -1;
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed())) {
continue;
}
colIndex++;
Div div = new Div();
ThemeUtils.addSclass("ad-gridtabrowrenderer", div);
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) {
Component component = getDisplayComponent(currentValues[i], gridField[i]);
div.appendChild(component);
// if (compCount == 1) {
//add hidden input component to help focusing to row
div.appendChild(createAnchorInput());
if (DisplayType.YesNo == gridField[i].getDisplayType() || DisplayType.Image == gridField[i].getDisplayType()) {
ThemeUtils.addSclass("yes-no", div);
//divStyle += "text-align:center; ";
} else if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
ThemeUtils.addSclass("numeric", div);
//divStyle += "text-align:right; ";
}
}
div.setAttribute("columnName", gridField[i].getColumnName());
div.addEventListener(Events.ON_CLICK, rowListener);
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
row.appendChild(div);
}
if (rowIndex == gridTab.getCurrentRow()) {
setCurrentRow(row);
}
row.addEventListener(Events.ON_OK, rowListener);
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class Group method autoFirstCell.
private GroupHeader autoFirstCell() {
Component cell = getFirstChild();
if (cell == null || cell instanceof GroupHeader) {
if (cell == null)
cell = new GroupHeader();
cell.applyProperties();
cell.setParent(this);
return (GroupHeader) cell;
}
throw new UiException("Unsupported child for setLabel: " + cell);
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class DrillCommand method service.
public boolean service(AuRequest request, boolean everError) {
if (!DrillEvent.ON_DRILL_ACROSS.equals(request.getCommand()) && !DrillEvent.ON_DRILL_DOWN.equals(request.getCommand()))
return false;
final Map<?, ?> map = request.getData();
JSONArray data = (JSONArray) map.get("data");
final Component comp = request.getComponent();
if (comp == null)
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
if (data == null || data.size() < 2)
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { Objects.toString(data), this });
String columnName = (String) data.get(0);
String tableName = MQuery.getZoomTableName(columnName);
String code = (String) data.get(1);
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
Events.postEvent(new DrillEvent(request.getCommand(), comp, query));
return true;
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class GridTabRowRenderer method getDisplayComponent.
private Component getDisplayComponent(Object value, GridField gridField) {
Component component;
if (gridField.getDisplayType() == DisplayType.YesNo) {
component = createReadonlyCheckbox(value);
} else {
String text = getDisplayText(value, gridField);
Label label = new Label();
setLabelText(text, label);
component = label;
}
return component;
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class GridPanel method focusToRow.
private void focusToRow(org.zkoss.zul.Row row) {
if (renderer.isEditing()) {
if (columnOnClick != null && columnOnClick.trim().length() > 0) {
setFocusToField(columnOnClick);
columnOnClick = null;
} else {
renderer.setFocusToEditor();
}
} else {
Component cmp = null;
List<?> childs = row.getChildren();
for (Object o : childs) {
Component c = (Component) o;
if (!c.isVisible())
continue;
c = c.getFirstChild();
if (c == null)
continue;
if (c.getNextSibling() != null) {
cmp = c.getNextSibling();
break;
}
}
if (cmp != null)
Clients.response(new AuScript(null, "scrollToRow('" + cmp.getUuid() + "');"));
if (columnOnClick != null && columnOnClick.trim().length() > 0) {
List<?> list = row.getChildren();
for (Object element : list) {
if (element instanceof Div) {
Div div = (Div) element;
if (columnOnClick.equals(div.getAttribute("columnName"))) {
cmp = div.getFirstChild().getNextSibling();
Clients.response(new AuScript(null, "scrollToRow('" + cmp.getUuid() + "');"));
break;
}
}
}
columnOnClick = null;
}
}
}
Aggregations