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

📄 help.java

📁 Java写的ERP系统
💻 JAVA
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is                  Compiere  ERP & CRM  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.apps;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;

import org.compiere.model.*;
import org.compiere.grid.*;
import org.compiere.util.*;

/**
 *	Help and HTML Window
 *
 *  @author 	Jorg Janke
 *  @version 	$Id: Help.java,v 1.8 2003/01/28 04:23:21 jjanke Exp $
 */
public class Help extends JDialog implements ActionListener
{
	/**
	 *	Help System for Window Help
	 *
	 * @param frame Parent
	 * @param title Title
	 * @param mWindow Window Model
	 */
	public Help (Frame frame, String title, MWindow mWindow)
	{
		super(frame, title, false);
		try
		{
			jbInit();
			loadInfo(mWindow);
		}
		catch(Exception ex)
		{
			Log.error("Help", ex);
		}
		AEnv.positionCenterWindow(frame, this);
	}	//	Help

	/**
	 *	Help System
	 *
	 * @param frame Parent
	 * @param title Window
	 * @param url   URL to display
	 */
	public Help (Frame frame, String title, URL url)
	{
		super(frame, title, false);
		try
		{
			jbInit();
			info.setPage(url);
		}
		catch(Exception ex)
		{
			Log.error("Help", ex);
		}
		AEnv.positionCenterWindow(frame, this);
	}	//	Help

	private JPanel mainPanel = new JPanel();
	private BorderLayout mainLayout = new BorderLayout();
	private OnlineHelp info = new OnlineHelp();
	private JScrollPane infoPane = new JScrollPane();
	private ConfirmPanel confirmPanel = new ConfirmPanel();

	/**
	 *	Static Init
	 *
	 * @throws Exception
	 */
	void jbInit() throws Exception
	{
		mainPanel.setLayout(mainLayout);
		mainLayout.setHgap(2);
		mainLayout.setVgap(2);
		infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
		infoPane.setPreferredSize(new Dimension(500, 400));
		getContentPane().add(mainPanel);
		mainPanel.add(infoPane, BorderLayout.CENTER);
		mainPanel.add(confirmPanel, BorderLayout.SOUTH);
		infoPane.getViewport().add(info, null);
		confirmPanel.addActionListener(this);
	}	//	jbInit

	/*************************************************************************/

	/**
	 *	Load Info - Windows Help
	 *  @param mWindow window model
	 */
	private void loadInfo(MWindow mWindow)
	{
		StringBuffer buffer = new StringBuffer();
		buffer.append("<HTML>");
		buffer.append("<HEADER><TITLE>" + mWindow.getName() + "</TITLE></HEADER>");
		buffer.append("<BODY>");
		buffer.append("&copy;&nbsp;Compiere &nbsp; ");
		buffer.append("<A HREF=\"http://www.compiere.org/help/\">Online Help</A>");
		//	Window
		buffer.append("<H1>" + Msg.getMsg(Env.getCtx(), "Window") + ": " + mWindow.getName() + "</H1>");
		if (mWindow.getDescription().length() != 0)
			buffer.append("<P><I>" + mWindow.getDescription() + "</I></P>");
		if (mWindow.getHelp().length() != 0)
			buffer.append("<P>" + mWindow.getHelp() + "</P>");

		//	Links to Tabs
		int size = mWindow.getTabCount();
		for (int i = 0; i < size; i++)
		{
			MTab tab = mWindow.getTab(i);
			buffer.append("<A HREF=\"#Tab").append(i).append("\">").append(tab.getName()).append("</A> - ");
		}

		//	For all Tabs
		for (int i = 0; i < size; i++)
		{
			MTab tab = mWindow.getTab(i);
			buffer.append("<HR><H2><A NAME=\"Tab").append(i).append("\"><FONT COLOR=green>")
				.append(Msg.getMsg(Env.getCtx(), "Tab")).append(": ").append(tab.getName()).append("</FONT></A></H2>");
			if (tab.getDescription().length() != 0)
				buffer.append("<P><I>").append(tab.getDescription()).append("</I></P>");
			if (tab.getHelp().length() != 0)
				buffer.append("<P>").append(tab.getHelp()).append("</P>");

			//	Links to Fields
			for (int j = 0; j < tab.getFieldCount(); j++)
			{
				MField field = tab.getField(j);
				String hdr = field.getHeader();
				if (hdr != null && hdr.length() > 0)
					buffer.append("<A HREF=\"#Field").append(i).append(j).append("\">")
						.append(hdr).append("</A> - ");
			}

			//	For all Fields
			for (int j = 0; j < tab.getFieldCount(); j++)
			{
				MField field = tab.getField(j);
				String hdr = field.getHeader();
				if (hdr != null && hdr.length() > 0)
				{
					buffer.append ("<H3><A NAME=\"Field").append (i).append (j)
						.append ("\"><FONT COLOR=\"#FF0000\">")
						.append (Msg.getMsg (Env.getCtx (), "Field"))
						.append (": ").append (hdr)
						.append ("</FONT></A></H3>");
					if (field.getDescription ().length () != 0)
						buffer.append ("<P><I>").append (field.getDescription ())
							.append ("</I></P>");
					if (field.getHelp ().length () != 0)
						buffer.append ("<P>").append (field.getHelp ())
							.append ("</P>");
				}
			}	//	for all Fields

		}	//	for all Tabs

		//	Finish
		buffer.append("</BODY>");
		buffer.append("</HTML>");

		//	Set Info
	//	System.out.println(buffer);
		info.setText(buffer.toString());
	}	//	loadInfo

	/*************************************************************************/

	/**
	 *	Action Listener
	 *  @param e event
	 */
	public void actionPerformed(ActionEvent e)
	{
		if (e.getActionCommand().equals(ConfirmPanel.A_OK))
			dispose();
	}	//	actionPerformed

}	//	Help

⌨️ 快捷键说明

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