Search in sources :

Example 1 with WListItemRenderer

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

the class WPOSTable method setColumnClass.

/**
	 * Set the attributes of the column.
	 *
	 * @param index		The index of the column to be modified
	 * @param classType	The class of data that the column will contain
	 * @param readOnly	Whether the data in the column is read only
	 * @param header	The header text for the column
	 *
	 * @see #setColumnClass(int, Class, boolean)
	 */
public void setColumnClass(int index, Class classType, boolean readOnly, String header) {
    WListItemRenderer renderer = (WListItemRenderer) getItemRenderer();
    setColumnReadOnly(index, readOnly);
    renderer.setColumnHeader(index, header);
    renderer.setColumnClass(index, classType);
    if (index < m_modelHeaderClass.size())
        m_modelHeaderClass.set(index, classType);
    else
        m_modelHeaderClass.add(classType);
    return;
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer)

Example 2 with WListItemRenderer

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

the class WPOSTable method setColumnClass.

public void setColumnClass(int index, Class classType, boolean readOnly) {
    setColumnReadOnly(index, readOnly);
    WListItemRenderer renderer = (WListItemRenderer) getItemRenderer();
    renderer.setColumnClass(index, classType);
    m_modelHeaderClass.add(classType);
    return;
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer)

Example 3 with WListItemRenderer

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

the class WWFActivity method loadActivities.

/**
	 * 	Load Activities
	 * 	@return int
	 */
public int loadActivities() {
    long start = System.currentTimeMillis();
    int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue("MAX_ACTIVITIES_IN_LIST", 200, Env.getAD_Client_ID(Env.getCtx()));
    model = new ListModelTable();
    ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
    String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + //	Owner of Activity
    " a.AD_User_ID=?" + //	Invoker (if no invoker = all)
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#2
    " AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#3
    " AND r.AD_User_ID=?)" + //	Responsible Role
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + //	#4
    " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
    ") ORDER BY a.Priority DESC, Created";
    int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
    MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
    sql = role.addAccessSQL(sql, "a", true, false);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_User_ID);
        pstmt.setInt(2, AD_User_ID);
        pstmt.setInt(3, AD_User_ID);
        pstmt.setInt(4, AD_User_ID);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
            list.add(activity);
            List<Object> rowData = new ArrayList<Object>();
            rowData.add(activity.getPriority());
            rowData.add(activity.getNodeName());
            rowData.add(activity.getSummary());
            model.add(rowData);
            if (list.size() > MAX_ACTIVITIES_IN_LIST && MAX_ACTIVITIES_IN_LIST > 0) {
                log.warning("More then 200 Activities - ignored");
                break;
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    m_activities = new MWFActivity[list.size()];
    list.toArray(m_activities);
    //
    log.fine("#" + m_activities.length + "(" + (System.currentTimeMillis() - start) + "ms)");
    m_index = 0;
    String[] columns = new String[] { Msg.translate(Env.getCtx(), "Priority"), Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), Msg.translate(Env.getCtx(), "Summary") };
    WListItemRenderer renderer = new WListItemRenderer(Arrays.asList(columns));
    ListHeader header = new ListHeader();
    header.setWidth("30px");
    renderer.setListHeader(0, header);
    renderer.addTableValueChangeListener(listbox);
    model.setNoColumns(columns.length);
    listbox.setModel(model);
    listbox.setItemRenderer(renderer);
    listbox.repaint();
    listbox.setFixedLayout(true);
    return m_activities.length;
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer) MRole(org.compiere.model.MRole) ArrayList(java.util.ArrayList) ListModelTable(org.adempiere.webui.component.ListModelTable) PreparedStatement(java.sql.PreparedStatement) MWFActivity(org.compiere.wf.MWFActivity) ResultSet(java.sql.ResultSet) ListHeader(org.adempiere.webui.component.ListHeader)

Example 4 with WListItemRenderer

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

the class WPOSTable method addColumn.

/**
	 * Set the attributes of the column.
	 *
	 * @param classType	The class of data that the column will contain
	 * @param readOnly	Whether the data in the column is read only
	 * @param header	The header text for the column
	 *
	 * @see #setColumnClass(int, Class, boolean)
	 * @see #addColumn(String)
	 */
public void addColumn(Class classType, boolean readOnly, String header) {
    m_modelHeaderClass.add(classType);
    setColumnReadOnly(m_modelHeaderClass.size() - 1, readOnly);
    addColumn(header);
    WListItemRenderer renderer = (WListItemRenderer) getItemRenderer();
    renderer.setColumnClass((renderer.getNoColumns() - 1), classType);
    return;
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer)

Example 5 with WListItemRenderer

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

the class WAcctViewer method actionQuery.

// sortAddItem
/**
	 *  Query
	 */
private void actionQuery() {
    //  Parameter Info
    StringBuffer para = new StringBuffer();
    //  Reset Selection Data
    m_data.C_AcctSchema_ID = 0;
    m_data.AD_Org_ID = 0;
    //  Save Selection Choices
    Listitem listitem = selAcctSchema.getSelectedItem();
    KeyNamePair kp = null;
    if (listitem != null)
        kp = (KeyNamePair) listitem.getValue();
    if (kp != null)
        m_data.C_AcctSchema_ID = kp.getKey();
    para.append("C_AcctSchema_ID=").append(m_data.C_AcctSchema_ID);
    listitem = selPostingType.getSelectedItem();
    ValueNamePair vp = null;
    if (listitem != null)
        vp = (ValueNamePair) listitem.getValue();
    else
        return;
    m_data.PostingType = vp.getValue();
    para.append(", PostingType=").append(m_data.PostingType);
    //  Document
    m_data.documentQuery = selDocument.isChecked();
    para.append(", DocumentQuery=").append(m_data.documentQuery);
    if (selDocument.isChecked()) {
        if (m_data.AD_Table_ID == 0 || m_data.Record_ID == 0)
            return;
        para.append(", AD_Table_ID=").append(m_data.AD_Table_ID).append(", Record_ID=").append(m_data.Record_ID);
    } else {
        m_data.DateFrom = selDateFrom.getValue() != null ? new Timestamp(selDateFrom.getValue().getTime()) : null;
        para.append(", DateFrom=").append(m_data.DateFrom);
        m_data.DateTo = selDateTo.getValue() != null ? new Timestamp(selDateTo.getValue().getTime()) : null;
        para.append(", DateTo=").append(m_data.DateTo);
        listitem = selOrg.getSelectedItem();
        if (listitem != null)
            kp = (KeyNamePair) listitem.getValue();
        else
            kp = null;
        if (kp != null)
            m_data.AD_Org_ID = kp.getKey();
        para.append(", AD_Org_ID=").append(m_data.AD_Org_ID);
        //
        Iterator<String> it = m_data.whereInfo.values().iterator();
        while (it.hasNext()) para.append(", ").append(it.next());
    }
    //  Save Display Choices
    m_data.displayQty = displayQty.isChecked();
    para.append(" - Display Qty=").append(m_data.displayQty);
    m_data.displaySourceAmt = displaySourceAmt.isChecked();
    para.append(", Source=").append(m_data.displaySourceAmt);
    m_data.displayDocumentInfo = displayDocumentInfo.isChecked();
    para.append(", Doc=").append(m_data.displayDocumentInfo);
    listitem = sortBy1.getSelectedItem();
    vp = null;
    if (listitem != null) {
        vp = (ValueNamePair) listitem.getValue();
        if (vp.getName() != null && vp.getName().trim().length() > 0) {
            //vp.getName();
            m_data.sortBy1 = vp.getValue();
            m_data.group1 = group1.isChecked();
            para.append(" - Sorting: ").append(m_data.sortBy1).append("/").append(m_data.group1);
        }
    }
    listitem = sortBy2.getSelectedItem();
    vp = null;
    if (listitem != null) {
        vp = (ValueNamePair) listitem.getValue();
        if (vp.getName() != null && vp.getName().trim().length() > 0) {
            //vp.getName();
            m_data.sortBy2 = vp.getValue();
            m_data.group2 = group2.isChecked();
            para.append(", ").append(m_data.sortBy2).append("/").append(m_data.group2);
        }
    }
    listitem = sortBy3.getSelectedItem();
    vp = null;
    if (listitem != null) {
        vp = (ValueNamePair) listitem.getValue();
        if (vp.getName() != null && vp.getName().trim().length() > 0) {
            //vp.getName();
            m_data.sortBy3 = vp.getValue();
            m_data.group3 = group3.isChecked();
            para.append(", ").append(m_data.sortBy3).append("/").append(m_data.group3);
        }
    }
    listitem = sortBy4.getSelectedItem();
    vp = null;
    if (listitem != null) {
        vp = (ValueNamePair) listitem.getValue();
        if (vp.getName() != null && vp.getName().trim().length() > 0) {
            //vp.getName();
            m_data.sortBy4 = vp.getValue();
            m_data.group4 = group4.isChecked();
            para.append(", ").append(m_data.sortBy4).append("/").append(m_data.group4);
        }
    }
    bQuery.setEnabled(false);
    statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "Processing"));
    log.config(para.toString());
    //  Switch to Result pane
    tabbedPane.setSelectedIndex(1);
    //  Set TableModel with Query
    RModel rmodel = m_data.query();
    m_queryData = rmodel.getRows();
    List<ArrayList<Object>> list = null;
    paging.setPageSize(PAGE_SIZE);
    if (m_queryData.size() > PAGE_SIZE) {
        list = m_queryData.subList(0, PAGE_SIZE);
        paging.setTotalSize(m_queryData.size());
        pagingPanel.setVisible(true);
    } else {
        list = m_queryData;
        paging.setTotalSize(m_queryData.size());
        pagingPanel.setVisible(false);
    }
    paging.setActivePage(0);
    ListModelTable listmodeltable = new ListModelTable(list);
    if (table.getListhead() == null) {
        Listhead listhead = new Listhead();
        listhead.setSizable(true);
        for (int i = 0; i < rmodel.getColumnCount(); i++) {
            // Replace user columns with the user selected names
            String displayColumnName = rmodel.getColumnName(i);
            ;
            String columnName;
            RColumn col = rmodel.getColumn(i);
            columnName = col.getColumnName();
            MAcctSchema as = MAcctSchema.get(Env.getCtx(), m_data.C_AcctSchema_ID);
            if (columnName.equals("User1_ID")) {
                MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList1);
                if (ase != null)
                    displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
            } else if (columnName.equals("User2_ID")) {
                MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList2);
                if (ase != null)
                    displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
            } else if (columnName.equals("User3_ID")) {
                MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList3);
                if (ase != null)
                    displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
            } else if (columnName.equals("User4_ID")) {
                MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList4);
                if (ase != null)
                    displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
            }
            Listheader listheader = new Listheader(displayColumnName);
            listheader.setTooltiptext(rmodel.getColumnName(i));
            listhead.appendChild(listheader);
        }
        table.appendChild(listhead);
    } else // Elaine 2008/07/28
    {
        Listhead listhead = table.getListhead();
        // remove existing column header
        listhead.getChildren().clear();
        // add in new column header
        for (int i = 0; i < rmodel.getColumnCount(); i++) {
            Listheader listheader = new Listheader(rmodel.getColumnName(i));
            listhead.appendChild(listheader);
        }
    }
    //
    table.getItems().clear();
    table.setItemRenderer(new WListItemRenderer());
    table.setModel(listmodeltable);
    resultPanel.invalidate();
    bQuery.setEnabled(true);
    statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions"));
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer) Listheader(org.zkoss.zul.Listheader) Listhead(org.zkoss.zul.Listhead) Listitem(org.zkoss.zul.Listitem) ArrayList(java.util.ArrayList) RModel(org.compiere.report.core.RModel) ListModelTable(org.adempiere.webui.component.ListModelTable) RColumn(org.compiere.report.core.RColumn) Timestamp(java.sql.Timestamp) MAcctSchema(org.compiere.model.MAcctSchema) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Aggregations

WListItemRenderer (org.adempiere.webui.component.WListItemRenderer)7 ArrayList (java.util.ArrayList)2 ListModelTable (org.adempiere.webui.component.ListModelTable)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Timestamp (java.sql.Timestamp)1 Vector (java.util.Vector)1 ListHeader (org.adempiere.webui.component.ListHeader)1 MAcctSchema (org.compiere.model.MAcctSchema)1 MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)1 MRole (org.compiere.model.MRole)1 RColumn (org.compiere.report.core.RColumn)1 RModel (org.compiere.report.core.RModel)1 KeyNamePair (org.compiere.util.KeyNamePair)1 ValueNamePair (org.compiere.util.ValueNamePair)1 MWFActivity (org.compiere.wf.MWFActivity)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Listhead (org.zkoss.zul.Listhead)1 Listheader (org.zkoss.zul.Listheader)1