Search in sources :

Example 1 with Waiting

use of org.compiere.apps.Waiting in project adempiere by adempiere.

the class POSActionMenu method executeCommand.

private void executeCommand(Command command) {
    Waiting waiting = new Waiting(pos.getFrame(), Msg.parseTranslation(pos.getCtx(), "@Processing@"), false, 120);
    try {
        CommandReceiver receiver = commandManager.getCommandReceivers(command.getEvent());
        if (command.getCommand() == CommandManager.GENERATE_IMMEDIATE_INVOICE && pos.getC_Order_ID() > 0 && pos.isCompleted() && !pos.isVoided()) {
            receiver.setCtx(pos.getCtx());
            receiver.setPartnerId(queryPartner.getRecord_ID());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            MBPartner partner = MBPartner.get(pos.getCtx(), receiver.getPartnerId());
            Optional<String> taxId = Optional.ofNullable(partner.getTaxID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + partner.getName() + " @TaxID@ : " + taxId.orElse("");
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    if (processInfo != null)
                        pos.setOrder(processInfo.getRecord_ID());
                    pos.refreshHeader();
                    //	Print Ticket
                    pos.printTicket();
                }
            }
        } else //Reverse The Sales Transaction
        if (command.getCommand() == CommandManager.GENERATE_REVERSE_SALES && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && !pos.isVoided() && !pos.isClosed()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @order.no@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                }
                pos.printTicket();
            }
        } else //Return product
        if (command.getCommand() == CommandManager.GENERATE_RETURN && pos.getC_Order_ID() > 0 && !pos.isReturnMaterial() && pos.isCompleted()) {
            receiver.setCtx(pos.getCtx());
            receiver.setOrderId(pos.getC_Order_ID());
            receiver.setPOSId(pos.getC_POS_ID());
            receiver.setPartnerId(pos.getC_BPartner_ID());
            receiver.setBankAccountId(pos.getC_BankAccount_ID());
            String processMessage = receiver.getName() + " @DisplayDocumentInfo@ : " + pos.getDocumentNo() + " @To@ @C_BPartner_ID@ : " + pos.getBPName();
            if (ADialog.ask(pos.getWindowNo(), popupMenu, "StartProcess?", Msg.parseTranslation(pos.getCtx(), processMessage))) {
                AEnv.showCenterScreen(waiting);
                command.execute(receiver);
                ProcessInfo processInfo = receiver.getProcessInfo();
                waiting.setVisible(false);
                if (processInfo != null && processInfo.isError()) {
                    showError(processInfo);
                } else {
                    afterExecutionCommand(command);
                    showOkMessage(processInfo);
                    //execute out transaction
                    if (processInfo != null && processInfo.getRecord_ID() > 0) {
                        pos.setOrder(processInfo.getRecord_ID());
                        pos.refreshHeader();
                    }
                }
            }
        } else if (command.getCommand() == CommandManager.GENERATE_WITHDRAWAL) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            Dimension size = new Dimension(1024, 768);
            FormFrame ff = new FormFrame(pos.getWindowNo());
            ff.setSize(size);
            MBrowse browse = new MBrowse(Env.getCtx(), 50056, null);
            new VBrowser(ff, true, pos.getWindowNo(), "", browse, "", true, "", true);
            ff.pack();
            AEnv.showCenterScreen(ff);
        } else if (command.getCommand() == CommandManager.CLOSE_STATEMENT) {
            Env.setContext(pos.getCtx(), pos.getWindowNo(), "C_POS_ID", pos.getC_POS_ID());
            Dimension size = new Dimension(1024, 768);
            FormFrame ff = new FormFrame(pos.getWindowNo());
            ff.setSize(size);
            MBrowse browse = new MBrowse(Env.getCtx(), 50057, null);
            new VBrowser(ff, true, pos.getWindowNo(), "", browse, "", true, "", true);
            ff.pack();
            AEnv.showCenterScreen(ff);
        }
    } catch (Exception exception) {
        waiting.setVisible(false);
        ADialog.error(pos.getWindowNo(), pos.getFrame(), exception.getLocalizedMessage());
    } finally {
        waiting.setVisible(false);
        waiting = null;
    }
}
Also used : CommandReceiver(org.adempiere.pos.command.CommandReceiver) FormFrame(org.compiere.apps.form.FormFrame) MBPartner(org.compiere.model.MBPartner) ProcessInfo(org.compiere.process.ProcessInfo) Dimension(java.awt.Dimension) MBrowse(org.adempiere.model.MBrowse) VBrowser(org.eevolution.form.VBrowser) AdempiereException(org.adempiere.exceptions.AdempiereException) Waiting(org.compiere.apps.Waiting)

Example 2 with Waiting

use of org.compiere.apps.Waiting in project adempiere by adempiere.

the class VBrowser method cmd_Process.

/**
	 * Process Action
	 */
private void cmd_Process() {
    m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    m_ok = true;
    // End Worker
    if (m_worker != null) {
        // worker continues, but it does not block UI
        if (m_worker.isAlive())
            m_worker.interrupt();
        log.config("Worker alive=" + m_worker.isAlive());
    }
    m_worker = null;
    saveResultSelection(detail);
    saveSelection(detail);
    //	Is Process ok
    boolean isOk = false;
    //	Valid Process, Selected Keys and process parameters
    if (getAD_Process_ID() > 0 && getSelectedKeys() != null) {
        processParameterPanel.getProcessInfo().setAD_PInstance_ID(-1);
        // BR [ 249 ]
        if (processParameterPanel.validateParameters() == null) {
            //	Save Parameters
            if (processParameterPanel.saveParameters() == null) {
                //	Get Process Info
                ProcessInfo pi = processParameterPanel.getProcessInfo();
                //	Set Selected Values
                if (getFieldKey() != null && getFieldKey().get_ID() > 0) {
                    MViewDefinition viewDefinition = (MViewDefinition) getFieldKey().getAD_View_Column().getAD_View_Definition();
                    pi.setAliasForTableSelection(viewDefinition.getTableAlias());
                    pi.setTableSelectionId(viewDefinition.getAD_Table_ID());
                }
                pi.setSelectionValues(getSelectedValues());
                //	
                setBrowseProcessInfo(pi);
                // Execute Process
                ProcessCtl worker = new ProcessCtl(this, getWindowNo(), pi, null);
                //	
                String msg = Msg.getMsg(Env.getCtx(), "Processing");
                //	For Dialog
                if (m_frame.isDialog()) {
                    m_waiting = new Waiting(m_frame.getCDialog(), msg, false, getBrowseProcessInfo().getEstSeconds());
                } else {
                    m_waiting = new Waiting(m_frame.getCFrame(), msg, false, getBrowseProcessInfo().getEstSeconds());
                }
                // complete tasks in unlockUI /
                worker.run();
                m_waiting.doNotWait();
                setStatusLine(pi.getSummary(), pi.isError());
                //	For Valid Ok
                isOk = !pi.isError();
            }
        }
    }
    m_frame.setCursor(Cursor.getDefaultCursor());
    //	For when is ok the process
    if (isOk) {
        //	Close
        if (getParentWindowNo() > 0) {
            dispose();
            return;
        }
        //	Else Reset
        p_loadedOK = initBrowser();
        collapsibleSearch.setCollapsed(false);
    }
}
Also used : ProcessCtl(org.compiere.apps.ProcessCtl) ProcessInfo(org.compiere.process.ProcessInfo) MViewDefinition(org.adempiere.model.MViewDefinition) Waiting(org.compiere.apps.Waiting)

Aggregations

Waiting (org.compiere.apps.Waiting)2 ProcessInfo (org.compiere.process.ProcessInfo)2 Dimension (java.awt.Dimension)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MBrowse (org.adempiere.model.MBrowse)1 MViewDefinition (org.adempiere.model.MViewDefinition)1 CommandReceiver (org.adempiere.pos.command.CommandReceiver)1 ProcessCtl (org.compiere.apps.ProcessCtl)1 FormFrame (org.compiere.apps.form.FormFrame)1 MBPartner (org.compiere.model.MBPartner)1 VBrowser (org.eevolution.form.VBrowser)1