Search in sources :

Example 1 with WEditor

use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.

the class WBrowserSearch method formatEditor.

public void formatEditor(CEditor editor1, CEditor editor2) {
    WEditor editor = (WEditor) editor1;
    WEditor editorTo = (WEditor) editor2;
    //	
    configColumns(editor, editorTo);
    WEditorPopupMenu popupMenu;
    // Editor
    //setup editor context menu
    popupMenu = editor.getPopupMenu();
    if (popupMenu != null) {
        popupMenu.addMenuListener((ContextMenuListener) editor);
        mainPanel.appendChild(popupMenu);
    }
    //streach component to fill grid cell
    editor.fillHorizontal();
    Div div = new Div();
    div.setAlign("right");
    Label label = editor.getLabel();
    div.appendChild(label);
    if (label.getDecorator() != null)
        div.appendChild(label.getDecorator());
    //	
    currentRow.appendChild(div);
    //	Add Child
    cols += 2;
    //	
    Hbox box;
    if (editorTo != null) {
        box = new Hbox();
        box.appendChild(editor.getComponent());
    } else {
        currentRow.appendChild(editor.getComponent());
        m_separators.add(null);
        return;
    }
    // EditorTo
    //setup editor context menu
    popupMenu = editorTo.getPopupMenu();
    if (popupMenu != null) {
        popupMenu.addMenuListener((ContextMenuListener) editor2);
        mainPanel.appendChild(popupMenu);
    }
    //
    editorTo.fillHorizontal();
    Label separator = new Label(" - ");
    m_separators.add(separator);
    box.appendChild(separator);
    box.appendChild(editorTo.getComponent());
    //	Add
    currentRow.appendChild(box);
}
Also used : Div(org.zkoss.zul.Div) Hbox(org.zkoss.zul.Hbox) Label(org.adempiere.webui.component.Label) WEditor(org.adempiere.webui.editor.WEditor) WEditorPopupMenu(org.adempiere.webui.editor.WEditorPopupMenu)

Example 2 with WEditor

use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.

the class ListPanel method dynamicDisplay.

/**
	 * validate the display properties of fields of current row
	 * @param col
	 */
public void dynamicDisplay(int col) {
    if (!gridTab.isOpen()) {
        return;
    }
    //  Selective
    if (col > 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 {
                //  r/w - check Context
                boolean rw = mField.isEditable(true);
                comp.setReadWrite(rw);
                comp.dynamicDisplay();
            }
        }
    }
//  all components
}
Also used : WEditor(org.adempiere.webui.editor.WEditor) GridField(org.compiere.model.GridField)

Example 3 with WEditor

use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.

the class GridTabListItemRenderer method getEditorCell.

private Listcell getEditorCell(GridField gridField, Object object, int i) {
    Listcell cell = new Listcell("", null);
    WEditor editor = editors.get(gridField);
    if (editor != null) {
        if (editor instanceof WButtonEditor) {
            Object window = SessionManager.getAppDesktop().findWindow(windowNo);
            if (window != null && window instanceof ADWindow) {
                AbstractADWindowPanel windowPanel = ((ADWindow) window).getADWindowPanel();
                ((WButtonEditor) editor).addActionListener(windowPanel);
            }
        } else {
            editor.addValueChangeListener(dataBinder);
        }
        cell.appendChild(editor.getComponent());
        if (editor.getComponent() instanceof Checkbox || editor.getComponent() instanceof Image) {
            cell.setStyle("text-align:center");
        } else if (DisplayType.isNumeric(gridField.getDisplayType())) {
            cell.setStyle("text-align:right");
        }
        gridField.addPropertyChangeListener(editor);
        editor.setValue(gridField.getValue());
        WEditorPopupMenu popupMenu = editor.getPopupMenu();
        if (popupMenu != null) {
            popupMenu.addMenuListener((ContextMenuListener) editor);
            cell.appendChild(popupMenu);
        }
        //streach component to fill grid cell
        editor.fillHorizontal();
    }
    return cell;
}
Also used : WButtonEditor(org.adempiere.webui.editor.WButtonEditor) Listcell(org.zkoss.zul.Listcell) ADWindow(org.adempiere.webui.window.ADWindow) AbstractADWindowPanel(org.adempiere.webui.panel.AbstractADWindowPanel) WEditor(org.adempiere.webui.editor.WEditor) Image(org.zkoss.zul.Image) WEditorPopupMenu(org.adempiere.webui.editor.WEditorPopupMenu)

Example 4 with WEditor

use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.

the class GridTabRowRenderer method getEditorCell.

/**
	 * 
	 * @param gridField
	 * @param object
	 * @param i
	 * @return
	 */
private WEditor getEditorCell(GridField gridField, Object object, int i) {
    WEditor editor = editors.get(gridField);
    if (editor != null) {
        if (editor instanceof WButtonEditor) {
            if (m_windowPanel != null) {
                ((WButtonEditor) editor).addActionListener(m_windowPanel);
            } else {
                Object window = SessionManager.getAppDesktop().findWindow(windowNo);
                if (window != null && window instanceof ADWindow) {
                    AbstractADWindowPanel windowPanel = ((ADWindow) window).getADWindowPanel();
                    ((WButtonEditor) editor).addActionListener(windowPanel);
                }
            }
        } else {
            editor.addValueChangeListener(dataBinder);
        }
        gridField.removePropertyChangeListener(editor);
        gridField.addPropertyChangeListener(editor);
        editor.setValue(gridField.getValue());
        //streach component to fill grid cell
        if (editor.getComponent() instanceof Textbox)
            ((HtmlBasedComponent) editor.getComponent()).setWidth("98%");
        else
            editor.fillHorizontal();
    }
    return editor;
}
Also used : WButtonEditor(org.adempiere.webui.editor.WButtonEditor) ADWindow(org.adempiere.webui.window.ADWindow) AbstractADWindowPanel(org.adempiere.webui.panel.AbstractADWindowPanel) WEditor(org.adempiere.webui.editor.WEditor)

Example 5 with WEditor

use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.

the class FindWindow method addSelectionColumn.

// setValues
/**
     *  Add Selection Column to first Tab
     *  @param mField field
    **/
public void addSelectionColumn(GridField mField) {
    log.config(mField.getHeader());
    int displayLength = mField.getDisplayLength();
    if (displayLength <= 0 || displayLength > FIELDLENGTH)
        mField.setDisplayLength(FIELDLENGTH);
    else
        displayLength = 0;
    //  Editor
    WEditor editor = null;
    Label label = null;
    if (mField.isRangeLookup()) {
        Hbox box = new Hbox();
        editor = WebEditorFactory.getEditor(mField, false);
        label = editor.getLabel();
        editor.setMandatory(false);
        editor.setReadWrite(true);
        editor.dynamicDisplay();
        Component fieldLabel = editor.getComponent();
        box.appendChild(editor.getComponent());
        rangeFirstEditor.add(mField.getColumnName());
        // The Editor
        WEditor toRangeEditor = WebEditorFactory.getEditor(mField, false);
        // New Field value to be updated to editor
        toRangeEditor.setMandatory(false);
        toRangeEditor.setReadWrite(true);
        toRangeEditor.dynamicDisplay();
        //
        m_sEditors2.add(toRangeEditor);
        Label separator = new Label(" - ");
        box.appendChild(separator);
        Component fieldLabel1 = toRangeEditor.getComponent();
        box.appendChild(toRangeEditor.getComponent());
        if (//  set it back
        displayLength > 0)
            mField.setDisplayLength(displayLength);
        //
        if (isTwoColumns) {
            if (!isPair)
                panel = new Row();
        } else
            panel = new Row();
        panel.appendChild(LayoutUtils.makeRightAlign(label));
        panel.appendChild(box);
        contentSimpleRows.appendChild(panel);
        fieldLabel.addEventListener(Events.ON_OK, this);
        fieldLabel1.addEventListener(Events.ON_OK, this);
    } else {
        editor = WebEditorFactory.getEditor(mField, false);
        label = editor.getLabel();
        editor.setMandatory(false);
        editor.setReadWrite(true);
        editor.dynamicDisplay();
        Component fieldLabel = editor.getComponent();
        if (//  set it back
        displayLength > 0)
            mField.setDisplayLength(displayLength);
        //
        if (isTwoColumns) {
            if (!isPair)
                panel = new Row();
        } else
            panel = new Row();
        panel.appendChild(LayoutUtils.makeRightAlign(label));
        panel.appendChild(fieldLabel);
        contentSimpleRows.appendChild(panel);
        fieldLabel.addEventListener(Events.ON_OK, this);
        m_sEditors2.add(null);
    }
    m_sEditors.add(editor);
}
Also used : Hbox(org.zkoss.zul.Hbox) Label(org.adempiere.webui.component.Label) WEditor(org.adempiere.webui.editor.WEditor) Row(org.adempiere.webui.component.Row) Component(org.zkoss.zk.ui.Component)

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