Search in sources :

Example 96 with MQuery

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

the class VOrderPlanning method find.

private String find() {
    int AD_Window_ID = MTable.get(Env.getCtx(), MOrder.Table_ID).getAD_Window_ID();
    int AD_Tab_ID = MTab.getTab_ID(AD_Window_ID, "Order");
    //
    GridField[] findFields = GridField.createFields(Env.getCtx(), AD_Window_ID, 0, AD_Tab_ID);
    Find find = new Find(Env.getFrame(this), AD_Window_ID, this.getName(), AD_Tab_ID, AD_Table_ID, getTableName(), "", findFields, 1);
    MQuery query = find.getQuery();
    if (query != null && query.isActive())
        return query.getWhereClause();
    else
        return "";
}
Also used : Find(org.compiere.apps.search.Find) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField)

Example 97 with MQuery

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

the class WWFActivity 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 + ")");
        AEnv.zoom(AD_Window_ID, query);
    } else if (MWFNode.ACTION_UserForm.equals(node.getAction())) {
        int AD_Form_ID = node.getAD_Form_ID();
        Window form = ADForm.openForm(AD_Form_ID);
        AEnv.showWindow(form);
    } else if (MWFNode.ACTION_SmartBrowse.equals(node.getAction())) {
        int AD_Browse_ID = node.getAD_Browse_ID();
        Window browse = WBrowser.openBrowse(0, AD_Browse_ID, "", m_activity.isSOTrx());
        AEnv.showWindow(browse);
    } else
        log.log(Level.SEVERE, "No User Action:" + node.getAction());
}
Also used : Window(org.adempiere.webui.component.Window) MWFNode(org.compiere.wf.MWFNode) MQuery(org.compiere.model.MQuery)

Example 98 with MQuery

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

the class AbstractADWindowPanel method onZoomAcross.

/**
     * @see ToolbarListener#onZoomAcross()
     */
public void onZoomAcross() {
    if (toolbar.getEvent() != null) {
        GridTab currentTab = toolbar.getCurrentPanel().getGridTab();
        int record_ID = currentTab.getRecord_ID();
        if (record_ID <= 0)
            return;
        //	Query
        MQuery query = new MQuery();
        //	Current row
        String link = currentTab.getKeyColumnName();
        //	Link for detail records
        if (link.length() == 0)
            link = currentTab.getLinkColumnName();
        if (link.length() != 0) {
            if (link.endsWith("_ID"))
                query.addRestriction(link, MQuery.EQUAL, new Integer(Env.getContextAsInt(ctx, curWindowNo, link)));
            else
                query.addRestriction(link, MQuery.EQUAL, Env.getContext(ctx, curWindowNo, link));
        }
        new WZoomAcross(toolbar.getEvent().getTarget(), currentTab.getTableName(), currentTab.getAD_Window_ID(), query);
    }
}
Also used : GridTab(org.compiere.model.GridTab) MQuery(org.compiere.model.MQuery) WZoomAcross(org.adempiere.webui.WZoomAcross)

Example 99 with MQuery

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

the class AbstractADWindowPanel method initPanel.

/**
     * @param adWindowId
     * @param query
     * @return boolean
     */
public boolean initPanel(int adWindowId, MQuery query) {
    // This temporary validation code is added to check the reported bug
    // [ adempiere-ZK Web Client-2832968 ] User context lost?
    // https://sourceforge.net/tracker/?func=detail&atid=955896&aid=2832968&group_id=176962
    // it's harmless, if there is no bug then this must never fail
    Session currSess = Executions.getCurrent().getDesktop().getSession();
    int checkad_user_id = -1;
    if (currSess != null && currSess.getAttribute("Check_AD_User_ID") != null)
        checkad_user_id = (Integer) currSess.getAttribute("Check_AD_User_ID");
    if (checkad_user_id != Env.getAD_User_ID(ctx)) {
        String msg = "Timestamp=" + new Date() + ", Bug 2832968 SessionUser=" + checkad_user_id + ", ContextUser=" + Env.getAD_User_ID(ctx) + ".  Please report conditions to your system administrator or in sf tracker 2832968";
        ApplicationException ex = new ApplicationException(msg);
        logger.log(Level.SEVERE, msg, ex);
        throw ex;
    }
    // Set AutoCommit for this Window
    if (embeddedTabIndex < 0) {
        Env.setAutoCommit(ctx, curWindowNo, Env.isAutoCommit(ctx));
        boolean autoNew = Env.isAutoNew(ctx);
        Env.setAutoNew(ctx, curWindowNo, autoNew);
        GridWindowVO gWindowVO = AEnv.getMWindowVO(curWindowNo, adWindowId, 0);
        if (gWindowVO == null) {
            throw new ApplicationException(Msg.getMsg(ctx, "AccessTableNoView") + "(No Window Model Info)");
        }
        gridWindow = new GridWindow(gWindowVO, true);
        title = gridWindow.getName();
        // Set SO/AutoNew for Window
        Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx());
        if (!autoNew && gridWindow.isTransaction()) {
            Env.setAutoNew(ctx, curWindowNo, true);
        }
    }
    m_onlyCurrentRows = embeddedTabIndex < 0 && gridWindow.isTransaction();
    MQuery detailQuery = null;
    /**
         * Window Tabs
         */
    if (embeddedTabIndex < 0) {
        if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null && query.getZoomValue() instanceof Integer && (Integer) query.getZoomValue() > 0) {
            if (!query.getZoomTableName().equalsIgnoreCase(gridWindow.getTab(0).getTableName())) {
                detailQuery = query;
                query = new MQuery();
                query.addRestriction("1=2");
                query.setRecordCount(0);
            }
        }
        int tabSize = gridWindow.getTabCount();
        for (int tab = 0; tab < tabSize; tab++) {
            initTab(query, tab);
            if (tab == 0 && curTab == null && m_findCancelled)
                return false;
        }
        setActiveTab(0);
        getToolbar().setCurrentPanel(curTabPanel);
        Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName());
    } else {
        initEmbeddedTab(query, embeddedTabIndex);
    }
    if (curTab != null)
        curTab.getTableModel().setChanged(false);
    if (embeddedTabIndex < 0) {
        curTabIndex = 0;
        adTab.setSelectedIndex(0);
        toolbar.enableTabNavigation(adTab.getTabCount() > 1);
        toolbar.enableFind(true);
        adTab.evaluate(null);
        if (gridWindow.isTransaction()) {
            toolbar.enableHistoryRecords(true);
        }
        if (detailQuery != null && zoomToDetailTab(detailQuery)) {
            return true;
        }
    } else {
        curTabIndex = embeddedTabIndex;
        toolbar.enableTabNavigation(false);
        toolbar.enableFind(true);
        toolbar.enableHistoryRecords(false);
    }
    updateToolbar();
    return true;
}
Also used : ApplicationException(org.adempiere.webui.exception.ApplicationException) GridWindow(org.compiere.model.GridWindow) GridWindowVO(org.compiere.model.GridWindowVO) MQuery(org.compiere.model.MQuery) Date(java.util.Date) Session(org.zkoss.zk.ui.Session)

Example 100 with MQuery

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

the class InfoAssignmentPanel method zoom.

/**
	 *  Zoom action
	 *	To be overwritten by concrete classes
	 */
public void zoom() {
    if (getSelectedRowKey() != null && getSelectedRowKey() > 0) {
        //  ColumnName might be changed in MTab.validateQuery
        MQuery zoomQuery = new MQuery();
        String column = getKeyColumn();
        //strip off table name, fully qualify name doesn't work when zoom into detail tab
        if (column.indexOf(".") > 0)
            column = column.substring(column.indexOf(".") + 1);
        zoomQuery.addRestriction(column, MQuery.EQUAL, getSelectedRowKey());
        zoomQuery.setRecordCount(1);
        zoomQuery.setTableName(column.substring(0, column.length() - 3));
        AEnv.zoom(236, zoomQuery);
    }
}
Also used : MQuery(org.compiere.model.MQuery)

Aggregations

MQuery (org.compiere.model.MQuery)109 PrintInfo (org.compiere.model.PrintInfo)19 GridField (org.compiere.model.GridField)15 MPrintFormat (org.compiere.print.MPrintFormat)14 ReportEngine (org.compiere.print.ReportEngine)12 Point (java.awt.Point)11 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)9 GridWindowVO (org.compiere.model.GridWindowVO)9 SQLException (java.sql.SQLException)8 GridTab (org.compiere.model.GridTab)8 GridWindow (org.compiere.model.GridWindow)7 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 AWindow (org.compiere.apps.AWindow)6 File (java.io.File)5 IOException (java.io.IOException)5 Language (org.compiere.util.Language)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MClient (org.compiere.model.MClient)3 MLookup (org.compiere.model.MLookup)3