Search in sources :

Example 1 with FindWindow

use of org.adempiere.webui.window.FindWindow in project adempiere by adempiere.

the class AbstractADWindowPanel method initialQuery.

/**
     * Initial Query
     *
     * @param query
     *            initial query
     * @param mTab
     *            tab
     * @return query or null
     */
private MQuery initialQuery(MQuery query, GridTab mTab) {
    // We have a (Zoom) query
    if (query != null && query.isActive() && query.getRecordCount() < 10)
        return query;
    //
    StringBuffer where = new StringBuffer(Env.parseContext(ctx, curWindowNo, mTab.getWhereExtended(), false));
    // Query automatically if high volume and no query
    boolean require = mTab.isHighVolume();
    if (// No Trx Window
    !require && !m_onlyCurrentRows) {
        if (query != null) {
            String wh2 = query.getWhereClause();
            if (wh2.length() > 0) {
                if (where.length() > 0)
                    where.append(" AND ");
                where.append(wh2);
            }
        }
        //
        StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ").append(mTab.getTableName());
        if (where.length() > 0)
            sql.append(" WHERE ").append(where);
        // Does not consider security
        int no = DB.getSQLValue(null, sql.toString());
        //
        require = MRole.getDefault().isQueryRequire(no);
    }
    // Show Query
    if (require) {
        m_findCancelled = false;
        m_findCreateNew = false;
        GridField[] findFields = mTab.getFields();
        FindWindow find = new FindWindow(curWindowNo, mTab.getName(), mTab.getAD_Table_ID(), mTab.getTableName(), where.toString(), findFields, 10, // no query below 10
        mTab.getAD_Tab_ID());
        if (find.getTitle() != null && find.getTitle().length() > 0) {
            // Title is not set when the number of rows is below the minRecords parameter (10)
            if (!find.isCancel()) {
                query = find.getQuery();
                m_findCreateNew = find.isCreateNew();
            } else
                m_findCancelled = true;
            find = null;
        }
    }
    return query;
}
Also used : GridField(org.compiere.model.GridField) FindWindow(org.adempiere.webui.window.FindWindow)

Aggregations

FindWindow (org.adempiere.webui.window.FindWindow)1 GridField (org.compiere.model.GridField)1