Search in sources :

Example 1 with AWindow

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

the class VMRPDetailed method zoom.

// End of variables declaration//GEN-END:variables
/**
	 * Zoom to target
	 * 
	 * @param AD_Window_ID
	 *            window id
	 * @param zoomQuery
	 *            zoom query
	 * @throws InterruptedException
	 */
public void zoom(int AD_Window_ID, MQuery zoomQuery) {
    panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    final AWindow frame = new AWindow();
    if (!frame.initWindow(AD_Window_ID, zoomQuery))
        return;
    new Thread() {

        public void run() {
            try {
                sleep(50);
            } catch (Exception e) {
            }
            AEnv.showCenterScreen(frame);
        }
    }.start();
}
Also used : AWindow(org.compiere.apps.AWindow) PropertyVetoException(java.beans.PropertyVetoException) DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException)

Example 2 with AWindow

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

the class Viewer method cmd_customize.

/**
	 * 	Call Customize
	 */
private void cmd_customize() {
    AWindow win = new AWindow(getGraphicsConfiguration());
    //	forwards Window Events
    new AWindowListener(win, this);
    //	hardcoded
    int AD_Window_ID = 240;
    int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID();
    boolean loadedOK = win.initWindow(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID));
    if (loadedOK) {
        AEnv.addToWindowManager(win);
        AEnv.showCenterScreen(win);
    }
//	see windowStateChanged for applying change
}
Also used : AWindow(org.compiere.apps.AWindow) AWindowListener(org.compiere.apps.AWindowListener) Point(java.awt.Point)

Example 3 with AWindow

use of org.compiere.apps.AWindow 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 4 with AWindow

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

the class Info method zoom.

//  ValueChanged
/**
	 *	Zoom to target
	 *  @param AD_Window_ID window id
	 *  @param zoomQuery zoom query
	 */
@SuppressWarnings("deprecation")
protected void zoom(int AD_Window_ID, MQuery zoomQuery) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    final AWindow frame = new AWindow();
    if (!frame.initWindow(AD_Window_ID, zoomQuery))
        return;
    AEnv.addToWindowManager(frame);
    //	Modal Window causes UI lock
    if (isModal()) {
        //	remove modal option has no effect
        setModal(false);
        //	VLookup.actionButton - Result = null (not cancelled)
        dispose();
    } else
        setCursor(Cursor.getDefaultCursor());
    //	VLookup gets info after method finishes
    new Thread() {

        public void run() {
            try {
                sleep(50);
            } catch (Exception e) {
            }
            AEnv.showCenterScreen(frame);
        }
    }.start();
}
Also used : AWindow(org.compiere.apps.AWindow) SQLException(java.sql.SQLException)

Example 5 with AWindow

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

the class VLookup method actionZoom.

//	actionBPartner
/**
	 *	Action - Zoom
	 *	@param selectedItem item
	 */
private void actionZoom(Object selectedItem) {
    if (m_lookup == null)
        return;
    //
    MQuery zoomQuery = m_lookup.getZoomQuery();
    Object value = getValue();
    if (value == null)
        value = selectedItem;
    //	If not already exist or exact value
    if (zoomQuery == null || value != null) {
        //	ColumnName might be changed in MTab.validateQuery
        zoomQuery = new MQuery();
        String keyTableName = null;
        String keyColumnName = null;
        //	Check if it is a Table Reference
        if (m_lookup != null && m_lookup instanceof MLookup) {
            int AD_Reference_ID = ((MLookup) m_lookup).getAD_Reference_Value_ID();
            if (DisplayType.List == m_lookup.getDisplayType()) {
                keyColumnName = "AD_Ref_List_ID";
                keyTableName = "AD_Ref_List";
                value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value);
            } else {
                if (AD_Reference_ID != 0) {
                    String query = "SELECT kc.ColumnName, kt.TableName" + " FROM AD_Ref_Table rt" + " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)" + " INNER JOIN AD_Table kt ON (rt.AD_Table_ID=kt.AD_Table_ID)" + " WHERE rt.AD_Reference_ID=?";
                    PreparedStatement pstmt = null;
                    ResultSet rs = null;
                    try {
                        pstmt = DB.prepareStatement(query, null);
                        pstmt.setInt(1, AD_Reference_ID);
                        rs = pstmt.executeQuery();
                        if (rs.next()) {
                            keyColumnName = rs.getString(1);
                            keyTableName = rs.getString(2);
                        }
                    } catch (Exception e) {
                        log.log(Level.SEVERE, query, e);
                    } finally {
                        DB.close(rs, pstmt);
                        rs = null;
                        pstmt = null;
                    }
                }
            //	Table Reference
            }
        }
        if (keyColumnName != null && keyColumnName.length() != 0) {
            zoomQuery.addRestriction(keyColumnName, MQuery.EQUAL, value);
            zoomQuery.setZoomColumnName(keyColumnName);
            zoomQuery.setZoomTableName(keyTableName);
        } else {
            zoomQuery.addRestriction(m_columnName, MQuery.EQUAL, value);
            if (m_columnName.indexOf(".") > 0) {
                zoomQuery.setZoomColumnName(m_columnName.substring(m_columnName.indexOf(".") + 1));
                zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.indexOf(".")));
            } else {
                zoomQuery.setZoomColumnName(m_columnName);
                //remove _ID to get table name
                zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.length() - 3));
            }
        }
        zoomQuery.setZoomValue(value);
        //	guess
        zoomQuery.setRecordCount(1);
    }
    int AD_Window_ID = m_lookup.getZoom(zoomQuery);
    //
    log.info(m_columnName + " - AD_Window_ID=" + AD_Window_ID + " - Query=" + zoomQuery + " - Value=" + value);
    //
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    //
    AWindow frame = new AWindow(getGraphicsConfiguration());
    if (!frame.initWindow(AD_Window_ID, zoomQuery, false)) {
        setCursor(Cursor.getDefaultCursor());
        ValueNamePair pp = CLogger.retrieveError();
        String msg = pp == null ? "AccessTableNoView" : pp.getValue();
        ADialog.error(m_lookup.getWindowNo(), this, msg, pp == null ? "" : pp.getName());
    } else {
        AEnv.addToWindowManager(frame);
        if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) {
            AEnv.showMaximized(frame);
        } else {
            AEnv.showCenterScreen(frame);
        }
    }
    //  async window - not able to get feedback
    frame = null;
    //
    setCursor(Cursor.getDefaultCursor());
}
Also used : AWindow(org.compiere.apps.AWindow) MLookup(org.compiere.model.MLookup) ResultSet(java.sql.ResultSet) MQuery(org.compiere.model.MQuery) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException)

Aggregations

AWindow (org.compiere.apps.AWindow)15 MQuery (org.compiere.model.MQuery)8 SQLException (java.sql.SQLException)5 PropertyVetoException (java.beans.PropertyVetoException)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MLookup (org.compiere.model.MLookup)2 KeyNamePair (org.compiere.util.KeyNamePair)2 ValueNamePair (org.compiere.util.ValueNamePair)2 Cursor (java.awt.Cursor)1 Point (java.awt.Point)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 DBException (org.adempiere.exceptions.DBException)1 AWindowListener (org.compiere.apps.AWindowListener)1 FormFrame (org.compiere.apps.form.FormFrame)1 CFrame (org.compiere.swing.CFrame)1 MWFNode (org.compiere.wf.MWFNode)1