⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vaccountdialog.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************
 * 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  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.grid.ed;

import java.awt.*;
import java.awt.event.*;
import java.math.*;
import javax.swing.*;
import javax.swing.border.*;
import java.sql.*;
import java.util.*;

import org.compiere.apps.*;
import org.compiere.util.*;
import org.compiere.model.*;
import org.compiere.grid.*;
import org.compiere.grid.ed.*;
import org.compiere.plaf.*;
import org.compiere.swing.*;

/**
 *	Dialog to enter Account Info
 *
 * 	@author 	Jorg Janke
 * 	@version 	$Id: VAccountDialog.java,v 1.14 2002/11/08 05:42:39 jjanke Exp $
 */
public final class VAccountDialog extends JDialog
	implements ActionListener, DataStatusListener
{
	/**
	 * 	Constructor
	 *  @param frame frame
	 *  @param title title
	 *  @param mAccount account
	 */
	public VAccountDialog (Frame frame, String title, MAccount mAccount)
	{
		super (frame, title, true);
		Log.trace(Log.l2_Sub, "VAccountDialog");
		m_mAccount = mAccount;
		m_WindowNo = Env.createWindowNo (this);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		try
		{
			jbInit();
		}
		catch(Exception ex)
		{
			Log.error ("VAccountDialog" + ex);
		}
		initAccount();
		AEnv.showCenterWindow(frame, this);
	}	//	VLocationDialog

	private int					m_WindowNo;
	protected boolean			m_changed = false;

	/** Accounting Schema           */
	private static AcctSchema	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 MAccount			m_mAccount = null;
	/** Result                      */
	private int 				m_C_ValidCombination_ID;
	/** Client                      */
	private int                 m_AD_Client_ID;
	/** Where clause for combination search */
	private MQuery				m_query;

	//  Editors for Query
	private VEditor 			f_Alias, f_Combination,
		f_AD_Org_ID, f_Account_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
	{
		CompiereColor.setBackground(this);
		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 Primary AcctSchema Info
		int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID");
		if (C_AcctSchema_ID == 0)
			C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID");
		if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != C_AcctSchema_ID)
			s_AcctSchema = new AcctSchema(C_AcctSchema_ID);
		Log.trace(Log.l3_Util, "VAccountDialog.initAccount - " + s_AcctSchema.toString()
			+ ", #" + s_AcctSchema.getAcctSchemaElementList().size());
		Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", C_AcctSchema_ID);

		//  Model
		MWindowVO wVO = AEnv.getMWindowVO (m_WindowNo, 153, 0);     //  hardcoded
		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);
		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;
		Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", C_AcctSchema_ID);

		//	Alias
		if (s_AcctSchema.hasAlias())
		{
			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
		 */
		ArrayList ase_list = s_AcctSchema.getAcctSchemaElementList();
		for (int i = 0; i < ase_list.size(); i++)
		{
			AcctSchemaElement ase = (AcctSchemaElement)ase_list.get(i);
			String type = ase.getSegmentType();
			boolean isMandatory = ase.isMandatory();
			//
			if (type.equals(AcctSchemaElement.SEGMENT_Org))
			{
				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(AcctSchemaElement.SEGMENT_Account))
			{
				MField field = m_mTab.getField("Account_ID");
				f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
				addLine(field, f_Account_ID, isMandatory);
			}
			else if (type.equals(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_TrxOrg))
			{
				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(AcctSchemaElement.SEGMENT_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(AcctSchemaElement.SEGMENT_User1))
			{
				MField field = m_mTab.getField("User1_ID");
				f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -