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

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

/*
 * Created on 2006/8/7
 *
 * @Author: Xiaojun Chen
 * $Revision$ 1.0
 *
 */

package eti.bi.alphaminer.tools.SystemTools;
import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane;
import javax.swing.plaf.basic.BasicToolBarUI;
import eti.bi.alphaminer.core.handler.AccessController;
import eti.bi.alphaminer.core.observer.HelpObserveSubject;
import eti.bi.alphaminer.core.observer.HelpObserver;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.alphaminer.jhelpcomponent.JHelpTabbedPane;
import eti.bi.alphaminer.jhelpcomponent.JHelpToolBar;

import eti.bi.common.Locale.Resource;

public class SystemHelpToolBarHandler extends MouseAdapter implements Observer, HelpObserver, MouseListener, ActionListener {
	private JHelpToolBar ToolBar;
	private JHelpTabbedPane m_TabbedPane;
	private SystemHelpToolBarContainer m_Container;
	private GroupFloatMenu m_SystemToolBarFloatMenu;
	private boolean m_HelpState = false;
	private JCheckBoxMenuItem m_Float = new JCheckBoxMenuItem(Resource.srcStr("m_FloatToolbar"));
	
	//At least one element
	private MenuItemGroup constant = new MenuItemGroup();

	private Vector<MenuItemGroup> groups = new Vector<MenuItemGroup>();
	private Vector<SystemToolPagePanel> pages = new Vector<SystemToolPagePanel>();
	private Vector<JCheckBoxMenuItem> pagesMainMenus = new Vector<JCheckBoxMenuItem>();
	
	public SystemHelpToolBarHandler(SystemHelpToolBarContainer aSystemWindow, String name) throws NullPointerException {
		if (aSystemWindow == null) {
			throw new NullPointerException();
		}
		m_TabbedPane = new JHelpTabbedPane();
		m_TabbedPane.setBackground(Color.white);
		m_TabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
		m_TabbedPane.addMouseListener(this);
		m_Container = aSystemWindow;
		AccessController.getInstance().registerInterest(this);
		HelpObserveSubject.registerInterest(this);
		ToolBar = new JHelpToolBar(name);
		ToolBar.setBackground(Color.WHITE);
		ToolBar.add(m_TabbedPane);
		
		//menuItem
		m_Float.addActionListener(this);
		constant.add(m_Float);
		constant.add(new JPopupMenu.Separator());
		
		m_SystemToolBarFloatMenu = new GroupFloatMenu(constant,groups);
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @return the container
	 */
	public SystemHelpToolBarContainer getContainer() {
		return m_Container;
	}

	/**
	 * @return a ToolBar belong to this
	 */
	public JHelpToolBar getToolBar() {
		return ToolBar;
	}

	/**
	 * add a SystemToolPanel into this ToolBar
	 * 
	 * @param aSystemToolPanel
	 *            a SystemToolPanel to be added
	 * @return <code>true<code> if adding succeed, else <code>false<code>
	 */
	public boolean addSystemToolPagePane(SystemToolPagePanel aSystemToolPanel) {
		if (aSystemToolPanel == null) {
			return false;
		}
		aSystemToolPanel.validate();
		m_TabbedPane.addTab(aSystemToolPanel.getName(), aSystemToolPanel);
		pages.add(aSystemToolPanel);
		aSystemToolPanel.addToolPageMouseListener(this);
		
		//page menu
		JCheckBoxMenuItem pageMenu = new JCheckBoxMenuItem(aSystemToolPanel.getName());
		pageMenu.setSelected(true);
		pageMenu.addActionListener(this);
		pagesMainMenus.add(pageMenu);
		constant.add(pageMenu);
		
		//group
		groups.add(aSystemToolPanel.getMenuItemGroup());
		return true;
	}
	
	/**
	 * add a SystemToolPanel into this ToolBar
	 * 
	 * @param aSystemToolPanel
	 *            a SystemToolPanel to be added
	 * @return <code>true<code> if adding succeed, else <code>false<code>
	 */
	public boolean addSystemToolPagePane(SystemToolPagePanel aSystemToolPanel,int tabIndex) {
		if (aSystemToolPanel == null) {
			return false;
		}
		aSystemToolPanel.validate();
		m_TabbedPane.insertTab(aSystemToolPanel.getName(), null, aSystemToolPanel, null, tabIndex);
		pages.add(tabIndex,aSystemToolPanel);
		aSystemToolPanel.addToolPageMouseListener(this);
		
		//page menu
		JCheckBoxMenuItem pageMenu = new JCheckBoxMenuItem(aSystemToolPanel.getName());
		pageMenu.setSelected(true);
		pageMenu.addActionListener(this);
		pagesMainMenus.add(tabIndex, pageMenu);
		constant.add(pageMenu);
		
		//group
		groups.add(tabIndex,aSystemToolPanel.getMenuItemGroup());
		return true;
	}
	

	/**
	 * remove the specific SystemToolPanel
	 * 
	 * @param aSystemToolPanel
	 *            the SystemToolPanel to be removed
	 * @return 'true' if remoing succeed, else 'false'
	 */
	public boolean removeSystemToolPane(SystemToolPagePanel aSystemToolPanel) {
		if (aSystemToolPanel == null) {
			return false;
		}
		int index = m_TabbedPane.indexOfComponent(aSystemToolPanel);
		if(index<=-1) {
			return false;
		}
		m_TabbedPane.remove(index);
		groups.remove(index);
		pages.remove(index);
		JCheckBoxMenuItem pageMenu = pagesMainMenus.remove(index);
		constant.remove(pageMenu);
		return true;
	}

	/**
	 * select a specific SystemToolPanel
	 * 
	 * @param aSystemToolPanel
	 *            a SystemToolPanel to be selected
	 * @return 'true' if selecting the specific SystemToolPanel succeed, else
	 *         'false'
	 */
	public boolean selectSystemToolPane(SystemToolPagePanel aSystemToolPanel) {
		if (aSystemToolPanel == null) {
			return false;
		}
		if(m_TabbedPane.indexOfComponent(aSystemToolPanel)>-1) {
			m_TabbedPane.setSelectedComponent(aSystemToolPanel);
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * deselect a specific SystemToolPanel
	 * 
	 * @param aSystemToolPanel
	 *            a SystemToolPanel to be deselected
	 * @return <code>true<code> if deselecting the specific SystemToolPanel succeed, else
	 *         <code>false<code>
	 */
	public boolean deselectToolPane(SystemToolPagePanel aSystemToolPanel) {
		if (aSystemToolPanel == null) {
			return false;
		}
		m_TabbedPane.setSelectedIndex(0);
		return true;
	}
	
	public SystemToolPagePanel getSelectToolPage() {
		return pages.get(m_TabbedPane.getSelectedIndex());
	}
	
	public void showAllToolPage() {
		m_TabbedPane.removeAll();
		int size = pages.size();
		SystemToolPagePanel aSystemToolPanel;
		for(int i=0;i<size;i++) {
			aSystemToolPanel = pages.get(i);
			m_TabbedPane.addTab(aSystemToolPanel.getName(), aSystemToolPanel);
			pagesMainMenus.get(i).setSelected(true);
		}
		m_SystemToolBarFloatMenu.reset();
	}
	
	/**
	 * Sets the <code>floatable</code> property, which must be
	 * <code>true</code> for the user to move the tool bar. Typically, a
	 * floatable tool bar can be dragged into a different position within the
	 * same container or out into its own window. The default value of this
	 * property is <code>false</code>.
	 * 
	 * @param b
	 *            if <code>true</code>, the tool bar can be moved;
	 *            <code>false</code> otherwise
	 */
	public void setFloatable(boolean b) {
		ToolBar.setFloatable(b);
	}

	public boolean isFloatable() {
		return ToolBar.isFloatable();
	}

	public void Float(Point location) {
		((BasicToolBarUI) ToolBar.getUI()).setFloating(true, location);
		((Window) ToolBar.getTopLevelAncestor()).setAlwaysOnTop(true);
		((Window) ToolBar.getTopLevelAncestor()).addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				m_Float.setSelected(false);
				Dock();
			}
		});
		m_Float.setSelected(true);
		m_Container.Float();
	}

	public void Dock(){
		//((BasicToolBarUI) ToolBar.getUI()).setFloating(false, null);
		m_Container.Dock();
	}
	
	public void dispose() {
		m_TabbedPane.removeAll();
		m_SystemToolBarFloatMenu.dispose();
		m_TabbedPane = null;
		m_SystemToolBarFloatMenu = null;
	}

	public void sendNotify(String a_Message) {
	}

	public void sendNotify(int a_Message) {
	}

	public void sendNotify(int a_Message, Object a_Object) {
	}

	public void Update(boolean a_HelpState) {
	}

⌨️ 快捷键说明

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