Search in sources :

Example 1 with ListItem

use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.

the class ADSortTab method migrateValueAcrossLists.

/**
	 * @param event
	 */
void migrateValueAcrossLists(Event event) {
    Object source = event.getTarget();
    if (source instanceof ListItem) {
        source = ((ListItem) source).getListbox();
    }
    Listbox listFrom = (source == bAdd || source == noList) ? noList : yesList;
    Listbox listTo = (source == bAdd || source == noList) ? yesList : noList;
    SimpleListModel lmFrom = (source == bAdd || source == noList) ? noModel : yesModel;
    SimpleListModel lmTo = (lmFrom == yesModel) ? noModel : yesModel;
    Set selectedItems = listFrom.getSelectedItems();
    List<ListElement> selObjects = new ArrayList<ListElement>();
    for (Object obj : selectedItems) {
        ListItem listItem = (ListItem) obj;
        int index = listFrom.getIndexOfItem(listItem);
        ListElement selObject = (ListElement) lmFrom.getElementAt(index);
        selObjects.add(selObject);
    }
    for (ListElement selObject : selObjects) {
        if (selObject == null || !selObject.isUpdateable())
            continue;
        lmFrom.removeElement(selObject);
        lmTo.addElement(selObject);
        //  Enable explicit Save
        setIsChanged(true);
    }
    for (ListElement selObject : selObjects) {
        int index = lmTo.indexOf(selObject);
        listTo.setSelectedIndex(index);
    }
    if (listTo.getSelectedItem() != null) {
        AuFocus focus = new AuFocus(listTo.getSelectedItem());
        Clients.response(focus);
    }
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) SimpleListModel(org.adempiere.webui.component.SimpleListModel) ArrayList(java.util.ArrayList) ListItem(org.adempiere.webui.component.ListItem) Listbox(org.adempiere.webui.component.Listbox) AuFocus(org.zkoss.zk.au.out.AuFocus)

Example 2 with ListItem

use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.

the class WFileImport method cmd_loadFile.

/**************************************************************************
	 *	Load File
	 */
private void cmd_loadFile() {
    Media media = null;
    media = Fileupload.get();
    if (media == null)
        return;
    if (media.isBinary()) {
        m_file_istream = media.getStreamData();
    } else {
        ListItem listitem = fCharset.getSelectedItem();
        if (listitem == null) {
            m_file_istream = new ReaderInputStream(media.getReaderData());
        } else {
            Charset charset = (Charset) listitem.getValue();
            m_file_istream = new ReaderInputStream(media.getReaderData(), charset.name());
        }
    }
    log.config(media.getName());
    bFile.setLabel(media.getName());
    cmd_reloadFile();
}
Also used : ReaderInputStream(org.adempiere.webui.util.ReaderInputStream) Media(org.zkoss.util.media.Media) Charset(java.nio.charset.Charset) ListItem(org.adempiere.webui.component.ListItem)

Example 3 with ListItem

use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.

the class WFileImport method dynInit.

/**
	 *	Dynamic Init
	 */
private void dynInit() {
    //	Load Formats
    pickFormat.appendItem(s_none, s_none);
    String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) pickFormat.appendItem(rs.getString(1), rs.getString(1));
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    pickFormat.setSelectedIndex(0);
    pickFormat.addEventListener(Events.ON_SELECT, this);
    Charset charset = Ini.getCharset();
    for (int i = 0; i < fCharset.getItemCount(); i++) {
        ListItem listitem = fCharset.getItemAtIndex(i);
        Charset compare = (Charset) listitem.getValue();
        if (charset == compare) {
            fCharset.setSelectedIndex(i);
            break;
        }
    }
    fCharset.addEventListener(Events.ON_SELECT, this);
    confirmPanel.setEnabled("Ok", false);
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Charset(java.nio.charset.Charset) PreparedStatement(java.sql.PreparedStatement) ListItem(org.adempiere.webui.component.ListItem)

Example 4 with ListItem

use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.

the class WFileImport method cmd_reloadFile.

/**
	 * Reload/Load file
	 */
private void cmd_reloadFile() {
    if (m_file_istream == null)
        return;
    m_data.clear();
    rawData.setText("");
    try {
        //  see NaturalAccountMap
        ListItem listitem = fCharset.getSelectedItem();
        Charset charset = null;
        if (listitem == null)
            return;
        charset = (Charset) listitem.getValue();
        BufferedReader in = new BufferedReader(new InputStreamReader(m_file_istream, charset), 10240);
        //	not safe see p108 Network pgm
        String s = null;
        String concat = "";
        while ((s = in.readLine()) != null) {
            m_data.add(s);
            concat += s;
            concat += "\n";
            if (m_data.size() < MAX_LOADED_LINES) {
                rawData.setValue(concat);
            }
        }
        in.close();
    } catch (Exception e) {
        log.log(Level.SEVERE, "", e);
        bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
    }
    //	second line as first may be heading
    int index = 1;
    if (m_data.size() == 1)
        index = 0;
    int length = 0;
    if (m_data.size() > 0)
        length = m_data.get(index).toString().length();
    info.setValue(Msg.getMsg(Env.getCtx(), "Records") + "=" + m_data.size() + ", " + Msg.getMsg(Env.getCtx(), "Length") + "=" + length + "   ");
    //setCursor (Cursor.getDefaultCursor());
    log.config("Records=" + m_data.size() + ", Length=" + length);
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Charset(java.nio.charset.Charset) ListItem(org.adempiere.webui.component.ListItem) SQLException(java.sql.SQLException)

Example 5 with ListItem

use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.

the class ZkReportViewer method cmd_export.

//	cmd_archive
/**
	 * 	Export
	 */
private void cmd_export() {
    log.config("");
    if (!m_isCanExport) {
        FDialog.error(m_WindowNo, this, "AccessCannotExport", getTitle());
        return;
    }
    if (winExportFile == null) {
        winExportFile = new Window();
        winExportFile.setTitle(Msg.getMsg(Env.getCtx(), "Export") + ": " + getTitle());
        winExportFile.setWidth("450px");
        winExportFile.setClosable(true);
        winExportFile.setBorder("normal");
        winExportFile.setStyle("position:absolute");
        cboType.setMold("select");
        cboType.getItems().clear();
        cboType.appendItem("ps" + " - " + Msg.getMsg(Env.getCtx(), "FilePS"), "ps");
        cboType.appendItem("xml" + " - " + Msg.getMsg(Env.getCtx(), "FileXML"), "xml");
        ListItem li = cboType.appendItem("pdf" + " - " + Msg.getMsg(Env.getCtx(), "FilePDF"), "pdf");
        cboType.appendItem("html" + " - " + Msg.getMsg(Env.getCtx(), "FileHTML"), "html");
        cboType.appendItem("txt" + " - " + Msg.getMsg(Env.getCtx(), "FileTXT"), "txt");
        cboType.appendItem("ssv" + " - " + Msg.getMsg(Env.getCtx(), "FileSSV"), "ssv");
        cboType.appendItem("csv" + " - " + Msg.getMsg(Env.getCtx(), "FileCSV"), "csv");
        cboType.appendItem("xls" + " - " + Msg.getMsg(Env.getCtx(), "FileXLS"), "xls");
        cboType.setSelectedItem(li);
        Hbox hb = new Hbox();
        Div div = new Div();
        div.setAlign("right");
        div.appendChild(new Label(Msg.getMsg(Env.getCtx(), "FilesOfType")));
        hb.appendChild(div);
        hb.appendChild(cboType);
        cboType.setWidth("100%");
        Vbox vb = new Vbox();
        vb.setWidth("390px");
        winExportFile.appendChild(vb);
        vb.appendChild(hb);
        vb.appendChild(confirmPanel);
        confirmPanel.addActionListener(this);
    }
    AEnv.showCenterScreen(winExportFile);
}
Also used : Window(org.adempiere.webui.component.Window) Div(org.zkoss.zul.Div) Hbox(org.zkoss.zul.Hbox) Label(org.adempiere.webui.component.Label) ListItem(org.adempiere.webui.component.ListItem) Vbox(org.zkoss.zul.Vbox)

Aggregations

ListItem (org.adempiere.webui.component.ListItem)52 KeyNamePair (org.compiere.util.KeyNamePair)22 Timestamp (java.sql.Timestamp)8 Listbox (org.adempiere.webui.component.Listbox)8 SQLException (java.sql.SQLException)7 BigDecimal (java.math.BigDecimal)6 Label (org.adempiere.webui.component.Label)5 ResultSet (java.sql.ResultSet)4 Date (java.util.Date)4 MLocator (org.compiere.model.MLocator)4 ValueNamePair (org.compiere.util.ValueNamePair)4 Charset (java.nio.charset.Charset)3 PreparedStatement (java.sql.PreparedStatement)3 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 NumberBox (org.adempiere.webui.component.NumberBox)3 Row (org.adempiere.webui.component.Row)3 Textbox (org.adempiere.webui.component.Textbox)3 MAttributeValue (org.compiere.model.MAttributeValue)3 BufferedImage (java.awt.image.BufferedImage)2