Search in sources :

Example 51 with CPanel

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

the class POSInfoProduct method init.

@Override
protected void init() {
    //	Set Layout
    setLayout(new GridBagLayout());
    //	Set Border
    TitledBorder border = BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "InfoProduct"));
    border.setTitleFont(posPanel.getFont());
    border.setTitleColor(AdempierePLAF.getTextColor_Label());
    setBorder(border);
    //	
    FontMetrics metrics = getFontMetrics(posPanel.getPlainFont());
    //	Instance Panels
    rightPanel = new CPanel(new GridBagLayout());
    //	For Name
    labelName = new CLabel(Msg.getElement(Env.getCtx(), "ProductName"));
    labelName.setFont(posPanel.getBigFont());
    labelName.setHorizontalAlignment(CLabel.LEFT);
    //	Add
    rightPanel.add(labelName, new GridBagConstraints(0, 0, 1, 1, 1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 0), 0, 0));
    labelPriceName = new CLabel(Msg.parseTranslation(ctx, "@PriceStd@ , @PriceList@ ") + posPanel.getCurSymbol());
    labelPriceName.setFont(posPanel.getBigFont());
    labelPriceName.setHorizontalAlignment(CLabel.LEFT);
    labelPriceName.setHorizontalTextPosition(CLabel.LEFT);
    //	Add
    rightPanel.add(labelPriceName, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
    /*labelPriceLimit = new CLabel (posPanel.getNumberFormat().format(Env.ZERO));
		labelPriceLimit.setFont(posPanel.getBigFont());
		labelPriceLimit.setHorizontalAlignment(CLabel.RIGHT);
		labelPriceLimit.setHorizontalTextPosition(CLabel.RIGHT);
		labelPriceLimit.setPreferredSize(new Dimension(100, metrics.getHeight()));
		labelPriceLimit.setMinimumSize(new Dimension(150, metrics.getHeight()));
		//	Add
		rightPanel.add(labelPriceLimit, new GridBagConstraints(1, 1, 1, 1, 1, 1
				,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));*/
    //	For Price
    labelPrice = new CLabel(posPanel.getNumberFormat().format(Env.ZERO));
    labelPrice.setFont(posPanel.getBigFont());
    labelPrice.setHorizontalAlignment(CLabel.RIGHT);
    labelPrice.setHorizontalTextPosition(CLabel.RIGHT);
    labelPrice.setPreferredSize(new Dimension(100, metrics.getHeight()));
    labelPrice.setMinimumSize(new Dimension(150, metrics.getHeight()));
    //	Add
    rightPanel.add(labelPrice, new GridBagConstraints(2, 1, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
    labelPriceList = new CLabel(posPanel.getNumberFormat().format(Env.ZERO));
    labelPriceList.setFont(posPanel.getBigFont());
    labelPriceList.setHorizontalAlignment(CLabel.RIGHT);
    labelPriceList.setHorizontalTextPosition(CLabel.RIGHT);
    labelPriceList.setPreferredSize(new Dimension(100, metrics.getHeight()));
    labelPriceList.setMinimumSize(new Dimension(150, metrics.getHeight()));
    //	Add
    rightPanel.add(labelPriceList, new GridBagConstraints(3, 1, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
    //	For Value
    labelValue = new CLabel(Msg.getElement(Env.getCtx(), "ProductValue"));
    labelValue.setFont(posPanel.getPlainFont());
    labelValue.setHorizontalAlignment(CLabel.LEFT);
    labelValue.setHorizontalTextPosition(CLabel.LEFT);
    //	Add
    rightPanel.add(labelValue, new GridBagConstraints(0, 2, 1, 1, 1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
    //	For UOM
    labelUOMSymbol = new CLabel(Msg.getElement(Env.getCtx(), "C_UOM_ID"));
    labelUOMSymbol.setFont(posPanel.getPlainFont());
    labelUOMSymbol.setHorizontalAlignment(CLabel.LEFT);
    labelUOMSymbol.setHorizontalTextPosition(CLabel.LEFT);
    //	Add
    rightPanel.add(labelUOMSymbol, new GridBagConstraints(0, 3, 1, 1, 1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
    //	For Category
    labelProductCategory = new CLabel(Msg.getElement(Env.getCtx(), "M_Product_Category_ID"));
    labelProductCategory.setFont(posPanel.getPlainFont());
    labelProductCategory.setHorizontalAlignment(CLabel.LEFT);
    //	Add
    rightPanel.add(labelProductCategory, new GridBagConstraints(0, 4, 2, 1, 1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
    //	For Category
    labelProductTax = new CLabel(Msg.getElement(Env.getCtx(), "C_TaxCategory_ID"));
    labelProductTax.setFont(posPanel.getPlainFont());
    labelProductTax.setHorizontalAlignment(CLabel.LEFT);
    //	Add
    rightPanel.add(labelProductTax, new GridBagConstraints(0, 5, 2, 1, 1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
    //	For Description
    labelDescription = new CLabel(Msg.getElement(Env.getCtx(), "Description"));
    labelDescription.setFont(posPanel.getPlainFont());
    labelDescription.setHorizontalAlignment(CLabel.LEFT);
    labelDescription.setPreferredSize(new Dimension(20, metrics.getHeight()));
    labelDescription.setMaximumSize(new Dimension(20, metrics.getHeight()));
    //	Add
    rightPanel.add(labelDescription, new GridBagConstraints(0, 6, 2, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
    //	For Image
    buttonImage = new CButton();
    buttonImage.setFont(posPanel.getFont());
    buttonImage.setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
    buttonImage.setMinimumSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
    buttonImage.setFocusable(false);
    buttonImage.setVerticalTextPosition(SwingConstants.BOTTOM);
    buttonImage.setHorizontalTextPosition(SwingConstants.CENTER);
    //	Add to panel
    //	Add Doc Info
    add(buttonImage, new GridBagConstraints(0, 0, 1, 1, 0.1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
    //	Add to Header
    add(rightPanel, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
}
Also used : CLabel(org.compiere.swing.CLabel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) FontMetrics(java.awt.FontMetrics) CPanel(org.compiere.swing.CPanel) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder) CButton(org.compiere.swing.CButton)

Example 52 with CPanel

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

the class POSKeyboard method init.

/**
	 * 	Initialize
	 * @param startText 
	 * @param POSKeyLayout_ID 
	 */
public void init(int POSKeyLayout_ID) {
    CPanel panel = new CPanel();
    getContentPane().add(panel);
    //	Content
    panel.setLayout(new MigLayout("fill"));
    if (m_Keylayout.getPOSKeyLayoutType() != null && m_Keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad))
        m_Text.setHorizontalAlignment(JTextField.TRAILING);
    //	Add Listener
    m_Text.addKeyListener(this);
    m_Text.addFocusListener(this);
    m_Text.setFocusable(true);
    //	
    panel.add(m_Text, "north, growx, h 30!, wrap, gap 10 10 10 10");
    //	
    POSKeyPanel keys = new POSKeyPanel(POSKeyLayout_ID, this);
    keys.setFocusable(false);
    //	
    panel.add(keys, "center, growx, growy");
    ConfirmPanel confirm = new ConfirmPanel(true, false, true, false, false, false, false);
    confirm.addActionListener(this);
    Dimension buttonDim = new Dimension(50, 50);
    confirm.getResetButton().setPreferredSize(buttonDim);
    confirm.getOKButton().setPreferredSize(buttonDim);
    confirm.getCancelButton().setPreferredSize(buttonDim);
    panel.add(confirm, "south");
    pack();
}
Also used : ConfirmPanel(org.compiere.apps.ConfirmPanel) MigLayout(net.miginfocom.swing.MigLayout) CPanel(org.compiere.swing.CPanel) Dimension(java.awt.Dimension)

Example 53 with CPanel

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

the class POSLogin method init.

private void init() {
    CPanel panel = new CPanel();
    panel.setLayout(new MigLayout());
    getContentPane().add(panel);
    panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "SalesRep_ID")));
    username = new POSTextField(Msg.translate(posPanel.getCtx(), "SalesRep_ID"), posPanel.getKeyboard());
    panel.add(username, "wrap");
    panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "UserPIN")));
    pin = new POSTextField(Msg.translate(posPanel.getCtx(), "UserPIN"), posPanel.getKeyboard());
    panel.add(pin, "");
    AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
    act.setDelegate(this);
    bProcess = (CButton) act.getButton();
    bProcess.setFocusable(false);
    panel.add(bProcess, "h 50!, w 50!");
    pack();
}
Also used : CLabel(org.compiere.swing.CLabel) AppsAction(org.compiere.apps.AppsAction) MigLayout(net.miginfocom.swing.MigLayout) CPanel(org.compiere.swing.CPanel)

Example 54 with CPanel

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

the class VAttributeGrid method getGridElement.

//	createGrid
/**
	 * 	Get Grid Element
	 *	@param xValue X value
	 *	@param yValue Y value
	 *	@return Panel with Info
	 */
private CPanel getGridElement(MAttributeValue xValue, MAttributeValue yValue) {
    CPanel element = new CPanel();
    element.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
    element.setLayout(new BoxLayout(element, BoxLayout.Y_AXIS));
    String sql = "SELECT * FROM M_Product WHERE IsActive='Y'";
    //	Product Attributes
    if (xValue != null)
        sql += " AND M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID " + "FROM M_AttributeInstance " + "WHERE M_Attribute_ID=" + xValue.getM_Attribute_ID() + " AND M_AttributeValue_ID=" + xValue.getM_AttributeValue_ID() + ")";
    if (yValue != null)
        sql += " AND M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID " + "FROM M_AttributeInstance " + "WHERE M_Attribute_ID=" + yValue.getM_Attribute_ID() + " AND M_AttributeValue_ID=" + yValue.getM_AttributeValue_ID() + ")";
    sql = MRole.getDefault().addAccessSQL(sql, "M_Product", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    PreparedStatement pstmt = null;
    int noProducts = 0;
    try {
        pstmt = DB.prepareStatement(sql, null);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            MProduct product = new MProduct(Env.getCtx(), rs, null);
            addProduct(element, product);
            noProducts++;
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    }
    try {
        if (pstmt != null)
            pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        pstmt = null;
    }
    int mode = modeCombo.getSelectedIndex();
    //	No Products
    if (noProducts == 0 && mode == MODE_VIEW) {
    //	CButton button = ConfirmPanel.createNewButton(true);
    //	button.addActionListener(this);
    //	element.add(button);
    } else //	Additional Elements
    {
        if (mode == MODE_PRICE) {
        //	Price Field
        } else if (mode == MODE_PO) {
        //	Qty Field
        }
    }
    return element;
}
Also used : MProduct(org.compiere.model.MProduct) BoxLayout(javax.swing.BoxLayout) CPanel(org.compiere.swing.CPanel) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) SQLException(java.sql.SQLException)

Example 55 with CPanel

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

the class VPanel method addField.

/**
	 *	Add the previous Field and Label to Panel
	 *  @param editor editor
	 *  @param mField field model
	 *  @param wrap move to next line after this field
	 */
public void addField(VEditor editor, GridField mField) {
    //[ 1757088 ]
    int AD_Tab_ID = mField.getIncluded_Tab_ID();
    if (AD_Tab_ID != 0) {
        CollapsiblePanel m_tab = new CollapsiblePanel("");
        m_tabincludelist.put(AD_Tab_ID, m_tab);
        m_main.add(m_tab, "newline, spanx, growx");
        m_tab.setName("IncludedTab#" + AD_Tab_ID);
        if (includedTabList.containsKey(AD_Tab_ID)) {
            includeTab(includedTabList.get(AD_Tab_ID));
        }
        return;
    }
    CLabel label = VEditorFactory.getLabel(mField);
    if (label == null && editor == null)
        return;
    boolean sameLine = mField.isSameLine();
    //[ 1757088 ]              		//	sets top
    String fieldGroup = mField.getFieldGroup();
    String fieldGroupType = mField.getFieldGroupType();
    if (Util.isEmpty(fieldGroup)) {
        fieldGroup = m_oldFieldGroup;
        fieldGroupType = m_oldFieldGroupType;
    }
    if (//	sets top			
    addGroup(fieldGroup, fieldGroupType)) {
        if (X_AD_FieldGroup.FIELDGROUPTYPE_Collapse.equals(fieldGroupType)) {
            CollapsiblePanel panel = (CollapsiblePanel) m_tablist.get(fieldGroup);
            panel.getCollapsiblePane().setCollapsed(mField.getIsCollapsedByDefault());
        }
        sameLine = false;
    } else {
        fieldGroup = m_oldFieldGroup;
        fieldGroupType = m_oldFieldGroupType;
    }
    // label constraints
    String constraints = "align trailing";
    if (!sameLine) {
        constraints += ", newline";
    }
    //	*** The Label ***
    if (label == null) {
        label = new CLabel("");
        label.setName(mField.getColumnName());
    }
    //
    if (mField.isCreateMnemonic())
        setMnemonic(label, mField.getMnemonic());
    if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) {
        CPanel m_tab = (CPanel) m_tablist.get(fieldGroup);
        m_tab.add(label, constraints);
    } else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) {
        CollapsiblePanel m_tab = (CollapsiblePanel) m_tablist.get(fieldGroup);
        m_tab.getCollapsiblePane().getContentPane().add(label, constraints);
    } else // Label
    {
        m_main.add(label, constraints);
    }
    int currentWidth = label.getPreferredSize().width;
    labelMinWidth = currentWidth > labelMinWidth ? currentWidth : labelMinWidth;
    //	*** The Field ***
    if (editor != null) {
        Component field = (Component) editor;
        //	field constraints
        //  long fields span all remaining columns
        constraints = "growx, pushx";
        if (mField.isLongField()) {
            constraints += mField.isLongField() ? ",spanx" : "";
        }
        if (wrap) {
            //   Vertical Spacing in Swing Client
            // - https://sourceforge.net/tracker/?func=detail&aid=3073406&group_id=176962&atid=883808
            constraints += ", wrap 0";
        }
        //[ 1757088 ]
        if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) {
            CPanel m_tab = (CPanel) m_tablist.get(fieldGroup);
            m_tab.add(field, constraints);
        } else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) {
            CollapsiblePanel m_tab = (CollapsiblePanel) m_tablist.get(fieldGroup);
            Component comp = (Component) editor;
            comp.setMinimumSize(comp.getPreferredSize());
            if (mField.getDisplayType() == DisplayType.Text || mField.getDisplayType() == DisplayType.Memo || mField.getDisplayType() == DisplayType.TextLong) {
                Component component = (Component) editor;
                component.setMinimumSize(component.getPreferredSize());
            }
            if (!mField.isLongField())
                fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth;
            m_tab.getCollapsiblePane().getContentPane().add(field, constraints);
        } else // Label or null
        {
            m_main.add(field, constraints);
            if (!mField.isLongField())
                fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth;
        }
        //	Link Label to Field
        if (label != null)
            label.setLabelFor(field);
        else if (mField.isCreateMnemonic())
            setMnemonic(editor, mField.getMnemonic());
    }
}
Also used : CLabel(org.compiere.swing.CLabel) CPanel(org.compiere.swing.CPanel) Component(java.awt.Component) CollapsiblePanel(org.compiere.swing.CollapsiblePanel)

Aggregations

CPanel (org.compiere.swing.CPanel)64 Dimension (java.awt.Dimension)29 GridBagConstraints (java.awt.GridBagConstraints)28 Insets (java.awt.Insets)28 BorderLayout (java.awt.BorderLayout)24 GridBagLayout (java.awt.GridBagLayout)21 CLabel (org.compiere.swing.CLabel)20 MigLayout (net.miginfocom.swing.MigLayout)10 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)10 TitledBorder (javax.swing.border.TitledBorder)9 ALayout (org.compiere.apps.ALayout)9 VLookup (org.compiere.grid.ed.VLookup)9 CScrollPane (org.compiere.swing.CScrollPane)9 JScrollPane (javax.swing.JScrollPane)8 FlowLayout (java.awt.FlowLayout)7 Component (java.awt.Component)6 AppsAction (org.compiere.apps.AppsAction)6 VNumber (org.compiere.grid.ed.VNumber)5 MLookup (org.compiere.model.MLookup)5 CButton (org.compiere.swing.CButton)5