Search in sources :

Example 11 with WEditor

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);
        }
    }
}
Also used : Listcell(org.zkoss.zul.Listcell) GridField(org.compiere.model.GridField) WEditor(org.adempiere.webui.editor.WEditor)

Example 12 with WEditor

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));
        }
    }
}
Also used : WEditor(org.adempiere.webui.editor.WEditor) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent) AuFocus(org.zkoss.zk.au.out.AuFocus)

Example 13 with WEditor

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);
    }
}
Also used : GridField(org.compiere.model.GridField) WEditor(org.adempiere.webui.editor.WEditor) WEditorPopupMenu(org.adempiere.webui.editor.WEditorPopupMenu) Div(org.zkoss.zul.Div)

Example 14 with WEditor

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
}
Also used : GridField(org.compiere.model.GridField) WEditor(org.adempiere.webui.editor.WEditor)

Example 15 with WEditor

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);
}
Also used : Div(org.zkoss.zul.Div) Label(org.zkoss.zhtml.Label) Row(org.zkoss.zul.Row) GridField(org.compiere.model.GridField) WEditor(org.adempiere.webui.editor.WEditor) Component(org.zkoss.zk.ui.Component) HtmlBasedComponent(org.zkoss.zk.ui.HtmlBasedComponent)

Aggregations

WEditor (org.adempiere.webui.editor.WEditor)22 GridField (org.compiere.model.GridField)11 Component (org.zkoss.zk.ui.Component)6 Label (org.adempiere.webui.component.Label)4 WEditorPopupMenu (org.adempiere.webui.editor.WEditorPopupMenu)4 Div (org.zkoss.zul.Div)4 Listbox (org.adempiere.webui.component.Listbox)3 Hbox (org.zkoss.zul.Hbox)3 Button (org.adempiere.webui.component.Button)2 ListCell (org.adempiere.webui.component.ListCell)2 WButtonEditor (org.adempiere.webui.editor.WButtonEditor)2 WNumberEditor (org.adempiere.webui.editor.WNumberEditor)2 WStringEditor (org.adempiere.webui.editor.WStringEditor)2 AbstractADWindowPanel (org.adempiere.webui.panel.AbstractADWindowPanel)2 ADWindow (org.adempiere.webui.window.ADWindow)2 Label (org.zkoss.zhtml.Label)2 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)2 Listcell (org.zkoss.zul.Listcell)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1