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

📄 caseinformationpanel.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 *    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.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.text.JTextComponent;

import eti.bi.alphaminer.core.handler.CaseInfoListHandler;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.alphaminer.tools.ExportCase.BreCaseDiagram;
import eti.bi.alphaminer.tools.ExportCase.BreCaseDiagramPanel;
import eti.bi.alphaminer.tools.ExportCase.CaseDocument;
import eti.bi.alphaminer.ui.dialog.MessageDialog;
import eti.bi.alphaminer.vo.CaseInfoList;
import eti.bi.alphaminer.vo.CaseInformation;
import eti.bi.alphaminer.vo.SearchCriteria;
import eti.bi.alphaminer.vo.SearchedCaseInfoList;

import eti.bi.common.Locale.Resource;


/**
 * CaseInformationPanel is a JPanel used to show detail of a CaseInformation.
 */
public class CaseInformationPanel
	extends JPanel
	implements Observer, ActionListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	JPanel m_PanelContent = new JPanel(new BorderLayout());

	JPanel m_PanelDetail = new JPanel(new BorderLayout());
	JScrollPane m_ScrollPaneDetail = new JScrollPane();

	JPanel m_PanelButton = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
	JButton m_ButtonView = new JButton(Resource.srcStr("m_ButtonView"));
	JButton m_ButtonEdit = new JButton(Resource.srcStr("m_ButtonEdit"));
	JButton m_ButtonCopy = new JButton(Resource.srcStr("m_ButtonCopy"));
	JButton m_ButtonExport = new JButton(Resource.srcStr("m_ButtonExport"));
	
	JPanel m_PanelCase = new JPanel(new BorderLayout());
	//<<21/02/2005 Mark Li: Add Case Name
//	JLabel m_LabelCase = new JLabel("Case:");
	JLabel m_LabelCaseName = new JLabel(Resource.srcStr("m_LabelCaseName"));	
	JTextField m_TextCaseName = new JTextField();
//	21/02/2005 Mark Li: Add Case Name>>
	JPanel m_PanelCaseRest = new JPanel(new BorderLayout());

	JPanel m_PanelCompany = new JPanel(new BorderLayout());
	JLabel m_LabelCompany = new JLabel(Resource.srcStr("m_LabelCompanyname"));
	JTextField m_TextCompany = new JTextField();
	JPanel m_PanelCompanyRest = new JPanel(new BorderLayout());

	JPanel m_PanelDepartment = new JPanel(new BorderLayout());
	JLabel m_LabelDepartment = new JLabel(Resource.srcStr("m_LabelDepartment"));
	JTextField m_TextDepartment = new JTextField();
	JPanel m_PanelDepartmentRest = new JPanel(new BorderLayout());

	JPanel m_PanelIndustry = new JPanel(new BorderLayout());
	JLabel m_LabelIndustry = new JLabel(Resource.srcStr("m_LabelIndustry"));
	JTextField m_TextIndustry = new JTextField();
	JPanel m_PanelIndustryRest = new JPanel(new BorderLayout());

	JPanel m_PanelProblemType = new JPanel(new BorderLayout());
	JLabel m_LabelProblemType = new JLabel(Resource.srcStr("m_LabelProblemType"));
	JTextField m_TextProblemType = new JTextField();
	JPanel m_PanelProblemTypeRest = new JPanel(new BorderLayout());

	JPanel m_PanelBusinessObjective = new JPanel(new BorderLayout());
	JLabel m_LabelBusinessObjective = new JLabel(Resource.srcStr("m_LabelBusinessObjective"));
	JTextArea m_TextBusinessObjective = new JTextArea();
	JScrollPane m_ScrollPaneBusinessObjective = new JScrollPane();
	JPanel m_PanelBusinessObjectiveRest = new JPanel(new BorderLayout());

	JPanel m_PanelDataMiningGoal = new JPanel(new BorderLayout());
	JLabel m_LabelDataMiningGoal = new JLabel(Resource.srcStr("m_LabelDataMiningGoal"));
	JTextArea m_TextDataMiningGoal = new JTextArea();
	JScrollPane m_ScrollPaneDataMiningGoal = new JScrollPane();
	JPanel m_PanelDataMiningGoalRest = new JPanel(new BorderLayout());

	JPanel m_PanelScore = new JPanel(new BorderLayout());
	JLabel m_LabelScore = new JLabel(Resource.srcStr("m_LabelScore"));
	JTextField m_TextScore = new JTextField();
	JPanel m_PanelScoreRest = new JPanel(new BorderLayout());

	JPanel m_PanelSearchingCriteria = new JPanel(new BorderLayout());
	JLabel m_LabelSearchingCriteria = new JLabel(Resource.srcStr("m_LabelSearchingCriteria"));
	JTextArea m_TextSearchingCriteria = new JTextArea();
	JScrollPane m_ScrollPaneSearchingCriteria = new JScrollPane();
	
	JScrollPane m_BCaseDiagram = new JScrollPane();
	BreCaseDiagram m_CaseDiagram;
	
	private ManagementWindow m_Container = null;
	private String m_CaseID = null;

	/**
	 * Constructs a CaseInformationPanel.
	 * @param a_Window the ManagementWindow containing this CaseInformationPanel.
	 */
	public CaseInformationPanel(ManagementWindow a_Window) {
		m_Container = a_Window;
		m_CaseDiagram = new BreCaseDiagram(m_Container.getApplicationWindow());
		createCaseInformationPanel();
		setShownDetail(false);
	}

	/**
	 * Gets the Case ID of the CaseInformation currently shown.
	 * @return ID of the Case.
	 */
	public String getCaseID() {
		return m_CaseID;
	}

	/**
	 * Showns/Unshows CaseInformation details.
	 * @param a_IsShown true to show the CaseInformation; 
	 * false to unshow CaseInformation that is showing.
	 */
	public void setShownDetail(boolean a_IsShown) {
		m_PanelContent.setVisible(a_IsShown);
	}

	/**
	 * Sets action command for buttons.
	 * @param a_String the action command to be set.
	 */
	public void setButtonActionCommand(String a_Command) {
		m_CaseID = a_Command;
		if (a_Command == null)
			a_Command = "";

		m_ButtonView.setActionCommand(a_Command);
		m_ButtonEdit.setActionCommand(a_Command);
		m_ButtonCopy.setActionCommand(a_Command);
		m_ButtonExport.setActionCommand(a_Command);
	}

	/**
	 * Clears details .
	 */
	public void clearDetail() {
		setTextCase(null);
		setTextCompany(null);
		setTextDepartment(null);
		setTextIndustry(null);
		setTextProblemType(null);
		setTextBusinessObjective(null);
		setTextDataMiningGoal(null);
		setTextScore(0);
		setTextSearchingCriteria(null);
	}

	/**
	 * Displays CaseInforamtion detail of a specific Case.
	 * @param a_CaseID ID of the Case that its CaseInformation is to be shown.
	 * @param a_IsSearched true if the specific Case is selected from the '
	 * Search Result' table; false if the specific Case is selected from the
	 * 'Case List' tree.
	 */
	public void displayCaseDetail(String a_CaseID, boolean a_IsSearched) {
		CaseInformation caseInfo = null;
		SearchCriteria result = null;
		if (a_IsSearched) {
			SearchedCaseInfoList list =
				CaseInfoListHandler.getInstance().getSearchedCaseInfoList();
			result = list.getSearchCriteria();
			caseInfo = list.getCaseInfo(a_CaseID);
		} else {
			CaseInfoList list =
				CaseInfoListHandler.getInstance().getCaseInfoList(false);
			caseInfo = list.getCaseInfo(a_CaseID);
		}
		setDetail(caseInfo, result, a_IsSearched);
		setDisplayDetail(a_IsSearched);
		try {
			m_CaseDiagram.drawCase(getCaseID());
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			m_CaseDiagram.clear();
		}
		setShownDetail(true);
	}


	/**
	 * @see eti.bi.alphaminer.core.observer.Observer#sendNotify(String)
	 */
	public void sendNotify(String a_Message) {
		if(a_Message.equals(Resource.CHANGE_LOCALE)) {
			m_ButtonView.setText(Resource.srcStr("m_ButtonView"));
			m_ButtonEdit.setText(Resource.srcStr("m_ButtonEdit"));
			m_ButtonCopy.setText(Resource.srcStr("m_ButtonCopy"));
			m_ButtonExport.setText(Resource.srcStr("m_ButtonExport"));
			m_LabelCaseName.setText(Resource.srcStr("m_LabelCaseName"));
			m_LabelCompany.setText(Resource.srcStr("m_LabelCompanyname"));
			m_LabelDepartment.setText(Resource.srcStr("m_LabelDepartment"));
			m_LabelIndustry.setText(Resource.srcStr("m_LabelIndustry"));
			m_LabelProblemType.setText(Resource.srcStr("m_LabelProblemType"));
			m_LabelBusinessObjective.setText(Resource.srcStr("m_LabelBusinessObjective"));
			m_LabelDataMiningGoal.setText(Resource.srcStr("m_LabelDataMiningGoal"));
			m_LabelScore.setText(Resource.srcStr("m_LabelScore"));
			m_LabelSearchingCriteria.setText(Resource.srcStr("m_LabelSearchingCriteria"));
		}
	}

	/**
	 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();
		if (source == m_ButtonView)
			m_Container.getApplicationWindow().editCase(
				e.getActionCommand(),
				false);
		else if (source == m_ButtonEdit)
			m_Container.getApplicationWindow().editCase(
				e.getActionCommand(),
				true);
		else if (source == m_ButtonCopy)
			m_Container.getApplicationWindow().copyCase(e.getActionCommand());
		else if(source == m_ButtonExport) {
			exportCase(e.getActionCommand());
		}
	}


	/**
	 * Sets properties of a given label component.
	 * @param a_Label the label component.
	 */
	private void setLabelProperty(JLabel a_Label) {
		a_Label.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 5));
		a_Label.setMaximumSize(new Dimension(99, 17));
		a_Label.setMinimumSize(new Dimension(99, 17));
		a_Label.setPreferredSize(new Dimension(99, 17));
		a_Label.setHorizontalAlignment(SwingConstants.LEFT);
		a_Label.setVerticalAlignment(SwingConstants.TOP);
	}

	/**
	 * Sets properties of a given text component.
	 * @param a_Text the text component.
	 */
	private void setTextProperty(JTextComponent a_Text) {
		a_Text.setBackground(new Color(212, 208, 200));
		a_Text.setBorder(null);
		a_Text.setEditable(false);
		JTextArea text = null;
		if (a_Text instanceof JTextArea) {
			text = (JTextArea) a_Text;
			text.setLineWrap(true);
			text.setWrapStyleWord(true);
		} else {
			a_Text.setMinimumSize(new Dimension(150, 23));
			a_Text.setPreferredSize(new Dimension(150, 23));
		}
	}

	/**
	 * Sets properties of a given scroll pane component.
	 * @param a_Pane the scroll pane component.
	 */
	private void setScrollPaneProperty(JScrollPane a_Pane) {
		a_Pane.setBorder(BorderFactory.createEmptyBorder(4, 0, 2, 0));
		a_Pane.setHorizontalScrollBarPolicy(
			JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		a_Pane.setVerticalScrollBarPolicy(
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
	}

	/**
	 * Sets text for Case textfield.
	 * @param a_String the text to be set.
	 */
	private void setTextCase(String a_String) {
		m_TextCaseName.setText(a_String);
	}
	
	/**
	 * Sets text for Componay textfield.
	 * @param a_String the text to be set.
	 */
	private void setTextCompany(String a_String) {
		m_TextCompany.setText(a_String);
	}

	/**
	 * Sets text for Department textfield.
	 * @param a_String the text to be set.
	 */

⌨️ 快捷键说明

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