📄 formframe.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-2002 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.apps.form;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import org.compiere.apps.*;
import org.compiere.plaf.*;
import org.compiere.util.*;
import java.awt.event.*;
/**
* Form Framework
*
* @author Jorg Janke
* @version $Id: FormFrame.java,v 1.8 2002/09/03 05:11:09 jjanke Exp $
*/
public class FormFrame extends JFrame implements ActionListener
{
/**
* Create Form.
* Need to call openForm
*/
public FormFrame ()
{
super();
m_WindowNo = Env.createWindowNo (this);
try
{
jbInit();
createMenu();
}
catch(Exception e)
{
Log.error("FormFrame", e);
}
} // FormFrame
/** WindowNo */
private int m_WindowNo;
private JMenuBar menuBar = new JMenuBar();
/**
* Static Init
* @throws Exception
*/
private void jbInit() throws Exception
{
CompiereColor.setBackground(this);
//
this.setIconImage(org.compiere.Compiere.getImage16());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setJMenuBar(menuBar);
//
} // jbInit
/**
* Create Menu
*/
private void createMenu()
{
// File
JMenu mFile = AEnv.getMenu("File");
menuBar.add(mFile);
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), mFile, this);
AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.ALT_MASK), mFile, this);
mFile.addSeparator();
AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), mFile, this);
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK+Event.ALT_MASK), mFile, this);
// View
JMenu mView = AEnv.getMenu("View");
menuBar.add(mView);
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK), mView, this);
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK), mView, this);
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK+Event.CTRL_MASK), 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("InfoSchedule", "Info", null, mView, this);
// Tools
JMenu mTools = AEnv.getMenu("Tools");
menuBar.add(mTools);
AEnv.addMenuItem("Calculator", null, null, mTools, this);
AEnv.addMenuItem("Calendar", null, null, mTools, this);
AEnv.addMenuItem("Editor", null, null, mTools, this);
AEnv.addMenuItem("Script", null, null, mTools, this);
mTools.addSeparator();
AEnv.addMenuItem("Preference", null, null, mTools, this);
// Help
JMenu mHelp = AEnv.getMenu("Help");
menuBar.add(mHelp);
AEnv.addMenuItem("Online", null, null, mHelp, this);
AEnv.addMenuItem("SendMail", null, null, mHelp, this);
AEnv.addMenuItem("About", null, null, mHelp, this);
} // createMenu
/**
* Dispose
*/
public void dispose()
{
Log.trace(Log.l3_Util, "FormFrame.dispose");
Env.clearWinContext(m_WindowNo);
super.dispose();
} // dispose
/**
* Open Form
* @param AD_Form_ID form
* @return true if form opened
*/
public boolean openForm (int AD_Form_ID)
{
Properties ctx = Env.getCtx();
//
String name = null;
String description = null;
String className = null;
String sql = "SELECT Name, Description, ClassName FROM AD_Form WHERE AD_Form_ID=?";
boolean trl = !Env.isBaseLanguage(ctx, "AD_Form");
if (trl)
sql = "SELECT t.Name, t.Description, f.ClassName "
+ "FROM AD_Form f INNER JOIN AD_Form_Trl t"
+ " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)"
+ "WHERE f.AD_Form_ID=?";
try
{
PreparedStatement pstmt = DB.prepareStatement (sql);
if (trl)
{
pstmt.setString(1, Env.getAD_Language(ctx));
pstmt.setInt(2, AD_Form_ID);
}
else
pstmt.setInt(1, AD_Form_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
name = rs.getString(1);
description = rs.getString(2);
className = rs.getString(3);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
Log.error ("FormFrame.openForm", e);
}
if (className == null)
return false;
//
Log.trace(Log.l1_User, "FormFrame.openForm - AD_Form_ID=" + AD_Form_ID, "Class=" + className);
Env.setContext(ctx, m_WindowNo, "WindowName", name);
setTitle(Env.getHeader(ctx, m_WindowNo));
FormPanel panel = null;
try
{
// Create instance w/o parameters
panel = (FormPanel)Class.forName(className).newInstance();
//
}
catch (Exception e)
{
Log.error("FormFrame.openForm - class=" + className + ", AD_Form_ID=" + AD_Form_ID, e);
return false;
}
//
panel.init(m_WindowNo, this);
return true;
} // openForm
/**
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if (cmd.equals("End"))
dispose();
else if (!AEnv.actionPerformed(cmd, m_WindowNo, this))
Log.error("FormFrame.actionPerformed - Not handeled=" + cmd);
} // actionPerformed
} // FormFrame
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -