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);
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations