use of org.adempiere.webui.component.SimpleListModel in project adempiere by adempiere.
the class WTreeMaintenance method onListSelection.
// action_fillTree
/**
* List Selection Listener
* @param e event
*/
private void onListSelection(Event e) {
ListItem selected = null;
try {
SimpleListModel model = (SimpleListModel) centerList.getModel();
int i = centerList.getSelectedIndex();
selected = (ListItem) model.getElementAt(i);
} catch (Exception ex) {
}
log.info("Selected=" + selected);
if (// allow add if not in tree
selected != null) {
SimpleTreeModel tm = (SimpleTreeModel) (TreeModel<?>) centerTree.getModel();
DefaultTreeNode stn = tm.find(tm.getRoot(), selected.id);
if (stn != null) {
int[] path = tm.getPath(stn);
Treeitem ti = centerTree.renderItemByPath(path);
ti.setSelected(true);
}
bAdd.setEnabled(stn == null);
}
}
use of org.adempiere.webui.component.SimpleListModel in project adempiere by adempiere.
the class WTreeMaintenance method onEvent.
// dispose
/**
* Action Listener
* @param e event
*/
public void onEvent(Event e) {
if (e.getTarget() == treeField) {
action_loadTree();
ThemeUtils.sendDeferLayoutEvent(mainLayout, 100);
} else if (e.getTarget() == bAddAll)
action_treeAddAll();
else if (e.getTarget() == bAdd) {
SimpleListModel model = (SimpleListModel) centerList.getModel();
int i = centerList.getSelectedIndex();
if (i >= 0) {
action_treeAdd((ListItem) model.getElementAt(i));
}
} else if (e.getTarget() == bDelete) {
SimpleListModel model = (SimpleListModel) centerList.getModel();
int i = centerList.getSelectedIndex();
if (i >= 0) {
action_treeDelete((ListItem) model.getElementAt(i));
}
} else if (e.getTarget() == bDeleteAll)
action_treeDeleteAll();
else if (e.getTarget() == centerList)
onListSelection(e);
else if (e.getTarget() == centerTree)
onTreeSelection(e);
}
use of org.adempiere.webui.component.SimpleListModel in project adempiere by adempiere.
the class WFieldRecordInfo method dynInit.
// init
/**
* Dynamic Init
* @param title title
* @return true if table initialized
*/
private boolean dynInit(String title) {
// Title
if (AD_Table_ID != 0) {
MTable table1 = MTable.get(Env.getCtx(), AD_Table_ID);
setTitle(title + " - " + table1.getName());
}
// Only Client Preference can view Change Log
if (!MRole.PREFERENCETYPE_Client.equals(MRole.getDefault().getPreferenceType()))
return false;
if (Record_ID == 0)
return false;
// Data
String sql = "SELECT AD_Column_ID, Updated, UpdatedBy, OldValue, NewValue " + "FROM AD_ChangeLog " + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Column_ID=?" + "ORDER BY Updated DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
pstmt.setInt(2, Record_ID);
pstmt.setInt(3, AD_Column_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
addLine(rs.getInt(1), rs.getTimestamp(2), rs.getInt(3), rs.getString(4), rs.getString(5));
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
}
//
Vector<String> columnNames = new Vector<String>();
columnNames.add(Msg.translate(Env.getCtx(), "NewValue"));
columnNames.add(Msg.translate(Env.getCtx(), "OldValue"));
columnNames.add(Msg.translate(Env.getCtx(), "UpdatedBy"));
columnNames.add(Msg.translate(Env.getCtx(), "Updated"));
Listhead listhead = new Listhead();
listhead.setSizable(true);
for (int i = 0; i < columnNames.size(); i++) {
Listheader listheader = new Listheader(columnNames.get(i).replaceAll("[&]", ""));
listhead.appendChild(listheader);
}
table.appendChild(listhead);
List<Object> list = new ArrayList<Object>();
for (Vector<String> data : m_data) {
list.add(data.toString());
}
SimpleListModel model = new SimpleListModel(list);
table.setItemRenderer(model);
table.setModel(model);
return true;
}
use of org.adempiere.webui.component.SimpleListModel in project adempiere by adempiere.
the class AboutWindow method updateLogTable.
private void updateLogTable() {
Vector<Vector<Object>> data = CLogErrorBuffer.get(true).getLogData(bErrorsOnly.isChecked());
SimpleListModel model = new SimpleListModel(data);
model.setMaxLength(new int[] { 0, 0, 0, 200, 0, 200 });
logTable.setItemRenderer(model);
logTable.setModel(model);
if (bErrorsOnly.isSelected())
tabLog.setLabel(Msg.getMsg(Env.getCtx(), "Errors") + " (" + data.size() + ")");
else
tabLog.setLabel(Msg.getMsg(Env.getCtx(), "TraceInfo") + " (" + data.size() + ")");
}
use of org.adempiere.webui.component.SimpleListModel 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);
}
}
Aggregations