📄 vaccountdialog.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.grid.ed;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.sql.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.border.*;
import org.compiere.apps.*;
import org.compiere.grid.*;
import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*;
/**
* Dialog to enter Account Info
*
* @author Jorg Janke
* @version $Id: VAccountDialog.java,v 1.35 2005/12/27 06:18:36 jjanke Exp $
*/
public final class VAccountDialog extends CDialog
implements ActionListener, DataStatusListener, VetoableChangeListener
{
/**
* Constructor
* @param frame frame
* @param title title
* @param mAccount account info
* @param C_AcctSchema_ID as
*/
public VAccountDialog (Frame frame, String title,
MAccountLookup mAccount, int C_AcctSchema_ID)
{
super (frame, title, true);
log.config("C_AcctSchema_ID=" + C_AcctSchema_ID
+ ", C_ValidCombination_ID=" + mAccount.C_ValidCombination_ID);
m_mAccount = mAccount;
m_C_AcctSchema_ID = C_AcctSchema_ID;
m_WindowNo = Env.createWindowNo (this);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
try
{
jbInit();
}
catch(Exception ex)
{
log.log(Level.SEVERE, ex.toString());
}
if (initAccount())
AEnv.showCenterWindow(frame, this);
else
dispose();
} // VLocationDialog
/** Window No */
private int m_WindowNo;
/** Journal Entry *
private boolean m_onlyNonDocControlled = false;
/** Selection changed */
protected boolean m_changed = false;
/** Accounting Schema */
private static MAcctSchema s_AcctSchema = null;
/** MWindow for AccountCombination */
private MWindow m_mWindow = null;
/** MTab for AccountCombination */
private MTab m_mTab = null;
/** GridController */
private GridController m_gridController = null;
/** Account used */
private MAccountLookup m_mAccount = null;
/** Result */
private int m_C_ValidCombination_ID;
/** Acct Schema */
private int m_C_AcctSchema_ID = 0;
/** Client */
private int m_AD_Client_ID;
/** Where clause for combination search */
private MQuery m_query;
/** Logger */
private static CLogger log = CLogger.getCLogger(VAccountDialog.class);
// Editors for Query
private VEditor f_Alias, f_Combination,
f_AD_Org_ID, f_Account_ID, f_SubAcct_ID,
f_M_Product_ID, f_C_BPartner_ID, f_C_Campaign_ID, f_C_LocFrom_ID, f_C_LocTo_ID,
f_C_Project_ID, f_C_SalesRegion_ID, f_AD_OrgTrx_ID, f_C_Activity_ID,
f_User1_ID, f_User2_ID;
//
private JLabel f_Description = new JLabel ("", JLabel.CENTER);
private GridBagConstraints m_gbc = new GridBagConstraints();
private Insets m_labelInsets = new Insets(2,15,2,0); // top,left,bottom,right
private Insets m_fieldInsets = new Insets(2,5,2,10);
private int m_line = 0;
private boolean m_newRow = true;
//
private CPanel panel = new CPanel();
private BorderLayout panelLayout = new BorderLayout();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private TitledBorder titledBorder;
private StatusBar statusBar = new StatusBar();
private CPanel northPanel = new CPanel();
private CPanel parameterPanel = new CPanel();
private GridBagLayout parameterLayout = new GridBagLayout();
private BorderLayout northLayout = new BorderLayout();
private JToolBar toolBar = new JToolBar();
private CButton bRefresh = new CButton();
private CButton bSave = new CButton();
private CButton bIgnore = new CButton();
/**
* Static component init.
* <pre>
* - panel
* - northPanel
* - parameterPanel
* - toolBar
* - gridController
* - confirmPanel
* - statusBar
* </pre>
* @throws Exception
*/
void jbInit() throws Exception
{
titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(134, 134, 134)), "Parameter");
//
panelLayout.setHgap(5);
panelLayout.setVgap(5);
northLayout.setHgap(5);
northLayout.setVgap(5);
//
parameterPanel.setLayout(parameterLayout);
parameterPanel.setBorder(titledBorder);
northPanel.setLayout(northLayout);
toolBar.setOrientation(JToolBar.VERTICAL);
toolBar.setBorder(null);
toolBar.setRequestFocusEnabled(false);
toolBar.setBorderPainted(false);
toolBar.setMargin(new Insets(5, 5, 5, 5));
bSave.setIcon(new ImageIcon(org.compiere.Compiere.class.getResource("images/Save24.gif")));
bSave.setMargin(new Insets(2, 2, 2, 2));
bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"AccountNewUpdate"));
bSave.addActionListener(this);
bRefresh.setIcon(new ImageIcon(org.compiere.Compiere.class.getResource("images/Refresh24.gif")));
bRefresh.setMargin(new Insets(2, 2, 2, 2));
bRefresh.setToolTipText(Msg.getMsg(Env.getCtx(),"Refresh"));
bRefresh.addActionListener(this);
bIgnore.setIcon(new ImageIcon(org.compiere.Compiere.class.getResource("images/Ignore24.gif")));
bIgnore.setMargin(new Insets(2, 2, 2, 2));
bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(),"Ignore"));
bIgnore.addActionListener(this);
//
toolBar.addSeparator();
toolBar.add(bRefresh, null);
toolBar.add(bIgnore, null);
toolBar.add(bSave, null);
//
getContentPane().add(panel);
panel.setLayout(panelLayout);
panel.add(confirmPanel, BorderLayout.SOUTH);
panel.add(northPanel, BorderLayout.NORTH);
northPanel.add(parameterPanel, BorderLayout.CENTER);
northPanel.add(toolBar, BorderLayout.EAST);
//
this.getContentPane().add(statusBar, BorderLayout.SOUTH);
confirmPanel.addActionListener(this);
} // jbInit
/**
* Dyanmic Init.
* When a row is selected, the editor values are set
* (editors do not change grid)
* @return true if initialized
*/
private boolean initAccount()
{
m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
// Get AcctSchema Info
if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
s_AcctSchema = new MAcctSchema (Env.getCtx(), m_C_AcctSchema_ID, null);
log.config(s_AcctSchema.toString()
+ ", #" + s_AcctSchema.getAcctSchemaElements().length);
Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);
// Model
int AD_Window_ID = 153; // Maintain Account Combinations
MWindowVO wVO = AEnv.getMWindowVO (m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return false;
m_mWindow = new MWindow (wVO);
m_mTab = m_mWindow.getTab(0);
// ParameterPanel restrictions
m_mTab.getField("Alias").setDisplayLength(15);
m_mTab.getField("Combination").setDisplayLength(15);
// Grid restrictions
m_mTab.getField("AD_Client_ID").setDisplayed(false);
m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
m_mTab.getField("IsActive").setDisplayed(false);
m_mTab.getField("IsFullyQualified").setDisplayed(false);
// don't show fields not being displayed in this environment
for (int i = 0; i < m_mTab.getFieldCount(); i++)
{
MField field = m_mTab.getField(i);
if (!field.isDisplayed (true)) // check context
field.setDisplayed (false);
}
// GridController
m_gridController = new GridController();
m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
m_gridController.setPreferredSize(new Dimension(300,100));
panel.add(m_gridController, BorderLayout.CENTER);
// Prepare Parameter
m_gbc.anchor = GridBagConstraints.NORTHWEST;
m_gbc.gridy = 0; // line
m_gbc.gridx = 0;
m_gbc.gridwidth = 1;
m_gbc.insets = m_fieldInsets;
m_gbc.fill = GridBagConstraints.HORIZONTAL;
m_gbc.weightx = 0;
m_gbc.weighty = 0;
int TabNo = 0;
// Alias
if (s_AcctSchema.isHasAlias())
{
MField alias = m_mTab.getField("Alias");
f_Alias = VEditorFactory.getEditor(m_mTab, alias, false);
addLine(alias, f_Alias, false);
} // Alias
// Combination
MField combination = m_mTab.getField("Combination");
f_Combination = VEditorFactory.getEditor(m_mTab, combination, false);
addLine(combination, f_Combination, false);
m_newRow = true;
/**
* Create Fields in Element Order
*/
MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
for (int i = 0; i < elements.length; i++)
{
MAcctSchemaElement ase = elements[i];
String type = ase.getElementType();
boolean isMandatory = ase.isMandatory();
//
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization))
{
MField field = m_mTab.getField("AD_Org_ID");
f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_AD_Org_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account))
{
MField field = m_mTab.getField("Account_ID");
f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
// ((VLookup)f_Account_ID).setWidth(400);
addLine(field, f_Account_ID, isMandatory);
f_Account_ID.addVetoableChangeListener(this);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount))
{
MField field = m_mTab.getField("C_SubAcct_ID");
f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false);
// ((VLookup)f_SubAcct_ID).setWidth(400);
addLine(field, f_SubAcct_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product))
{
MField field = m_mTab.getField("M_Product_ID");
f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_M_Product_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner))
{
MField field = m_mTab.getField("C_BPartner_ID");
f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_BPartner_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign))
{
MField field = m_mTab.getField("C_Campaign_ID");
f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Campaign_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom))
{
MField field = m_mTab.getField("C_LocFrom_ID");
f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_LocFrom_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo))
{
MField field = m_mTab.getField("C_LocTo_ID");
f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_LocTo_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project))
{
MField field = m_mTab.getField("C_Project_ID");
f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Project_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion))
{
MField field = m_mTab.getField("C_SalesRegion_ID");
f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_SalesRegion_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx))
{
MField field = m_mTab.getField("AD_OrgTrx_ID");
f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_AD_OrgTrx_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity))
{
MField field = m_mTab.getField("C_Activity_ID");
f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Activity_ID, isMandatory);
}
// User1
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1))
{
MField field = m_mTab.getField("User1_ID");
f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_User1_ID, isMandatory);
}
else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2))
{
MField field = m_mTab.getField("User2_ID");
f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_User2_ID, isMandatory);
}
} // Create Fields in Element Order
// Add description
m_newRow = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -