Search in sources :

Example 6 with MigLayout

use of net.miginfocom.swing.MigLayout in project adempiere by adempiere.

the class VPanel method addGroup.

//	addField
/**
	 *	Add Group
	 *  @param fieldGroup field group
	 *  @param fieldGroupType 
	 *  @return true if group added
	 */
private boolean addGroup(String fieldGroup, String fieldGroupType) {
    //	First time - add top
    if (m_oldFieldGroup == null) {
        m_oldFieldGroup = "";
        m_oldFieldGroupType = "";
    }
    if (fieldGroup == null || fieldGroup.length() == 0 || fieldGroup.equals(m_oldFieldGroup))
        return false;
    //[ 1757088 ]
    if (m_tablist.get(fieldGroup) != null) {
        return false;
    }
    //[ 1757088 ]
    if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) {
        CPanel m_tab = new CPanel();
        m_tab.setBackground(AdempierePLAF.getFormBackground());
        String tpConstraints = defaultLayoutConstraints;
        MigLayout layout = new MigLayout(tpConstraints);
        layout.addLayoutCallback(callback);
        m_tab.setLayout(layout);
        m_tab.setName(fieldGroup);
        CPanel dummy = new CPanel();
        dummy.setLayout(new BorderLayout());
        dummy.add(m_tab, BorderLayout.NORTH);
        dummy.setName(m_tab.getName());
        dummy.setBorder(BorderFactory.createEmptyBorder(10, 12, 0, 12));
        this.add(dummy);
        m_tablist.put(fieldGroup, m_tab);
    } else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) {
        CollapsiblePanel collapsibleSection = new CollapsiblePanel(fieldGroup);
        JXCollapsiblePane m_tab = collapsibleSection.getCollapsiblePane();
        m_tab.setAnimated(false);
        m_tab.getContentPane().setBackground(AdempierePLAF.getFormBackground());
        String cpConstraints = defaultLayoutConstraints;
        // 0 inset left and right as this is a nested panel
        // 0 inset top because of the struts added below
        cpConstraints += ", ins 0 0 n 0";
        MigLayout layout = new MigLayout(cpConstraints);
        layout.addLayoutCallback(callback);
        collapsibleSection.setName(fieldGroup);
        m_main.add(collapsibleSection, "newline, spanx, growx");
        m_tab.setLayout(layout);
        /* for compatibility with old layout, force collapsible field groups
			 *  to have a minimum of two columns by inserting invisible components
			 */
        Component strut1 = Box.createVerticalStrut(1);
        strut1.setName("vstrut1" + fieldGroup);
        Component strut2 = Box.createVerticalStrut(1);
        strut2.setName("vstrut2" + fieldGroup);
        m_tab.add(new CLabel(""), "gap 0 0 0 0");
        m_tab.add(strut1, "pushx, growx, gap 0 0 0 0");
        m_tab.add(new CLabel(""), "");
        m_tab.add(strut2, "pushx, growx, gap 0 0 0 0, wrap");
        m_tablist.put(fieldGroup, collapsibleSection);
    } else // Label or null
    {
        CLabel label = new CLabel(fieldGroup, CLabel.LEADING);
        label.setFont(AdempierePLAF.getFont_Label().deriveFont(Font.BOLDITALIC, AdempierePLAF.getFont_Label().getSize2D()));
        //	BR [ 359 ]
        //	Show label completely
        m_main.add(label, "newline, alignx leading, spanx, growx");
        m_main.add(new JSeparator(), "newline, spanx, growx");
    //	reset
    }
    m_oldFieldGroup = fieldGroup;
    m_oldFieldGroupType = fieldGroupType;
    return true;
}
Also used : CLabel(org.compiere.swing.CLabel) BorderLayout(java.awt.BorderLayout) MigLayout(net.miginfocom.swing.MigLayout) JXCollapsiblePane(org.jdesktop.swingx.JXCollapsiblePane) CPanel(org.compiere.swing.CPanel) Component(java.awt.Component) CollapsiblePanel(org.compiere.swing.CollapsiblePanel) JSeparator(javax.swing.JSeparator)

Example 7 with MigLayout

use of net.miginfocom.swing.MigLayout 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 8 with MigLayout

use of net.miginfocom.swing.MigLayout in project adempiere by adempiere.

the class QueryBPartner method init.

/**
	 * 	Set up Panel
	 */
protected void init() {
    setTitle(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    //	North
    parameterPanel.setLayout(new MigLayout("fill", "", "[50][50][]"));
    parameterPanel.setBorder(new TitledBorder(Msg.getMsg(ctx, "Query")));
    CLabel labelValue = new CLabel(Msg.translate(ctx, "Value"));
    parameterPanel.add(labelValue, " growy");
    fieldValue = new POSTextField("", posPanel.getKeyboard());
    labelValue.setLabelFor(fieldValue);
    parameterPanel.add(fieldValue, "h 30, w 200");
    fieldValue.addActionListener(this);
    CLabel labelTaxID = new CLabel(Msg.translate(ctx, "TaxID"));
    parameterPanel.add(labelTaxID, " growy");
    fieldTaxID = new POSTextField("", posPanel.getKeyboard());
    labelTaxID.setLabelFor(fieldTaxID);
    parameterPanel.add(fieldTaxID, "h 30, w 200");
    fieldTaxID.addActionListener(this);
    //
    CLabel labelContact = new CLabel(Msg.translate(ctx, "Contact"));
    parameterPanel.add(labelContact, " growy");
    fieldContact = new POSTextField("", posPanel.getKeyboard());
    labelContact.setLabelFor(fieldContact);
    parameterPanel.add(fieldContact, "h 30, w 200");
    fieldContact.addActionListener(this);
    //
    CLabel labelPhone = new CLabel(Msg.translate(ctx, "Phone"));
    parameterPanel.add(labelPhone, " growy");
    fieldPhone = new POSTextField("", posPanel.getKeyboard());
    labelPhone.setLabelFor(fieldPhone);
    parameterPanel.add(fieldPhone, "h 30, w 200, wrap");
    fieldPhone.addActionListener(this);
    //
    CLabel labelName = new CLabel(Msg.translate(ctx, "Name"));
    parameterPanel.add(labelName, " growy");
    fieldName = new POSTextField("", posPanel.getKeyboard());
    labelName.setLabelFor(fieldName);
    parameterPanel.add(fieldName, "h 30, w 200");
    fieldName.addActionListener(this);
    CLabel labelName2 = new CLabel(Msg.translate(ctx, "Name2"));
    parameterPanel.add(labelName2, " growy");
    fieldName2 = new POSTextField("", posPanel.getKeyboard());
    labelName2.setLabelFor(fieldName2);
    parameterPanel.add(fieldName2, "h 30, w 200");
    fieldName2.addActionListener(this);
    //
    CLabel labelEmail = new CLabel(Msg.translate(ctx, "Email"));
    parameterPanel.add(labelEmail, " growy");
    fieldEmail = new POSTextField("", posPanel.getKeyboard());
    labelEmail.setLabelFor(fieldEmail);
    parameterPanel.add(fieldEmail, "h 30, w 200");
    fieldEmail.addActionListener(this);
    //
    CLabel labelCity = new CLabel(Msg.translate(ctx, "City"));
    parameterPanel.add(labelCity, " growy");
    fieldCity = new POSTextField("", posPanel.getKeyboard());
    labelCity.setLabelFor(fieldCity);
    parameterPanel.add(fieldCity, "h 30, w 200");
    fieldCity.addActionListener(this);
    //	Center
    posTable.prepareTable(s_layout, sqlFrom, sqlWhere, false, "RV_BPartner");
    //	
    posTable.growScrollbars();
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            fieldValue.requestFocus();
        }
    });
    addNewAction();
}
Also used : CLabel(org.compiere.swing.CLabel) POSTextField(org.adempiere.pos.POSTextField) MigLayout(net.miginfocom.swing.MigLayout) TitledBorder(javax.swing.border.TitledBorder)

Example 9 with MigLayout

use of net.miginfocom.swing.MigLayout in project intellij-community by JetBrains.

the class SearchTextArea method updateLayout.

protected void updateLayout() {
    setBorder(myHelper.getBorder());
    setLayout(new MigLayout(myHelper.getLayoutConstraints()));
    removeAll();
    add(myHistoryPopupButton, myHelper.getHistoryButtonConstraints());
    add(myScrollPane, "ay top, growx, pushx");
    //TODO combine icons/info modes
    if (myInfoMode) {
        add(myInfoLabel, "gapright " + JBUI.scale(4));
    }
    add(myIconsPanel, myHelper.getIconsPanelConstraints());
    updateIconsLayout();
}
Also used : MigLayout(net.miginfocom.swing.MigLayout)

Example 10 with MigLayout

use of net.miginfocom.swing.MigLayout in project intellij-community by JetBrains.

the class ToolEditorDialog method getOptionsPanel.

private JPanel getOptionsPanel() {
    JPanel panel = new JPanel(new MigLayout("fill, gap 10"));
    panel.setBorder(IdeBorderFactory.createTitledBorder(ToolsBundle.message("tools.options.group"), true));
    panel.add(mySynchronizedAfterRunCheckbox);
    panel.add(myUseConsoleCheckbox);
    panel.add(myOutputFiltersButton, "ax right, wrap");
    panel.add(myShowConsoleOnStdOutCheckbox);
    panel.add(myShowConsoleOnStdErrCheckbox, "spanx 2");
    return panel;
}
Also used : MigLayout(net.miginfocom.swing.MigLayout)

Aggregations

MigLayout (net.miginfocom.swing.MigLayout)29 JPanel (javax.swing.JPanel)7 ArrayList (java.util.ArrayList)5 CLabel (org.compiere.swing.CLabel)5 Column (org.gephi.graph.api.Column)5 CPanel (org.compiere.swing.CPanel)4 Comparator (java.util.Comparator)3 TitledBorder (javax.swing.border.TitledBorder)3 POSTextField (org.adempiere.pos.POSTextField)3 Dimension (java.awt.Dimension)2 JCheckBox (javax.swing.JCheckBox)2 ActionButton (com.intellij.openapi.actionSystem.impl.ActionButton)1 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 ListPopup (com.intellij.openapi.ui.popup.ListPopup)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 JBCheckBox (com.intellij.ui.components.JBCheckBox)1 JBLabel (com.intellij.ui.components.JBLabel)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 Wrapper (com.intellij.ui.components.panels.Wrapper)1