question: private void cmd_save ( boolean saveQuery ) { Object selected = fQueryName . getSelectedItem ( ) ; if ( selected == null ) { return ; } StringBuffer code = codeUserQuery ( ) ; String name = selected . toString ( ) ; if ( name . equals ( m_sNew ) || name . equals ( m_sLast ) || name . equals ( m_sTipText ) || Util . isEmpty ( name , true ) ) { } else { MUserQuery uq = MUserQuery . get ( Env . getCtx ( ) , m_AD_Tab_ID , name ) ; if ( code . length ( ) > 0 ) { if ( uq == null ) { uq = new MUserQuery ( Env . getCtx ( ) , 0 , null ) ; uq . setName ( name ) ; uq . setAD_Table_ID ( m_AD_Table_ID ) ; uq . setAD_Tab_ID ( m_AD_Tab_ID ) ; uq . setAD_User_ID ( Env . getAD_User_ID ( Env . getCtx ( ) ) ) ; } uq . setCode ( code . toString ( ) ) ; } else if ( code . length ( ) <= 0 ) { if ( uq . delete ( true ) ) { ADialog . info ( m_targetWindowNo , this , "Deleted" , name ) ; refreshUserQueries ( ) ; } else ADialog . warn ( m_targetWindowNo , this , "DeleteError" , name ) ; return ; } if ( uq . save ( ) ) { refreshUserQueries ( ) ; } else ADialog . warn ( m_targetWindowNo , this , "SaveError" , name ) ; } if ( saveQuery ) { MUserQuery last = MUserQuery . get ( Env . getCtx ( ) , m_AD_Tab_ID , m_sLast ) ; if ( code . length ( ) > 0 ) { if ( last == null ) { last = new MUserQuery ( Env . getCtx ( ) , 0 , null ) ; last . setName ( m_sLast ) ; last . setAD_Table_ID ( m_AD_Table_ID ) ; last . setAD_Tab_ID ( m_AD_Tab_ID ) ; last . setAD_User_ID ( Env . getAD_User_ID ( Env . getCtx ( ) ) ) ; } last . setCode ( code . toString ( ) ) ; } else if ( code . length ( ) <= 0 ) { if ( ! last . delete ( true ) ) ADialog . warn ( m_targetWindowNo , this , "DeleteError" , name ) ; return ; } if ( ! last . save ( ) ) ADialog . warn ( m_targetWindowNo , this , "SaveError" , name ) ; } }
target:  Save the advanced query in the database using the query name. If the query name is set, the query will be updated or a new query saved.