use of org.zkoss.zul.Menuitem in project adempiere by adempiere.
the class WPOSActionMenu method addMenuItem.
private void addMenuItem(String optionName) {
Menuitem menuItem = new Menuitem(optionName, null);
popupMenu.appendChild(menuItem);
menuItem.setAttribute(EVENT_ATTRIBUTE, optionName);
menuItem.addEventListener(Events.ON_CLICK, this);
}
use of org.zkoss.zul.Menuitem in project adempiere by adempiere.
the class ADTreeOnDropListener method moveNode.
/**
* Move TreeNode
* @param movingNode The node to be moved
* @param toNode The target node
*/
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode) {
log.info(movingNode.toString() + " to " + toNode.toString());
if (movingNode == toNode)
return;
MTreeNode toMNode = (MTreeNode) toNode.getData();
DefaultTreeNode newParent;
int index;
if (// drop on a child node
!toMNode.isSummary()) {
moveNode(movingNode, toNode, false);
} else // drop on a summary node
{
//prompt user to select insert after or drop into the summary node
int[] path = treeModel.getPath(toNode);
Treeitem toItem = tree.renderItemByPath(path);
tree.setSelectedItem(toItem);
Events.sendEvent(tree, new Event(Events.ON_SELECT, tree));
MenuListener listener = new MenuListener(movingNode, toNode);
//TODO: translation
Menupopup popup = new Menupopup();
Menuitem menuItem = new Menuitem("Insert After");
menuItem.setValue("InsertAfter");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
menuItem = new Menuitem("Move Into");
menuItem.setValue("MoveInto");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
popup.setPage(tree.getPage());
popup.open(toItem.getTreerow());
}
}
use of org.zkoss.zul.Menuitem 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;
}
use of org.zkoss.zul.Menuitem in project adempiere by adempiere.
the class WRequest method getRequests.
/**
* Display Request Options - New/Existing.
* @param invoker button
*/
private void getRequests(Component invoker) {
m_new = new Menuitem(Msg.getMsg(Env.getCtx(), "RequestNew"));
m_new.setImage(ServletFns.resolveThemeURL("~./images/New16.png"));
m_new.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(m_new);
//
int activeCount = 0;
int inactiveCount = 0;
m_where = new StringBuffer();
m_where.append("(AD_Table_ID=").append(m_AD_Table_ID).append(" AND Record_ID=").append(m_Record_ID).append(")");
//
if (m_AD_Table_ID == MUser.Table_ID)
m_where.append(" OR AD_User_ID=").append(m_Record_ID).append(" OR SalesRep_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_BPartner.Table_ID)
m_where.append(" OR C_BPartner_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_Order.Table_ID)
m_where.append(" OR C_Order_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_Invoice.Table_ID)
m_where.append(" OR C_Invoice_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_Payment.Table_ID)
m_where.append(" OR C_Payment_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_M_Product.Table_ID)
m_where.append(" OR M_Product_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_Project.Table_ID)
m_where.append(" OR C_Project_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_C_Campaign.Table_ID)
m_where.append(" OR C_Campaign_ID=").append(m_Record_ID);
else if (m_AD_Table_ID == I_A_Asset.Table_ID)
m_where.append(" OR A_Asset_ID=").append(m_Record_ID);
//
String sql = "SELECT Processed, COUNT(*) " + "FROM R_Request WHERE " + m_where + " GROUP BY Processed " + "ORDER BY Processed DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) {
if ("Y".equals(rs.getString(1)))
inactiveCount = rs.getInt(2);
else
activeCount += rs.getInt(2);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
if (activeCount > 0) {
m_active = new Menuitem(Msg.getMsg(Env.getCtx(), "RequestActive") + " (" + activeCount + ")");
m_active.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(m_active);
}
if (inactiveCount > 0) {
m_all = new Menuitem(Msg.getMsg(Env.getCtx(), "RequestAll") + " (" + (activeCount + inactiveCount) + ")");
m_all.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(m_all);
}
m_popup.setPage(invoker.getPage());
m_popup.open(invoker);
}
use of org.zkoss.zul.Menuitem in project adempiere by adempiere.
the class WReport method showPopup.
// getPrintFormats
private void showPopup() {
m_popup = new Menupopup();
for (int i = 0; i < m_list.size(); i++) {
KeyNamePair pp = (KeyNamePair) m_list.get(i);
Menuitem menuitem = new Menuitem(pp.getName());
menuitem.setValue(i + "");
menuitem.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(menuitem);
}
m_popup.setPage(parent.getPage());
m_popup.open(parent);
}
Aggregations