Search in sources :

Example 1 with ImpFormatRow

use of org.compiere.impexp.ImpFormatRow in project adempiere by adempiere.

the class WFileImport method cmd_loadFormat.

//	cmd_loadFile
/**
	 *	Load Format
	 */
private void cmd_loadFormat() {
    //	clear panel
    previewPanel.getChildren().clear();
    ListItem listitem = pickFormat.getSelectedItem();
    String formatName = (String) listitem.getValue();
    if (formatName.equals(s_none))
        return;
    m_format = ImpFormat.load(formatName);
    if (m_format == null) {
        FDialog.error(m_WindowNo, this, formatName);
        return;
    }
    //	pointers
    int size = m_format.getRowCount();
    m_labels = new Label[size];
    m_fields = new Textbox[size];
    for (int i = 0; i < size; i++) {
        ImpFormatRow row = m_format.getRow(i);
        m_labels[i] = new Label(row.getColumnName());
        Hbox hbox = new Hbox();
        hbox.setWidth("100%");
        hbox.setWidths("30%, 70%");
        hbox.setStyle("padding-bottom: 3px");
        hbox.appendChild(m_labels[i].rightAlign());
        int length = row.getEndNo() - row.getStartNo();
        if (length <= 5)
            length = 5;
        else if (length > 20)
            length = 20;
        m_fields[i] = new Textbox();
        m_fields[i].setStyle("margin-left: 2px");
        hbox.appendChild(m_fields[i]);
        previewPanel.appendChild(hbox);
    }
    m_record = -1;
    record.setValue("------");
    previewPanel.invalidate();
}
Also used : ImpFormatRow(org.compiere.impexp.ImpFormatRow) Hbox(org.zkoss.zul.Hbox) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) ListItem(org.adempiere.webui.component.ListItem)

Example 2 with ImpFormatRow

use of org.compiere.impexp.ImpFormatRow in project adempiere by adempiere.

the class VFileImport method cmd_loadFormat.

//	cmd_loadFile
/**
	 *	Load Format
	 */
private void cmd_loadFormat() {
    //	clear panel
    previewPanel.removeAll();
    //
    String formatName = pickFormat.getSelectedItem().toString();
    if (formatName.equals(s_none))
        return;
    m_format = ImpFormat.load(formatName);
    if (m_format == null) {
        ADialog.error(m_WindowNo, this, "FileImportNoFormat", formatName);
        return;
    }
    //	pointers
    int size = m_format.getRowCount();
    m_labels = new JLabel[size];
    m_fields = new JTextField[size];
    for (int i = 0; i < size; i++) {
        ImpFormatRow row = m_format.getRow(i);
        m_labels[i] = new JLabel(row.getColumnName());
        previewPanel.add(m_labels[i], new GridBagConstraints(i, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
        //
        int length = row.getEndNo() - row.getStartNo();
        if (length <= 5)
            length = 5;
        else if (length > 20)
            length = 20;
        m_fields[i] = new JTextField(length);
        previewPanel.add(m_fields[i], new GridBagConstraints(i, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
    }
    m_record = -1;
    record.setText("------");
    previewPanel.invalidate();
    previewPanel.repaint();
}
Also used : ImpFormatRow(org.compiere.impexp.ImpFormatRow) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Aggregations

ImpFormatRow (org.compiere.impexp.ImpFormatRow)2 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 JLabel (javax.swing.JLabel)1 JTextField (javax.swing.JTextField)1 Label (org.adempiere.webui.component.Label)1 ListItem (org.adempiere.webui.component.ListItem)1 Textbox (org.adempiere.webui.component.Textbox)1 Hbox (org.zkoss.zul.Hbox)1