📄 apanel.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;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import org.compiere.model.*;
import org.compiere.process.*;
import org.compiere.util.*;
import org.compiere.grid.*;
import org.compiere.grid.ed.*;
import org.compiere.images.ImageFactory;
import org.compiere.apps.search.*;
import org.compiere.print.*;
import org.compiere.plaf.*;
import org.compiere.swing.*;
/**
* Main Application Panel.
* <pre>
* Structure:
* (MenuBar) -> to be added to owning window
* northPanel (ToolBar)
* tabPanel
* southPanel (StatusBar)
* </pre>
*
* @author Jorg Janke
* @version $Id: APanel.java,v 1.74 2003/04/29 09:17:16 jpedersen Exp $
*/
public final class APanel extends CPanel
implements DataStatusListener, ChangeListener, ActionListener, ASyncProcess
{
/**
* Constructs a new instance.
* Need to call initPanel for dynamic initialization
*/
public APanel()
{
super();
m_ctx = Env.getCtx();
//
try
{
jbInit();
}
catch (Exception e)
{
Log.error("APanel", e);
}
createMenu();
} // APanel
/**
* Dispose
*/
public void dispose()
{
Log.trace(Log.l1_User, "APanel.dispose");
// ignore changes
m_disposing = true;
// close panels
tabPanel.dispose(this);
tabPanel = null;
// All Workbenches
for (int i = 0; i < m_mWorkbench.getWindowCount(); i++)
{
m_curWindowNo = m_mWorkbench.getWindowNo(i);
Log.trace(Log.l1_User, "APanel.dispose #" + m_curWindowNo);
Env.setAutoCommit(m_ctx, m_curWindowNo, false);
m_mWorkbench.dispose(i);
Env.clearWinContext(m_ctx, m_curWindowNo);
} // all Workbenchens
// Get rid of remaining model
if (m_mWorkbench != null)
m_mWorkbench.dispose();
m_mWorkbench = null;
// MenuBar
if (menuBar != null)
menuBar.removeAll();
menuBar = null;
// ToolBar
if (toolBar != null)
toolBar.removeAll();
toolBar = null;
// Prepare GC
this.removeAll();
} // dispose
/**
* The Layout.
*/
private BorderLayout mainLayout = new BorderLayout();
private VTabbedPane tabPanel = new VTabbedPane(true);
private StatusBar statusBar = new StatusBar();
private CPanel northPanel = new CPanel();
private JToolBar toolBar = new JToolBar();
private JMenuBar menuBar = new JMenuBar();
private FlowLayout northLayout = new FlowLayout();
/**
* Initializes the state of this instance.
* @throws Exception
*/
private void jbInit() throws Exception
{
this.setLocale(Language.getLanguage().getLocale());
this.setLayout(mainLayout);
// tabPanel
mainLayout.setHgap(2);
mainLayout.setVgap(2);
this.add(tabPanel, BorderLayout.CENTER);
// southPanel
this.add(statusBar, BorderLayout.SOUTH);
// northPanel
this.add(northPanel, BorderLayout.NORTH);
northPanel.setLayout(northLayout);
northLayout.setAlignment(FlowLayout.LEFT);
northPanel.add(toolBar, null);
} // jbInit
private AppsAction aPrevious, aNext, aParent, aDetail, aFirst, aLast,
aNew, aCopy, aDelete, aIgnore, aPrint,
aRefresh, aHistory, aAttachment, aMulti, aFind;
public AppsAction aSave;
// Local (added to toolbar)
private AppsAction aReport, aEnd, aHome, aHelp, aProduct,
aAccount, aCalculator, aCalendar, aEditor, aPreference, aScript,
aOnline, aSendMail, aAbout, aPrintScr, aScrShot, aExit, aBPartner;
/*************************************************************************/
/**
* Create Menu and Toolbar and registers keyboard actions.
* - started from constructor
*/
private void createMenu()
{
/**
* Menu
*/
// menuBar.setHelpMenu();
// File
JMenu mFile = AEnv.getMenu("File");
menuBar.add(mFile);
aPrintScr = addAction("PrintScreen", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), false);
aScrShot = addAction("ScreenShot", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), false);
aReport = addAction("Report", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.ALT_MASK), false);
aPrint = addAction("Print", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK), false);
mFile.addSeparator();
aEnd = addAction("End", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), false);
aExit = addAction("Exit", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK+Event.ALT_MASK), false);
// Edit
JMenu mEdit = AEnv.getMenu("Edit");
menuBar.add(mEdit);
aNew = addAction("New", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK), false);
aSave = addAction("Save", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK), false);
mEdit.addSeparator();
aCopy = addAction("Copy", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK), false);
aDelete = addAction("Delete", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK), false);
aIgnore = addAction("Ignore", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), false);
aRefresh = addAction("Refresh", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), false);
mEdit.addSeparator();
aFind = addAction("Find", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK), true); // toggle
// View
JMenu mView = AEnv.getMenu("View");
menuBar.add(mView);
aProduct = addAction("InfoProduct", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK), false);
aBPartner = addAction("InfoBPartner", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK), false);
aAccount = addAction("InfoAccount", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK+Event.CTRL_MASK), false);
AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
mView.addSeparator();
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this);
AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this);
mView.addSeparator();
aAttachment = addAction("Attachment", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), true); // toggle
aHistory = addAction("History", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0), true); // toggle
mView.addSeparator();
aMulti = addAction("Multi", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), true); // toggle
// Go
JMenu mGo = AEnv.getMenu("Go");
menuBar.add(mGo);
aFirst = addAction("First", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, Event.ALT_MASK), false);
aPrevious = addAction("Previous", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_UP, Event.ALT_MASK), false);
aNext = addAction("Next", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, Event.ALT_MASK), false);
aLast = addAction("Last", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, Event.ALT_MASK), false);
mGo.addSeparator();
aParent = addAction("Parent", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.ALT_MASK), false);
aDetail = addAction("Detail", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.ALT_MASK), false);
mGo.addSeparator();
aHome = addAction("Home", mGo, null, false);
// Tools
JMenu mTools = AEnv.getMenu("Tools");
menuBar.add(mTools);
aCalculator = addAction("Calculator", mTools, null, false);
aCalendar = addAction("Calendar", mTools, null, false);
aEditor = addAction("Editor", mTools, null, false);
aScript = addAction("Script", mTools, null, false);
mTools.addSeparator();
aPreference = addAction("Preference", mTools, null, false);
// Help
JMenu mHelp = AEnv.getMenu("Help");
menuBar.add(mHelp);
aHelp = addAction("Help", mHelp, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), false);
aOnline = addAction("Online", mHelp, null, false);
aSendMail = addAction("SendMail", mHelp, null, false);
aAbout = addAction("About", mHelp, null, false);
/**
* KeyBoard Actions
*
* Function Keys (if not defined above)
*/
int c = CPanel.WHEN_IN_FOCUSED_WINDOW; // default condition = WHEN_FOCUSED
// ESC = Ignore
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), aIgnore.getName());
getActionMap().put(aIgnore.getName(), aIgnore);
// F1 = Help
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), aHelp.getName());
getActionMap().put(aHelp.getName(), aHelp);
// F2 = New
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), aNew.getName());
getActionMap().put(aNew.getName(), aNew);
// F3 = Delete
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), aDelete.getName());
getActionMap().put(aDelete.getName(), aDelete);
// F4 = Save
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), aSave.getName());
getActionMap().put(aSave.getName(), aSave);
// F5 = Refresh
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), aRefresh.getName());
getActionMap().put(aRefresh.getName(), aRefresh);
// F6 = Find
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), aFind.getName());
getActionMap().put(aFind.getName(), aFind);
// F7 = Arrachment
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), aAttachment.getName());
getActionMap().put(aAttachment.getName(), aAttachment);
// F8 = Multi
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), aMulti.getName());
getActionMap().put(aMulti.getName(), aMulti);
// F9 = History
getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0), aHistory.getName());
getActionMap().put(aHistory.getName(), aHistory);
/**
* ToolBar
*/
toolBar.add(aIgnore.getButton()); // ESC
toolBar.addSeparator();
toolBar.add(aHelp.getButton()); // F1
toolBar.add(aNew.getButton());
toolBar.add(aDelete.getButton());
toolBar.add(aSave.getButton());
toolBar.addSeparator();
toolBar.add(aRefresh.getButton()); // F5
toolBar.add(aFind.getButton());
toolBar.add(aAttachment.getButton());
toolBar.add(aMulti.getButton());
toolBar.addSeparator();
toolBar.add(aHistory.getButton()); // F9
toolBar.add(aHome.getButton()); // F10 is Windows Menu Key
toolBar.add(aParent.getButton());
toolBar.add(aDetail.getButton());
toolBar.addSeparator();
toolBar.add(aFirst.getButton());
toolBar.add(aPrevious.getButton());
toolBar.add(aNext.getButton());
toolBar.add(aLast.getButton());
toolBar.addSeparator();
toolBar.add(aReport.getButton());
toolBar.add(aPrint.getButton());
toolBar.addSeparator();
toolBar.add(aProduct.getButton());
toolBar.addSeparator();
toolBar.add(aEnd.getButton());
//
if (Log.getTraceLevel() > Log.l6_Database)
AEnv.printActionInputMap(this);
} // createMenu
/**
* Add (Toggle) Action to Toolbar and Menu
* @param action action
* @param menu manu
* @param accelerator accelerator
* @param toggle toggle button
* @return AppsAction
*/
private AppsAction addAction (String action, JMenu menu, KeyStroke accelerator, boolean toggle)
{
AppsAction act = new AppsAction(action, accelerator, toggle);
if (menu != null)
menu.add(act.getMenuItem());
act.setDelegate(this);
return act;
} // addAction
/**
* Return MenuBar
* @return JMenuBar
*/
public JMenuBar getMenuBar()
{
return menuBar;
} // getMenuBar
/**
* Get Title of Window
* @return String with Title
*/
public String getTitle()
{
if (m_mWorkbench.getWindowCount() > 1)
{
StringBuffer sb = new StringBuffer();
sb.append(m_mWorkbench.getName()).append(" ")
.append(Env.getContext(m_ctx, "#AD_User_Name")).append("@")
.append(Env.getContext(m_ctx, "#AD_Client_Name")).append(".")
.append(Env.getContext(m_ctx, "#AD_Org_Name")).append(" [")
.append(Env.getContext(m_ctx, "#DB_UID")).append("]");
return sb.toString();
}
return Env.getHeader(m_ctx, m_curWindowNo);
} // getTitle
private Properties m_ctx;
private boolean m_isSOTrx;
/** Workbench Model */
private MWorkbench m_mWorkbench;
/** Current MTab */
private MTab m_curTab;
/** Current GridController */
private GridController m_curGC;
/** Current Window Panel */
private JTabbedPane m_curWinTab = null;
/** Current Window No */
private int m_curWindowNo;
/** Current Window Panel Index */
private int m_curTabIndex = -1;
/** Current Tab Order */
private APanelTab m_curAPanelTab = null;
/** Dispose active */
private boolean m_disposing = false;
/** Save Error Message indicator */
private boolean m_errorDisplayed = false;
/** Only current row flag */
private boolean m_onlyCurrentRows = true;
/** Number of days to show */
private int m_onlyCurrentDays = 1;
/** Process Info */
private boolean m_isLocked = false;
/*************************************************************************/
/**
* Dynamic Panel Initialization - either single window or workbench.
* <pre>
* either
* - Workbench tabPanel (VTabbedPane)
* - Tab (GridController)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -