📄 applicationwindow.java
字号:
AccessController.getInstance().login("username", "password");
}
/**
* Disconnects the current user from the present connection.
* It returns the ApplicationWindow state into the log-off state.
*/
public void disconnect() {
//System.out.println("Disconnect");
if (m_ManagementWindow != null) {
closeManagementWindow();
m_ManagementWindow.dispose();
m_ManagementWindow = null;
}
if (closeAllCase())
AccessController.getInstance().logoff();
CaseInfoListHandler.getInstance().clearList();
}
/**
* @see java.awt.Window#processWindowEvent(WindowEvent)
*/
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING)
windowClosing();
else if (e.getID() == WindowEvent.WINDOW_OPENED)
try {
windowOpened();
} catch (SysException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
else
super.processWindowEvent(e);
}
/**
* It is called when ApplicationWindow is newly opened.
* @throws SysException
*/
private void windowOpened() throws SysException {
connect();
//<<18/02/2005 Mark Li: modify the initial case list window
showCaseList();
//18/02/2005 Mark Li: modify the initial case list window>>
}
//<<18/02/2005 Mark Li: modify the initial case list window
/**
* It is call the Case List panel after connect to the database
* @throws SysException
*/
private void showCaseList() throws SysException {
m_ManagementWindow = new ManagementWindow(this);
m_ManagementWindow.setLocation(10, 10);
//m_ManagementWindow.setSize(400, 300);
m_ContentApplicationWindow.add(m_ManagementWindow);
m_ManagementWindow.setVisible(true);
try {
m_ManagementWindow.setMaximum(true);
m_ManagementWindow.setSelected(true);
// <<23/03/2005 Mark Li: Set flag to show Search Window
if(enableSerachResultPanel){
m_ManagementWindow.displayCaseList();
}
// 23/03/2005 Mark Li: Set flag to show Search Window>>
} catch (java.beans.PropertyVetoException pe) {
}
}
//18/02/2005 Mark Li: modify the initial case list window>>
/**
* It is called when ApplicationWindow is closing.
*/
private void windowClosing() {
if (closeAllCase()) {
Resource.close();
SysConfig.exit();
this.dispose();
System.exit(0);
}
}
/**
* Creates UI of ApplicationWindow.
* @throws SysException
*/
private void createApplicationWindow() throws SysException {
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// Toolkit.getDefaultToolkit().getScreenSize();
// <<10/08/2005 Kenneth Lai: Modified to prevent panel from being behind start menu bar
setSize(new Dimension(800, 600));
//setSize(Toolkit.getDefaultToolkit().getScreenSize());
// 10/08/2005 Kenneth Lai: Modified to prevent panel from being behind start menu bar>>
// <<10/08/2005 Kenneth Lai: Added to set default extended
setExtendedState(MAXIMIZED_BOTH);
// 10/08/2005 Kenneth Lai: Added to set default extended>>
// <<11/08/2005 Kenneth Lai: Added for hidden iconified frame problem
addWindowStateListener(this);
// 11/08/2005 Kenneth Lai: Added for hidden iconified frame problem>>
setTitle(Resource.srcStr("AlphaMiner"));
m_MenuBarHandler = new MainMenuBarHandler(this);
m_ContentPaneApplicationWindow = (JPanel) getContentPane();
// m_PanelContent = new JPanel();
m_PanelContent = new JHelpPanel(); //<<27/07/2005 Kenneth Lai: Modify for JHelp>>
m_PanelContent.setLayout(new BorderLayout());
m_ToolBarHandler = new ToolBarHandler(this);
m_ContentApplicationWindow = new JHelpDesktopPane();
m_ApplicationWindowDesktopManager = new ApplicationWindowDesktopManager();
m_ContentApplicationWindow.setDesktopManager(m_ApplicationWindowDesktopManager);
m_ContentApplicationWindow.addMouseListener(this);
m_StatusBarApplicationWindow = new JHelpPanel();
m_StatusBarMessage = new JLabel();
// Window Content Pane
m_ContentPaneApplicationWindow.setLayout(new BorderLayout());
m_ContentPaneApplicationWindow.add(m_PanelContent, BorderLayout.CENTER);
m_ContentPaneApplicationWindow.add(
m_StatusBarApplicationWindow,
BorderLayout.SOUTH);
// Panel Content
m_PanelContent.add(m_ToolBarHandler.getToolBar(), BorderLayout.NORTH);
m_PanelContent.add(m_ContentApplicationWindow, BorderLayout.CENTER);
// Desktop Pane
m_ContentApplicationWindow.setBackground(new Color(212, 208, 200));
m_ContentApplicationWindow.setBorder(
BorderFactory.createBevelBorder(
BevelBorder.LOWERED,
Color.white,
Color.white,
new Color(103, 98, 98),
new Color(148, 141, 140)));
//<<01/02/2005, Mark
// backgroundLabel = new JLabel(new ImageIcon(backgroundImage));
// backgroundLabel.setSize(Toolkit.getDefaultToolkit().getScreenSize());
// m_ContentApplicationWindow.add(backgroundLabel,
// JLayeredPane.FRAME_CONTENT_LAYER);
//01/02/2005, Mark>>
// StatusBar Panel
m_StatusBarApplicationWindow.setBorder(
BorderFactory.createBevelBorder(
BevelBorder.LOWERED,
Color.white,
Color.white,
new Color(103, 101, 98),
new Color(148, 145, 140)));
m_StatusBarApplicationWindow.setMinimumSize(new Dimension(6, 19));
m_StatusBarApplicationWindow.setPreferredSize(new Dimension(6, 19));
FlowLayout statusBarLayout = new FlowLayout(FlowLayout.LEFT, 1, 1);
m_StatusBarApplicationWindow.setLayout(statusBarLayout);
m_StatusBarApplicationWindow.add(m_StatusBarMessage, null);
// StatusBar Font Style
m_StatusBarMessage.setFont(new java.awt.Font("SansSerif", 0, 9));
m_StatusBarMessage.setAlignmentX((float) 0.0);
m_StatusBarMessage.setAlignmentY((float) 0.0);
m_StatusBarMessage.setVerticalAlignment(SwingConstants.BOTTOM);
m_StatusBarMessage.setVerticalTextPosition(SwingConstants.BOTTOM);
//System monitor
//<<11/08/2006 Xiaojun Chen Add for System monitor
// //<<18/02/2005 Mark Li: modify the initial case list window
//// //<<02/02/2005 Mark Li: Show the search window at initial status
//// showManagementWindow(true);
//// //02/02/2005 Mark Li>>
// //18/02/2005 Mark Li: modify the initial case list window>>
// <<19/07/05: Mark Li: Add for JHelp
// AlphaminerHelpHandler HelpHandler = new AlphaminerHelpHandler();
// HelpHandler.setHelpKey(m_ContentPaneApplicationWindow,"AlphaMinerHelp");
//19/07/05: Mark Li: Add for JHelp>>
//7/11/2006 Xiaojun Chen Add for Workspace Manager
WorkspacesManager.setContainer(this);
LocalesManager.setContainer(this);
}
public synchronized boolean switchWorkspaces(){
m_ManagementWindow.dispose();
try {
showCaseList();
return true;
} catch (SysException e) {
e.printStackTrace();
return false;
}
}
/**
* 2006/8/01
* @author Xiaojun Chen
* update the case with the current workspace
* @return 'true' if updating succeed, else 'false'
* */
public synchronized boolean updateWorkspaces(){
m_MenuBarHandler.updateWorkspaces();
return true;
}
/**
* 2006/09/05
* @author Xiaojun Chen
* update the Locale menu
* @return 'true' if updating succeed, else 'false'
* */
public synchronized boolean updateLocales(){
m_MenuBarHandler.updateLocales();
return true;
}
/**
* @return Returns the m_NewCase.
*/
public int getNewCaseIndex() {
return m_NewCase;
}
/**
* @see java.awt.event.MouseListener#mouseEntered(MouseEvent)
*/
public void mouseEntered(MouseEvent e) {
}
/**
* @see java.awt.event.MouseListener#mouseExited(MouseEvent)
*/
public void mouseExited(MouseEvent e) {
}
/**
* @see java.awt.event.MouseListener#mousePressed(MouseEvent)
*/
public void mousePressed(MouseEvent e) {
// <<25/07/2005 Kenneth Lai: Add for JHelp
if ( isHelpMode() ) {
setHelpMode(false);
HelpObserveSubject.sendNotify(false);
}
// 25/07/2005 Kenneth Lai: Add for JHelp>>
}
/**
* @see java.awt.event.MouseListener#mouseReleased(MouseEvent)
*/
public void mouseReleased(MouseEvent e) {
}
/**
* @see java.awt.event.MouseListener#mouseClicked(MouseEvent)
*/
public void mouseClicked(MouseEvent e) {
}
// <<22/07/2005 Kenneth Lai: Added for JHelp
public void Update(boolean a_HelpState) {
setHelpMode(a_HelpState);
}
private void setHelpMode(boolean a_HelpState) {
HelpCursor helpCursor = new HelpCursor();
m_HelpState = a_HelpState;
if ( a_HelpState )
setCursor(helpCursor.getCursor());
else
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
private boolean isHelpMode() {
return m_HelpState;
}
//22/07/2005 Kenneth Lai: Added for JHelp>>
// <<11/08/2005 Kenneth Lai: Added for hidden frame/iconified frame problem
public void windowStateChanged(WindowEvent e) {
if ( e.getNewState() == NORMAL ) {
validate(); // update the m_ContentApplicationWindow dimension
int windowWidth = m_ContentApplicationWindow.getSize().width;
int windowHeight = m_ContentApplicationWindow.getSize().height;
//check all internal frames if they need repositioning or not
Component [] components = m_ContentApplicationWindow.getComponents();
for (int i=0; i<components.length; i++) {
if ( components[i] instanceof JInternalFrame ) {
JInternalFrame frame = (JInternalFrame)components[i];
int frameX = (int)frame.getLocation().getX();
int frameY = (int)frame.getLocation().getY();
int frameWidth = frame.getWidth();
int frameHeight = frame.getHeight();
if ( frameX + frameWidth > windowWidth &&
frameY + frameHeight <= windowHeight )
frame.setLocation(windowWidth - frameWidth, frameY);
else if ( frameY + frameHeight > windowHeight &&
frameX + frameWidth <= windowWidth)
frame.setLocation(frameX, windowHeight - frameHeight);
else if ( frameY + frameHeight > windowHeight &&
frameX + frameWidth > windowWidth )
frame.setLocation(windowWidth - frameWidth,
windowHeight - frameHeight);
}
// check all iconfied frames if they need repositioning or not
else {
JDesktopIcon icon = (JDesktopIcon)components[i];
int iconX = (int)icon.getLocation().getX();
int iconY = (int)icon.getLocation().getY();
int iconWidth = icon.getWidth();
int iconHeight = icon.getHeight();
if ( iconX + iconWidth > windowWidth &&
iconY + iconHeight <= windowHeight )
icon.setLocation(windowWidth - iconWidth, iconY);
else if ( iconY + iconHeight > windowHeight &&
iconX + iconWidth <= windowWidth)
icon.setLocation(iconX, windowHeight - iconHeight);
else if ( iconY + iconHeight > windowHeight &&
iconX + iconWidth > windowWidth )
icon.setLocation(windowWidth - iconWidth,
windowHeight - iconHeight);
}
}
}
}
// 11/08/2005 Kenneth Lai: Added for hidden frame/iconified frame problem>>
public void sendNotify(String a_Message) {
if(a_Message.equals(Resource.CHANGE_LOCALE)) {
setTitle(Resource.srcStr("AlphaMiner"));
//Menu
m_MenuBarHandler.resetLocale();
//Toolbar
m_ToolBarHandler.resetLocale();
//ManagementWindow
m_ManagementWindow.resetLocale();
//SearchingCriteria
if(m_SearchingCriteria!=null){
m_SearchingCriteria.resetLocale();
}
CaseWindow casewindow = null;
for(int i=0;i<CaseWindowList.size();i++){
casewindow = CaseWindowList.get(i);
casewindow.sendNotify(a_Message);
}
if(getAboutDialog()!=null) {
getAboutDialog().sendNotify(a_Message);
}
}
}
public void sendNotify(int a_Message) {
}
public void sendNotify(int a_Message, Object a_Object) {
}
public void registerInterest(Observer a_Observer) {
if(a_Observer==null){
return;
}
observers.add(a_Observer);
}
public void removeInterest(Observer a_Observer) {
observers.remove(a_Observer);
}
private void sendNotifytoObserver(String aNotitfy) {
Iterator<Observer> i = observers.iterator();
while(i.hasNext()) {
i.next().sendNotify(aNotitfy);
}
}
}
/**
* ApplicationWindowDesktopManager is a class which manages the arrangement of
* internal frames on the desktop pane of ApplicationWindow.
*/
class ApplicationWindowDesktopManager extends DefaultDesktopManager {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* @see javax.swing.DesktopManager#dragFrame(JComponent, int, int)
*/
public void dragFrame(JComponent f, int x, int y) {
if (f instanceof JInternalFrame) {
JInternalFrame frame = (JInternalFrame) f;
JDesktopPane desk = frame.getDesktopPane();
Dimension d = desk.getSize();
if (x < 0)
x = 0;
else if (x + frame.getWidth() > d.width)
x = d.width - frame.getWidth();
if (y < 0)
y = 0;
else if (y + frame.getHeight() > d.height)
y = d.height - frame.getHeight();
}
// <<01/08/2005 Kenneth Lai: Added for moving iconified frame within
// the desktop pane
else if (f instanceof JDesktopIcon) {
JDesktopIcon icon = (JDesktopIcon) f;
JDesktopPane desk = icon.getDesktopPane();
Dimension d = desk.getSize();
if (x < 0)
x = 0;
else if (x + icon.getWidth() > d.width)
x = d.width - icon.getWidth();
if (y < 0)
y = 0;
else if (y + icon.getHeight() > d.height)
y = d.height - icon.getHeight();
}
// 01/08/2005 Kenneth Lai: Added for moving iconified frame within
// the desktop pane>>
super.dragFrame(f, x, y);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -