Search in sources :

Example 81 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class AbstractADWindowPanel method onChat.

public void onChat() {
    int recordId = curTab.getRecord_ID();
    logger.info("Record_ID=" + recordId);
    if (//	No Key
    recordId == -1) {
        return;
    }
    //	Find display
    String infoName = null;
    String infoDisplay = null;
    for (int i = 0; i < curTab.getFieldCount(); i++) {
        GridField field = curTab.getField(i);
        if (field.isKey())
            infoName = field.getHeader();
        if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo")) && field.getValue() != null)
            infoDisplay = field.getValue().toString();
        if (infoName != null && infoDisplay != null)
            break;
    }
    String description = infoName + ": " + infoDisplay;
    new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null);
    curTab.loadChats();
    toolbar.getButton("Chat").setPressed(curTab.hasChat());
    focusToActivePanel();
}
Also used : WChat(org.adempiere.webui.window.WChat) GridField(org.compiere.model.GridField)

Example 82 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class AbstractADWindowPanel method doZoomToDetail.

private boolean doZoomToDetail(GridTab gTab, MQuery query, int tabIndex) {
    GridField[] fields = gTab.getFields();
    for (GridField field : fields) {
        if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName())) {
            gridWindow.initTab(tabIndex);
            int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
            if (parentId > 0) {
                Map<Integer, Object[]> parentMap = new TreeMap<Integer, Object[]>();
                int index = tabIndex;
                int oldpid = parentId;
                GridTab currentTab = gTab;
                while (index > 0) {
                    index--;
                    GridTab pTab = gridWindow.getTab(index);
                    if (pTab.getTabLevel() < currentTab.getTabLevel()) {
                        gridWindow.initTab(index);
                        if (index > 0) {
                            if (pTab.getLinkColumnName() != null && pTab.getLinkColumnName().trim().length() > 0) {
                                int pid = DB.getSQLValue(null, "SELECT " + pTab.getLinkColumnName() + " FROM " + pTab.getTableName() + " WHERE " + currentTab.getLinkColumnName() + " = ?", oldpid);
                                if (pid > 0) {
                                    parentMap.put(index, new Object[] { currentTab.getLinkColumnName(), oldpid });
                                    oldpid = pid;
                                    currentTab = pTab;
                                } else {
                                    parentMap.clear();
                                    break;
                                }
                            }
                        } else {
                            parentMap.put(index, new Object[] { currentTab.getLinkColumnName(), oldpid });
                        }
                    }
                }
                for (Map.Entry<Integer, Object[]> entry : parentMap.entrySet()) {
                    GridTab pTab = gridWindow.getTab(entry.getKey());
                    Object[] value = entry.getValue();
                    MQuery pquery = new MQuery(pTab.getAD_Table_ID());
                    pquery.addRestriction((String) value[0], "=", value[1]);
                    pTab.setQuery(pquery);
                    IADTabPanel tp = adTab.findADTabpanel(pTab);
                    tp.createUI();
                    tp.query();
                }
                MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
                targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId);
                gTab.setQuery(targetQuery);
                IADTabPanel gc = null;
                if (!includedMap.containsKey(gTab.getAD_Tab_ID())) {
                    gc = adTab.findADTabpanel(gTab);
                } else {
                    ADTabPanel parent = (ADTabPanel) includedMap.get(gTab.getAD_Tab_ID());
                    gc = parent.findEmbeddedPanel(gTab);
                }
                gc.createUI();
                gc.query(false, 0, 0);
                GridTable table = gTab.getTableModel();
                int count = table.getRowCount();
                for (int i = 0; i < count; i++) {
                    int id = table.getKeyID(i);
                    if (id == ((Integer) query.getZoomValue()).intValue()) {
                        if (!includedMap.containsKey(gTab.getAD_Tab_ID())) {
                            setActiveTab(gridWindow.getTabIndex(gTab));
                        } else {
                            IADTabPanel parent = includedMap.get(gTab.getAD_Tab_ID());
                            int pindex = gridWindow.getTabIndex(parent.getGridTab());
                            if (pindex >= 0)
                                setActiveTab(pindex);
                        }
                        gTab.setCurrentRow(i);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : GridTable(org.compiere.model.GridTable) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) TreeMap(java.util.TreeMap) GridTab(org.compiere.model.GridTab) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 83 with GridField

use of org.compiere.model.GridField 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)

Example 84 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class AbstractADWindowPanel method onFind.

//
/**
     * @see ToolbarListener#onFind()
     */
public void onFind() {
    GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
    if (currentTab == null)
        return;
    if (!onSave(false))
        return;
    //  Gets Fields from AD_Field_v
    GridField[] findFields = GridField.createFields(ctx, currentTab.getWindowNo(), 0, currentTab.getAD_Tab_ID());
    //        FindWindow find = new FindWindow (currentTab.getWindowNo(), currentTab.getName(),
    //                currentTab.getAD_Table_ID(), currentTab.getTableName(),
    //                currentTab.getWhereExtended(), findFields, 1, currentTab.getAD_Tab_ID());
    //  Open a popup or the search window
    WSearch find = new WSearch(this, toolbar.getEvent().getTarget(), currentTab, findFields);
}
Also used : WSearch(org.adempiere.webui.WSearch) GridTab(org.compiere.model.GridTab) GridField(org.compiere.model.GridField)

Example 85 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class BrowserRow method setValue.

/**
	 * BR[ 268 ]
	 * Set value to a column and row
	 * @param p_Row
	 * @param p_ColumnName
	 * @param p_Value
	 */
public void setValue(int p_Row, String p_ColumnName, Object p_Value) {
    //	Valid Table
    if (m_Table == null)
        return;
    Integer columnIndex = columnNamesIndex.get(p_ColumnName);
    //	Valid Index
    if (columnIndex == null)
        return;
    //	Get current Value
    GridField gridField = getValue(p_Row, columnIndex);
    gridField.setValue(p_Value, true);
    if (gridField.isDisplayed()) {
        m_Table.setValueAt(p_Row, getDisplayIndex(columnIndex), gridField);
    } else {
        setValue(p_Row, columnIndex, gridField);
    }
}
Also used : GridField(org.compiere.model.GridField)

Aggregations

GridField (org.compiere.model.GridField)114 MQuery (org.compiere.model.MQuery)15 WEditor (org.adempiere.webui.editor.WEditor)11 GridFieldVO (org.compiere.model.GridFieldVO)10 GridTab (org.compiere.model.GridTab)10 Lookup (org.compiere.model.Lookup)9 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)8 MLookup (org.compiere.model.MLookup)8 Component (java.awt.Component)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)7 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)7 ValueNamePair (org.compiere.util.ValueNamePair)7 SQLException (java.sql.SQLException)6 MBrowseField (org.adempiere.model.MBrowseField)6 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)6 VEditor (org.compiere.grid.ed.VEditor)6 Point (java.awt.Point)5 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)5 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)5