Search in sources :

Example 16 with Event

use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.

the class LoginPanel method init.

private void init() {
    //this.setContentSclass(ITheme.LOGIN_WINDOW_CLASS);
    Div div = new Div();
    ThemeUtils.addSclass("ad-loginpanel-header", div);
    // TODO - localization
    Label label = new Label("Login");
    ThemeUtils.addSclass("ad-loginpanel-header-text", label);
    div.appendChild(label);
    this.appendChild(div);
    Table table = new Table();
    table.setId("grdLogin");
    ThemeUtils.addSclass("ad-loginpanel-body", table);
    this.appendChild(table);
    Tr tr = new Tr();
    table.appendChild(tr);
    Td td = new Td();
    ThemeUtils.addSclass("ad-loginpanel-header-logo", td);
    tr.appendChild(td);
    td.setDynamicProperty("colspan", "2");
    Image image = new Image();
    image.setSrc(ThemeUtils.getLargeLogo());
    ThemeUtils.addSclass("ad-loginpanel-header-logo", image);
    td.appendChild(image);
    tr = new Tr();
    tr.setId("rowUser");
    table.appendChild(tr);
    td = new Td();
    tr.appendChild(td);
    ThemeUtils.addSclass("login-label", td);
    td.appendChild(lblUserId);
    td = new Td();
    ThemeUtils.addSclass("login-field", td);
    tr.appendChild(td);
    td.appendChild(txtUserId);
    tr = new Tr();
    tr.setId("rowPassword");
    table.appendChild(tr);
    td = new Td();
    tr.appendChild(td);
    ThemeUtils.addSclass("login-label", td);
    td.appendChild(lblPassword);
    td = new Td();
    ThemeUtils.addSclass("login-field", td);
    tr.appendChild(td);
    td.appendChild(txtPassword);
    tr = new Tr();
    tr.setId("rowLanguage");
    table.appendChild(tr);
    td = new Td();
    tr.appendChild(td);
    ThemeUtils.addSclass("login-label", td);
    td.appendChild(lblLanguage);
    td = new Td();
    ThemeUtils.addSclass("login-field", td);
    tr.appendChild(td);
    td.appendChild(lstLanguage);
    if (MSystem.isZKRememberUserAllowed()) {
        tr = new Tr();
        tr.setId("rowRememberMe");
        table.appendChild(tr);
        td = new Td();
        tr.appendChild(td);
        ThemeUtils.addSclass("login-label", td);
        td.appendChild(new Label(""));
        td = new Td();
        ThemeUtils.addSclass("login-field", td);
        tr.appendChild(td);
        td.appendChild(chkRememberMe);
    }
    div = new Div();
    ThemeUtils.addSclass("ad-loginpanel-footer", div);
    ConfirmPanel pnlButtons = new ConfirmPanel(false);
    pnlButtons.addActionListener(this);
    ThemeUtils.addSclass("ad-loginpanel-footer-pnl", pnlButtons);
    pnlButtons.getButton(ConfirmPanel.A_OK).setSclass("login-btn");
    div.appendChild(pnlButtons);
    this.appendChild(div);
    this.addEventListener(TokenEvent.ON_USER_TOKEN, new EventListener<Event>() {

        @Override
        public void onEvent(Event event) throws Exception {
            String[] data = (String[]) event.getData();
            try {
                int AD_Session_ID = Integer.parseInt(data[0]);
                MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
                if (session.get_ID() == AD_Session_ID) {
                    int AD_User_ID = session.getCreatedBy();
                    MUser user = MUser.get(Env.getCtx(), AD_User_ID);
                    if (user != null && user.get_ID() == AD_User_ID) {
                        String token = data[1];
                        if (BrowserToken.validateToken(session, user, token)) {
                            if (MSystem.isZKRememberUserAllowed()) {
                                txtUserId.setValue(user.getName());
                                onUserIdChange();
                                chkRememberMe.setChecked(true);
                            }
                            if (MSystem.isZKRememberPasswordAllowed()) {
                                txtPassword.setValue(token);
                                txtPassword.setAttribute("user.token.hash", token);
                                txtPassword.setAttribute("user.token.sid", AD_Session_ID);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                //safe to ignore
                logger.log(Level.INFO, e.getLocalizedMessage(), e);
            }
        }
    });
}
Also used : Table(org.zkoss.zhtml.Table) Label(org.adempiere.webui.component.Label) MSession(org.compiere.model.MSession) Image(org.zkoss.zul.Image) WrongValueException(org.zkoss.zk.ui.WrongValueException) ApplicationException(org.adempiere.webui.exception.ApplicationException) Div(org.zkoss.zhtml.Div) Td(org.zkoss.zhtml.Td) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Event(org.zkoss.zk.ui.event.Event) TokenEvent(org.adempiere.webui.event.TokenEvent) MUser(org.compiere.model.MUser) Tr(org.zkoss.zhtml.Tr)

Example 17 with Event

use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.

the class TreeSearchPanel method onPostSelect.

/**
     * don't call this directly, use internally for post selection event
     */
public void onPostSelect() {
    Clients.clearBusy();
    Event event = null;
    if (eventToFire.equals(Events.ON_CLICK))
        event = new Event(Events.ON_CLICK, tree.getSelectedItem().getTreerow());
    else
        event = new Event(eventToFire, tree);
    Events.postEvent(event);
}
Also used : Event(org.zkoss.zk.ui.event.Event) TreeDataEvent(org.zkoss.zul.event.TreeDataEvent)

Example 18 with Event

use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.

the class WOrderReceiptIssue method valueChange.

//  executeQuery
@Override
public void valueChange(ValueChangeEvent e) {
    String name = e.getPropertyName();
    Object value = e.getNewValue();
    if (value == null)
        return;
    //  PP_Order_ID
    if (name.equals("PP_Order_ID")) {
        orderField.setValue(value);
        MPPOrder pp_order = getPP_Order();
        if (pp_order != null) {
            setS_Resource_ID(pp_order.getS_Resource_ID());
            setM_Warehouse_ID(pp_order.getM_Warehouse_ID());
            setDeliveredQty(pp_order.getQtyDelivered());
            setOrderedQty(pp_order.getQtyOrdered());
            //m_PP_order.getQtyOrdered().subtract(m_PP_order.getQtyDelivered());
            setQtyBatchs(pp_order.getQtyBatchs());
            setQtyBatchSize(pp_order.getQtyBatchSize());
            setOpenQty(pp_order.getQtyOrdered().subtract(pp_order.getQtyDelivered()));
            setToDeliverQty(getOpenQty());
            setM_Product_ID(pp_order.getM_Product_ID());
            MProduct m_product = MProduct.get(Env.getCtx(), pp_order.getM_Product_ID());
            setC_UOM_ID(m_product.getC_UOM_ID());
            setOrder_UOM_ID(pp_order.getC_UOM_ID());
            //Default ASI defined from the Parent BOM Order
            setM_AttributeSetInstance_ID(pp_order.getMPPOrderBOM().getM_AttributeSetInstance_ID());
            //default to first entry - isBackflush
            pickcombo.setSelectedIndex(0);
            Event ev = new Event(Events.ON_CHANGE, pickcombo);
            try {
                onEvent(ev);
            } catch (Exception e1) {
                throw new AdempiereException(e1);
            }
        }
    }
    if (name.equals(toDeliverQty.getColumnName()) || name.equals(scrapQtyField.getColumnName())) {
        if (getPP_Order_ID() > 0 && isBackflush()) {
            executeQuery();
        }
    }
}
Also used : MProduct(org.compiere.model.MProduct) AdempiereException(org.adempiere.exceptions.AdempiereException) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Event(org.zkoss.zk.ui.event.Event) WTableModelEvent(org.adempiere.webui.event.WTableModelEvent) MPPOrder(org.eevolution.model.MPPOrder) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 19 with Event

use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.

the class WMRPDetailed method statInit.

private void statInit() throws Exception {
    //Resource Lookup 
    // Base Language
    Language language = Language.getLoginLanguage();
    MLookup resourceL = MLookupFactory.get(getCtx(), p_WindowNo, MColumn.getColumn_ID(MResource.Table_Name, MResource.COLUMNNAME_S_Resource_ID), DisplayType.TableDir, language, MResource.COLUMNNAME_S_Resource_ID, 0, false, MResource.Table_Name + "." + MResource.COLUMNNAME_ManufacturingResourceType + "= '" + MResource.MANUFACTURINGRESOURCETYPE_Plant + "'");
    fResource_ID = new WSearchEditor(MPPMRP.COLUMNNAME_S_Resource_ID, false, false, true, resourceL) {

        private final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    fPlanner_ID = new WSearchEditor(MPPMRP.COLUMNNAME_Planner_ID, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPProductPlanning.Table_Name, MPPMRP.COLUMNNAME_Planner_ID), DisplayType.Table)) {

        private final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    fWarehouse_ID = new WSearchEditor(MPPMRP.COLUMNNAME_M_Warehouse_ID, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MWarehouse.Table_Name, MPPMRP.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir)) {

        private final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    fMaster.setSelected(false);
    fMaster.setEnabled(false);
    fMRPReq.setSelected(false);
    fMRPReq.setEnabled(false);
    fCreatePlan.setSelected(false);
    fCreatePlan.setEnabled(false);
    lUOM.setText(Msg.translate(getCtx(), MUOM.COLUMNNAME_C_UOM_ID));
    fUOM.setReadonly(true);
    lType.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Policy));
    fType.setReadonly(true);
    lOrderPeriod.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Period));
    fOrderPeriod.setReadWrite(false);
    lTimefence.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_TimeFence));
    fTimefence.setReadWrite(false);
    lLeadtime.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_DeliveryTime_Promised));
    fLeadtime.setReadWrite(false);
    lMinOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Min));
    fMinOrd.setReadWrite(false);
    lMaxOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Max));
    fMaxOrd.setReadWrite(false);
    lOrdMult.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Pack));
    fOrdMult.setReadWrite(false);
    lOrderQty.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Qty));
    fOrderQty.setReadWrite(false);
    lYield.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Yield));
    fYield.setReadWrite(false);
    lOnhand.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyOnHand));
    fOnhand.setReadWrite(false);
    lSafetyStock.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_SafetyStock));
    fSafetyStock.setReadWrite(false);
    lReserved.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyReserved));
    fReserved.setReadWrite(false);
    lAvailable.setText(Msg.translate(getCtx(), "QtyAvailable"));
    fAvailable.setReadWrite(false);
    lOrdered.setText(Msg.translate(getCtx(), MPPOrder.COLUMNNAME_QtyOrdered));
    fOrdered.setReadWrite(false);
    //Product Lookup
    fProduct_ID = new WSearchEditor(MPPMRP.COLUMNNAME_M_Product_ID, true, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProduct.Table_Name, MPPMRP.COLUMNNAME_M_Product_ID), DisplayType.Search)) {

        private final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    fMaster.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_IsMPS));
    fMRPReq.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_IsRequiredMRP));
    fCreatePlan.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_IsCreatePlan));
    //AttributeSet Button
    fAttrSetInstance_ID = new Button() {

        private final long serialVersionUID = 1L;

        private Object m_value;

        public void setLabel(String text) {
            if (text == null) {
                text = "---";
            }
            if (text.length() > 23) {
                text = text.substring(0, 20) + "...";
            }
            super.setLabel(text);
        }

        public void setValue(Object arg0) {
            m_value = arg0;
            int i = (arg0 instanceof Integer) ? ((Integer) arg0).intValue() : 0;
            if (i == 0) {
                setLabel(null);
            }
        }

        public Object getValue() {
            return m_value;
        }
    };
    fAttrSetInstance_ID.addActionListener(new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            selectAttributeSetInstance();
        }
    });
    //
    fDateFrom.getComponent().setTooltiptext(Msg.translate(getCtx(), MLot.COLUMNNAME_DateFrom));
    fDateTo.getComponent().setTooltiptext(Msg.translate(getCtx(), MLot.COLUMNNAME_DateTo));
    fSupplyType = new WSearchEditor(MPPMRP.COLUMNNAME_TypeMRP, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPMRP.Table_Name, MPPMRP.COLUMNNAME_TypeMRP), DisplayType.List));
    Rows rows = null;
    Row row = null;
    rows = new Rows();
    rows.setParent(parameterPanel);
    //  1st Row
    row = rows.newRow();
    row.appendChild(lProduct_ID.rightAlign());
    row.appendChild(fProduct_ID.getComponent());
    row.appendChild(lUOM.rightAlign());
    row.appendChild(fUOM);
    row.appendChild(lType.rightAlign());
    row.appendChild(fType);
    //  2nd Row
    row = rows.newRow();
    row.appendChild(lAttrSetInstance_ID.rightAlign());
    row.appendChild(fAttrSetInstance_ID);
    row.appendChild(lOnhand.rightAlign());
    row.appendChild(fOnhand.getComponent());
    row.appendChild(lOrderPeriod.rightAlign());
    row.appendChild(fOrderPeriod.getComponent());
    //  3rd Row
    row = rows.newRow();
    row.appendChild(lPlanner_ID.rightAlign());
    row.appendChild(fPlanner_ID.getComponent());
    row.appendChild(lSafetyStock.rightAlign());
    row.appendChild(fSafetyStock.getComponent());
    row.appendChild(lMinOrd.rightAlign());
    row.appendChild(fMinOrd.getComponent());
    //  4th Row
    row = rows.newRow();
    row.appendChild(lWarehouse_ID.rightAlign());
    row.appendChild(fWarehouse_ID.getComponent());
    row.appendChild(lReserved.rightAlign());
    row.appendChild(fReserved.getComponent());
    row.appendChild(lMaxOrd.rightAlign());
    row.appendChild(fMaxOrd.getComponent());
    //  5th Row
    row = rows.newRow();
    row.appendChild(lResource_ID.rightAlign());
    row.appendChild(fResource_ID.getComponent());
    row.appendChild(lAvailable.rightAlign());
    row.appendChild(fAvailable.getComponent());
    row.appendChild(lOrdMult.rightAlign());
    row.appendChild(fOrdMult.getComponent());
    //  6th Row
    row = rows.newRow();
    row.appendChild(lDateFrom.rightAlign());
    row.appendChild(fDateFrom.getComponent());
    row.appendChild(lOrdered.rightAlign());
    row.appendChild(fOrdered.getComponent());
    row.appendChild(lOrderQty.rightAlign());
    row.appendChild(fOrderQty.getComponent());
    //  7th Row
    row = rows.newRow();
    row.appendChild(lDateTo.rightAlign());
    row.appendChild(fDateTo.getComponent());
    row.appendChild(new Space());
    row.appendChild(new Space());
    row.appendChild(lTimefence.rightAlign());
    row.appendChild(fTimefence.getComponent());
    //  8th Row
    row = rows.newRow();
    row.appendChild(new Space());
    row.appendChild(fMaster);
    row.appendChild(new Space());
    row.appendChild(fCreatePlan);
    row.appendChild(lLeadtime.rightAlign());
    row.appendChild(fLeadtime.getComponent());
    //  9th Row
    row = rows.newRow();
    row.appendChild(new Space());
    row.appendChild(new Space());
    row.appendChild(new Space());
    row.appendChild(fMRPReq);
    row.appendChild(lYield.rightAlign());
    row.appendChild(fYield.getComponent());
}
Also used : Space(org.zkoss.zul.Space) MLookup(org.compiere.model.MLookup) DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException) Language(org.compiere.util.Language) Button(org.adempiere.webui.component.Button) WSearchEditor(org.adempiere.webui.editor.WSearchEditor) Event(org.zkoss.zk.ui.event.Event) WTableModelEvent(org.adempiere.webui.event.WTableModelEvent) ListDataEvent(org.zkoss.zul.event.ListDataEvent) EventListener(org.zkoss.zk.ui.event.EventListener) Row(org.adempiere.webui.component.Row) Rows(org.adempiere.webui.component.Rows)

Example 20 with Event

use of org.zkoss.zk.ui.event.Event in project adempiere by adempiere.

the class WGraph method render.

// loadData
private void render(JFreeChart chart) {
    ChartRenderingInfo info = new ChartRenderingInfo();
    int width = 560;
    int height = 400;
    if (zoomFactor > 0) {
        width = width * zoomFactor / 100;
        height = height * zoomFactor / 100;
    }
    if (m_hideTitle) {
        chart.setTitle("");
    }
    BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info);
    try {
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
        AImage image = new AImage("", bytes);
        Imagemap myImage = new Imagemap();
        myImage.setContent(image);
        if (panel.getPanelchildren() != null) {
            panel.getPanelchildren().getChildren().clear();
            panel.getPanelchildren().appendChild(myImage);
        } else {
            Panelchildren pc = new Panelchildren();
            panel.appendChild(pc);
            pc.appendChild(myImage);
        }
        int count = 0;
        for (Iterator<?> it = info.getEntityCollection().getEntities().iterator(); it.hasNext(); ) {
            ChartEntity entity = (ChartEntity) it.next();
            String key = null;
            if (entity instanceof CategoryItemEntity) {
                Comparable<?> colKey = ((CategoryItemEntity) entity).getColumnKey();
                if (colKey != null) {
                    key = colKey.toString();
                }
            } else if (entity instanceof PieSectionEntity) {
                Comparable<?> sectionKey = ((PieSectionEntity) entity).getSectionKey();
                if (sectionKey != null) {
                    key = sectionKey.toString();
                }
            }
            if (key == null) {
                continue;
            }
            Area area = new Area();
            myImage.appendChild(area);
            area.setCoords(entity.getShapeCoords());
            area.setShape(entity.getShapeType());
            area.setTooltiptext(entity.getToolTipText());
            area.setId(count + "_WG_" + key);
            count++;
        }
        myImage.addEventListener(Events.ON_CLICK, new EventListener() {

            public void onEvent(Event event) throws Exception {
                MouseEvent me = (MouseEvent) event;
                String areaId = me.getArea();
                if (areaId != null) {
                    for (int i = 0; i < list.size(); i++) {
                        String s = "_WG_" + list.get(i).getLabel();
                        if (areaId.endsWith(s)) {
                            chartMouseClicked(i);
                            return;
                        }
                    }
                }
            }
        });
    } catch (Exception e) {
        log.log(Level.SEVERE, "", e);
    }
}
Also used : MouseEvent(org.zkoss.zk.ui.event.MouseEvent) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) Panelchildren(org.zkoss.zul.Panelchildren) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) Area(org.zkoss.zul.Area) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) AImage(org.zkoss.image.AImage) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Event(org.zkoss.zk.ui.event.Event) MouseEvent(org.zkoss.zk.ui.event.MouseEvent) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartEntity(org.jfree.chart.entity.ChartEntity) EventListener(org.zkoss.zk.ui.event.EventListener) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity) PieSectionEntity(org.jfree.chart.entity.PieSectionEntity) Imagemap(org.zkoss.zul.Imagemap)

Aggregations

Event (org.zkoss.zk.ui.event.Event)60 EventListener (org.zkoss.zk.ui.event.EventListener)42 JSONObject (org.json.simple.JSONObject)11 ForwardEvent (org.zkoss.zk.ui.event.ForwardEvent)9 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)7 Component (org.zkoss.zk.ui.Component)7 CheckEvent (org.zkoss.zk.ui.event.CheckEvent)7 LegendObject (au.org.ala.legend.LegendObject)6 IOException (java.io.IOException)6 SQLException (java.sql.SQLException)6 JSONParser (org.json.simple.parser.JSONParser)6 Center (org.zkoss.zul.Center)6 MapLayer (au.org.emii.portal.menu.MapLayer)5 JSONArray (org.json.simple.JSONArray)5 Borderlayout (org.zkoss.zul.Borderlayout)5 Tabpanel (org.adempiere.webui.component.Tabpanel)4 WTableModelEvent (org.adempiere.webui.event.WTableModelEvent)4 ParseException (org.json.simple.parser.ParseException)4 Div (org.zkoss.zul.Div)4 North (org.zkoss.zul.North)4