FR [ 2391012 ] Invoke AD_Form from button

https://sourceforge.net/tracker/index.php?func=detail&aid=2391012&group_id=176962&atid=879335
This commit is contained in:
phib 2008-12-04 23:44:30 +00:00
parent 50bebf4bd6
commit dba4db09f7
6 changed files with 233 additions and 108 deletions

View File

@ -1,31 +1,22 @@
/**********************************************************************
* This file is part of Adempiere ERP Bazaar *
* http://www.adempiere.org *
* *
* Copyright (C) Trifon Trifonov. *
* Copyright (C) Contributors *
* *
* This program is free software, you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation, either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY, without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program, if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Trifon Trifonov (trifonnt@users.sourceforge.net) *
* *
* Sponsors: *
* - Company (http://www.site.com) *
**********************************************************************/
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
* This program is free software;
you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program;
if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.math.BigDecimal;
@ -52,18 +43,33 @@ public interface I_AD_Process
/** Load Meta Data */
/** Column name AccessLevel */
public static final String COLUMNNAME_AccessLevel = "AccessLevel";
/** Column name AD_Form_ID */
public static final String COLUMNNAME_AD_Form_ID = "AD_Form_ID";
/** Set Data Access Level.
* Access Level required
/** Set Special Form.
* Special Form
*/
public void setAccessLevel (String AccessLevel);
public void setAD_Form_ID (int AD_Form_ID);
/** Get Data Access Level.
* Access Level required
/** Get Special Form.
* Special Form
*/
public String getAccessLevel();
public int getAD_Form_ID();
public I_AD_Form getAD_Form() throws RuntimeException;
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_PrintFormat_ID */
public static final String COLUMNNAME_AD_PrintFormat_ID = "AD_PrintFormat_ID";
@ -78,7 +84,7 @@ public interface I_AD_Process
*/
public int getAD_PrintFormat_ID();
public I_AD_PrintFormat getAD_PrintFormat() throws Exception;
public I_AD_PrintFormat getAD_PrintFormat() throws RuntimeException;
/** Column name AD_Process_ID */
public static final String COLUMNNAME_AD_Process_ID = "AD_Process_ID";
@ -106,7 +112,7 @@ public interface I_AD_Process
*/
public int getAD_ReportView_ID();
public I_AD_ReportView getAD_ReportView() throws Exception;
public I_AD_ReportView getAD_ReportView() throws RuntimeException;
/** Column name AD_Workflow_ID */
public static final String COLUMNNAME_AD_Workflow_ID = "AD_Workflow_ID";
@ -121,7 +127,20 @@ public interface I_AD_Process
*/
public int getAD_Workflow_ID();
public I_AD_Workflow getAD_Workflow() throws Exception;
public I_AD_Workflow getAD_Workflow() throws RuntimeException;
/** Column name AccessLevel */
public static final String COLUMNNAME_AccessLevel = "AccessLevel";
/** Set Data Access Level.
* Access Level required
*/
public void setAccessLevel (String AccessLevel);
/** Get Data Access Level.
* Access Level required
*/
public String getAccessLevel();
/** Column name Classname */
public static final String COLUMNNAME_Classname = "Classname";

View File

@ -40,8 +40,8 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
super (ctx, AD_Process_ID, trxName);
/** if (AD_Process_ID == 0)
{
setAccessLevel (null);
setAD_Process_ID (0);
setAccessLevel (null);
setEntityType (null);
// U
setIsBetaFunctionality (false);
@ -80,39 +80,46 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
return sb.toString();
}
/** AccessLevel AD_Reference_ID=5 */
public static final int ACCESSLEVEL_AD_Reference_ID=5;
/** Organization = 1 */
public static final String ACCESSLEVEL_Organization = "1";
/** Client+Organization = 3 */
public static final String ACCESSLEVEL_ClientPlusOrganization = "3";
/** System only = 4 */
public static final String ACCESSLEVEL_SystemOnly = "4";
/** All = 7 */
public static final String ACCESSLEVEL_All = "7";
/** System+Client = 6 */
public static final String ACCESSLEVEL_SystemPlusClient = "6";
/** Client only = 2 */
public static final String ACCESSLEVEL_ClientOnly = "2";
/** Set Data Access Level.
@param AccessLevel
Access Level required
*/
public void setAccessLevel (String AccessLevel)
public I_AD_Form getAD_Form() throws RuntimeException
{
if (AccessLevel == null) throw new IllegalArgumentException ("AccessLevel is mandatory");
if (AccessLevel.equals("1") || AccessLevel.equals("3") || AccessLevel.equals("4") || AccessLevel.equals("7") || AccessLevel.equals("6") || AccessLevel.equals("2")); else throw new IllegalArgumentException ("AccessLevel Invalid value - " + AccessLevel + " - Reference_ID=5 - 1 - 3 - 4 - 7 - 6 - 2"); set_Value (COLUMNNAME_AccessLevel, AccessLevel);
Class<?> clazz = MTable.getClass(I_AD_Form.Table_Name);
I_AD_Form result = null;
try {
Constructor<?> constructor = null;
constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
result = (I_AD_Form)constructor.newInstance(new Object[] {getCtx(), new Integer(getAD_Form_ID()), get_TrxName()});
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw new RuntimeException( e );
}
return result;
}
/** Get Data Access Level.
@return Access Level required
/** Set Special Form.
@param AD_Form_ID
Special Form
*/
public String getAccessLevel ()
public void setAD_Form_ID (int AD_Form_ID)
{
return (String)get_Value(COLUMNNAME_AccessLevel);
if (AD_Form_ID < 1)
set_Value (COLUMNNAME_AD_Form_ID, null);
else
set_Value (COLUMNNAME_AD_Form_ID, Integer.valueOf(AD_Form_ID));
}
public I_AD_PrintFormat getAD_PrintFormat() throws Exception
/** Get Special Form.
@return Special Form
*/
public int getAD_Form_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Form_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_AD_PrintFormat getAD_PrintFormat() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_AD_PrintFormat.Table_Name);
I_AD_PrintFormat result = null;
@ -123,7 +130,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw e;
throw new RuntimeException( e );
}
return result;
}
@ -173,7 +180,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
return ii.intValue();
}
public I_AD_ReportView getAD_ReportView() throws Exception
public I_AD_ReportView getAD_ReportView() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_AD_ReportView.Table_Name);
I_AD_ReportView result = null;
@ -184,7 +191,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw e;
throw new RuntimeException( e );
}
return result;
}
@ -212,7 +219,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
return ii.intValue();
}
public I_AD_Workflow getAD_Workflow() throws Exception
public I_AD_Workflow getAD_Workflow() throws RuntimeException
{
Class<?> clazz = MTable.getClass(I_AD_Workflow.Table_Name);
I_AD_Workflow result = null;
@ -223,7 +230,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
} catch (Exception e) {
log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
throw e;
throw new RuntimeException( e );
}
return result;
}
@ -251,6 +258,38 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent
return ii.intValue();
}
/** AccessLevel AD_Reference_ID=5 */
public static final int ACCESSLEVEL_AD_Reference_ID=5;
/** Organization = 1 */
public static final String ACCESSLEVEL_Organization = "1";
/** Client+Organization = 3 */
public static final String ACCESSLEVEL_ClientPlusOrganization = "3";
/** System only = 4 */
public static final String ACCESSLEVEL_SystemOnly = "4";
/** All = 7 */
public static final String ACCESSLEVEL_All = "7";
/** System+Client = 6 */
public static final String ACCESSLEVEL_SystemPlusClient = "6";
/** Client only = 2 */
public static final String ACCESSLEVEL_ClientOnly = "2";
/** Set Data Access Level.
@param AccessLevel
Access Level required
*/
public void setAccessLevel (String AccessLevel)
{
if (AccessLevel == null) throw new IllegalArgumentException ("AccessLevel is mandatory");
if (AccessLevel.equals("1") || AccessLevel.equals("3") || AccessLevel.equals("4") || AccessLevel.equals("7") || AccessLevel.equals("6") || AccessLevel.equals("2")); else throw new IllegalArgumentException ("AccessLevel Invalid value - " + AccessLevel + " - Reference_ID=5 - 1 - 3 - 4 - 7 - 6 - 2"); set_Value (COLUMNNAME_AccessLevel, AccessLevel);
}
/** Get Data Access Level.
@return Access Level required
*/
public String getAccessLevel ()
{
return (String)get_Value(COLUMNNAME_AccessLevel);
}
/** Set Classname.
@param Classname
Java Classname

View File

@ -57,6 +57,7 @@ import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.compiere.apps.form.FormFrame;
import org.compiere.apps.search.Find;
import org.compiere.grid.APanelTab;
import org.compiere.grid.GridController;
@ -77,6 +78,7 @@ import org.compiere.model.GridWindow;
import org.compiere.model.GridWindowVO;
import org.compiere.model.GridWorkbench;
import org.compiere.model.Lookup;
import org.compiere.model.MProcess;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MUser;
@ -2337,6 +2339,7 @@ public final class APanel extends CPanel
/**
* Start Process ----
* or invoke user form
*/
log.config("Process_ID=" + vButton.getProcess_ID() + ", Record_ID=" + record_ID);
@ -2347,36 +2350,30 @@ public final class APanel extends CPanel
if (!cmd_save(true))
return;
// hengsin - [ 1639242 ] Inconsistent appearance of Process/Report Dialog
// globalqss - Add support for Don't ShowHelp option in Process
// this code must be changed if integrated the parameters and help in only one window
/*
// call form
MProcess pr = new MProcess(m_ctx, vButton.getProcess_ID(), null);
if (pr.getShowHelp() != null && pr.getShowHelp().equals("N")) {
startWOasking = true;
}
// end globalqss
int form_ID = pr.getAD_Form_ID();
if (form_ID != 0 )
{
// Ask user to start process, if Description and Help is not empty
if (!startWOasking && !(vButton.getDescription().equals("") && vButton.getHelp().equals("")))
if (!ADialog.ask(m_curWindowNo, this, "StartProcess?",
// "<b><i>" + vButton.getText() + "</i></b><br>" +
vButton.getDescription() + "\n" + vButton.getHelp()))
if (m_curTab.needSave(true, false))
if (!cmd_save(true))
return;
//
FormFrame ff = new FormFrame();
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));
pi.setIsBatch(batch);
// Trx trx = Trx.get(Trx.createTrxName("AppsPanel"), true);
ProcessCtl.process(this, m_curWindowNo, pi, null); // calls lockUI, unlockUI
*/
ff.setProcessInfo(pi);
ff.openForm(form_ID);
ff.pack();
AEnv.showCenterScreen(ff);
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);
@ -2386,6 +2383,7 @@ public final class APanel extends CPanel
dialog.pack();
AEnv.showCenterWindow(Env.getWindow(m_curWindowNo), dialog);
}
}
} // actionButton

View File

@ -44,6 +44,8 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Trace;
import org.compiere.process.ProcessInfo;
/**
* Form Framework
@ -85,6 +87,8 @@ public class FormFrame extends CFrame
}
} // FormFrame
private ProcessInfo m_pi;
/** WindowNo */
private int m_WindowNo;
/** The GlassPane */
@ -407,6 +411,21 @@ public class FormFrame extends CFrame
}
} // formWindowOpened
// Add window and tab no called from
public void setProcessInfo(ProcessInfo pi)
{
m_pi = pi;
}
public ProcessInfo getProcessInfo()
{
return m_pi;
}
// End
/**
* Start Batch
* @param process

View File

@ -0,0 +1,25 @@
-- 4/12/2008 17:08:52
-- Call form from button
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56515,1298,0,19,284,'AD_Form_ID',TO_DATE('2008-12-04 17:08:50','YYYY-MM-DD HH24:MI:SS'),100,'Special Form','D',10,'The Special Form field identifies a unique Special Form in the system.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Special Form',0,TO_DATE('2008-12-04 17:08:50','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- 4/12/2008 17:08:52
-- Call form from button
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56515 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
;
-- 4/12/2008 17:08:57
-- Call form from button
ALTER TABLE AD_Process ADD AD_Form_ID NUMBER(10)
;
-- 4/12/2008 17:11:17
-- Call form from button
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,56515,56497,0,245,TO_DATE('2008-12-04 17:11:03','YYYY-MM-DD HH24:MI:SS'),100,'Special Form',14,'D','The Special Form field identifies a unique Special Form in the system.','Y','Y','Y','N','N','N','N','N','Special Form',155,0,TO_DATE('2008-12-04 17:11:03','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 4/12/2008 17:11:17
-- Call form from button
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56497 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
;

View File

@ -0,0 +1,25 @@
-- 4/12/2008 17:08:52
-- Call form from button
INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56515,1298,0,19,284,'AD_Form_ID',TO_TIMESTAMP('2008-12-04 17:08:50','YYYY-MM-DD HH24:MI:SS'),100,'Special Form','D',10,'The Special Form field identifies a unique Special Form in the system.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Special Form',0,TO_TIMESTAMP('2008-12-04 17:08:50','YYYY-MM-DD HH24:MI:SS'),100,0)
;
-- 4/12/2008 17:08:52
-- Call form from button
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56515 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
;
-- 4/12/2008 17:08:57
-- Call form from button
ALTER TABLE AD_Process ADD COLUMN AD_Form_ID NUMERIC(10)
;
-- 4/12/2008 17:11:17
-- Call form from button
INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,56515,56497,0,245,TO_TIMESTAMP('2008-12-04 17:11:03','YYYY-MM-DD HH24:MI:SS'),100,'Special Form',14,'D','The Special Form field identifies a unique Special Form in the system.','Y','Y','Y','N','N','N','N','N','Special Form',155,0,TO_TIMESTAMP('2008-12-04 17:11:03','YYYY-MM-DD HH24:MI:SS'),100)
;
-- 4/12/2008 17:11:17
-- Call form from button
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56497 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
;