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

📄 managementpopupmenu.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.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import eti.bi.alphaminer.core.handler.CaseInfoListHandler;
import eti.bi.alphaminer.vo.CaseInfoList;
import eti.bi.alphaminer.vo.CaseInformation;
import eti.bi.exception.BaseException;
import eti.bi.common.Locale.Resource;
/**
 * ManagementPopupMenu is a popup menu which shows when user right-click any Case
 * entry in the 'Case List' table or 'Search Result' table in the ManagementWindow.
 */
public class ManagementPopupMenu extends JPopupMenu implements ActionListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JMenuItem m_MenuView = new JMenuItem();
	private JMenuItem m_MenuEdit = new JMenuItem();
	private JMenuItem m_MenuCopy = new JMenuItem();
	private JMenuItem m_MenuDelete = new JMenuItem();	
//	private JCheckBoxMenuItem m_CheckBoxMenuActivate = new JCheckBoxMenuItem();//<<23/03/2005 Mark Li :Remove "activate" from popup window

	/* ID of Case this popup menu is operating */
	private String m_CaseID;
	/* ManagementWindow containing this popup menu */
	private ManagementWindow m_Container;

	/**
	 * Constructs a ManagementPopupMenu.
	 * @param a_Window the ManagementWindow that this popup menu shows on.
	 */
	public ManagementPopupMenu(ManagementWindow a_Window) {
		super();
		m_Container = a_Window;
		createManagementPopupMenu();
	}

	/**
	 * Sets ID of Case ManagementPopupMenu is operating.
	 * @param a_CaseID ID to be set.
	 */
	public void setCaseID(String a_CaseID) {
		m_CaseID = a_CaseID;
		setMenuActionCommand();
		initMenuActivate();
	}

	/**
	 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();
		if (source == m_MenuView)
			m_Container.getApplicationWindow().editCase(m_CaseID, false);
		else if (source == m_MenuEdit)
			m_Container.getApplicationWindow().editCase(m_CaseID, true);
		else if (source == m_MenuDelete)
			m_Container.getApplicationWindow().deleteCase(m_CaseID);
//		<<23/03/2005 Mark Li :Remove "activate" from popup window
//		else if (source == m_CheckBoxMenuActivate)
//			setMenuActivate(m_CheckBoxMenuActivate.isSelected());
//		23/03/2005 Mark Li :Remove "activate" from popup window>>
		else if (source == m_MenuCopy)
			m_Container.getApplicationWindow().copyCase(m_CaseID);
	}

	/**
	 * Sets action command for popup menu items.
	 */
	private void setMenuActionCommand() {
		m_MenuView.setActionCommand(m_CaseID);
		m_MenuCopy.setActionCommand(m_CaseID);
		m_MenuDelete.setActionCommand(m_CaseID);
//		m_CheckBoxMenuActivate.setActionCommand(m_CaseID);//<<23/03/2005 Mark Li :Remove "activate" from popup window
		m_MenuDelete.setActionCommand(m_CaseID);
	}

	/**
	 * Initializes state of 'Activate' checkbox menu item.
	 */
	private void initMenuActivate() {

		CaseInfoList infoList =
			CaseInfoListHandler.getInstance().getCaseInfoList(false);
		if (infoList != null) {
			CaseInformation info = infoList.getCaseInfo(m_CaseID);
			if (info != null) {
//				<<23/03/2005 Mark Li :Remove "activate" from popup window
//				if (info.getStatus().equalsIgnoreCase(BICase.ACTIVATE))
//					m_CheckBoxMenuActivate.setSelected(true);
//				else
//					m_CheckBoxMenuActivate.setSelected(false);
//				23/03/2005 Mark Li :Remove "activate" from popup window>>
			} 
		} else
		{
			System.err.println("Case info list is null");
		}
	}

	/**
	 * Activates/Deactivates the Case operated by this popup menu.
	 * @param a_IsActivated true to activate the Case; false to deactivate it.
	 */
	@SuppressWarnings("unused")
	private void setMenuActivate(boolean a_IsActivated) {
		try {
			m_Container.getApplicationWindow().activateCase(
				m_CaseID,
				a_IsActivated);
		} catch (BaseException be) {
			System.err.println(be.getMessage());
		}
	}

	/**
	 * Creates UI of the ManagementPopupMenu.
	 */
	private void createManagementPopupMenu() {

		m_MenuView.setText(Resource.srcStr("m_MenuView"));
		m_MenuCopy.setText(Resource.srcStr("m_MenuCopy"));
		m_MenuEdit.setText(Resource.srcStr("m_MenuEdit"));
//		m_CheckBoxMenuActivate.setText("Activate");//<<23/03/2005 Mark Li :Remove "activate" from popup window
		m_MenuDelete.setText(Resource.srcStr("m_MenuDelete"));

		m_MenuView.addActionListener(this);
		m_MenuCopy.addActionListener(this);
		m_MenuEdit.addActionListener(this);
//		m_CheckBoxMenuActivate.addActionListener(this);//<<23/03/2005 Mark Li :Remove "activate" from popup window
		m_MenuDelete.addActionListener(this);

		add(m_MenuView);
		add(m_MenuEdit);
		add(m_MenuDelete);
//		addSeparator();//<<23/03/2005 Mark Li :Remove "activate" from popup window
//		add(m_CheckBoxMenuActivate);//<<23/03/2005 Mark Li :Remove "activate" from popup window
//		addSeparator();//<<23/03/2005 Mark Li :Remove "activate" from popup window
		add(m_MenuCopy);
	}
}

⌨️ 快捷键说明

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