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

📄 operatorresult.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.
 */

/*
 * Created on Sep 1, 2004
 *
 * $Author$
 * $Date$
 * $Revision$
 *
 */
package eti.bi.alphaminer.operation.result;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JInternalFrame;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;

import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.core.help.AlphaminerHelpHandler;
import eti.bi.alphaminer.core.observer.ObserveMessage;
import eti.bi.alphaminer.core.observer.ObserveSubject;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.ui.IMessageDialog;
import eti.bi.alphaminer.ui.ISystemMessageHandler;
import eti.bi.alphaminer.vo.IOperatorNode;
import eti.bi.exception.AppException;
import eti.bi.exception.SysException;
import eti.bi.util.ResourceLoader;
import eti.bi.common.ImageLocation;
import eti.bi.common.System.SysLog;

/**
 * @author achiu
 *
 */
public abstract class OperatorResult extends JInternalFrame
implements ObserveSubject, ChangeListener, ActionListener, InternalFrameListener {

	protected String m_FilePath;

	protected String m_CaseID;
	protected String m_NodeID;
	protected Operator m_Operator;
	protected Vector m_ParentOperatorNodes;
	protected IOperatorNode m_Node;
	
	private OperatorResultMenuBarHandler m_OperatorResultMenuBarHandler;
	private Vector<Observer> m_Observers = new Vector<Observer>();
	
	// The tabed pane contains the result views in multiple mode
	private JTabbedPane m_MultipleTabbedPane = new JTabbedPane();

	// The result view that is selected
	protected ResultView m_SelectedView;
	
	/* Flag to indicate if the operator result pane is going to be show single result or not
	 * If the result pane is in mulitple mode, a mulitple view could be added in a tabbed pane
	 * If the result pane is in single mode, only the first view would be added
	 * Default is multiple mode.  
	 */
	private boolean m_SingleMode = false;
	
	protected ICaseHandler m_CaseHandler;

	protected INodeInfo m_NodeInfo;
	
	protected IMessageDialog m_MessageDialog;
	
	protected ISystemMessageHandler m_SystemMessageHandler;
	
	// The index of the selected view
//	private int m_SelectedViewIndex = -1;
	
	public OperatorResult(String a_Title, String a_CaseID, String a_NodeID, INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws Exception 
	{
		// Default is in mutliple mode
		this(a_Title, false, a_CaseID, a_NodeID, a_NodeInfo, a_CaseHandler);
	}
	
	public OperatorResult(String a_Title, boolean a_SingleMode, String a_CaseID, String a_NodeID, INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws Exception
	{
		super(a_Title, false);
		m_CaseID = a_CaseID;
		m_NodeID = a_NodeID;
		m_CaseHandler = a_CaseHandler;
		m_NodeInfo = a_NodeInfo;
		m_MessageDialog = m_CaseHandler.getMessageDialog();
		m_SystemMessageHandler = m_CaseHandler.getSystemMessageHandler(m_CaseID);
		m_SingleMode = a_SingleMode;
		
		// A panel to hold the "Close" Button
		//JPanel buttonPanel = new JPanel();
		//JButton buttonClose = new JButton();

		m_OperatorResultMenuBarHandler = new OperatorResultMenuBarHandler(this,m_CaseHandler);
		setJMenuBar(m_OperatorResultMenuBarHandler.getMenuBar());

		if (!m_SingleMode)
		{
			// Add the tabbed pane to this.contentPane, and add the changelistener
			this.getContentPane().add(m_MultipleTabbedPane);
			m_MultipleTabbedPane.addChangeListener(this);
		}else{
			// Do nothing
		}
		//buttonClose.setSelected(false);
		//buttonClose.setText(Resource.srcStr("m_ButtonClose"));

		//buttonPanel.add(buttonClose, null);
		//this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

		//buttonClose.addActionListener(this);
		this.addInternalFrameListener(this);
		
		try {
			m_Operator = m_CaseHandler.getOperator(m_CaseID, m_NodeID);
			m_Node = m_CaseHandler.getOperatorNode(m_CaseID, m_NodeID);
			m_ParentOperatorNodes = m_CaseHandler.getParentOperatorNodes(m_CaseID, m_NodeID);
		} catch (SysException e) {
			SysLog.error(null,e);
			//Do Nothing
		}
		
		init();
		getContent();
		createResult();

		//set icon
		try {
			this.setFrameIcon(ResourceLoader.getImageIcon(ImageLocation.APP_ICON));
		} catch (SysException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try
		{
            AlphaminerHelpHandler HelpHandler = AlphaminerHelpHandler.getInstance();
            HelpHandler.setHelpKey(this.getContentPane(),m_NodeInfo.getDefinitionID()+"_Result");
		}catch (Exception e)
		{
		    m_SystemMessageHandler.appendMessage("Cannot initiate on-help files.");
		}
		
		this.setClosable(true);	  	
 		this.setMaximizable(true);
 		this.setResizable(true);		
	}
	
	/**
	 * @author Xiaojun Chen
	 * init the result, inheritor must implement this method.
	 * */
	protected abstract void init()throws Exception;
	
	/**
	 * @author Xiaojun Chen
	 * retrieve the result to display, class extending from this class must implement this method
	 * */
	protected abstract void getContent()throws Exception;
	
	/**
	 * @author Xiaojun Chen
	 * to create the UI to display result, class extending from this class must implement this method
	 * */
	protected abstract void createResult() throws Exception;
	
	// Called by child result panel to add result view
	protected void addView(ResultView a_View)
	{
		if (m_SingleMode && this.getContentPane().getComponentCount()==1)
		{
			// Add the single view result to the content pane directly
			this.getContentPane().add(a_View);
		}else
		{
			// Add the view result to the multiple tabbed pane
			m_MultipleTabbedPane.add(a_View);
		}
	}
	
	// call when the user changed the focus to result view (a_View)
	public void selectView(ResultView a_View)
	{
		m_SelectedView = a_View;
		sendNotify(ObserveMessage.MESSAGE_CHANGE_VIEW);
	}
	
	/* return the selectedView */
	public ResultView getSelectedView() 
	{
		return m_SelectedView;
	}
	
	/* Close this dialog */
	public void close() {
		sendNotify(ObserveMessage.MSG_CLOSE_UNCHANGED);
		dispose();
	}
	
	/* To register the oberser that would receive the messages send by sendNotify()*/
	public void registerInterest(Observer a_Observer)
	{
		m_Observers.add(a_Observer);
	}
	
	// Send message to all observers
	public void sendNotify(String a_Message)
	{
		
		for (int i=0;i<m_Observers.size();i++)
		{
			m_Observers.elementAt(i).sendNotify(a_Message);
		}
	}
	
	// Send message to all observers
	public void sendNotify(int a_Message)
	{
		for (int i=0;i<m_Observers.size();i++)
		{
			m_Observers.elementAt(i).sendNotify(a_Message);
		}
	}

	/* return case id */
	public String getCaseID()
	{
		return m_CaseID;
		
	}
	
	/* Invoke when the state is changed */
	public void stateChanged(ChangeEvent a_Event)
	{
		Object sourceObject = a_Event.getSource();
		// Check if the TabbedPane state is changed
		if (sourceObject instanceof JTabbedPane)
		{
			JTabbedPane tabbedPane = (JTabbedPane)sourceObject;
			Object selectedObject = tabbedPane.getSelectedComponent();
			if (selectedObject instanceof ResultView)
			{
//				m_SelectedViewIndex = tabbedPane.getSelectedIndex(); 
				// Get the select view and invoke the changeView() method
				ResultView aView = (ResultView)selectedObject;
				selectView(aView);
			}
		}
	}
	
	public void export() throws SysException, AppException {
		m_SelectedView.export();
	}

	public void enableAdvanceResults()
	{
	    
	}
	
	public void disableAdvanceResults()
	{
	    
	}
	
	protected void enableAdvanceMenu()
	{
	    m_OperatorResultMenuBarHandler.enableAdvanceMenu();
	}
	
	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosing(InternalFrameEvent)
	 */
	public void internalFrameClosing(InternalFrameEvent e) {
		close();
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosed(InternalFrameEvent)
	 */
	public void internalFrameClosed(InternalFrameEvent e) {
		
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameOpened(InternalFrameEvent)
	 */
	public void internalFrameOpened(InternalFrameEvent e) {
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(InternalFrameEvent)
	 */
	public void internalFrameActivated(InternalFrameEvent e) {
		sendNotify(ObserveMessage.MSG_ACTIVATED);
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(InternalFrameEvent)
	 */
	public void internalFrameDeactivated(InternalFrameEvent e) {
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(InternalFrameEvent)
	 */
	public void internalFrameIconified(InternalFrameEvent e) {
	}

	/**
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(InternalFrameEvent)
	 */
	public void internalFrameDeiconified(InternalFrameEvent e) {
	}
	
	/**
	 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
			close();
	}

	/**
	 *  Handler the change locale event
	 * */
	public void resetLocale() {
		
	}
}

⌨️ 快捷键说明

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