Search in sources :

Example 1 with FormFrame

use of org.compiere.apps.form.FormFrame in project adempiere by adempiere.

the class WFActivity method cmd_button.

//	cmd_zoom
/**
	 * 	Answer Button
	 */
private void cmd_button() {
    log.config("Activity=" + m_activity);
    if (m_activity == null)
        return;
    //
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserWindow.equals(node.getAction())) {
        // Explicit Window
        int AD_Window_ID = node.getAD_Window_ID();
        String ColumnName = m_activity.getPO().get_TableName() + "_ID";
        int Record_ID = m_activity.getRecord_ID();
        MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID);
        boolean IsSOTrx = m_activity.isSOTrx();
        //
        log.info("Zoom to AD_Window_ID=" + AD_Window_ID + " - " + query + " (IsSOTrx=" + IsSOTrx + ")");
        AWindow frame = new AWindow();
        if (!frame.initWindow(AD_Window_ID, query))
            return;
        AEnv.addToWindowManager(frame);
        AEnv.showCenterScreen(frame);
        frame = null;
    } else if (MWFNode.ACTION_UserForm.equals(node.getAction())) {
        int AD_Form_ID = node.getAD_Form_ID();
        FormFrame ff = new FormFrame();
        ff.openForm(AD_Form_ID);
        ff.pack();
        AEnv.addToWindowManager(ff);
        AEnv.showCenterScreen(ff);
    } else if (MWFNode.ACTION_SmartBrowse.equals(node.getAction())) {
        CFrame ff = VBrowser.openBrowse(0, node.getAD_Browse_ID(), "", m_activity.isSOTrx());
        ff.pack();
        AEnv.addToWindowManager(ff);
        AEnv.showCenterScreen(ff);
    } else
        /*
		else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
		{
			
		}*/
        log.log(Level.SEVERE, "No User Action:" + node.getAction());
}
Also used : AWindow(org.compiere.apps.AWindow) FormFrame(org.compiere.apps.form.FormFrame) MWFNode(org.compiere.wf.MWFNode) MQuery(org.compiere.model.MQuery) CFrame(org.compiere.swing.CFrame)

Example 2 with FormFrame

use of org.compiere.apps.form.FormFrame 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 3 with FormFrame

use of org.compiere.apps.form.FormFrame in project adempiere by adempiere.

the class APanel method actionButton.

/**************************************************************************
	 *	Start Button Process
	 *  @param vButton button
	 */
protected void actionButton(VButton vButton) {
    log.info(vButton.toString());
    if (m_curTab.hasChangedCurrentTabAndParents()) {
        String msg = CLogger.retrieveErrorString("Please ReQuery Window");
        ADialog.error(m_curWindowNo, this, null, msg);
        return;
    }
    boolean startWOasking = false;
    //		boolean batch = false;
    String col = vButton.getColumnName();
    //  Zoom
    if (col.equals("Record_ID")) {
        int AD_Table_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Table_ID");
        int Record_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "Record_ID");
        AEnv.zoom(AD_Table_ID, Record_ID);
        return;
    }
    //  save first	---------------
    if (m_curTab.needSave(true, false))
        if (!cmd_save(true))
            return;
    // Save included tabs if necessary - teo_sarca BF [ 2876892 ]
    for (GridTab includedTab : m_curTab.getIncludedTabs()) {
        if (includedTab.needSave(true, false))
            if (!includedTab.dataSave(true))
                return;
    }
    //
    int table_ID = m_curTab.getAD_Table_ID();
    //	Record_ID
    int record_ID = m_curTab.getRecord_ID();
    //	Record_ID - Language Handling
    if (record_ID == -1 && m_curTab.getKeyColumnName().equals("AD_Language"))
        record_ID = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Language_ID");
    //	Record_ID - Change Log ID
    if (record_ID == -1 && (vButton.getProcess_ID() == 306 || vButton.getProcess_ID() == 307)) {
        Integer id = (Integer) m_curTab.getValue("AD_ChangeLog_ID");
        record_ID = id.intValue();
    }
    //	Ensure it's saved
    if (record_ID == -1 && m_curTab.getKeyColumnName().endsWith("_ID")) {
        ADialog.error(m_curWindowNo, this, "SaveErrorRowNotFound");
        return;
    }
    boolean isProcessMandatory = false;
    //	Pop up Payment Rules
    if (col.equals("PaymentRule")) {
        VPayment vp = new VPayment(m_curWindowNo, m_curTab, vButton);
        if (//	may not be allowed
        vp.isInitOK())
            vp.setVisible(true);
        vp.dispose();
        if (vp.needSave()) {
            cmd_save(false);
            cmd_refresh();
        }
    } else //	Pop up Document Action (Workflow)
    if (col.equals("DocAction")) {
        isProcessMandatory = true;
        VDocAction vda = new VDocAction(m_curWindowNo, m_curTab, vButton, record_ID);
        //	Something to select from?
        if (vda.getNumberOfOptions() == 0) {
            vda.dispose();
            log.info("DocAction - No Options");
            return;
        } else {
            vda.setVisible(true);
            if (!vda.isStartProcess())
                return;
            //				batch = vda.isBatch();
            startWOasking = true;
            vda.dispose();
        }
    } else //  Pop up Create From
    if (col.equals("CreateFrom")) {
        // Run form only if the button has no process defined - teo_sarca [ 1974354 ]
        if (vButton.getProcess_ID() <= 0) {
            ICreateFrom cf = VCreateFromFactory.create(m_curTab);
            if (cf != null) {
                if (cf.isInitOK()) {
                    cf.showWindow();
                    cf.closeWindow();
                    m_curTab.dataRefresh();
                } else
                    cf.closeWindow();
                return;
            }
        //	else may start process
        }
    } else //  Posting -----
    if (col.equals("Posted") && MRole.getDefault().isShowAcct()) {
        //  Check Doc Status
        String processed = Env.getContext(m_ctx, m_curWindowNo, "Processed");
        if (!processed.equals("Y")) {
            String docStatus = Env.getContext(m_ctx, m_curWindowNo, "DocStatus");
            if (DocAction.STATUS_Completed.equals(docStatus) || DocAction.STATUS_Closed.equals(docStatus) || DocAction.STATUS_Reversed.equals(docStatus) || DocAction.STATUS_Voided.equals(docStatus))
                ;
            else {
                ADialog.error(m_curWindowNo, this, "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(m_ctx, m_curWindowNo, "AD_Table_ID", true);
        int recordId = Env.getContextAsInt(m_ctx, m_curWindowNo, "Record_ID", true);
        if (tableId == 0 || recordId == 0) {
            tableId = m_curTab.getAD_Table_ID();
            recordId = m_curTab.getRecord_ID();
        }
        //  Check Post Status
        Object ps = m_curTab.getValue("Posted");
        if (ps != null && ps.equals("Y")) {
            new org.compiere.acct.AcctViewer(Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Client_ID"), tableId, recordId);
        } else {
            if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) {
                //	force when problems
                boolean force = ps != null && !ps.equals("N");
                String error = AEnv.postImmediate(m_curWindowNo, Env.getAD_Client_ID(m_ctx), tableId, recordId, force);
                if (error != null)
                    ADialog.error(m_curWindowNo, this, "PostingError-N", error);
                cmd_refresh();
            }
        }
        return;
    }
    //  Posted
    /**
		 *  Start Process ----
		 *  or invoke user form
		 */
    log.config("Process_ID=" + vButton.getProcess_ID() + ", Record_ID=" + record_ID);
    if (vButton.getProcess_ID() == 0) {
        if (isProcessMandatory) {
            ADialog.error(m_curWindowNo, this, null, Msg.parseTranslation(m_ctx, "@NotFound@ @AD_Process_ID@"));
        }
        return;
    }
    //	Save item changed
    if (m_curTab.needSave(true, false))
        if (!cmd_save(true))
            return;
    // call form
    MProcess pr = new MProcess(m_ctx, vButton.getProcess_ID(), null);
    //	Validate Access
    MRole role = MRole.getDefault(m_ctx, false);
    Boolean accessRW = role.checkProcessAccess(pr.getAD_Process_ID());
    if (accessRW == null || !accessRW.booleanValue()) {
        ADialog.error(m_curWindowNo, this, null, Msg.parseTranslation(m_ctx, "@AccessCannotProcess@"));
        return;
    }
    //	
    int form_ID = pr.getAD_Form_ID();
    if (form_ID != 0) {
        if (m_curTab.needSave(true, false))
            if (!cmd_save(true))
                return;
        //	Yamel Senih FR [ 114 ] 2015-11-23 Add Support to Dialog for create from
        FormFrame ff = new FormFrame(getWindowNo());
        String title = vButton.getDescription();
        if (title == null || title.length() == 0)
            title = vButton.getName();
        ProcessInfo pi = new ProcessInfo(title, vButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(m_ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(m_ctx));
        ff.setProcessInfo(pi);
        ff.openForm(form_ID);
        ff.pack();
        AEnv.showCenterScreen(ff);
        //	Refresh
        m_curTab.dataRefresh();
        //	End Yamel Senih
        return;
    }
    int browse_ID = pr.getAD_Browse_ID();
    if (browse_ID != 0) {
        if (m_curTab.needSave(true, false))
            if (!cmd_save(true))
                return;
        String title = vButton.getDescription();
        if (title == null || title.length() == 0)
            title = vButton.getName();
        ProcessInfo pi = new ProcessInfo(title, vButton.getProcess_ID(), table_ID, record_ID);
        pi.setAD_User_ID(Env.getAD_User_ID(m_ctx));
        pi.setAD_Client_ID(Env.getAD_Client_ID(m_ctx));
        FormFrame ff = new FormFrame(getWindowNo());
        ff.setProcessInfo(pi);
        MBrowse browse = new MBrowse(Env.getCtx(), browse_ID, null);
        new VBrowser(ff, true, getWindowNo(), "", browse, "", true, "", Env.isSOTrx(Env.getCtx(), m_curWindowNo));
        ff.pack();
        AEnv.showCenterScreen(ff);
        //	Yamel Senih
        //	Refresh
        m_curTab.dataRefresh();
        return;
    } else {
        ProcessModalDialog dialog = new ProcessModalDialog(m_ctx, Env.getWindow(m_curWindowNo), Env.getHeader(m_ctx, m_curWindowNo), this, m_curWindowNo, vButton.getProcess_ID(), table_ID, record_ID, startWOasking);
        //	BR [ 323 ]
        if (!startWOasking) {
            dialog.validate();
            dialog.pack();
            AEnv.showCenterWindow(Env.getWindow(m_curWindowNo), dialog);
        }
    }
}
Also used : VDocAction(org.compiere.grid.ed.VDocAction) MProcess(org.compiere.model.MProcess) FormFrame(org.compiere.apps.form.FormFrame) MRole(org.compiere.model.MRole) VPayment(org.compiere.grid.VPayment) ProcessInfo(org.compiere.process.ProcessInfo) MBrowse(org.adempiere.model.MBrowse) Point(java.awt.Point) VBrowser(org.eevolution.form.VBrowser) ICreateFrom(org.compiere.grid.ICreateFrom) GridTab(org.compiere.model.GridTab)

Example 4 with FormFrame

use of org.compiere.apps.form.FormFrame in project adempiere by adempiere.

the class AMenuStartItem method startForm.

//	startTask
/**
	 *	Start Form
	 *  @param AD_Form_ID form
	 */
private void startForm(int AD_Form_ID) {
    FormFrame ff = null;
    if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) {
        ff = m_menu.getWindowManager().findForm(AD_Form_ID);
        if (ff != null) {
            ff.toFront();
            return;
        }
    }
    //	Yamel Senih FR [ 114 ] Add Support to Dialog Frame
    ff = new FormFrame(0);
    //	1
    SwingUtilities.invokeLater(m_updatePB);
    boolean ok = ff.openForm(AD_Form_ID);
    if (!ok) {
        ff.dispose();
        return;
    }
    //	Add Menu
    m_menu.getWindowManager().add(ff.getCFrame());
    //	2
    SwingUtilities.invokeLater(m_updatePB);
    //	Center the window
    //	3
    SwingUtilities.invokeLater(m_updatePB);
    if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) {
        AEnv.showMaximized(ff.getCFrame());
    } else
        AEnv.showCenterScreen(ff);
//	End Yamel Senih
}
Also used : FormFrame(org.compiere.apps.form.FormFrame)

Example 5 with FormFrame

use of org.compiere.apps.form.FormFrame in project adempiere by adempiere.

the class VBrowser method openBrowse.

/**
	 * get Browse
	 * @param windowNo
	 * @param browserId
	 * @param whereClause
	 * @param isSOTrx
	 */
public static CFrame openBrowse(int windowNo, int browserId, String whereClause, Boolean isSOTrx) {
    MBrowse browse = new MBrowse(Env.getCtx(), browserId, null);
    boolean modal = false;
    if (windowNo > 0)
        modal = true;
    String value = "";
    String keyColumn = "";
    boolean multiSelection = true;
    FormFrame ff = new FormFrame(windowNo);
    return new VBrowser(ff, modal, windowNo, value, browse, keyColumn, multiSelection, whereClause, isSOTrx).getFrame();
}
Also used : FormFrame(org.compiere.apps.form.FormFrame) MBrowse(org.adempiere.model.MBrowse)

Aggregations

FormFrame (org.compiere.apps.form.FormFrame)8 MBrowse (org.adempiere.model.MBrowse)4 Properties (java.util.Properties)2 ProcessInfo (org.compiere.process.ProcessInfo)2 CFrame (org.compiere.swing.CFrame)2 VBrowser (org.eevolution.form.VBrowser)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 CommandReceiver (org.adempiere.pos.command.CommandReceiver)1 ALogin (org.compiere.apps.ALogin)1 AWindow (org.compiere.apps.AWindow)1 Waiting (org.compiere.apps.Waiting)1 ArchiveViewer (org.compiere.apps.form.ArchiveViewer)1 ICreateFrom (org.compiere.grid.ICreateFrom)1 VPayment (org.compiere.grid.VPayment)1 VDocAction (org.compiere.grid.ed.VDocAction)1 GridTab (org.compiere.model.GridTab)1 MBPartner (org.compiere.model.MBPartner)1 MProcess (org.compiere.model.MProcess)1