📄 alphaminerhelphandler.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.core.help;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedList;
import javax.help.HelpBroker;
import javax.help.HelpSet;
import javax.help.HelpSetException;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.common.Locale.Resource;
import eti.bi.common.System.SysConfig;
import eti.bi.common.System.SysLog;
/**
* @author mli
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class AlphaminerHelpHandler implements Observer{
// <<16/08/2006: Xiaojun Chen: Added for multi-language help>>
// <<17/08/2005: Kenneth Lai: Added for helpHandler singleton
private static AlphaminerHelpHandler m_alphaminerHelpHandler;
// 17/08/2005: Kenneth Lai: Added for helpHandler singleton>>
static final String helpsetName = "AlphaMiner.hs";
private LinkedList<helpLocation> URLset = new LinkedList<helpLocation>();
// Main HelpSet & Broker
HelpSet HS = null;
// <<18/08/2005: Kenneth Lai: Modified for helpHandler singleton
// HelpBroker HB;
static HelpBroker HB;
// 18/08/2005: Kenneth Lai: Modified for helpHandler singleton>>
// 16/08/2006: Xiaojun Chen: Added for multi-language help>>
public AlphaminerHelpHandler(){
// <<19/07/05: Mark Li: Add for JHelp
// <<16/08/2006: Xiaojun Chen: Remove
/*
try {
ClassLoader cl = AlphaminerHelpHandler.class.getClassLoader();
URL hsURL = HelpSet.findHelpSet(cl, helpsetName);
HS = new HelpSet(null, hsURL);
} catch (Exception ee) {
// Say what the exception really is
System.out.println("HelpSet " + ee.getMessage());
System.out.println("HelpSet " + HS + " not found");
return;
}
if ( HB == null ) {
HB = HS.createHelpBroker();
}
*/
// 16/08/2006: Xiaojun Chen: Remove>>
//CSH.setHelpIDString(this,"Sampling_htm");
//OperatorHB.enableHelpKey(this.getContentPane(), "AlphaMinerHelp.help", OperatorHS, "javax.help.MainWindow", null);
//19/07/05: Mark Li: Add for JHelp>>
// <<16/08/2006: Xiaojun Chen: Add for JHlp
//HS = new HelpSet();
//init();
// 16/08/2006: Xiaojun Chen: Add for JHlp>>
}
/**
* add url of help set
* @param classloader classloader for this help set
* @param url url of help set
* @throws Exception
* */
public void addUrl(ClassLoader classloader, URL url) {
helpLocation aLocation = new helpLocation(classloader,url);
if(aLocation!=null) {
try {
aLocation.url.openStream();
HelpSet helpset = new HelpSet(aLocation.classloader,aLocation.url);
HS.add(helpset);
URLset.add(aLocation);
} catch (HelpSetException e) {
System.out.println("HelpSet " + HS + " not found");
e.printStackTrace();
SysLog.error("HelpSet " + HS + " not found", e);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void create(){
HB = HS.createHelpBroker();
}
/**
* reset the help set
* */
public void reset() {
HS = new HelpSet();
}
public void setHelpKey(Component c,String comptID){
if (HS!=null && c!=null && comptID!=null)
{
HB.enableHelpKey(c, comptID, HS);
}
}
// <<25/07/2005 Kenneth Lai: Add for JHelp
public void setHelpButton(Component c, String comptID) {
if (HS!=null && c!=null && comptID!=null)
{
HB.enableHelpOnButton(c, comptID, HS);
}
}
// 25/07/2005 Kenneth Lai: Add for JHelp>>
public HelpBroker getHelpBroker(){
return HB;
}
public HelpSet getHelpSet(){
return HS;
}
// <<17/08/2005: Kenneth Lai: Added for helpHandler singleton
public static AlphaminerHelpHandler getInstance() {
if (m_alphaminerHelpHandler == null ) {
m_alphaminerHelpHandler = new AlphaminerHelpHandler();
}
return m_alphaminerHelpHandler;
}
// 17/08/2005: Kenneth Lai: Added for helpHandler singleton>>
// <<16/08/2006 Xiaojun Chen: Added for multi-language helpHandler
public void sendNotify(String a_Message) {
if(a_Message.equals(Resource.CHANGE_LOCALE)) {
synchronized(this) {
URLset.clear();
HS =new HelpSet();
try {
SysConfig.initAlphaminerHelp();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
}
}
// 16/08/2006 Xiaojun Chen: Added for multi-language helpHandler>>
public void sendNotify(int a_Message) {
// TODO Auto-generated method stub
}
public void sendNotify(int a_Message, Object a_Object) {
// TODO Auto-generated method stub
}
}
class helpLocation{
URL url;
ClassLoader classloader;
helpLocation(ClassLoader classloader2,URL url){
this.classloader = classloader2;
this.url = url;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -