use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class GridTabListItemRenderer method stopEditing.
/**
* Detach all editor and optionally set the current value of the editor as cell label.
* @param updateCellLabel
*/
public void stopEditing(boolean updateCellLabel) {
for (Entry<GridField, WEditor> entry : editors.entrySet()) {
if (entry.getValue().getComponent().getParent() != null) {
if (updateCellLabel) {
Listcell cell = (Listcell) entry.getValue().getComponent().getParent();
if (entry.getKey().getDisplayType() == DisplayType.YesNo) {
cell.setLabel("");
createReadonlyCheckbox(entry.getValue().getValue(), cell);
} else {
cell.setLabel(getDisplayText(entry.getValue().getValue(), getColumnIndex(entry.getKey())));
}
}
entry.getValue().getComponent().detach();
entry.getKey().removePropertyChangeListener(entry.getValue());
entry.getValue().removeValuechangeListener(dataBinder);
}
}
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class GridTabRowRenderer method setFocusToEditor.
/**
* set focus to first active editor
*/
public void setFocusToEditor() {
if (currentRow != null && currentRow.getParent() != null) {
WEditor toFocus = null;
WEditor firstEditor = null;
for (WEditor editor : getEditors()) {
if (editor.isHasFocus() && editor.isVisible() && editor.getComponent().getParent() != null) {
toFocus = editor;
break;
}
if (editor.isVisible() && editor.getComponent().getParent() != null) {
if (toFocus == null && editor.isReadWrite()) {
toFocus = editor;
}
if (firstEditor == null)
firstEditor = editor;
}
}
if (toFocus != null) {
Component c = toFocus.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox) c).getTextbox();
}
Clients.response(new AuFocus(c));
} else if (firstEditor != null) {
Component c = firstEditor.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox) c).getTextbox();
}
Clients.response(new AuFocus(c));
}
}
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class GridTabRowRenderer method editCurrentRow.
/**
* Enter edit mode
*/
public void editCurrentRow() {
if (currentRow != null && currentRow.getParent() != null && currentRow.isVisible() && grid != null && grid.isVisible() && grid.getParent() != null && grid.getParent().isVisible()) {
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
org.zkoss.zul.Columns columns = grid.getColumns();
int colIndex = -1;
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed() && gridField[i].isDisplayedGrid())) {
continue;
}
colIndex++;
if (editors.get(gridField[i]) == null) {
WEditor editor = WebEditorFactory.getEditor(gridField[i], true);
if (!gridField[i].isUpdateable() && gridTab.getRecord_ID() <= 0) {
editor.setReadWrite(true);
editor.dynamicDisplay();
}
editors.put(gridField[i], editor);
}
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) {
Div div = (Div) currentRow.getChildren().get(colIndex);
WEditor editor = getEditorCell(gridField[i], currentValues[i], i);
div.appendChild(editor.getComponent());
WEditorPopupMenu popupMenu = editor.getPopupMenu();
if (popupMenu != null) {
popupMenu.addMenuListener((ContextMenuListener) editor);
div.appendChild(popupMenu);
}
div.getFirstChild().setVisible(false);
//check context
if (!gridField[i].isDisplayed(true)) {
editor.setVisible(false);
}
editor.setReadWrite(gridField[i].isEditable(true));
}
}
editing = true;
GridTableListModel model = (GridTableListModel) grid.getModel();
model.setEditing(true);
}
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class GridPanel method dynamicDisplay.
/**
* Validate display properties of fields of current row
* @param col
*/
public void dynamicDisplay(int col) {
if (gridTab == null || !gridTab.isOpen()) {
return;
}
// Selective
if (col > 0) {
GridField changedField = gridTab.getField(col);
String columnName = changedField.getColumnName();
ArrayList<?> dependants = gridTab.getDependantFields(columnName);
if (dependants.size() == 0 && changedField.getCallout().length() > 0) {
return;
}
}
boolean noData = gridTab.getRowCount() == 0;
List<WEditor> list = renderer.getEditors();
for (WEditor comp : list) {
GridField mField = comp.getGridField();
if (mField != null && mField.getIncluded_Tab_ID() <= 0) {
if (noData) {
comp.setReadWrite(false);
} else {
comp.dynamicDisplay();
// r/w - check Context
boolean rw = mField.isEditable(true);
comp.setReadWrite(rw);
}
comp.setVisible(mField.isDisplayed(true));
comp.repaintComponent(true);
}
}
// all components
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class GridTabRowRenderer method stopEditing.
/**
* Detach all editor and optionally set the current value of the editor as cell label.
* @param updateCellLabel
*/
public void stopEditing(boolean updateCellLabel) {
if (!editing) {
return;
} else {
editing = false;
}
Row row = null;
for (Entry<GridField, WEditor> entry : editors.entrySet()) {
if (entry.getValue().getComponent().getParent() != null) {
Component child = entry.getValue().getComponent();
Div div = null;
while (div == null && child != null) {
Component parent = child.getParent();
if (parent instanceof Div && parent.getParent() instanceof Row)
div = (Div) parent;
else
child = parent;
}
Component component = div.getFirstChild();
if (updateCellLabel) {
if (component instanceof Label) {
Label label = (Label) component;
label.getChildren().clear();
String text = getDisplayText(entry.getValue().getValue(), entry.getValue().getGridField());
setLabelText(text, label);
} else if (component instanceof Checkbox) {
Checkbox checkBox = (Checkbox) component;
Object value = entry.getValue().getValue();
if (value != null && "true".equalsIgnoreCase(value.toString()))
checkBox.setChecked(true);
else
checkBox.setChecked(false);
}
}
component.setVisible(true);
if (row == null)
row = ((Row) div.getParent());
entry.getValue().getComponent().detach();
entry.getKey().removePropertyChangeListener(entry.getValue());
entry.getValue().removeValuechangeListener(dataBinder);
}
}
GridTableListModel model = (GridTableListModel) grid.getModel();
model.setEditing(false);
}
Aggregations