⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managementwindow.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package eti.bi.alphaminer.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.beans.PropertyVetoException;

import javax.swing.JInternalFrame;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import eti.bi.exception.SysException;
import eti.bi.util.ResourceLoader;
import eti.bi.common.ImageLocation;
import eti.bi.common.Locale.Resource;
/**
 * ManagementWindow is a class of the management window user interface (UI).
 */
public class ManagementWindow extends JInternalFrame implements 
	ChangeListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JSplitPane m_SplitPaneManagement;
	private CaseInformationPanel m_PanelCaseDetail;
	private JTabbedPane m_TabbedPaneManagement;
	private CaseListPanel m_PanelCaseList;
	private SearchResultPanel m_PanelSearchResult;
	@SuppressWarnings("unused")
	private boolean m_HelpState; //<26/07/2005 Kenneth Lai: Add for JHelp>>
	
	/**
	 * ApplicationWindow containing this ManagementWindow instance.
	 */
	private ApplicationWindow m_ParentFrame;

	/**
	 * Constructs a ManagementWindow instance.
	 * @throws SysException
	 */
	public ManagementWindow(ApplicationWindow a_Frame) throws SysException {
		m_ParentFrame = a_Frame;
		createUI();
	}
	
	/**
	 * Close the ManagementWindow UI.
	 */
	public void close() {
		this.setVisible(false);
		m_ParentFrame.setFocusToFirstWindow(this.isMaximum());
	}
		
	/**
	 * Displays detail of a case in the case information panel.
	 * @param a_CaseID case ID of the case information to be displayed.
	 * @param a_IsSearched true if the case information to be displayed 
	 * is contained in the searched case information list; false otherwise.
	 */
	public void displayCaseDetail(String a_CaseID, boolean a_IsSearched) {
		m_PanelCaseDetail.displayCaseDetail(a_CaseID, a_IsSearched);
	}

	/**
	 * Select "Case List" tab in the UI. This tab contains a tree of case information list.
	 */
	public void displayCaseList() {
		m_TabbedPaneManagement.setSelectedComponent(m_PanelCaseList);
	}

	/**
	 * Select "Search Result" tab in the UI. This tab contains a table of searched case 
	 * information list.
	 */
	public void displaySearchResult() {
		m_TabbedPaneManagement.setSelectedComponent(m_PanelSearchResult);
	}

	/**
	 * Returns the ApplicationWindow containing the ManagementWindow instance.
	 * @return ApplicationWindow the ApplicationWindow instance which contains 
	 * the current ManagementWindow instance.
	 */
	public ApplicationWindow getApplicationWindow() {
		return m_ParentFrame;
	}

	/**
	 * Returns the case information panel of the ManagementWindow instance.
	 * @return CaseInformationPanel the CaseInformationPanel of the current 
	 * ManagementWindow instance.
	 */
	public CaseInformationPanel getCaseInformationPanel() {
		return m_PanelCaseDetail;
	}	
	
	//<<21/03/2005 Mark Li: Add to return the Case List window
	public CaseListPanel getCaseListPanel(){
		return m_PanelCaseList;
	}
	//	21/03/2005 Mark Li: Add to return the Case List window>>
	/**
	 * @see javax.swing.event.ChangeListener#stateChanged(ChangeEvent)
	 */
	public void stateChanged(ChangeEvent e) {
		Component comp = ((JTabbedPane) e.getSource()).getSelectedComponent();
		
		/*  "Case List" tab is selected */
		if (comp == m_PanelCaseList) {
			TreePath path =
				m_PanelCaseList.getCaseListTree().getSelectionPath();
			if (path != null
				&& ((DefaultMutableTreeNode) path.getLastPathComponent())
					.isLeaf())
				m_PanelCaseList.getCaseListTree().valueChanged(
					new TreeSelectionEvent(
						m_PanelCaseList.getCaseListTree(),
						path,
						true,
						path,
						path));						
		}
		/* "Search Result" tab is selected */
		else if (comp == m_PanelSearchResult) {
			int selectedRow =
				m_PanelSearchResult.getSearchResultTable().getSelectedRow();
			if (selectedRow != -1)
				m_PanelSearchResult.getSearchResultTable().valueChanged(
					new ListSelectionEvent(
						m_PanelSearchResult.getSearchResultTable(),
						selectedRow,
						selectedRow,
						true));
		}
	}

	/**
	 * Create the UI of ManagementWindow.
	 * @throws SysException
	 */
	private void createUI() throws SysException {

		/* Initialize swing UI components */
		m_SplitPaneManagement = new JSplitPane();
		m_PanelCaseDetail = new CaseInformationPanel(this);
		m_TabbedPaneManagement = new JTabbedPane();
		m_PanelCaseList = new CaseListPanel(this);
		m_PanelSearchResult = new SearchResultPanel(this);

		/* Set JInternalFrame properties of ManagementWindow */
		this.setClosable(true);
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		this.setFrameIcon(ResourceLoader.getImageIcon(ImageLocation.MGT_WINDOW));
		this.setIconifiable(true);
		this.setJMenuBar(null);
		this.setLayer(0);
		this.setMaximizable(true);
		this.setResizable(true);
//		this.setTitle("Case Management");
		this.setPreferredSize(new Dimension(492, 1298));
		this.addInternalFrameListener(new ManagementWindowListener(this, m_ParentFrame));

		/* Add swing UI components onto ManagementWindow JInternalFrame */
		this.getContentPane().add(m_SplitPaneManagement, BorderLayout.CENTER);
		m_SplitPaneManagement.add(m_PanelCaseDetail, JSplitPane.RIGHT);
//		<<23/03/2005 Mark Li: Set flag to show Search Window
		if (m_ParentFrame.enableSerachResultPanel) {
			this.setTitle(Resource.srcStr("CaseManagementTitle"));
			m_SplitPaneManagement.add(m_TabbedPaneManagement, JSplitPane.LEFT);
			m_TabbedPaneManagement.add(m_PanelCaseList, Resource.srcStr("CaseList"));
			m_TabbedPaneManagement.add(m_PanelSearchResult, Resource.srcStr("SearchResult"));
		} else {
			this.setTitle(Resource.srcStr("CaseListTitle"));
			m_SplitPaneManagement.add(m_PanelCaseList, JSplitPane.LEFT);
		}
//		23/03/2005 Mark Li: Set flag to show Search Window>>
		
		/* Set swing UI components properties */
		m_SplitPaneManagement.setBorder(null);
		m_SplitPaneManagement.setDoubleBuffered(false);
		m_SplitPaneManagement.setResizeWeight(0);
		m_SplitPaneManagement.setDividerSize(2);
		m_SplitPaneManagement.setLastDividerLocation(205);
		m_SplitPaneManagement.setDividerLocation(205);
		
		//<<02/02/2005 Mark Li: Add to set the background color OF dETAIL Panel Case
		m_PanelCaseDetail.setBackground(Color.WHITE);
		//02/02/2005 Mark Li>>
		/* Add event listener */
		m_TabbedPaneManagement.addChangeListener(this);
	}
	
	
	//03/17/2006 Xiaojun Chen aAdd for
	/**
	 * reset language
	 */
	public synchronized void resetLocale(){
		//m_PanelCaseDetail
		m_PanelCaseDetail.sendNotify(Resource.CHANGE_LOCALE);
		//m_PanelCaseList
		m_PanelCaseList.sendNotify(Resource.CHANGE_LOCALE);
		//m_PanelSearchResult
		if (m_ParentFrame.enableSerachResultPanel) {
			setTitle(Resource.srcStr("CaseManagementTitle"));
		}
		else{
			setTitle(Resource.srcStr("CaseListTitle"));
		}
		
		m_PanelSearchResult.resetLocale();
		m_TabbedPaneManagement.removeAll();
		
		m_TabbedPaneManagement.add(m_PanelCaseList, Resource.srcStr("CaseList"));
		m_TabbedPaneManagement.add(m_PanelSearchResult, Resource.srcStr("SearchResult"));
	}
}


/**
 * ManagementWindowListener is a class of internal frame listener of the 
 * ManagementWindow class.
 */
class ManagementWindowListener extends InternalFrameAdapter {
	
	/**
	 * The ManagementWindow to be listened
	 */
	private ManagementWindow m_ManagementWindow;
	private ApplicationWindow m_Window;

	/**
	 * Constructs a ManagementWindowListener.
	 * @param a_ManagementWindow the ManagementWindow to be listened.
	 */
	public ManagementWindowListener(ManagementWindow a_ManagementWindow, ApplicationWindow a_Window) {
		m_ManagementWindow = a_ManagementWindow;
		m_Window = a_Window;
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosing(InternalFrameEvent)
	 */
	public void internalFrameClosing(InternalFrameEvent e) {
		m_ManagementWindow.close();
		
		if (m_Window.getDesktopPane().getComponentCount() == 1 ){
		// Only change the menu when there is no CaseWindow TWang.
			notifyWindow(Resource.srcStr("LoginNotifyWindow","login"));
		}
		
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(InternalFrameEvent)
	 */
	public void internalFrameIconified(InternalFrameEvent e) {
		try {
			m_ManagementWindow.setSelected(true);
		} catch (PropertyVetoException pe) {
		}
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(InternalFrameEvent)
	 */
	public void internalFrameActivated(InternalFrameEvent e) {
		CaseInformationPanel casePanel =
			m_ManagementWindow.getCaseInformationPanel();
		m_ManagementWindow.getCaseListPanel().getCaseListTree().adjustAccordToTreeFoucsChange();
		if (casePanel.isVisible()) {
			if (casePanel.getCaseID() == null)
				return;
			else
				notifyWindow(Resource.srcStr("SelectNotifyWindow","select|") + casePanel.getCaseID());
		}
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(InternalFrameEvent)
	 */
	public void internalFrameDeactivated(InternalFrameEvent e) {
		notifyWindow(Resource.srcStr("LoginNotifyWindow","login"));
	}

	/**
	 * Notifies ApplicationWindow of the ManagementWindow instance to update its menu bar and tool bar.
	 * @param a_Message the String message to be notified.
	 */
	private void notifyWindow(String a_Message) {
		if (a_Message == null)
			return;

		ApplicationWindow window = m_ManagementWindow.getApplicationWindow();
	
		(window.getMenuBarHandler()).sendNotify(a_Message);
		(window.getToolBarHandler()).sendNotify(a_Message);		
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -