use of org.compiere.model.MPOSKey in project adempiere by adempiere.
the class WPOSKeyPanel method onEvent.
/**
* Action Listener
* @param e event
*/
@Override
public void onEvent(Event event) throws Exception {
String action = event.getTarget().getId();
HashMap<Integer, MPOSKey> currentKeymap = keymap.get(currentLayout);
try {
int C_POSKey_ID = Integer.parseInt(action);
MPOSKey key = currentKeymap.get(C_POSKey_ID);
if (key.getSubKeyLayout_ID() > 0) {
// Hidden current Panel
panelMap.get(currentLayout).setVisible(false);
currentLayout = key.getSubKeyLayout_ID();
// Show other Panel
panelMap.get(currentLayout).setVisible(true);
} else {
caller.keyReturned(key);
}
} catch (Exception ex) {
}
}
use of org.compiere.model.MPOSKey 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;
}
use of org.compiere.model.MPOSKey in project lar_361 by comitsrl.
the class PosKeyPanel method actionPerformed.
/**
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if (action == null || action.length() == 0 || keymap == null)
return;
log.info("PosSubFunctionKeys - actionPerformed: " + action);
HashMap<Integer, MPOSKey> currentKeymap = keymap.get(currentLayout);
try {
int C_POSKey_ID = Integer.parseInt(action);
MPOSKey key = currentKeymap.get(C_POSKey_ID);
// switch layout
if (key.getSubKeyLayout_ID() > 0) {
currentLayout = key.getSubKeyLayout_ID();
cardLayout.show(this, Integer.toString(key.getSubKeyLayout_ID()));
} else {
caller.keyReturned(key);
}
} catch (Exception ex) {
ADialog.error(0, this, ex.getMessage());
}
}
use of org.compiere.model.MPOSKey in project adempiere by adempiere.
the class CPOS method getProductImageId.
/**
* Get Product Image
* Right now, it is only possible a two-stage lookup.
* A general lookup has to be implemented, where more than 2 stages are considered.
* @param productId
* @param posKeyLayoutId
* @return int
*/
public int getProductImageId(int productId, int posKeyLayoutId) {
int imageId = 0;
// Valid Product
if (productId == 0)
return imageId;
// Get POS Key
int m_C_POSKey_ID = DB.getSQLValue(null, "SELECT pk.C_POSKey_ID " + "FROM C_POSKey pk " + "WHERE pk.C_POSKeyLayout_ID = ? " + "AND pk.M_Product_ID = ? " + "AND pk.IsActive = 'Y'", posKeyLayoutId, productId);
if (m_C_POSKey_ID > 0) {
// Valid POS Key
MPOSKey key = new MPOSKey(ctx, m_C_POSKey_ID, null);
imageId = key.getAD_Image_ID();
} else {
// No record has been found for a product in the current Key Layout. Try it in the Subkey Layout.
m_C_POSKey_ID = DB.getSQLValue(null, "SELECT pk2.C_POSKey_ID " + "FROM C_POSKey pk1 " + "INNER JOIN C_POSKey pk2 ON pk1.subkeylayout_id=pk2.c_poskeylayout_id AND pk1.subkeylayout_id IS NOT NULL " + "WHERE pk2.M_Product_ID = ? " + "AND pk1.IsActive = 'Y' AND pk2.IsActive = 'Y'", productId);
// Valid POS Key
if (m_C_POSKey_ID > 0) {
MPOSKey key = new MPOSKey(ctx, m_C_POSKey_ID, null);
imageId = key.getAD_Image_ID();
}
}
return imageId;
}
use of org.compiere.model.MPOSKey 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;
}
Aggregations