Search in sources :

Example 6 with CMenuItem

use of org.compiere.swing.CMenuItem in project lar_361 by comitsrl.

the class VPAttributeDialog method initAttributes.

// jbInit
/**
 *	Dyanmic Init.
 *  @return true if initialized
 */
private boolean initAttributes() {
    if (m_M_Product_ID == 0 && !m_productWindow)
        return false;
    MAttributeSet as = null;
    if (m_M_Product_ID != 0) {
        // Get Model
        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) {
        ADialog.error(m_WindowNo, this, "PAttributeNoAttributeSet");
        return false;
    }
    // Product has no Instance Attributes
    if (!m_productWindow && !as.isInstanceAttribute()) {
        ADialog.error(m_WindowNo, this, "PAttributeNoInstanceAttribute");
        return false;
    }
    // Show Product Attributes
    if (m_productWindow) {
        MAttribute[] attributes = as.getMAttributes(false);
        log.fine("Product Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(attributes[i], true, !m_productWindow);
    } else // Set Instance Attributes
    {
        // New/Edit - Selection
        if (// new
        m_M_AttributeSetInstance_ID == 0)
            cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "NewRecord"));
        else
            cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "EditRecord"));
        cbNewEdit.addActionListener(this);
        centerPanel.add(cbNewEdit, new ALayoutConstraint(m_row++, 0));
        bSelect.setText(Msg.getMsg(Env.getCtx(), "SelectExisting"));
        bSelect.addActionListener(this);
        centerPanel.add(bSelect, null);
        // All Attributes
        MAttribute[] attributes = as.getMAttributes(true);
        log.fine("Instance Attributes=" + attributes.length);
        for (int i = 0; i < attributes.length; i++) addAttributeLine(attributes[i], false, false);
    }
    // Lot
    if (!m_productWindow && as.isLot()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "Lot"));
        label.setLabelFor(fieldLotString);
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldLotString, null);
        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 CComboBox(DB.getKeyNamePairs(sql, true));
        label = new CLabel(Msg.translate(Env.getCtx(), "M_Lot_ID"));
        label.setLabelFor(fieldLot);
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldLot, null);
        if (m_masi.getM_Lot_ID() != 0) {
            for (int i = 1; i < fieldLot.getItemCount(); i++) {
                KeyNamePair pp = (KeyNamePair) fieldLot.getItemAt(i);
                if (pp.getKey() == m_masi.getM_Lot_ID()) {
                    fieldLot.setSelectedIndex(i);
                    fieldLotString.setEditable(false);
                    break;
                }
            }
        }
        fieldLot.addActionListener(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))) {
                centerPanel.add(bLot, null);
                bLot.addActionListener(this);
            }
        }
        // Popup
        // popup
        fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this));
        mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif"));
        mZoom.addActionListener(this);
        popupMenu.add(mZoom);
    }
    // SerNo
    if (!m_productWindow && as.isSerNo()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "SerNo"));
        label.setLabelFor(fieldSerNo);
        fieldSerNo.setText(m_masi.getSerNo());
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldSerNo, null);
        // 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))) {
                centerPanel.add(bSerNo, null);
                bSerNo.addActionListener(this);
            }
        }
    }
    // GuaranteeDate
    if (!m_productWindow && as.isGuaranteeDate()) {
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "GuaranteeDate"));
        label.setLabelFor(fieldGuaranteeDate);
        if (m_M_AttributeSetInstance_ID == 0)
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate(true));
        else
            fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate());
        centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
        centerPanel.add(fieldGuaranteeDate, null);
    }
    if (m_row == 0) {
        ADialog.error(m_WindowNo, this, "PAttributeNoInfo");
        return false;
    }
    // New/Edit Window
    if (!m_productWindow) {
        cbNewEdit.setSelected(m_M_AttributeSetInstance_ID == 0);
        cmd_newEdit();
    }
    // Attrribute Set Instance Description
    CLabel label = new CLabel(Msg.translate(Env.getCtx(), "Description"));
    label.setLabelFor(fieldDescription);
    fieldDescription.setText(m_masi.getDescription());
    fieldDescription.setEditable(false);
    centerPanel.add(label, new ALayoutConstraint(m_row++, 0));
    centerPanel.add(fieldDescription, null);
    // Window usually to wide (??)
    Dimension dd = centerPanel.getPreferredSize();
    dd.width = Math.min(500, dd.width);
    centerPanel.setPreferredSize(dd);
    return true;
}
Also used : CLabel(org.compiere.swing.CLabel) CComboBox(org.compiere.swing.CComboBox) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) Dimension(java.awt.Dimension) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) MAttributeSet(org.compiere.model.MAttributeSet) CMenuItem(org.compiere.swing.CMenuItem) KeyNamePair(org.compiere.util.KeyNamePair) MAttribute(org.compiere.model.MAttribute)

Example 7 with CMenuItem

use of org.compiere.swing.CMenuItem in project adempiere by adempiere.

the class RecordInfo method addMenu.

/**
	 * Add change log menu item
	 * @param l
	 * @param popupMenu
	 * @return CMenuItem
	 */
public static CMenuItem addMenu(ActionListener l, JPopupMenu popupMenu) {
    CMenuItem mi = new CMenuItem(Msg.getElement(Env.getCtx(), "AD_ChangeLog_ID"), s_icon);
    mi.setActionCommand(CHANGE_LOG_COMMAND);
    mi.addActionListener(l);
    popupMenu.add(mi);
    return mi;
}
Also used : CMenuItem(org.compiere.swing.CMenuItem)

Example 8 with CMenuItem

use of org.compiere.swing.CMenuItem in project adempiere by adempiere.

the class ValuePreference method addMenu.

//  create
/**
	 *  Create the popup menu item to start the ValuePreference editor.
	 *  <code>
	 *  .. add method
	 *  public void setField (MField mField)
	 *  {
	 *      m_mField = mField;
	 *      if (m_mField != null)
	 *          ValuePreference.addMenu (this, m_popupMenu);
	 *	}   //  setField
	 *
	 *  .. in actionPerformed add ..
	 *  if (e.getActionCommand().equals(ValuePreference.NAME))
	 *  {
	 *      ValuePreference.start (m_mField, getValue(), DisplayValue);
	 *      return;
	 *  }
	 *  </code>
	 *  @param l listener
	 *  @param popupMenu menu
	 *  @return JMenuItem
	 */
public static CMenuItem addMenu(ActionListener l, JPopupMenu popupMenu) {
    CMenuItem mi = new CMenuItem(Msg.getMsg(Env.getCtx(), NAME), s_icon);
    mi.setActionCommand(NAME);
    mi.addActionListener(l);
    popupMenu.add(mi);
    return mi;
}
Also used : CMenuItem(org.compiere.swing.CMenuItem)

Example 9 with CMenuItem

use of org.compiere.swing.CMenuItem in project adempiere by adempiere.

the class FieldRecordInfo method addMenu.

//	actionPerformed
/**
	 * Add change log menu item
	 * @param l
	 * @param popupMenu
	 * @return CMenuItem
	 */
public static CMenuItem addMenu(ActionListener l, JPopupMenu popupMenu) {
    CMenuItem mi = new CMenuItem(Msg.getElement(Env.getCtx(), "AD_ChangeLog_ID"), s_icon);
    mi.setActionCommand(CHANGE_LOG_COMMAND);
    mi.addActionListener(l);
    popupMenu.add(mi);
    return mi;
}
Also used : CMenuItem(org.compiere.swing.CMenuItem)

Example 10 with CMenuItem

use of org.compiere.swing.CMenuItem in project adempiere by adempiere.

the class AProcess method getPopupMenu.

private JPopupMenu getPopupMenu() {
    JPopupMenu popup = new JPopupMenu("ProcessMenu");
    List<I_AD_Process> processes = model.fetchProcesses(Env.getCtx(), parent.getCurrentTab());
    if (processes.size() == 0)
        return null;
    for (I_AD_Process process : processes) {
        CMenuItem mi = createProcessMenuItem(process);
        popup.add(mi);
    }
    return popup;
}
Also used : CMenuItem(org.compiere.swing.CMenuItem) I_AD_Process(org.compiere.model.I_AD_Process) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

CMenuItem (org.compiere.swing.CMenuItem)13 Dimension (java.awt.Dimension)3 KeyNamePair (org.compiere.util.KeyNamePair)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ImageIcon (javax.swing.ImageIcon)2 JPopupMenu (javax.swing.JPopupMenu)2 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MAttribute (org.compiere.model.MAttribute)2 MAttributeSet (org.compiere.model.MAttributeSet)2 MAttributeSetInstance (org.compiere.model.MAttributeSetInstance)2 CComboBox (org.compiere.swing.CComboBox)2 CLabel (org.compiere.swing.CLabel)2 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Icon (javax.swing.Icon)1 I_AD_Process (org.compiere.model.I_AD_Process)1 MQuery (org.compiere.model.MQuery)1 CCheckBoxMenuItem (org.compiere.swing.CCheckBoxMenuItem)1