📄 vlocatordialog.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 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 javax.swing.*;
import java.sql.*;
import org.compiere.util.*;
import org.compiere.model.*;
import org.compiere.apps.*;
import org.compiere.plaf.*;
import org.compiere.swing.*;
/**
* Dialog to enter Warehouse Locator Info
*
* @author Jorg Janke
* @version $Id: VLocatorDialog.java,v 1.9 2002/09/03 05:11:10 jjanke Exp $
*/
public class VLocatorDialog extends JDialog implements ActionListener, KeyListener
{
/**
* Constructor
* @param frame frame
* @param title title
* @param mLocator locator
* @param M_Locator_ID locator id
*/
public VLocatorDialog (Frame frame, String title, MLocator mLocator, int M_Locator_ID)
{
super (frame, title, true);
m_WindowNo = Env.getWindowNo(frame);
try
{
jbInit();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
catch(Exception ex)
{
Log.error("VLocatorDialog", ex);
}
//
m_mLocator = mLocator;
m_M_Locator_ID = M_Locator_ID;
//
initLocator();
AEnv.positionCenterWindow(frame, this);
} // VLocatorDialog
private int m_WindowNo;
private boolean m_change = false;
private MLocator m_mLocator;
private int m_M_Locator_ID;
//
private int m_M_Warehouse_ID;
private String m_M_WarehouseName;
private String m_M_WarehouseValue;
private String m_Separator;
private int m_AD_Client_ID;
private int m_AD_Org_ID;
//
private CPanel panel = new CPanel();
private CPanel mainPanel = new CPanel();
private CPanel southPanel = new CPanel();
private BorderLayout panelLayout = new BorderLayout();
private GridBagLayout gridBagLayout = new GridBagLayout();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private BorderLayout southLayout = new BorderLayout();
//
private VComboBox fLocator = new VComboBox();
private CComboBox fWarehouse = new CComboBox();
private JCheckBox fCreateNew = new JCheckBox();
private CTextField fX = new CTextField();
private CTextField fY = new CTextField();
private CTextField fZ = new CTextField();
private JLabel lLocator = new JLabel();
private CTextField fWarehouseInfo = new CTextField();
private CTextField fValue = new CTextField();
private JLabel lWarehouseInfo = new JLabel();
private JLabel lWarehouse = new JLabel();
private JLabel lX = new JLabel();
private JLabel lY = new JLabel();
private JLabel lZ = new JLabel();
private JLabel lValue = new JLabel();
/**
* Static component init
* @throws Exception
*/
void jbInit() throws Exception
{
CompiereColor.setBackground(this);
panel.setLayout(panelLayout);
southPanel.setLayout(southLayout);
mainPanel.setLayout(gridBagLayout);
panelLayout.setHgap(5);
panelLayout.setVgap(10);
fCreateNew.setText(Msg.getMsg(Env.getCtx(), "CreateNew"));
fX.setColumns(15);
fY.setColumns(15);
fZ.setColumns(15);
lLocator.setLabelFor(fLocator);
lLocator.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
fWarehouseInfo.setBackground(CompierePLAF.getFieldBackground_Inactive());
fWarehouseInfo.setReadWrite(false);
fWarehouseInfo.setColumns(15);
fValue.setColumns(15);
lWarehouseInfo.setLabelFor(fWarehouseInfo);
lWarehouseInfo.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
lWarehouse.setLabelFor(fWarehouse);
lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
lX.setLabelFor(fX);
lX.setText(Msg.getElement(Env.getCtx(), "X"));
lY.setLabelFor(fY);
lY.setText(Msg.getElement(Env.getCtx(), "Y"));
lZ.setLabelFor(fZ);
lZ.setText(Msg.getElement(Env.getCtx(), "Z"));
lValue.setLabelFor(fValue);
lValue.setText(Msg.translate(Env.getCtx(), "Value"));
getContentPane().add(panel);
panel.add(mainPanel, BorderLayout.CENTER);
//
mainPanel.add(lLocator, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fLocator, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(fCreateNew, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 5), 0, 0));
mainPanel.add(lWarehouseInfo, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fWarehouseInfo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(lWarehouse, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fWarehouse, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(lX, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fX, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(lY, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fY, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(lZ, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fZ, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
mainPanel.add(lValue, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
mainPanel.add(fValue, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
//
panel.add(southPanel, BorderLayout.SOUTH);
southPanel.add(confirmPanel, BorderLayout.NORTH);
confirmPanel.addActionListener(this);
} // jbInit
/**
* Dynanmic Init & fill fields
*/
private void initLocator()
{
Log.trace(Log.l5_DData, "VLocatorDialog.initLocator");
// Load Warehouse
String SQL = Access.addROAccessSQL(Env.getCtx(),
"SELECT M_Warehouse_ID, Name from M_Warehouse", "M_Warehouse", false)
+ " ORDER BY 2";
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
Log.error ("VLocatorDialog.initLoactor", e);
}
Log.trace(Log.l6_Database, "Warehouses=" + fWarehouse.getItemCount());
// Load existing Locators
m_mLocator.fillComboBox(true, true, true, false);
Log.trace(Log.l6_Database, "Locations", m_mLocator.toString());
fLocator.setModel(m_mLocator);
fLocator.setValue(m_M_Locator_ID);
fLocator.addActionListener(this);
displayLocator();
//
fCreateNew.setSelected(false);
fCreateNew.addActionListener(this);
enableNew();
//
fWarehouse.addActionListener(this);
fX.addKeyListener(this);
fY.addKeyListener(this);
fZ.addKeyListener(this);
// Update UI
pack();
} // initLocator
/*************************************************************************/
/**
* ActionListener
* @param e event
*/
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
//
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
{
actionOK();
m_change = true;
dispose();
}
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
{
m_change = false;
dispose();
}
// Locator Change
else if (e.getSource() == fLocator)
displayLocator();
// New Value Change
else if (source == fCreateNew)
enableNew();
// Entered/Changed data for Value
else if (fCreateNew.isSelected() && source == fWarehouse)
createValue();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -