Search in sources :

Example 6 with Label

use of org.adempiere.webui.component.Label in project adempiere by adempiere.

the class WPAttributeDialog method addAttributeLine.

//	initAttribute
/**
	 * 	Add Attribute Line
	 *	@param attribute attribute
	 * 	@param product product level attribute
	 * 	@param readOnly value is read only
	 */
private void addAttributeLine(Rows rows, MAttribute attribute, boolean product, boolean readOnly) {
    log.fine(attribute + ", Product=" + product + ", R/O=" + readOnly);
    m_row++;
    Label label = new Label(attribute.getName());
    if (product)
        label.setStyle("font-weight: bold");
    if (attribute.getDescription() != null)
        label.setTooltiptext(attribute.getDescription());
    Row row = rows.newRow();
    row.appendChild(label.rightAlign());
    //
    MAttributeInstance instance = attribute.getMAttributeInstance(m_M_AttributeSetInstance_ID);
    if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attribute.getAttributeValueType())) {
        //	optional = null
        MAttributeValue[] values = attribute.getMAttributeValues();
        Listbox editor = new Listbox();
        editor.setMold("select");
        for (MAttributeValue value : values) {
            ListItem item = new ListItem(value != null ? value.getName() : "", value);
            editor.appendChild(item);
        }
        boolean found = false;
        if (instance != null) {
            for (int i = 0; i < values.length; i++) {
                if (values[i] != null && values[i].getM_AttributeValue_ID() == instance.getM_AttributeValue_ID()) {
                    editor.setSelectedIndex(i);
                    found = true;
                    break;
                }
            }
            if (found)
                log.fine("Attribute=" + attribute.getName() + " #" + values.length + " - found: " + instance);
            else
                log.warning("Attribute=" + attribute.getName() + " #" + values.length + " - NOT found: " + instance);
        } else
            //	setComboBox
            log.fine("Attribute=" + attribute.getName() + " #" + values.length + " no instance");
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attribute.getAttributeValueType())) {
        NumberBox editor = new NumberBox(false);
        if (instance != null)
            editor.setValue(instance.getValueNumber());
        else
            editor.setValue(Env.ZERO);
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    } else //	Text Field
    {
        Textbox editor = new Textbox();
        if (instance != null)
            editor.setText(instance.getValue());
        row.appendChild(editor);
        if (readOnly)
            editor.setEnabled(false);
        else
            m_editors.add(editor);
    }
}
Also used : MAttributeInstance(org.compiere.model.MAttributeInstance) MAttributeValue(org.compiere.model.MAttributeValue) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) Row(org.adempiere.webui.component.Row) ListItem(org.adempiere.webui.component.ListItem) NumberBox(org.adempiere.webui.component.NumberBox) Listbox(org.adempiere.webui.component.Listbox)

Example 7 with Label

use of org.adempiere.webui.component.Label in project adempiere by adempiere.

the class WPAttributeDialog method initAttributes.

//	init
/**
	 *	Dyanmic Init.
	 *  @return true if initialized
	 */
private boolean initAttributes() {
    Rows rows = new Rows();
    rows.setParent(centerLayout);
    if (m_M_Product_ID == 0 && !m_productWindow)
        return false;
    MAttributeSet as = null;
    if (m_M_Product_ID != 0) {
        //	Get Model
        m_product = MProduct.get(Env.getCtx(), m_M_Product_ID);
        if (m_product.getM_AttributeSetInstance_ID() > 0) {
            m_productASI = true;
            //  The product has an instance associated with it.
            if (m_M_AttributeSetInstance_ID != m_product.getM_AttributeSetInstance_ID()) {
                log.fine("Different ASI than what is specified on Product!");
            }
        } else {
            // Only show product attributes when in the product window.
            m_productASI = m_productWindow;
        }
        m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID);
        if (m_masi == null) {
            log.severe("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID);
            return false;
        }
        Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID());
        //	Get Attribute Set
        as = m_masi.getMAttributeSet();
    } else {
        int M_AttributeSet_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_AttributeSet_ID");
        m_masi = new MAttributeSetInstance(Env.getCtx(), 0, M_AttributeSet_ID, null);
        as = m_masi.getMAttributeSet();
    }
    //	Product has no Attribute Set
    if (as == null) {
        FDialog.error(m_WindowNo, this, "PAttributeNoAttributeSet");
        return false;
    }
    //  always read/write.  The two are exclusive and can't co-exists.  
    if (//	Set Instance Attributes and dialog controls
    !m_productWindow || !m_productASI) {
        if (// Instance attributes possible.  Set up controls.
        !m_productASI) {
            Row row = new Row();
            //	New/Edit - Selection
            if (//	new
            m_M_AttributeSetInstance_ID == 0)
                cbNewEdit.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "NewRecord")));
            else
                cbNewEdit.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord")));
            cbNewEdit.addEventListener(Events.ON_CHECK, this);
            row.appendChild(cbNewEdit);
            bSelect.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "SelectExisting")));
            bSelect.setImage(ServletFns.resolveThemeURL("~./images/PAttribute16.png"));
            bSelect.addEventListener(Events.ON_CLICK, this);
            row.appendChild(bSelect);
            rows.appendChild(row);
        }
        //	Add the Instance Attributes if any.  If its a product attribute set
        //  this will do nothing.
        // True = Instances
        MAttribute[] attributes = as.getMAttributes(true);
        log.fine("Instance Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(rows, attributes[i], false, false);
    }
    //  Product attributes can be shown in any window but are read/write in the Product window only.
    //  This will do nothing if it is an instance attribute set. 
    // False = products
    MAttribute[] attributes = as.getMAttributes(false);
    log.fine("Product Attributes=" + attributes.length);
    for (int i = 0; i < attributes.length; i++) addAttributeLine(rows, attributes[i], true, !m_productWindow);
    //	Lot
    if ((!m_productWindow || !m_productASI) && as.isLot()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "Lot")));
        row.appendChild(label);
        row.appendChild(fieldLotString);
        fieldLotString.setText(m_masi.getLot());
        //	M_Lot_ID
        //	int AD_Column_ID = 9771;	//	M_AttributeSetInstance.M_Lot_ID
        //	fieldLot = new VLookup ("M_Lot_ID", false,false, true, 
        //		MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir));
        String sql = "SELECT M_Lot_ID, Name " + "FROM M_Lot l " + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p " + "WHERE p.M_AttributeSet_ID=" + m_masi.getM_AttributeSet_ID() + " AND p.M_Product_ID=l.M_Product_ID)";
        fieldLot = new Listbox();
        fieldLot.setMold("select");
        KeyNamePair[] keyNamePairs = DB.getKeyNamePairs(sql, true);
        for (KeyNamePair pair : keyNamePairs) {
            fieldLot.appendItem(pair.getName(), pair.getKey());
        }
        label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "M_Lot_ID")));
        row = new Row();
        row.setParent(rows);
        m_row++;
        row.appendChild(label);
        row.appendChild(fieldLot);
        if (m_masi.getM_Lot_ID() != 0) {
            for (int i = 1; i < fieldLot.getItemCount(); i++) {
                ListItem pp = fieldLot.getItemAtIndex(i);
                if ((Integer) pp.getValue() == m_masi.getM_Lot_ID()) {
                    fieldLot.setSelectedIndex(i);
                    fieldLotString.setReadonly(true);
                    break;
                }
            }
        }
        fieldLot.addEventListener(Events.ON_SELECT, this);
        //	New Lot Button
        if (m_masi.getMAttributeSet().getM_LotCtl_ID() != 0) {
            if (MRole.getDefault().isTableAccess(MLot.Table_ID, false) && MRole.getDefault().isTableAccess(MLotCtl.Table_ID, false) && !m_masi.isExcludeLot(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                row = new Row();
                row.setParent(rows);
                m_row++;
                row.appendChild(bLot);
                bLot.addEventListener(Events.ON_CLICK, this);
            }
        }
        //	Popup 
        //			fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this));    //  popup
        mZoom = new Menuitem(Msg.getMsg(Env.getCtx(), "Zoom"), ServletFns.resolveThemeURL("~./images/Zoom16.png"));
        mZoom.addEventListener(Events.ON_CLICK, this);
        popupMenu.appendChild(mZoom);
        this.appendChild(popupMenu);
    }
    //	SerNo
    if ((!m_productWindow || !m_productASI) && as.isSerNo()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "SerNo")));
        row.appendChild(label);
        row.appendChild(fieldSerNo);
        fieldSerNo.setText(m_masi.getSerNo());
        //	New SerNo Button
        if (m_masi.getMAttributeSet().getM_SerNoCtl_ID() != 0) {
            if (MRole.getDefault().isTableAccess(MSerNoCtl.Table_ID, false) && !m_masi.isExcludeSerNo(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) {
                row = new Row();
                row.setParent(rows);
                m_row++;
                row.appendChild(bSerNo);
                bSerNo.addEventListener(Events.ON_CLICK, this);
            }
        }
    }
    //	GuaranteeDate
    if ((!m_productWindow || !m_productASI) && as.isGuaranteeDate()) {
        Row row = new Row();
        row.setParent(rows);
        m_row++;
        Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "GuaranteeDate")));
        if (m_M_AttributeSetInstance_ID == 0)
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate(true));
        else
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate());
        row.appendChild(label);
        row.appendChild(fieldGuaranteeDate);
    }
    if (m_row == 0) {
        FDialog.error(m_WindowNo, this, "PAttributeNoInfo");
        return false;
    }
    //	New/Edit Window
    if (!m_productWindow) {
        cbNewEdit.setChecked(m_M_AttributeSetInstance_ID == 0);
        cmd_newEdit();
    }
    //	Attrribute Set Instance Description
    Label label = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "Description")));
    //		label.setLabelFor(fieldDescription);
    fieldDescription.setText(m_masi.getDescription());
    fieldDescription.setReadonly(true);
    Row row = new Row();
    row.setParent(rows);
    row.appendChild(label);
    row.appendChild(fieldDescription);
    return true;
}
Also used : Label(org.adempiere.webui.component.Label) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) MAttributeSet(org.compiere.model.MAttributeSet) Menuitem(org.zkoss.zul.Menuitem) Row(org.adempiere.webui.component.Row) KeyNamePair(org.compiere.util.KeyNamePair) ListItem(org.adempiere.webui.component.ListItem) Listbox(org.adempiere.webui.component.Listbox) Rows(org.adempiere.webui.component.Rows) MAttribute(org.compiere.model.MAttribute)

Example 8 with Label

use of org.adempiere.webui.component.Label in project adempiere by adempiere.

the class WAssignmentDialog method init.

/**
	 * 	Static Init
	 * 	@throws Exception
	 */
private void init() throws Exception {
    fResource.setMold("select");
    fResource.addEventListener(Events.ON_SELECT, this);
    delete.addEventListener(Events.ON_CLICK, this);
    confirmPanel.addComponentsLeft(delete);
    confirmPanel.addActionListener(Events.ON_CLICK, this);
    //
    this.appendChild(mainPanel);
    mainPanel.makeNoStrip();
    mainPanel.setStyle("background-color: transparent");
    Rows rows = new Rows();
    mainPanel.appendChild(rows);
    Row row = new Row();
    row.appendChild(ThemeUtils.makeRightAlign(lResource));
    row.appendChild(fResource);
    row.appendChild(new Label(" "));
    rows.appendChild(row);
    row = new Row();
    row.setSpans("1, 2");
    row.appendChild(ThemeUtils.makeRightAlign(lDate));
    Div div = new Div();
    div.appendChild(fDateFrom);
    div.appendChild(fTimeFrom);
    fTimeFrom.setStyle("margin-left: 1px");
    row.appendChild(div);
    rows.appendChild(row);
    row = new Row();
    row.appendChild(ThemeUtils.makeRightAlign(lQty));
    row.appendChild(fQty);
    row.appendChild(lUOM);
    rows.appendChild(row);
    row = new Row();
    row.setSpans("1, 2");
    row.appendChild(ThemeUtils.makeRightAlign(lName));
    row.appendChild(fName);
    fName.setStyle("width: 100%");
    rows.appendChild(row);
    row = new Row();
    row.setSpans("1, 2");
    row.appendChild(ThemeUtils.makeRightAlign(lDescription));
    row.appendChild(fDescription);
    fDescription.setMultiline(true);
    fDescription.setRows(3);
    fDescription.setStyle("width: 100%");
    rows.appendChild(row);
    row = new Row();
    row.setSpans("3");
    row.appendChild(new Label(" "));
    rows.appendChild(row);
    row = new Row();
    row.setSpans("3");
    row.appendChild(confirmPanel);
    rows.appendChild(row);
//
}
Also used : Div(org.zkoss.zul.Div) Label(org.adempiere.webui.component.Label) Row(org.adempiere.webui.component.Row) Rows(org.adempiere.webui.component.Rows)

Example 9 with Label

use of org.adempiere.webui.component.Label in project adempiere by adempiere.

the class WAccountDialog method addLine.

//	initAccount
/**
	 *	Add Editor to parameterPanel alernative right/left depending on m_newRow.
	 *  Field Value changes update Editors
	 *  @param field field
	 *  @param editor editor
	 *  @param mandatory mandatory
	 */
private void addLine(GridField field, WEditor editor, boolean mandatory) {
    log.fine("Field=" + field);
    Label label = editor.getLabel();
    editor.setReadWrite(true);
    editor.setMandatory(mandatory);
    //  MField => VEditor
    field.addPropertyChangeListener(editor);
    //	label
    if (m_newRow) {
        m_row = new Row();
        m_row.setStyle("background-color: transparent");
        m_rows.appendChild(m_row);
    }
    //		else
    //			m_gbc.gridx = 2;
    Div div = new Div();
    div.setStyle("text-align: right");
    div.appendChild(label);
    m_row.appendChild(div);
    m_row.appendChild(editor.getComponent());
    editor.dynamicDisplay();
    //
    m_newRow = !m_newRow;
}
Also used : Div(org.zkoss.zul.Div) Label(org.adempiere.webui.component.Label) Row(org.adempiere.webui.component.Row)

Example 10 with Label

use of org.adempiere.webui.component.Label in project adempiere by adempiere.

the class WEMailDialog method jbInit.

/**
	 *	Static Init
	 */
void jbInit() throws Exception {
    lFrom.setValue(Msg.getMsg(Env.getCtx(), "From") + ":");
    lTo.setValue(Msg.getMsg(Env.getCtx(), "To") + ":");
    lCc.setValue(Msg.getMsg(Env.getCtx(), "Cc") + ":");
    lSubject.setValue(Msg.getMsg(Env.getCtx(), "Subject") + ":");
    lAttachment.setValue(Msg.getMsg(Env.getCtx(), "Attachment") + ":");
    fFrom.setReadonly(true);
    statusBar.setStatusDB(null);
    //
    Grid grid = new Grid();
    grid.setWidth("480px");
    grid.setStyle("margin:0; padding:0; position: absolute; align: center; valign: center;");
    grid.makeNoStrip();
    grid.setOddRowSclass("even");
    Rows rows = new Rows();
    grid.appendChild(rows);
    Row row = new Row();
    rows.appendChild(row);
    Div div = new Div();
    div.setAlign("right");
    div.appendChild(lFrom);
    row.appendChild(div);
    row.appendChild(fFrom);
    fFrom.setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    div = new Div();
    div.setAlign("right");
    div.appendChild(lTo);
    row.appendChild(div);
    row.appendChild(fUser.getComponent());
    fUser.getComponent().setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    row.appendChild(new Label(""));
    row.appendChild(fTo);
    fTo.setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    div = new Div();
    div.setAlign("right");
    div.appendChild(lCc);
    row.appendChild(div);
    row.appendChild(fCcUser.getComponent());
    fCcUser.getComponent().setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    row.appendChild(new Label(""));
    row.appendChild(fCc);
    fCc.setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    row.setSpans("2");
    row.appendChild(new Separator());
    row = new Row();
    rows.appendChild(row);
    div = new Div();
    div.setAlign("right");
    div.appendChild(lSubject);
    row.appendChild(div);
    row.appendChild(fSubject);
    fSubject.setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    row.setSpans("2");
    row.appendChild(new Separator());
    row = new Row();
    rows.appendChild(row);
    div = new Div();
    div.setAlign("right");
    div.appendChild(lAttachment);
    row.appendChild(div);
    row.appendChild(fAttachment);
    fAttachment.setWidth("100%");
    row = new Row();
    rows.appendChild(row);
    row.setSpans("2");
    row.appendChild(fMessage);
    fMessage.setWidth("100%");
    fMessage.setRows(10);
    row = new Row();
    rows.appendChild(row);
    row.setSpans("2");
    row.appendChild(confirmPanel);
    confirmPanel.addActionListener(this);
    Borderlayout layout = new Borderlayout();
    layout.setWidth("490px");
    layout.setHeight("470px");
    layout.setStyle("background-color: white; position: absolute;");
    Center center = new Center();
    center.appendChild(grid);
    layout.appendChild(center);
    center.setStyle("background-color: white");
    South south = new South();
    south.appendChild(statusBar);
    layout.appendChild(south);
    south.setStyle("background-color: white");
    this.appendChild(layout);
}
Also used : Div(org.zkoss.zul.Div) Center(org.zkoss.zul.Center) Grid(org.adempiere.webui.component.Grid) Label(org.adempiere.webui.component.Label) South(org.zkoss.zul.South) Row(org.adempiere.webui.component.Row) Borderlayout(org.zkoss.zul.Borderlayout) Separator(org.zkoss.zul.Separator) Rows(org.adempiere.webui.component.Rows)

Aggregations

Label (org.adempiere.webui.component.Label)69 Row (org.adempiere.webui.component.Row)29 Rows (org.adempiere.webui.component.Rows)28 Div (org.zkoss.zul.Div)18 Hbox (org.zkoss.zul.Hbox)17 Panel (org.adempiere.webui.component.Panel)15 Grid (org.adempiere.webui.component.Grid)13 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)11 Textbox (org.adempiere.webui.component.Textbox)11 Center (org.zkoss.zkex.zul.Center)10 Separator (org.zkoss.zul.Separator)10 North (org.zkoss.zkex.zul.North)7 Checkbox (org.adempiere.webui.component.Checkbox)6 Caption (org.zkoss.zul.Caption)6 South (org.zkoss.zul.South)6 Listbox (org.adempiere.webui.component.Listbox)5 WTableDirEditor (org.adempiere.webui.editor.WTableDirEditor)5 South (org.zkoss.zkex.zul.South)5 Vbox (org.zkoss.zul.Vbox)5 SimpleDateFormat (java.text.SimpleDateFormat)4