Search in sources :

Example 1 with CScrollPane

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

the class ProcessPanel method initComponents.

@Override
public void initComponents() {
    mainLayout = new BorderLayout();
    centerPanel = new CPanel();
    parameterScrollPane = new CScrollPane(centerPanel);
    //	
    southPanel = new CPanel();
    southLayout = new FlowLayout();
    //	Buttons
    bOK = ConfirmPanel.createOKButton(true);
    bCancel = ConfirmPanel.createCancelButton(true);
    bPrint = ConfirmPanel.createPrintButton(true);
    bOK.addActionListener(this);
    bCancel.addActionListener(this);
    bPrint.addActionListener(this);
    //	
    mainPanel.setLayout(mainLayout);
    mainPanel.setMinimumSize(new Dimension(500, 100));
    //	South Panel
    southPanel.setLayout(southLayout);
    southLayout.setAlignment(FlowLayout.RIGHT);
    southPanel.add(bPrint, null);
    southPanel.add(bCancel, null);
    southPanel.add(bOK, null);
    //	Editors
    m_separators = new ArrayList<CLabel>();
    //	
    message.setContentType("text/html");
    message.setEditable(false);
    message.setBackground(Color.white);
    message.setFocusable(true);
    //	
    centerPanel.setLayout(new ALayout());
    centerPanel.setBorder(null);
    if (isShowDescription()) {
        mainPanel.add(messagePane, BorderLayout.NORTH);
        messagePane.setMaximumSize(new Dimension(600, 300));
    }
    //	Add Center Panel with scroll bar
    parameterScrollPane.setAutoscrolls(true);
    parameterScrollPane.createVerticalScrollBar();
    parameterScrollPane.createHorizontalScrollBar();
    //	
    mainPanel.add(parameterScrollPane, BorderLayout.CENTER);
    //	Add buttons
    if (isShowButtons()) {
        mainPanel.add(southPanel, BorderLayout.SOUTH);
    }
    //	
    mainLayout.setVgap(2);
    //	Set Text
    message.setText(getTextMsg());
}
Also used : CLabel(org.compiere.swing.CLabel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) CScrollPane(org.compiere.swing.CScrollPane) CPanel(org.compiere.swing.CPanel) Dimension(java.awt.Dimension)

Example 2 with CScrollPane

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

the class VAttributeGrid method createGrid.

/**
	 * 	Create Grid
	 */
private void createGrid() {
    if (attributeCombo1 == null || m_setting)
        //	init
        return;
    int indexAttr1 = attributeCombo1.getSelectedIndex();
    int indexAttr2 = attributeCombo2.getSelectedIndex();
    if (indexAttr1 == indexAttr2) {
        log.warning("Same Attribute Selected");
        tabbedPane.setSelectedIndex(0);
        return;
    }
    m_setting = true;
    m_M_PriceList_Version_ID = 0;
    KeyNamePair pl = (KeyNamePair) pickPriceList.getSelectedItem();
    if (pl != null)
        m_M_PriceList_Version_ID = pl.getKey();
    m_M_Warehouse_ID = 0;
    KeyNamePair wh = (KeyNamePair) pickWarehouse.getSelectedItem();
    if (wh != null)
        m_M_Warehouse_ID = wh.getKey();
    //	x dimension
    int cols = 2;
    MAttributeValue[] xValues = null;
    if (indexAttr1 > 0)
        xValues = m_attributes[indexAttr1 - 1].getMAttributeValues();
    if (xValues != null) {
        cols = xValues.length;
        log.info("X - " + m_attributes[indexAttr1 - 1].getName() + " #" + xValues.length);
    }
    //	y dimension
    int rows = 2;
    MAttributeValue[] yValues = null;
    if (indexAttr2 > 0)
        yValues = m_attributes[indexAttr2 - 1].getMAttributeValues();
    if (yValues != null) {
        rows = yValues.length;
        log.info("Y - " + m_attributes[indexAttr2 - 1].getName() + " #" + yValues.length);
    }
    //
    gridPanel.removeAll();
    CPanel grid = new CPanel(new GridLayout(rows, cols, 5, 5));
    gridPanel.add(modePanel, BorderLayout.NORTH);
    gridPanel.add(new CScrollPane(grid), BorderLayout.CENTER);
    //
    log.info("Rows=" + rows + " - Cols=" + cols);
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            MAttributeValue xValue = null;
            if (xValues != null)
                xValue = xValues[col];
            MAttributeValue yValue = null;
            if (yValues != null)
                yValue = yValues[row];
            //
            if (row == 0 && col == 0) {
                CPanel descr = new CPanel(new GridLayout(2, 1, 0, 0));
                if (xValues != null)
                    descr.add(new JLabel(m_attributes[indexAttr1 - 1].getName(), JLabel.TRAILING));
                if (yValues != null)
                    descr.add(new JLabel(m_attributes[indexAttr2 - 1].getName()));
                grid.add(descr);
            } else if (//	column labels
            row == 0) {
                if (xValue != null) {
                    grid.add(new JLabel(xValue.getName(), JLabel.TRAILING));
                } else
                    grid.add(new JLabel());
            } else if (//	row labels
            col == 0) {
                if (yValue != null)
                    grid.add(new JLabel(yValue.getName()));
                else
                    grid.add(new JLabel());
            } else {
                grid.add(getGridElement(xValue, yValue));
            }
        }
    }
    //
    tabbedPane.setSelectedIndex(1);
    m_setting = false;
    m_frame.pack();
}
Also used : GridLayout(java.awt.GridLayout) CScrollPane(org.compiere.swing.CScrollPane) MAttributeValue(org.compiere.model.MAttributeValue) CPanel(org.compiere.swing.CPanel) JLabel(javax.swing.JLabel) KeyNamePair(org.compiere.util.KeyNamePair) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 3 with CScrollPane

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

the class VBOMDrop method init.

/**
	 *	Initialize Panel
	 *  @param WindowNo window
	 *  @param frame parent frame
	 */
public void init(int WindowNo, FormFrame frame) {
    log.info("");
    m_WindowNo = WindowNo;
    m_frame = frame;
    try {
        //	Top Selection Panel
        createSelectionPanel(true, true, true);
        m_frame.getContentPane().add(selectionPanel, BorderLayout.NORTH);
        //	Center
        createMainPanel();
        CScrollPane scroll = new CScrollPane(this);
        m_frame.getContentPane().add(scroll, BorderLayout.CENTER);
        confirmPanel.addActionListener(this);
        //	South
        m_frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
    } catch (Exception e) {
        log.log(Level.SEVERE, "", e);
    }
    sizeIt();
}
Also used : CScrollPane(org.compiere.swing.CScrollPane)

Example 4 with CScrollPane

use of org.compiere.swing.CScrollPane 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 CScrollPane

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

the class VProductConfigurationBOM method init.

/**
	 *	Initialize Panel
	 *  @param WindowNo window
	 *  @param frame parent frame
	 */
public void init(int WindowNo, FormFrame frame) {
    log.info("");
    m_WindowNo = WindowNo;
    m_frame = frame;
    try {
        //	Top Selection Panel
        createSelectionPanel(true, true, true);
        m_frame.getContentPane().add(selectionPanel, BorderLayout.NORTH);
        //	Center
        createMainPanel();
        CScrollPane scroll = new CScrollPane(this);
        m_frame.getContentPane().add(scroll, BorderLayout.CENTER);
        confirmPanel.addActionListener(this);
        //	South
        m_frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
        //Tree stuff
        DefaultMutableTreeNode parent = new DefaultMutableTreeNode(Msg.translate(Env.getCtx(), "No Product Chosen"));
        this.m_RadioButtonTreeCellRenderer = new RadioButtonTreeCellRenderer();
    } catch (Exception e) {
        log.log(Level.SEVERE, "", e);
    }
    sizeIt();
}
Also used : RadioButtonTreeCellRenderer(org.eevolution.form.bom.RadioButtonTreeCellRenderer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CScrollPane(org.compiere.swing.CScrollPane) SQLException(java.sql.SQLException)

Aggregations

CScrollPane (org.compiere.swing.CScrollPane)15 CPanel (org.compiere.swing.CPanel)9 Dimension (java.awt.Dimension)8 MigLayout (net.miginfocom.swing.MigLayout)6 CLabel (org.compiere.swing.CLabel)5 BorderLayout (java.awt.BorderLayout)3 TitledBorder (javax.swing.border.TitledBorder)3 Color (java.awt.Color)2 Font (java.awt.Font)2 Insets (java.awt.Insets)2 HashMap (java.util.HashMap)2 MImage (org.compiere.model.MImage)2 MPOSKey (org.compiere.model.MPOSKey)2 MPOSKeyLayout (org.compiere.model.MPOSKeyLayout)2 MPrintColor (org.compiere.print.MPrintColor)2 MPrintFont (org.compiere.print.MPrintFont)2 CButton (org.compiere.swing.CButton)2 FlowLayout (java.awt.FlowLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1