Integrate Heng Sin contributions

[ 1600119 ] Add logout menu item
[ 1599516 ] Add window menu
This commit is contained in:
Carlos Ruiz 2006-11-22 04:51:12 +00:00
parent 9b80286758
commit df3b68dedd
13 changed files with 602 additions and 28 deletions

View File

@ -0,0 +1,3 @@
UPDATE ad_sequence
SET currentnextsys = 50000
WHERE istableid = 'Y'

View File

@ -0,0 +1,55 @@
INSERT INTO ad_message
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
createdby, updated, updatedby, VALUE, msgtext, msgtype,
entitytype
)
VALUES (50000, 0, 0, 'Y', SYSDATE,
0, SYSDATE, 0, 'CloseAllWindows', 'Close All Windows', 'I',
'D'
);
INSERT INTO ad_message
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
createdby, updated, updatedby, VALUE, msgtext, msgtype,
entitytype
)
VALUES (50001, 0, 0, 'Y', SYSDATE,
0, SYSDATE, 0, 'CloseOtherWindows', 'Close Other Windows', 'I',
'D'
);
INSERT INTO ad_message
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
createdby, updated, updatedby, VALUE,
msgtext, msgtype, entitytype
)
VALUES (50002, 0, 0, 'Y', SYSDATE,
0, SYSDATE, 0, 'ValidateConnectionOnStartup',
'Validate Connection on Startup', 'I', 'D'
);
INSERT INTO ad_message
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
createdby, updated, updatedby, VALUE,
msgtext, msgtype, entitytype
)
VALUES (50003, 0, 0, 'Y', SYSDATE,
0, SYSDATE, 0, 'SingleInstancePerWindow',
'Single Instance per Window', 'I', 'D'
);
INSERT INTO ad_message
(ad_message_id, ad_client_id, ad_org_id, isactive, created,
createdby, updated, updatedby, VALUE, msgtext,
msgtype, entitytype
)
VALUES (50004, 0, 0, 'Y', SYSDATE,
0, SYSDATE, 0, 'OpenWindowMaximized', 'Open Window Maximized',
'I', 'D'
);
UPDATE ad_sequence
SET currentnextsys = 50005
WHERE NAME = 'AD_Message';
COMMIT ;

View File

@ -297,6 +297,11 @@ public final class AEnv
if (ADialog.ask(WindowNo, c, "ExitApplication?"))
Env.exitEnv(0);
}
else if (actionCommand.equals("Logout"))
{
AMenu aMenu = (AMenu)Env.getWindow(WindowNo);
aMenu.logout();
}
// View Menu ------------------------
else if (actionCommand.equals("InfoProduct"))
@ -373,9 +378,10 @@ public final class AEnv
}
else if (actionCommand.equals("Preference"))
{
if (role.isShowPreference())
if (role.isShowPreference()) {
AEnv.showCenterScreen(new Preference (Env.getFrame(c), WindowNo));
}
}
// Help Menu ------------------------
else if (actionCommand.equals("Online"))
@ -552,6 +558,24 @@ public final class AEnv
Env.exitEnv(status);
} // exit
public static void logout()
{
if (s_server != null)
{
try
{
s_server.remove();
}
catch (Exception ex)
{
}
}
Env.logout();
//reload
new AMenu();
}
/**
* Is Workflow Process view enabled.
* @return true if enabled
@ -606,8 +630,14 @@ public final class AEnv
}
//
AWindow frame = new AWindow();
((AMenu)Env.getWindow(0)).getWindowManager().add(frame);
if (!frame.initWindow(s_workflow_Window_ID, query))
return;
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) {
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.toFront();
} else
AEnv.showCenterScreen(frame);
frame = null;
} // startWorkflowProcess

View File

@ -134,6 +134,8 @@ public final class AMenu extends CFrame
/** Logger */
private static CLogger log = CLogger.getCLogger(AMenu.class);
private WindowManager windowManager = new WindowManager();
/**************************************************************************
* Init System.
@ -312,6 +314,7 @@ public final class AMenu extends CFrame
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, KeyEvent.SHIFT_MASK), mFile, this);
mFile.addSeparator();
AEnv.addMenuItem("Logout", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.SHIFT_MASK+Event.ALT_MASK), mFile, this);
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK+Event.ALT_MASK), mFile, this);
// View
@ -346,6 +349,10 @@ public final class AMenu extends CFrame
AEnv.addMenuItem("Preference", null, null, mTools, this);
}
//Window Menu
JMenu mWindow = new WindowMenu(windowManager, this);
menuBar.add(mWindow);
// Help
JMenu mHelp = AEnv.getMenu("Help");
menuBar.add(mHelp);
@ -368,6 +375,14 @@ public final class AMenu extends CFrame
AEnv.exit(0);
} // dispose
public void logout()
{
windowManager.close();
Ini.saveProperties(true);
super.dispose();
AEnv.logout();
}
/**
* Window Events - requestFocus
* @param e event
@ -593,6 +608,9 @@ public final class AMenu extends CFrame
wfActivity.display();
} // stateChanged
public WindowManager getWindowManager() {
return windowManager;
}
/**************************************************************************
* Mouse Listener

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.compiere.apps;
import java.awt.Frame;
import java.awt.event.*;
import java.sql.*;
import java.util.logging.*;
@ -205,11 +206,22 @@ public class AMenuStartItem extends Thread implements ActionListener
*/
private void startWindow(int AD_Workbench_ID, int AD_Window_ID)
{
if (Env.showWindow(AD_Window_ID))
AWindow frame = (AWindow)Env.showWindow(AD_Window_ID);
if (frame != null) {
m_menu.getWindowManager().add(frame);
return;
}
if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) {
frame = m_menu.getWindowManager().find(AD_Window_ID);
if ( frame != null ) {
frame.toFront();
return;
}
}
SwingUtilities.invokeLater(m_updatePB); // 1
AWindow frame = new AWindow();
frame = new AWindow();
boolean OK = false;
if (AD_Workbench_ID != 0)
OK = frame.initWorkbench(AD_Workbench_ID);
@ -219,11 +231,20 @@ public class AMenuStartItem extends Thread implements ActionListener
return;
SwingUtilities.invokeLater(m_updatePB); // 2
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) )
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
else
frame.pack();
// Center the window
SwingUtilities.invokeLater(m_updatePB); // 3
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) )
frame.setVisible(true);
else
AEnv.showCenterScreen(frame);
frame.toFront();
m_menu.getWindowManager().add(frame);
// if (wfPanel.isVisible())
// m_WF_Window = frame; // maintain one reference
frame = null;
@ -246,6 +267,7 @@ public class AMenuStartItem extends Thread implements ActionListener
if (!pd.init())
return;
m_timer.start();
m_menu.getWindowManager().add(pd);
SwingUtilities.invokeLater(m_updatePB); // 2
pd.pack();
@ -282,7 +304,7 @@ public class AMenuStartItem extends Thread implements ActionListener
return;
SwingUtilities.invokeLater(m_updatePB); // 2
new ATask(m_name, task);
m_menu.getWindowManager().add(new ATask(m_name, task));
// ATask.start(m_name, task);
} // startTask
@ -292,13 +314,26 @@ public class AMenuStartItem extends Thread implements ActionListener
*/
private void startForm (int AD_Form_ID)
{
FormFrame ff = new FormFrame();
FormFrame ff = null;
if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) {
ff = m_menu.getWindowManager().findForm(AD_Form_ID);
if ( ff != null ) {
ff.toFront();
return;
}
}
ff = new FormFrame();
m_menu.getWindowManager().add(ff);
SwingUtilities.invokeLater(m_updatePB); // 1
ff.openForm(AD_Form_ID);
SwingUtilities.invokeLater(m_updatePB); // 2
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) == false)
ff.pack();
// Center the window
SwingUtilities.invokeLater(m_updatePB); // 3
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) )
ff.setExtendedState(Frame.MAXIMIZED_BOTH);
else
AEnv.showCenterScreen(ff);
} // startForm

View File

@ -52,9 +52,11 @@ public final class APanel extends CPanel
* Constructs a new instance.
* Need to call initPanel for dynamic initialization
*/
public APanel()
public APanel(AWindow window)
{
super();
m_window = window;
m_ctx = Env.getCtx();
//
try
@ -71,6 +73,8 @@ public final class APanel extends CPanel
/** Logger */
private static CLogger log = CLogger.getCLogger(APanel.class);
private AWindow m_window;
/**
* Dispose
*/
@ -144,6 +148,8 @@ public final class APanel extends CPanel
this.add(northPanel, BorderLayout.NORTH);
northPanel.setLayout(northLayout);
northLayout.setAlignment(FlowLayout.LEFT);
toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
//toolBar.setBorderPainted(false);
northPanel.add(toolBar, null);
} // jbInit
@ -248,6 +254,12 @@ public final class APanel extends CPanel
mTools.addSeparator();
aPreference = addAction("Preference", mTools, null, false);
}
//Window
AMenu aMenu = (AMenu)Env.getWindow(0);
JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), m_window);
menuBar.add(mWindow);
// Help
JMenu mHelp = AEnv.getMenu("Help");
menuBar.add(mHelp);

View File

@ -49,7 +49,8 @@ public class AWindow extends CFrame
/** The GlassPane */
private AGlassPane m_glassPane = new AGlassPane();
/** Application Window */
private APanel m_APanel = new APanel();
private APanel m_APanel = new APanel(this);
/** Logger */
private static CLogger log = CLogger.getCLogger(AWindow.class);

View File

@ -83,6 +83,9 @@ public final class Preference extends CDialog
private CCheckBox autoCommit = new CCheckBox();
private CCheckBox autoNew = new CCheckBox();
private CCheckBox printPreview = new CCheckBox();
private CCheckBox validateConnectionOnStartup = new CCheckBox();
private CCheckBox singleInstancePerWindow = new CCheckBox();
private CCheckBox openWindowMaximized = new CCheckBox();
private CPanel southPanel = new CPanel();
private BorderLayout southLayout = new BorderLayout();
private BorderLayout icontextLayout = new BorderLayout();
@ -161,6 +164,12 @@ public final class Preference extends CDialog
adempiereSys.setToolTipText(Msg.getMsg(Env.getCtx(), "AdempiereSys", false));
printPreview.setText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", true));
printPreview.setToolTipText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", false));
validateConnectionOnStartup.setText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", true));
validateConnectionOnStartup.setToolTipText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", false));
singleInstancePerWindow.setText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", true));
singleInstancePerWindow.setToolTipText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", false));
openWindowMaximized.setText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", true));
openWindowMaximized.setToolTipText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", false));
autoLogin.setText(Msg.getMsg(Env.getCtx(), "AutoLogin", true));
autoLogin.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoLogin", false));
storePassword.setText(Msg.getMsg(Env.getCtx(), "StorePassword", true));
@ -236,6 +245,12 @@ public final class Preference extends CDialog
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(printPreview, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(validateConnectionOnStartup, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(singleInstancePerWindow, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(openWindowMaximized, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
// Info
// tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
@ -393,6 +408,15 @@ public final class Preference extends CDialog
// Print Preview
printPreview.setSelected(Ini.isPropertyBool(Ini.P_PRINTPREVIEW));
// Validate Connection on Startup
validateConnectionOnStartup.setSelected(Ini.isPropertyBool(Ini.P_VALIDATE_CONNECTION_ON_STARTUP));
// Single Instance per Window
singleInstancePerWindow.setSelected(Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW));
// Open Window Maximized
openWindowMaximized.setSelected(Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED));
// TraceLevel
traceLevel.setSelectedItem(CLogMgt.getLevel());
traceFile.setSelected(Ini.isPropertyBool(Ini.P_TRACEFILE));
@ -460,6 +484,12 @@ public final class Preference extends CDialog
// Print Preview
Ini.setProperty(Ini.P_PRINTPREVIEW, (printPreview.isSelected()));
// Validate Connection on Startup
Ini.setProperty(Ini.P_VALIDATE_CONNECTION_ON_STARTUP, (validateConnectionOnStartup.isSelected()));
// Single Instance per Window
Ini.setProperty(Ini.P_SINGLE_INSTANCE_PER_WINDOW, (singleInstancePerWindow.isSelected()));
// Open Window Maximized
Ini.setProperty(Ini.P_OPEN_WINDOW_MAXIMIZED, (openWindowMaximized.isSelected()));
// TraceLevel/File
Level level = (Level)traceLevel.getSelectedItem();
CLogMgt.setLevel(level);

View File

@ -0,0 +1,185 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.apps;
import java.awt.Component;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.List;
import org.compiere.apps.form.FormFrame;
import org.compiere.swing.CFrame;
/**
* Managed a list of window.
* @author Low Heng Sin
* @version 2006/11/20
*/
public class WindowManager {
public WindowManager() {}
private List<CFrame> windows = new ArrayList<CFrame>();
private WindowEventListener eventListener = new WindowEventListener(this);
/**
* Add window
* @param window
*/
public void add(CFrame window) {
windows.add(window);
window.addComponentListener(eventListener);
window.addWindowListener(eventListener);
}
/**
* Close all windows managed by this window manager.
*/
public void close() {
for ( CFrame w : windows ) {
w.removeComponentListener(eventListener);
w.removeWindowListener(eventListener);
w.dispose();
}
windows = new ArrayList<CFrame>();
}
/**
* Close all except one window.
* @param window
*/
public void closeOthers(CFrame window) {
for ( CFrame w : windows ) {
w.removeComponentListener(eventListener);
w.removeWindowListener(eventListener);
if ( !w.equals(window)) {
w.dispose();
}
}
windows = new ArrayList<CFrame>();
add(window);
}
/**
* Remove window
* @param window
*/
public void remove(CFrame window) {
if ( windows.remove(window) ) {
window.removeComponentListener(eventListener);
window.removeWindowListener(eventListener);
}
}
/**
* Get list of windows managed by this window manager
* @return Array of windows
*/
public CFrame[] getWindows() {
CFrame[] a = new CFrame[windows.size()];
return windows.toArray(a);
}
/**
* @return Number of windows managed by this window manager
*/
public int getWindowCount() {
return windows.size();
}
/**
* Find window by ID
* @param AD_Window_ID
* @return AWindow reference, null if not found
*/
public AWindow find(int AD_Window_ID) {
for ( CFrame w : windows ) {
if ( w instanceof AWindow ) {
AWindow a = (AWindow)w;
if ( a.getAD_Window_ID() == AD_Window_ID )
return a;
}
}
return null;
}
public FormFrame findForm(int AD_FORM_ID) {
for ( CFrame w : windows ) {
if ( w instanceof FormFrame ) {
FormFrame ff = (FormFrame)w;
if ( ff.getAD_Form_ID() == AD_FORM_ID )
return ff;
}
}
return null;
}
}
class WindowEventListener implements ComponentListener, WindowListener {
WindowManager windowManager;
protected WindowEventListener(WindowManager windowManager) {
this.windowManager = windowManager;
}
public void componentHidden(ComponentEvent e) {
Component c = e.getComponent();
if ( c instanceof CFrame ) {
c.removeComponentListener(this);
((CFrame)c).removeWindowListener(this);
windowManager.remove((CFrame)c);
}
}
public void componentMoved(ComponentEvent e) {
}
public void componentResized(ComponentEvent e) {
}
public void componentShown(ComponentEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
Window w = e.getWindow();
if ( w instanceof CFrame ) {
w.removeComponentListener(this);
w.removeWindowListener(this);
windowManager.remove((CFrame)w);
}
}
public void windowClosing(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
}

View File

@ -0,0 +1,155 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.apps;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import org.compiere.swing.CFrame;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Menu component that handles the functionality expected of a standard
* "Windows" menu for MDI or MDI-like applications.
*
* @author Low Heng Sin
* @version 2006/11/20
*/
public class WindowMenu extends JMenu {
private WindowManager windowManager;
private JFrame frame;
private JMenuItem closeAll=new JMenuItem("Close All Windows");
private JMenuItem closeOthers = new JMenuItem("Close Other Windows");
private void setEnvText(JMenu menu, String msg) {
String text = Msg.getMsg(Env.getCtx(), msg);
int pos = text.indexOf("&");
if (pos != -1 && text.length() > pos) // We have a nemonic
{
char ch = text.toUpperCase().charAt(pos+1);
if (ch != ' ')
{
text = text.substring(0, pos) + text.substring(pos+1);
menu.setMnemonic(ch);
}
}
menu.setText(text);
}
private void setEnvText(JMenuItem menu, String msg) {
String text = Msg.getMsg(Env.getCtx(), msg);
int pos = text.indexOf("&");
if (pos != -1 && text.length() > pos) // We have a nemonic
{
char ch = text.toUpperCase().charAt(pos+1);
if (ch != ' ')
{
text = text.substring(0, pos) + text.substring(pos+1);
menu.setMnemonic(ch);
}
}
menu.setText(text);
}
public WindowMenu(WindowManager windowManager, JFrame frame) {
this.windowManager = windowManager;
this.frame = frame;
setEnvText(this, "Window");
closeAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
WindowMenu.this.windowManager.close();
}
});
setEnvText(closeAll, "CloseAllWindows");
closeOthers.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
WindowMenu.this.windowManager.closeOthers((AWindow)WindowMenu.this.frame);
}
});
setEnvText(closeOthers, "CloseOtherWindows");
addMenuListener(new MenuListener() {
public void menuCanceled (MenuEvent e) {}
public void menuDeselected (MenuEvent e) {
removeAll();
}
public void menuSelected (MenuEvent e) {
buildChildMenus();
}
});
}
/* Sets up the children menus depending on the current desktop state */
private void buildChildMenus() {
this.removeAll();
int i;
ChildMenuItem menu;
CFrame[] array = windowManager.getWindows();
if ( !(frame instanceof AMenu) )
add(closeOthers);
add(closeAll);
if (array.length > 0) {
closeAll.setEnabled(true);
if ( array.length > 1 )
closeOthers.setEnabled(true);
else
closeOthers.setEnabled(false);
addSeparator();
} else {
closeAll.setEnabled(false);
closeOthers.setEnabled(false);
}
for (i = 0; i < array.length; i++) {
menu = new ChildMenuItem(array[i]);
menu.setState(array[i].equals(frame));
menu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
CFrame frame = ((ChildMenuItem)ae.getSource()).getWindow();
frame.toFront();
}
});
//menu.setIcon(array[i].getIconImage());
add(menu);
}
}
/* This JCheckBoxMenuItem descendant is used to track the child frame that corresponds
to a give menu. */
class ChildMenuItem extends JCheckBoxMenuItem {
private CFrame window;
public ChildMenuItem(CFrame window) {
super(window.getTitle());
this.window=window;
}
public CFrame getWindow() {
return window;
}
}
}

View File

@ -82,6 +82,9 @@ public class FormFrame extends CFrame
/** Logger */
private static CLogger log = CLogger.getCLogger(FormFrame.class);
/** Form ID */
private int p_AD_Form_ID = 0;
/**
* Static Init
* @throws Exception
@ -233,6 +236,7 @@ public class FormFrame extends CFrame
}
//
m_panel.init(m_WindowNo, this);
p_AD_Form_ID = AD_Form_ID;
return true;
} // openForm
@ -354,4 +358,12 @@ public class FormFrame extends CFrame
return worker;
} // startBatch
/**
* @return Returns the AD_Form_ID.
*/
public int getAD_Form_ID ()
{
return p_AD_Form_ID;
} // getAD_Window_ID
} // FormFrame

View File

@ -60,6 +60,20 @@ public final class Env
System.exit (status);
} // close
/**
* Logout from the system
*/
public static void logout()
{
// End Session
MSession session = MSession.get(Env.getCtx(), false); // finish
if (session != null)
session.logout();
//
reset(true); // final cache reset
//
}
/**
* Reset Cache
* @param finalCall everything otherwise login data remains
@ -1345,8 +1359,15 @@ public final class Env
window.setVisible(false);
s_log.info(window.toString());
// window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED));
if (s_hiddenWindows.size() > 10)
s_hiddenWindows.remove(0); // sort of lru
if (s_hiddenWindows.size() > 10) {
CFrame toClose = s_hiddenWindows.remove(0); // sort of lru
try {
s_closingWindows = true;
toClose.dispose();
} finally {
s_closingWindows = false;
}
}
return true;
}
}
@ -1358,7 +1379,7 @@ public final class Env
* @param AD_Window_ID window
* @return true if window re-displayed
*/
static public boolean showWindow (int AD_Window_ID)
static public CFrame showWindow (int AD_Window_ID)
{
for (int i = 0; i < s_hiddenWindows.size(); i++)
{
@ -1369,10 +1390,10 @@ public final class Env
s_log.info(hidden.toString());
hidden.setVisible(true);
hidden.toFront();
return true;
return hidden;
}
}
return false;
return null;
} // showWindow
/**

View File

@ -126,6 +126,17 @@ public final class Ini implements Serializable
/** Print Preview */
public static final String P_PRINTPREVIEW = "PrintPreview";
private static final boolean DEFAULT_PRINTPREVIEW = false;
/** Validate connection on startup */
public static final String P_VALIDATE_CONNECTION_ON_STARTUP = "ValidateConnectionOnStartup";
private static final boolean DEFAULT_VALIDATE_CONNECTION_ON_STARTUP = false;
/** Single instance per window id **/
public static final String P_SINGLE_INSTANCE_PER_WINDOW = "SingleInstancePerWindow";
public static final boolean DEFAULT_SINGLE_INSTANCE_PER_WINDOW = false;
/** Open new windows as maximized **/
public static final String P_OPEN_WINDOW_MAXIMIZED = "OpenWindowMaximized";
public static final boolean DEFAULT_OPEN_WINDOW_MAXIMIZED = false;
//
private static final String P_WARNING = "Warning";
private static final String DEFAULT_WARNING = "Do_not_change_any_of_the_data_as_they_will_have_undocumented_side_effects.";
@ -144,6 +155,9 @@ public final class Ini implements Serializable
P_CONTEXT, P_TEMP_DIR,
P_ROLE, P_CLIENT, P_ORG, P_PRINTER, P_WAREHOUSE, P_TODAY,
P_PRINTPREVIEW,
P_VALIDATE_CONNECTION_ON_STARTUP,
P_SINGLE_INSTANCE_PER_WINDOW,
P_OPEN_WINDOW_MAXIMIZED,
P_WARNING, P_WARNING_de
};
/** Ini Property Values */
@ -158,6 +172,9 @@ public final class Ini implements Serializable
DEFAULT_CONTEXT, DEFAULT_TEMP_DIR,
DEFAULT_ROLE, DEFAULT_CLIENT, DEFAULT_ORG, DEFAULT_PRINTER, DEFAULT_WAREHOUSE, DEFAULT_TODAY.toString(),
DEFAULT_PRINTPREVIEW?"Y":"N",
DEFAULT_VALIDATE_CONNECTION_ON_STARTUP?"Y":"N",
DEFAULT_SINGLE_INSTANCE_PER_WINDOW?"Y":"N",
DEFAULT_OPEN_WINDOW_MAXIMIZED?"Y":"N",
DEFAULT_WARNING, DEFAULT_WARNING_de
};