📄 info.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.apps.search;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.math.*;
import org.compiere.util.*;
import org.compiere.apps.*;
import org.compiere.model.*;
import org.compiere.minigrid.*;
import org.compiere.grid.ed.*;
import org.compiere.plaf.*;
import org.compiere.swing.*;
/**
* Search Information and return selection - Base Class.
* <pre>
* Structure:
* parameterPanel (JPanel) - for subclasses to add parameter fields
* scrollPame (JScrollPane)
* m_table (MiniTable)
* southPanel (JPanel)
* confirmPanel
* statusPanel
* </pre>
*
* @author Jorg Janke
* @version $Id: Info.java,v 1.19 2003/02/18 06:12:44 jjanke Exp $
*/
public abstract class Info extends JDialog
implements ActionListener, MouseListener, ListSelectionListener
{
/**
* Factory Constructor
* @param frame parent frame
* @param modal new window is modal
* @param WindowNo window no
* @param tableName table name of the search
* @param keyColumn key column of the search
* @param value query value
* @param multiSelection allow to select more than one row
* @param whereClause fully qualified where clause for the search
* @return special or general Info Window
*/
public static Info create (Frame frame, boolean modal, int WindowNo,
String tableName, String keyColumn, String value,
boolean multiSelection, String whereClause)
{
Info info = null;
if (tableName.equals("C_BPartner"))
info = new InfoBPartner (frame, modal, WindowNo, value, !Env.getContext(Env.getCtx(),"IsSOTrx").equals("N"),
multiSelection, whereClause);
else if (tableName.equals("M_Product"))
info = new InfoProduct (frame, modal, WindowNo, 0,0, value,
multiSelection, whereClause);
else if (tableName.equals("C_Invoice"))
info = new InfoInvoice (frame, modal, WindowNo, value,
multiSelection, whereClause);
else if (tableName.equals("C_Order"))
info = new InfoOrder (frame, modal, WindowNo, value,
multiSelection, whereClause);
else if (tableName.equals("M_InOut"))
info = new InfoInOut (frame, modal, WindowNo, value,
multiSelection, whereClause);
else if (tableName.equals("C_Payment"))
info = new InfoPayment (frame, modal, WindowNo, value,
multiSelection, whereClause);
else if (tableName.equals("C_CashLine"))
info = new InfoCashLine (frame, modal, WindowNo, value,
multiSelection, whereClause);
else if (tableName.equals("S_ResourceAssigment"))
info = new InfoAssignment (frame, modal, WindowNo, value,
multiSelection, whereClause);
else
info = new InfoGeneral (frame, modal, WindowNo, tableName, keyColumn, multiSelection, whereClause);
//
AEnv.positionCenterWindow(frame, info);
return info;
} // create
/**
* Show BPartner Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
*/
public static void showBPartner (Frame frame, int WindowNo)
{
Info info = new InfoBPartner (frame, false, WindowNo, "",
!Env.getContext(Env.getCtx(),"IsSOTrx").equals("N"), false, "");
AEnv.showCenterWindow(frame, info);
} // showBPartner
/**
* Show Product Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
*/
public static void showProduct (Frame frame, int WindowNo)
{
Info info = new InfoProduct (frame, false, WindowNo,
Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"),
0, "", false, "");
AEnv.showCenterWindow(frame, info);
} // showProduct
/**
* Show Order Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showOrder (Frame frame, int WindowNo, String value)
{
Info info = new InfoOrder (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showOrder
/**
* Show Invoice Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showInvoice (Frame frame, int WindowNo, String value)
{
Info info = new InfoInvoice (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showInvoice
/**
* Show Shipment Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showInOut (Frame frame, int WindowNo, String value)
{
Info info = new InfoInOut (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showInOut
/**
* Show Payment Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showPayment (Frame frame, int WindowNo, String value)
{
Info info = new InfoPayment (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showPayment
/**
* Show Cash Line Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showCashLine (Frame frame, int WindowNo, String value)
{
Info info = new InfoCashLine (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showCashLine
/**
* Show Assignment Info (non modal)
* @param frame Parent Frame
* @param WindowNo window no
* @param value query value
*/
public static void showAssignment (Frame frame, int WindowNo, String value)
{
Info info = new InfoAssignment (frame, false, WindowNo, value,
false, "");
AEnv.showCenterWindow(frame, info);
} // showAssignment
/** Window Width */
static final int INFO_WIDTH = 800;
/*************************************************************************/
/**
* Detail Constructor
* @param frame parent frame
* @param modal modal
* @param WindowNo window no
* @param tableName table name
* @param keyColumn key column name
* @param multiSelection muiliple selection
* @param whereClause where clause
*/
protected Info (Frame frame, boolean modal, int WindowNo,
String tableName, String keyColumn,
boolean multiSelection, String whereClause)
{
super (frame, modal);
Log.trace(Log.l1_User, "Info for WinNo=" + m_WindowNo + " " + whereClause);
CompiereColor.setBackground(this);
m_WindowNo = WindowNo;
m_tableName = tableName;
m_keyColumn = keyColumn;
m_multiSelection = multiSelection;
m_whereClause = whereClause;
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
try
{
jbInit();
}
catch(Exception ex)
{
Log.error("Info", ex);
}
} // Info
/** Master (owning) Window */
protected int m_WindowNo;
/** Table Name */
protected String m_tableName;
/** Key Column Name */
protected String m_keyColumn;
/** Enable more than one selection */
protected boolean m_multiSelection;
/** Initial WHERE Clause */
protected String m_whereClause = "";
/** Table */
protected MiniTable m_table = new MiniTable();
/** Model Index of Key Column */
private int m_keyColumnIndex = -1;
/** OK pressed */
private boolean m_ok = false;
/** Cancel pressed */
private boolean m_cancel = false;
/** Result IDs */
private ArrayList m_results = new ArrayList(3);
/** Layout of Grid */
protected Info_Column[] m_layout;
/** Main SQL Statement */
private String m_sqlMain;
/** Order By Clause */
private String m_sqlAdd;
/** Loading success indicator */
protected boolean m_loadedOK = false;
/** Worker */
private Worker m_worker = null;
/** Static Layout */
private CPanel southPanel = new CPanel();
private BorderLayout southLayout = new BorderLayout();
private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, true, true, true, true);
protected StatusBar statusBar = new StatusBar();
protected CPanel parameterPanel = new CPanel();
private JScrollPane scrollPane = new JScrollPane();
//
private JPopupMenu popup = new JPopupMenu();
private JMenuItem calcMenu = new JMenuItem();
/**
* Static Init
* @throws Exception
*/
protected void jbInit() throws Exception
{
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
southPanel.setLayout(southLayout);
southPanel.add(confirmPanel, BorderLayout.CENTER);
southPanel.add(statusBar, BorderLayout.SOUTH);
getContentPane().add(southPanel, BorderLayout.SOUTH);
this.getContentPane().add(parameterPanel, BorderLayout.NORTH);
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
scrollPane.getViewport().add(m_table, null);
//
confirmPanel.addActionListener(this);
confirmPanel.getCustomizeButton().setVisible(hasCustomize());
confirmPanel.getHistoryButton().setVisible(hasHistory());
confirmPanel.getZoomButton().setVisible(hasZoom());
//
popup.add(calcMenu);
calcMenu.setText(Msg.getMsg(Env.getCtx(), "Calculator"));
calcMenu.setIcon(new ImageIcon(org.compiere.Compiere.class.getResource("images/Calculator16.gif")));
calcMenu.addActionListener(this);
//
m_table.getSelectionModel().addListSelectionListener(this);
enableButtons();
} // jbInit
/**
* Loaded correctly
* @return true if loaded OK
*/
public boolean loadedOK()
{
return m_loadedOK;
} // loadedOK
/**
* Set Status Line
* @param text text
* @param error error
*/
public void setStatusLine (String text, boolean error)
{
statusBar.setStatusLine(text, error);
Thread.yield();
} // setStatusLine
/**
* Set Status DB
* @param text text
*/
public void setStatusDB (String text)
{
statusBar.setStatusDB(text);
} // setStatusDB
/*************************************************************************/
/**
* Prepare Table, Construct SQL (m_m_sqlMain, m_sqlAdd)
* and size Window
* @param layout layout array
* @param from from clause
* @param staticWhere where clause
* @param orderBy order by clause
*/
protected void prepareTable(Info_Column[] layout, String from, String staticWhere, String orderBy)
{
m_layout = layout;
StringBuffer sql = new StringBuffer ("SELECT ");
// add columns & sql
for (int i = 0; i < layout.length; i++)
{
if (i > 0)
sql.append(", ");
sql.append(layout[i].getColSQL());
// adding ID column
if (layout[i].isIDcol())
sql.append(",").append(layout[i].getIDcolSQL());
// add to model
m_table.addColumn(layout[i].getColHeader());
if (layout[i].isColorColumn())
m_table.setColorColumn(i);
if (layout[i].getColClass() == IDColumn.class)
m_keyColumnIndex = i;
}
// set editors (two steps)
for (int i = 0; i < layout.length; i++)
m_table.setColumnClass(i, layout[i].getColClass(), layout[i].isReadOnly(), layout[i].getColHeader());
sql.append( " FROM ").append(from);
sql.append(" WHERE ").append(staticWhere);
m_sqlMain = sql.toString();
m_sqlAdd = "";
if (orderBy != null && orderBy.length() > 0)
m_sqlAdd = " ORDER BY " + orderBy;
// Table Selection
m_table.setRowSelectionAllowed(true);
m_table.addMouseListener(this);
m_table.setMultiSelection(m_multiSelection);
// Window Sizing
parameterPanel.setPreferredSize(new Dimension (INFO_WIDTH, parameterPanel.getPreferredSize().height));
scrollPane.setPreferredSize(new Dimension(INFO_WIDTH, 400));
} // prepareTable
/*************************************************************************/
/**
* Execute Query
*/
void executeQuery()
{
// ignore when running
if (m_worker != null && m_worker.isAlive())
return;
m_worker = new Worker();
m_worker.start();
} // executeQuery
/**
* Save Selection - Called by dispose
*/
protected void saveSelection ()
{
// Already disposed
if (m_table == null)
return;
Log.trace(Log.l3_Util, "Info.saveSelection");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -