Search in sources :

Example 21 with GridTab

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

the class ARequest method actionPerformed.

//	getZoomTargets
/**
	 * 	Listner
	 *	@param e event
	 */
public void actionPerformed(ActionEvent e) {
    MQuery query = null;
    if (e.getSource() == m_active) {
        query = new MQuery("");
        String where = "(" + m_where + ") AND Processed='N'";
        query.addRestriction(where);
        query.setRecordCount(0);
    } else if (e.getSource() == m_all) {
        query = new MQuery("");
        query.addRestriction(m_where.toString());
        query.setRecordCount(0);
    } else if (e.getSource() == m_new) {
        query = new MQuery("");
        query.addRestriction("1=2");
        query.setRecordCount(0);
    }
    //
    //	232=all - 201=my
    int AD_Window_ID = 232;
    AWindow frame = new AWindow(m_graphicsconfig);
    if (!frame.initWindow(AD_Window_ID, query))
        return;
    AEnv.addToWindowManager(frame);
    //	New - set Table/Record
    if (e.getSource() == m_new) {
        GridTab tab = frame.getAPanel().getCurrentTab();
        tab.dataNew(false);
        tab.setValue("AD_Table_ID", new Integer(m_AD_Table_ID));
        tab.setValue("Record_ID", new Integer(m_Record_ID));
        //
        if (m_C_BPartner_ID != 0)
            tab.setValue("C_BPartner_ID", new Integer(m_C_BPartner_ID));
        //
        if (m_AD_Table_ID == I_C_BPartner.Table_ID)
            tab.setValue("C_BPartner_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_AD_User.Table_ID)
            tab.setValue("AD_User_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Project.Table_ID)
            tab.setValue("C_Project_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_A_Asset.Table_ID)
            tab.setValue("A_Asset_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Order.Table_ID)
            tab.setValue("C_Order_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_C_Invoice.Table_ID)
            tab.setValue("C_Invoice_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_M_Product.Table_ID)
            tab.setValue("M_Product_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_C_Payment.Table_ID)
            tab.setValue("C_Payment_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_M_InOut.Table_ID)
            tab.setValue("M_InOut_ID", new Integer(m_Record_ID));
        else if (m_AD_Table_ID == I_M_RMA.Table_ID)
            tab.setValue("M_RMA_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_C_Campaign.Table_ID)
            tab.setValue("C_Campaign_ID", new Integer(m_Record_ID));
        else //
        if (m_AD_Table_ID == I_R_Request.Table_ID)
            tab.setValue(MRequest.COLUMNNAME_R_RequestRelated_ID, new Integer(m_Record_ID));
        else // FR [2842165] - Order Ref link from SO line creating new request
        if (m_AD_Table_ID == I_C_OrderLine.Table_ID) {
            MOrderLine oLine = new MOrderLine(Env.getCtx(), m_Record_ID, null);
            if (oLine != null) {
                tab.setValue(MOrderLine.COLUMNNAME_C_Order_ID, new Integer(oLine.getC_Order_ID()));
            }
        }
    }
    AEnv.showCenterScreen(frame);
    frame = null;
}
Also used : GridTab(org.compiere.model.GridTab) MQuery(org.compiere.model.MQuery) MOrderLine(org.compiere.model.MOrderLine)

Example 22 with GridTab

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

the class APanel 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())) {
            m_mWorkbench.getMWindow(0).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 = m_mWorkbench.getMWindow(0).getTab(index);
                    if (pTab.getTabLevel() < currentTab.getTabLevel()) {
                        m_mWorkbench.getMWindow(0).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 = m_mWorkbench.getMWindow(0).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);
                    GridController gc = (GridController) tabPanel.getComponentAt(entry.getKey());
                    gc.activate();
                    gc.query(false, 0, 0);
                }
                MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
                targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId);
                gTab.setQuery(targetQuery);
                GridController gc = null;
                if (!includedMap.containsKey(gTab.getAD_Tab_ID())) {
                    int target = tabPanel.findTabindex(gTab);
                    gc = (GridController) tabPanel.getComponentAt(target);
                } else {
                    GridController parent = includedMap.get(gTab.getAD_Tab_ID());
                    gc = parent.findChild(gTab);
                }
                gc.activate();
                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())) {
                            tabPanel.setSelectedIndex(tabPanel.findTabindex(gTab));
                        } else {
                            GridController parent = includedMap.get(gTab.getAD_Tab_ID());
                            int pindex = tabPanel.findTabindex(parent.getMTab());
                            if (pindex >= 0)
                                tabPanel.setSelectedIndex(pindex);
                        }
                        gTab.navigate(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) Point(java.awt.Point) GridTab(org.compiere.model.GridTab) GridController(org.compiere.grid.GridController) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 23 with GridTab

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

the class WEditorPopupMenu method updateItemsFromEditor.

/**
     * Update popup menu items from editor
     * @param editor
     */
private void updateItemsFromEditor(WEditor editor) {
    GridField gridField = editor.getGridField();
    if (gridField == null)
        return;
    final int windowNo = gridField.getWindowNo();
    GridTab gridTab = gridField.getGridTab();
    if (gridTab == null)
        return;
    final int tabNo = gridTab.getTabNo();
    final String columnName = gridField.getColumnName();
    for (String action : ACTIONS) {
        String context = buildDisableItemContext(action, columnName);
        String value = Env.getContext(Env.getCtx(), windowNo, tabNo, context);
        if ("Y".equals(value)) {
            mapDisabledItems.put(action, true);
            continue;
        } else if ("N".equals(value)) {
            mapDisabledItems.put(action, false);
            continue;
        }
        // Check settings for all columns:
        context = buildDisableItemContext(action, "*");
        if ("Y".equals(value)) {
            mapDisabledItems.put(action, true);
            continue;
        } else if ("N".equals(value)) {
            mapDisabledItems.put(action, false);
            continue;
        }
    }
    updateItemsDyn();
}
Also used : GridTab(org.compiere.model.GridTab) GridField(org.compiere.model.GridField)

Example 24 with GridTab

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

the class AbstractADWindowPanel method onNew.

/**
     * @see ToolbarListener#onNew()
     */
public void onNew() {
    GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
    ((ADTabPanel) toolbar.getCurrentPanel()).getListPanel().refresh(currentTab);
    if (!currentTab.isInsertRecord()) {
        logger.warning("Insert Record disabled for Tab");
        return;
    }
    if (!autoSave()) {
        return;
    }
    newRecord = currentTab.dataNew(false);
    if (newRecord) {
        //curTabPanel.dynamicDisplay(0);
        toolbar.getCurrentPanel().dynamicDisplay(0);
        toolbar.enableChanges(false);
        toolbar.enableDelete(false);
        toolbar.enableDeleteSelection(false);
        toolbar.enableNavigation(false);
        toolbar.enableTabNavigation(false);
        toolbar.enableIgnore(true);
        toolbar.enablePrint(currentTab.isPrinted());
        toolbar.enableReport(true);
    } else {
        logger.severe("Could not create new record");
    }
    focusToActivePanel();
}
Also used : GridTab(org.compiere.model.GridTab)

Example 25 with GridTab

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

the class AbstractADWindowPanel method actionButton.

//
/**************************************************************************
	 *	Start Button Process
	 *  @param wButton button
	 */
private void actionButton(WButtonEditor wButton) {
    GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
    if (currentTab.hasChangedCurrentTabAndParents()) {
        String msg = CLogger.retrieveErrorString("Please ReQuery Window");
        FDialog.error(curWindowNo, parent, null, msg);
        return;
    }
    logger.info(wButton.toString());
    boolean startWOasking = false;
    String col = wButton.getColumnName();
    //  Zoom
    if (col.equals("Record_ID")) {
        int AD_Table_ID = Env.getContextAsInt(ctx, curWindowNo, "AD_Table_ID");
        int Record_ID = Env.getContextAsInt(ctx, curWindowNo, "Record_ID");
        AEnv.zoom(AD_Table_ID, Record_ID);
        return;
    }
    if (currentTab.needSave(true, false)) {
        if (!onSave(false))
            return;
    }
    int table_ID = currentTab.getAD_Table_ID();
    //	Record_ID
    int record_ID = currentTab.getRecord_ID();
    if (record_ID == -1 && currentTab.getKeyColumnName().equals("AD_Language"))
        record_ID = Env.getContextAsInt(ctx, curWindowNo, "AD_Language_ID");
    if (record_ID == -1 && (wButton.getProcess_ID() == 306 || wButton.getProcess_ID() == 307)) {
        Integer id = (Integer) currentTab.getValue("AD_ChangeLog_ID");
        record_ID = id.intValue();
    }
    if (record_ID == -1 && currentTab.getKeyColumnName().endsWith("_ID")) {
        FDialog.error(curWindowNo, parent, "SaveErrorRowNotFound");
        return;
    }
    boolean isProcessMandatory = false;
    if (col.equals("PaymentRule")) {
        WPayment vp = new WPayment(curWindowNo, currentTab, wButton);
        if (//	may not be allowed
        vp.isInitOK()) {
            vp.setVisible(true);
            AEnv.showWindow(vp);
        }
        if (vp.needSave()) {
            onSave(false);
            onRefresh(false);
        }
    } else if (col.equals("DocAction")) {
        isProcessMandatory = true;
        WDocActionPanel win = new WDocActionPanel(currentTab);
        if (win.getNumberOfOptions() == 0) {
            logger.info("DocAction - No Options");
            return;
        } else {
            AEnv.showWindow(win);
            if (!win.isStartProcess())
                return;
            //batch = win.isBatch();
            startWOasking = true;
        //vda.dispose();
        }
    } else if (col.equals("CreateFrom")) {
        ICreateFrom cf = WCreateFromFactory.create(currentTab);
        if (cf != null) {
            if (cf.isInitOK()) {
                cf.showWindow();
                currentTab.dataRefresh();
            }
            return;
        }
    // else may start process
    } else if (col.equals("Posted") && MRole.getDefault().isShowAcct()) {
        //  Check Doc Status
        String processed = Env.getContext(ctx, curWindowNo, "Processed");
        if (!processed.equals("Y")) {
            String docStatus = Env.getContext(ctx, curWindowNo, "DocStatus");
            if (DocAction.STATUS_Completed.equals(docStatus) || DocAction.STATUS_Closed.equals(docStatus) || DocAction.STATUS_Reversed.equals(docStatus) || DocAction.STATUS_Voided.equals(docStatus))
                ;
            else {
                FDialog.error(curWindowNo, parent, "PostDocNotComplete");
                return;
            }
        }
        // try to get table and record id from context data (eg for unposted view)
        // otherwise use current table/record
        int tableId = Env.getContextAsInt(ctx, curWindowNo, "AD_Table_ID", true);
        int recordId = Env.getContextAsInt(ctx, curWindowNo, "Record_ID", true);
        if (tableId == 0 || recordId == 0) {
            tableId = currentTab.getAD_Table_ID();
            recordId = currentTab.getRecord_ID();
        }
        //  Check Post Status
        Object ps = currentTab.getValue("Posted");
        if (ps != null && ps.equals("Y")) {
            new org.adempiere.webui.acct.WAcctViewer(Env.getContextAsInt(ctx, curWindowNo, "AD_Client_ID"), tableId, recordId);
        } else {
            if (FDialog.ask(curWindowNo, null, "PostImmediate?")) {
                //	force when problems
                boolean force = ps != null && !ps.equals("N");
                String error = AEnv.postImmediate(curWindowNo, Env.getAD_Client_ID(ctx), tableId, recordId, force);
                if (error != null)
                    FDialog.error(curWindowNo, null, "PostingError-N", error);
                onRefresh(false);
            }
        }
        return;
    }
    //  Posted
    /**
		 *  Start Process ----
		 */
    logger.config("Process_ID=" + wButton.getProcess_ID() + ", Record_ID=" + record_ID);
    if (wButton.getProcess_ID() == 0) {
        if (isProcessMandatory) {
            FDialog.error(curWindowNo, null, null, Msg.parseTranslation(ctx, "@NotFound@ @AD_Process_ID@"));
        }
        return;
    }
    if (currentTab.needSave(true, false)) {
        if (!onSave(false))
            return;
    }
    // call form
    MProcess pr = new MProcess(ctx, wButton.getProcess_ID(), null);
    //	Validate Access
    //	BR [ 147 ]
    MRole role = MRole.getDefault(ctx, false);
    Boolean accessRW = role.checkProcessAccess(pr.getAD_Process_ID());
    if (accessRW == null || !accessRW.booleanValue()) {
        FDialog.error(curWindowNo, parent, "AccessCannotProcess");
        return;
    }
    int adFormID = pr.getAD_Form_ID();
    //	Yamel Senih BR[ 127 ], 2015-11-25
    //	Bug with launch form
    int adBrowseID = pr.getAD_Browse_ID();
    if (adFormID != 0) {
        String title = wButton.getDescription();
        if (title == null || title.length() == 0)
            title = wButton.getDisplay();
        ProcessInfo pi = new ProcessInfo(title, wButton.getProcess_ID(), table_ID, record_ID);
        pi.setWindowNo(curWindowNo);
        pi.setAD_User_ID(Env.getAD_User_ID(ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(ctx));
        ADForm form = ADForm.openForm(adFormID);
        form.setProcessInfo(pi);
        //	Yamel Senih FR [ 114 ], 2015-11-25
        form.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
        form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        form.setClosable(true);
        form.setMaximizable(true);
        form.setSizable(true);
        form.setContentStyle("overflow: auto");
        AEnv.showWindow(form);
        //	End Yamel Senih
        currentTab.dataRefreshAll();
    } else if (adBrowseID != 0) {
        String title = wButton.getDescription();
        if (title == null || title.length() == 0)
            title = wButton.getDisplay();
        ProcessInfo pi = new ProcessInfo(title, wButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(ctx));
        MBrowse browse = new MBrowse(Env.getCtx(), adBrowseID, null);
        WBrowser browser = new WBrowser(true, curWindowNo, "", browse, "", true, "", "Y".equals(Env.isSOTrx(Env.getCtx(), curWindowNo)));
        browser.setProcessInfo(pi);
        CustomForm ff = browser.getForm();
        ff.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        ff.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
        ff.setTitle(title);
        SessionManager.getAppDesktop().showWindow(ff);
        onRefresh(false);
    } else {
        ProcessModalDialog dialog = new ProcessModalDialog(this, curWindowNo, wButton.getProcess_ID(), table_ID, record_ID, startWOasking);
        if (dialog.isValid()) {
            dialog.setWidth("500px");
            dialog.setVisible(true);
            dialog.setPosition("center");
            AEnv.showWindow(dialog);
        }
    //onRefresh(true); // Need to fire events to activate subordinate tabs.
    }
}
Also used : MProcess(org.compiere.model.MProcess) MRole(org.compiere.model.MRole) ProcessInfo(org.compiere.process.ProcessInfo) ProcessModalDialog(org.adempiere.webui.apps.ProcessModalDialog) MBrowse(org.adempiere.model.MBrowse) WBrowser(org.eevolution.form.WBrowser) ICreateFrom(org.compiere.grid.ICreateFrom) WPayment(org.adempiere.webui.apps.form.WPayment) GridTab(org.compiere.model.GridTab)

Aggregations

GridTab (org.compiere.model.GridTab)38 GridField (org.compiere.model.GridField)10 MQuery (org.compiere.model.MQuery)8 AdempiereException (org.adempiere.exceptions.AdempiereException)4 Point (java.awt.Point)3 MRole (org.compiere.model.MRole)3 PO (org.compiere.model.PO)3 Dimension (java.awt.Dimension)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 MBrowse (org.adempiere.model.MBrowse)2 ProcessModalDialog (org.adempiere.webui.apps.ProcessModalDialog)2 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)2 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)2 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)2 GridController (org.compiere.grid.GridController)2 ICreateFrom (org.compiere.grid.ICreateFrom)2 GridTable (org.compiere.model.GridTable)2 MOrderLine (org.compiere.model.MOrderLine)2