📄 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 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.apps;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.event.*;
import org.compiere.apps.search.*;
import org.compiere.grid.*;
import org.compiere.grid.ed.*;
import org.compiere.model.*;
import org.compiere.plaf.*;
import org.compiere.print.*;
import org.compiere.process.*;
import org.compiere.swing.*;
import org.compiere.util.*;
/**
* 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.156 2006/02/12 02:18:26 jjanke 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.log(Level.SEVERE, "", e);
}
createMenu();
} // APanel
/** Logger */
private static CLogger log = CLogger.getCLogger(APanel.class);
/**
* Dispose
*/
public void dispose()
{
// log.config("");
// ignore changes
m_disposing = true;
//
if (m_curAPanelTab != null)
{
m_curAPanelTab.unregisterPanel();
m_curAPanelTab = null;
}
// 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.info("#" + 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.getLoginLanguage().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,
aWorkflow, aZoomAcross, aRequest, aWinSize, aArchive;
public AppsAction aSave, aLock;
// Local (added to toolbar)
private AppsAction aReport, aEnd, aHome, aHelp, aProduct,
aAccount, aCalculator, aCalendar, aEditor, aPreference, aScript,
aOnline, aMailSupport, 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_F11, 0), false);
aPrint = addAction("Print", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0), 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_F2, 0), false);
aSave = addAction("Save", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), false);
mEdit.addSeparator();
aCopy = addAction("Copy", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.SHIFT_MASK), false);
aDelete = addAction("Delete", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), 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_F6, 0), true); // toggle
if (m_isPersonalLock)
aLock = addAction("Lock", mEdit, null, true); // toggle
// View
JMenu mView = AEnv.getMenu("View");
menuBar.add(mView);
aProduct = addAction("InfoProduct", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK), false);
aBPartner = addAction("InfoBPartner", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.ALT_MASK), false);
if (MRole.getDefault().isShowAcct())
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);
AEnv.addMenuItem("InfoAsset", "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();
aZoomAcross = addAction("ZoomAcross", mGo, null, false);
aRequest = addAction("Request", mGo, null, false);
aArchive = addAction("Archive", mGo, null, false);
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);
if ("Y".equals(Env.getContext(m_ctx, "#SysAdmin"))) // set in DB.loginDB
aWinSize = addAction("WinSize", mTools, null, false);
if (AEnv.isWorkflowProcess())
aWorkflow = addAction("WorkFlow", mTools, null, false);
if (MRole.getDefault().isShowPreference())
{
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);
aMailSupport = addAction("EMailSupport", mHelp, null, false);
aAbout = addAction("About", mHelp, null, false);
/**
* 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(aArchive.getButton());
toolBar.add(aPrint.getButton());
toolBar.addSeparator();
if (m_isPersonalLock)
toolBar.add(aLock.getButton());
toolBar.add(aZoomAcross.getButton());
if (aWorkflow != null)
toolBar.add(aWorkflow.getButton());
toolBar.add(aRequest.getButton());
toolBar.add(aProduct.getButton());
toolBar.addSeparator();
toolBar.add(aEnd.getButton());
//
if (CLogMgt.isLevelAll())
Util.printActionInputMap(this);
} // createMenu
/**
* Add (Toggle) Action to Toolbar and Menu
* @param actionName action name
* @param menu manu
* @param accelerator accelerator
* @param toggle toggle button
* @return AppsAction
*/
private AppsAction addAction (String actionName, JMenu menu, KeyStroke accelerator, boolean toggle)
{
AppsAction action = new AppsAction(actionName, accelerator, toggle);
if (menu != null)
menu.add(action.getMenuItem());
action.setDelegate(this);
AbstractButton b = action.getButton();
String s = null;
if (b != null)
s = b.getToolTipText();
// Key Strokes
if (accelerator != null)
{
getInputMap(WHEN_IN_FOCUSED_WINDOW).put(accelerator, actionName);
getActionMap().put(actionName, action);
}
//
return action;
} // 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;
/** 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 0=all */
private int m_onlyCurrentDays = 0;
/** Process Info */
private boolean m_isLocked = false;
/** Show Personal Lock */
private boolean m_isPersonalLock = MRole.getDefault().isPersonalLock();
/** Last Modifier of Action Event */
private int m_lastModifiers;
/**************************************************************************
* Dynamic Panel Initialization - either single window or workbench.
* <pre>
* either
* - Workbench tabPanel (VTabbedPane)
* - Tab (GridController)
* or
* - Workbench tabPanel (VTabbedPane)
* - Window (VTabbedPane)
* - Tab (GridController)
* </pre>
* tabPanel
* @param AD_Workbench_ID if > 0 this is a workbench, AD_Window_ID ignored
* @param AD_Window_ID if not a workbench, Window ID
* @param query if not a Workbench, Zoom Query - additional SQL where clause
* @return true if Panel is initialized successfully
*/
public boolean initPanel (int AD_Workbench_ID, int AD_Window_ID, MQuery query)
{
log.info("WB=" + AD_Workbench_ID + ", Win=" + AD_Window_ID + ", Query=" + query);
this.setName("APanel" + AD_Window_ID);
// Single Window
if (AD_Workbench_ID == 0)
m_mWorkbench = new MWorkbench(m_ctx, AD_Window_ID);
else
// Workbench
{
// m_mWorkbench = new MWorkbench(m_ctx);
// if (!m_mWorkbench.initWorkbench (AD_Workbench_ID))
// {
// log.log(Level.SEVERE, "APanel.initWindow - No Workbench Model");
// return false;
// }
// tabPanel.setWorkbench(true);
// tabPanel.addChangeListener(this);
ADialog.warn(0, this, "","Not implemented yet");
return false;
}
Dimension windowSize = m_mWorkbench.getWindowSize();
/**
* WorkBench Loop
*/
for (int wb = 0; wb < m_mWorkbench.getWindowCount(); wb++)
{
// Get/set WindowNo
m_curWindowNo = Env.createWindowNo (this); // Timing: ca. 1.5 sec
m_mWorkbench.setWindowNo(wb, m_curWindowNo);
// Set AutoCommit for this Window
Env.setAutoCommit(m_ctx, m_curWindowNo, Env.isAutoCommit(m_ctx));
boolean autoNew = Env.isAutoNew(m_ctx);
Env.setAutoNew(m_ctx, m_curWindowNo, autoNew);
// Workbench Window
VTabbedPane window = null;
// just one window
if (m_mWorkbench.getWindowCount() == 1)
{
window = tabPanel;
window.setWorkbench(false);
}
else
{
VTabbedPane tp = new VTabbedPane(false);
window = tp;
}
// Window Init
window.addChangeListener(this);
/**
* Init Model
*/
int wbType = m_mWorkbench.getWindowType(wb);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -