Search in sources :

Example 1 with SimpleListModel

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);
    }
}
Also used : Treeitem(org.zkoss.zul.Treeitem) SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) SimpleListModel(org.adempiere.webui.component.SimpleListModel)

Example 2 with SimpleListModel

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);
}
Also used : SimpleListModel(org.adempiere.webui.component.SimpleListModel)

Example 3 with SimpleListModel

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;
}
Also used : Listheader(org.zkoss.zul.Listheader) Listhead(org.zkoss.zul.Listhead) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) MTable(org.compiere.model.MTable) SimpleListModel(org.adempiere.webui.component.SimpleListModel) ResultSet(java.sql.ResultSet) Vector(java.util.Vector)

Example 4 with SimpleListModel

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() + ")");
}
Also used : SimpleListModel(org.adempiere.webui.component.SimpleListModel) Vector(java.util.Vector)

Example 5 with SimpleListModel

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

Aggregations

SimpleListModel (org.adempiere.webui.component.SimpleListModel)9 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Vector (java.util.Vector)2 Listhead (org.zkoss.zul.Listhead)2 Listheader (org.zkoss.zul.Listheader)2 PreparedStatement (java.sql.PreparedStatement)1 Timestamp (java.sql.Timestamp)1 Set (java.util.Set)1 ListItem (org.adempiere.webui.component.ListItem)1 Listbox (org.adempiere.webui.component.Listbox)1 SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)1 WListbox (org.adempiere.webui.component.WListbox)1 ColumnInfo (org.compiere.minigrid.ColumnInfo)1 MTable (org.compiere.model.MTable)1 MTree (org.compiere.model.MTree)1 KeyNamePair (org.compiere.util.KeyNamePair)1 AuFocus (org.zkoss.zk.au.out.AuFocus)1 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)1 Treeitem (org.zkoss.zul.Treeitem)1