Search in sources :

Example 1 with MPOSKeyLayout

use of org.compiere.model.MPOSKeyLayout in project adempiere by adempiere.

the class WPOSKeyPanel method createPanel.

/** 
	 * Create Panel
	 * @param C_POSKeyLayout_ID
	 * @return
	 * @return Panel
	 */
public Panel createPanel(int C_POSKeyLayout_ID) {
    Panel card = new Panel();
    card.setWidth("100%");
    card.setStyle("overflow:AUTO");
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    // Removal panel static
    card = createButton(C_POSKeyLayout_ID);
    panelMap.put(C_POSKeyLayout_ID, card);
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    //	Content
    for (MPOSKey key : keys) {
        if (key.getSubKeyLayout_ID() > 0) {
            Panel subcard = new Panel();
            subcard = createButton(key.getSubKeyLayout_ID());
            panelMap.put(key.getSubKeyLayout_ID(), subcard);
            appendChild(subcard);
            subcard.setVisible(false);
        }
    }
    return card;
}
Also used : Panel(org.adempiere.webui.component.Panel) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) MPOSKey(org.compiere.model.MPOSKey)

Example 2 with MPOSKeyLayout

use of org.compiere.model.MPOSKeyLayout in project adempiere by adempiere.

the class WPOSKeyPanel method createButton.

/**
	 * Create Buttton For Keyboard
	 * @param C_POSKeyLayout_ID
	 * @param m_txtCalc
	 * @return
	 * @return Panel
	 */
private Panel createButton(int C_POSKeyLayout_ID, String m_txtCalc) {
    // already added
    if (keymap.containsKey(C_POSKeyLayout_ID)) {
        return null;
    }
    Panel card = new Panel();
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    Color stdColor = Color.lightGray;
    if (keyLayout.getAD_PrintColor_ID() != 0) {
        MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
        stdColor = color.getColor();
    }
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
    keymap.put(C_POSKeyLayout_ID, map);
    //	Min Columns
    int COLUMNS = 3;
    //	Min Rows
    int ROWS = 3;
    int noKeys = keys.length;
    int cols = keyLayout.getColumns();
    if (cols == 0)
        cols = COLUMNS;
    int buttons = 0;
    log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
    //	Content
    Panel content = new Panel();
    for (MPOSKey key : keys) {
        map.put(key.getC_POSKey_ID(), key);
        Color keyColor = stdColor;
        if (key.getAD_PrintColor_ID() != 0) {
            MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
            keyColor = color.getColor();
        }
        log.fine("#" + map.size() + " - " + keyColor);
        Panel button = new Panel();
        Label label = new Label(key.getName());
        label.setStyle("margin: 25px 0px 00px 0px; top:20px; font-size:medium; font-weight: bold;");
        label.setHeight("100%");
        button.appendChild(label);
        button.setClass("z-button");
        button.setStyle("float:left; white-space: pre-line;text-align:center; margin:0.4% 1%; Background-color:rgb(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + "); border: 2px outset #CCC; " + "background: -moz-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);" + "background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(247,247,247,1)), color-stop(7%, rgba(255,255,255,0.93)), color-stop(15%, rgba(186,186,186,0.25)), color-stop(100%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1)));" + "background: -webkit-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);");
        button.setHeight("55px");
        button.setWidth("55px");
        button.setAction("onClick : text_action.textEvent('" + m_txtCalc + "', '" + key.getText() + "', '" + this.keyBoardType + "')");
        button.setId("" + key.getC_POSKey_ID());
        button.addEventListener("onClick", this);
        int size = 1;
        if (key.getSpanX() > 1) {
            size = key.getSpanX();
        }
        if (key.getSpanY() > 1) {
            size = size * key.getSpanY();
        }
        buttons = buttons + size;
        content.appendChild(button);
    }
    int rows = Math.max((buttons / cols), ROWS);
    if (buttons % cols > 0)
        rows = rows + 1;
    for (int i = buttons; i < rows * cols; i++) {
        Panel button = new Panel();
        button.setStyle("float:left; text-align:center; margin:0.4% 1%;");
        button.setHeight("55px");
        button.setWidth("55px");
        content.appendChild(button);
    }
    card.appendChild(content);
    return card;
}
Also used : Panel(org.adempiere.webui.component.Panel) HashMap(java.util.HashMap) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) MPrintColor(org.compiere.print.MPrintColor) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) Label(org.adempiere.webui.component.Label) MPOSKey(org.compiere.model.MPOSKey)

Example 3 with MPOSKeyLayout

use of org.compiere.model.MPOSKeyLayout in project adempiere by adempiere.

the class WPOSKeyPanel method createButton.

/**
	 * Create Button
	 * @param C_POSKeyLayout_ID
	 * @return
	 * @return Panel
	 */
public Panel createButton(int C_POSKeyLayout_ID) {
    if (keymap.containsKey(C_POSKeyLayout_ID)) {
        return null;
    }
    Panel card = new Panel();
    card.setWidth("100%");
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    Color stdColor = Color.lightGray;
    if (keyLayout.getAD_PrintColor_ID() != 0) {
        MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
        stdColor = color.getColor();
    }
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
    keymap.put(C_POSKeyLayout_ID, map);
    //	Min Columns
    int COLUMNS = 3;
    //	Min Rows
    int ROWS = 3;
    int noKeys = keys.length;
    int cols = keyLayout.getColumns();
    if (cols == 0)
        cols = COLUMNS;
    int buttons = 0;
    log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
    //	Content
    Panel content = new Panel();
    for (MPOSKey key : keys) {
        if (!key.getName().equals("")) {
            map.put(key.getC_POSKey_ID(), key);
            Color keyColor = stdColor;
            if (key.getAD_PrintColor_ID() != 0) {
                MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
                keyColor = color.getColor();
            }
            log.fine("#" + map.size() + " - " + keyColor);
            Panel button = new Panel();
            Label label = new Label(key.getName());
            Center nt = new Center();
            South st = new South();
            Borderlayout mainLayout = new Borderlayout();
            if (key.getAD_Image_ID() != 0) {
                MImage m_mImage = MImage.get(Env.getCtx(), key.getAD_Image_ID());
                AImage img = null;
                byte[] data = m_mImage.getData();
                if (data != null && data.length > 0) {
                    try {
                        img = new AImage(null, data);
                    } catch (Exception e) {
                    }
                }
                Image bImg = new Image();
                bImg.setContent(img);
                bImg.setWidth("66%");
                bImg.setHeight("80%");
                nt.appendChild(bImg);
            }
            label.setStyle("word-wrap: break-word; white-space: pre-line;margin: 25px 0px 0px 0px; top:20px; font-size:10pt; font-weight: bold;color: #FFF;");
            label.setHeight("100%");
            button.setHeight("100px");
            st.appendChild(label);
            button.setClass("z-button");
            button.setStyle("float:left; white-space: pre-line;text-align:center; margin:0.4% 1%; Background-color:rgb(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + "); border: 2px outset #CCC; " + "background: -moz-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);" + "background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(247,247,247,1)), color-stop(7%, rgba(255,255,255,0.93)), color-stop(15%, rgba(186,186,186,0.25)), color-stop(100%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1)));" + "background: -webkit-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);");
            mainLayout.appendChild(nt);
            mainLayout.appendChild(st);
            mainLayout.setStyle("background-color: transparent");
            nt.setStyle("background-color: transparent");
            st.setStyle("clear: both; background-color: #333; opacity: 0.6;");
            st.setZindex(99);
            button.appendChild(mainLayout);
            button.setId("" + key.getC_POSKey_ID());
            button.addEventListener("onClick", this);
            int size = 1;
            if (key.getSpanX() > 1) {
                size = key.getSpanX();
                button.setWidth("96%");
            } else
                button.setWidth(90 / cols + "%");
            if (key.getSpanY() > 1) {
                size = size * key.getSpanY();
            }
            buttons = buttons + size;
            content.appendChild(button);
        }
    }
    int rows = Math.max((buttons / cols), ROWS);
    if (buttons % cols > 0)
        rows = rows + 1;
    card.appendChild(content);
    return card;
}
Also used : Center(org.zkoss.zkex.zul.Center) HashMap(java.util.HashMap) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) Label(org.adempiere.webui.component.Label) South(org.zkoss.zkex.zul.South) Borderlayout(org.adempiere.webui.component.Borderlayout) AImage(org.zkoss.image.AImage) Image(org.zkoss.zul.Image) MImage(org.compiere.model.MImage) Panel(org.adempiere.webui.component.Panel) MImage(org.compiere.model.MImage) MPrintColor(org.compiere.print.MPrintColor) AImage(org.zkoss.image.AImage) MPOSKey(org.compiere.model.MPOSKey)

Example 4 with MPOSKeyLayout

use of org.compiere.model.MPOSKeyLayout in project adempiere by adempiere.

the class POSKeyPanel method createCard.

/**
	 * @return
	 */
private CPanel createCard(int posKeyLayoutId) {
    // already added
    if (keyMaps.containsKey(posKeyLayoutId)) {
        return null;
    }
    CPanel card = new CPanel();
    card.setLayout(new MigLayout("fill, ins 0"));
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), posKeyLayoutId);
    Color stdColor = Color.lightGray;
    if (keyLayout.getAD_PrintColor_ID() != 0) {
        MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
        stdColor = color.getColor();
    }
    Font stdFont = AdempierePLAF.getFont_Field();
    if (keyLayout.getAD_PrintFont_ID() != 0) {
        MPrintFont font = MPrintFont.get(keyLayout.getAD_PrintFont_ID());
        stdFont = font.getFont();
    }
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
    keyMaps.put(posKeyLayoutId, map);
    //	Min Columns
    int COLUMNS = 3;
    //	Min Rows
    int ROWS = 3;
    int noKeys = keys.length;
    int cols = keyLayout.getColumns();
    if (cols == 0)
        cols = COLUMNS;
    int buttons = 0;
    log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
    //	Content
    CPanel content = new CPanel(new MigLayout("fill, wrap " + Math.max(cols, 3)));
    String buttonSize = "h 50, w 50, growx, growy, sg button,";
    for (MPOSKey key : keys) {
        if (key.getSubKeyLayout_ID() > 0) {
            CPanel subCard = createCard(key.getSubKeyLayout_ID());
            if (subCard != null)
                add(subCard, Integer.toString(key.getSubKeyLayout_ID()));
        }
        map.put(key.getC_POSKey_ID(), key);
        Color keyColor = stdColor;
        Font keyFont = stdFont;
        StringBuffer buttonHTML = new StringBuffer("<html><p>");
        if (key.getAD_PrintColor_ID() != 0) {
            MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
            keyColor = color.getColor();
        }
        if (key.getAD_PrintFont_ID() != 0) {
            MPrintFont font = MPrintFont.get(key.getAD_PrintFont_ID());
            keyFont = font.getFont();
        }
        buttonHTML.append(key.getName());
        buttonHTML.append("</p></html>");
        log.fine("#" + map.size() + " - " + keyColor);
        CButton button = new CButton(buttonHTML.toString());
        button.setBackground(keyColor);
        button.setFont(keyFont);
        if (key.getAD_Image_ID() != 0) {
            MImage image = MImage.get(Env.getCtx(), key.getAD_Image_ID());
            Image img = image.getImage();
            //	https://github.com/erpcya/AD-POS-WebUI/issues/29
            //	Change Image Size
            Image imgResized = img.getScaledInstance(IMAGE_SIZE, IMAGE_SIZE, Image.SCALE_SMOOTH);
            button.setIcon(new ImageIcon(imgResized));
            button.setVerticalTextPosition(SwingConstants.BOTTOM);
            button.setHorizontalTextPosition(SwingConstants.CENTER);
        }
        button.setFocusable(false);
        if (!key.isActive())
            button.setEnabled(false);
        button.setActionCommand(String.valueOf(key.getC_POSKey_ID()));
        button.addActionListener(this);
        String constraints = buttonSize;
        int size = 1;
        if (key.getSpanX() > 1) {
            constraints += "spanx " + key.getSpanX() + ",";
            size = key.getSpanX();
        }
        if (key.getSpanY() > 1) {
            constraints += "spany " + key.getSpanY() + ",";
            size = size * key.getSpanY();
        }
        buttons = buttons + size;
        content.add(button, constraints);
    }
    int rows = Math.max((buttons / cols), ROWS);
    if (buttons % cols > 0)
        rows = rows + 1;
    for (int i = buttons; i < rows * cols; i++) {
        CButton button = new CButton("");
        button.setFocusable(false);
        button.setReadWrite(false);
        content.add(button, buttonSize);
    }
    CScrollPane scroll = new CScrollPane(content);
    // scroll.setPreferredSize(new Dimension( 600 - 20, 400-20));
    card.add(scroll, "growx, growy");
    // increase scrollbar width for touchscreen
    scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
    scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 30));
    return card;
}
Also used : ImageIcon(javax.swing.ImageIcon) HashMap(java.util.HashMap) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) CScrollPane(org.compiere.swing.CScrollPane) MigLayout(net.miginfocom.swing.MigLayout) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) CPanel(org.compiere.swing.CPanel) MPrintFont(org.compiere.print.MPrintFont) Dimension(java.awt.Dimension) Image(java.awt.Image) MImage(org.compiere.model.MImage) Font(java.awt.Font) MPrintFont(org.compiere.print.MPrintFont) MImage(org.compiere.model.MImage) MPrintColor(org.compiere.print.MPrintColor) MPOSKey(org.compiere.model.MPOSKey) CButton(org.compiere.swing.CButton)

Example 5 with MPOSKeyLayout

use of org.compiere.model.MPOSKeyLayout in project adempiere by adempiere.

the class WPOSKeyPanel method createPanel.

/**
	 * Create Panel For Keyboard
	 * @param C_POSKeyLayout_ID
	 * @param m_txtCalc
	 * @return
	 * @return Panel
	 */
public Panel createPanel(int C_POSKeyLayout_ID, String m_txtCalc) {
    Panel card = new Panel();
    card.setWidth("100%");
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    // Removal panel static
    card = createButton(C_POSKeyLayout_ID, m_txtCalc);
    panelMap.put(C_POSKeyLayout_ID, card);
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    //	Content
    for (MPOSKey key : keys) {
        if (key.getSubKeyLayout_ID() > 0) {
            //  Add subCard Panel
            Panel subCard = new Panel();
            subCard = createButton(key.getSubKeyLayout_ID(), m_txtCalc);
            panelMap.put(key.getSubKeyLayout_ID(), subCard);
            appendChild(subCard);
            subCard.setVisible(false);
        }
    }
    return card;
}
Also used : Panel(org.adempiere.webui.component.Panel) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) MPOSKey(org.compiere.model.MPOSKey)

Aggregations

MPOSKey (org.compiere.model.MPOSKey)5 MPOSKeyLayout (org.compiere.model.MPOSKeyLayout)5 Panel (org.adempiere.webui.component.Panel)4 Color (java.awt.Color)3 HashMap (java.util.HashMap)3 MPrintColor (org.compiere.print.MPrintColor)3 Label (org.adempiere.webui.component.Label)2 MImage (org.compiere.model.MImage)2 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 Image (java.awt.Image)1 ImageIcon (javax.swing.ImageIcon)1 MigLayout (net.miginfocom.swing.MigLayout)1 Borderlayout (org.adempiere.webui.component.Borderlayout)1 MPrintFont (org.compiere.print.MPrintFont)1 CButton (org.compiere.swing.CButton)1 CPanel (org.compiere.swing.CPanel)1 CScrollPane (org.compiere.swing.CScrollPane)1 AImage (org.zkoss.image.AImage)1 Center (org.zkoss.zkex.zul.Center)1