/*
*
* HelpGui.java - Launch HelpGui API Demo
* Copyright (C) 2003 Alexandre THOMAS
* alexthomas@free.fr
* http://helpgui.sourceforge.net
*
* 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package salomeTMF_plug.helpgui;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Vector;
import javax.swing.JTabbedPane;
import org.java.plugin.ExtensionPoint;
import org.java.plugin.Plugin;
import org.java.plugin.PluginDescriptor;
import org.java.plugin.PluginManager;
import org.objectweb.salome_tmf.api.Util;
import org.objectweb.salome_tmf.ihm.main.SalomeTMF;
import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
import org.objectweb.salome_tmf.plugins.UICompCst;
import org.objectweb.salome_tmf.plugins.core.Common;
import salomeTMF_plug.helpgui.gui.MainFrame;
import salomeTMF_plug.helpgui.gui.MainPanel;
/**
* A class for Lauch the Help Viewer
*
* @author Alexandre THOMAS
*/
public class HelpGui extends Plugin implements Common {
public static boolean debug = false;
String helpPath;
MainPanel mainPanel;
Properties configFile;
Vector pluginList = new Vector();
//For Debug purpose
public static void main(String[] arg) {
MainFrame mainFrame = new MainFrame("/docs/help/", "crystal");
mainFrame.setVisible(true);
}
/**
* @param manager
* @param descr
*/
public HelpGui(PluginManager manager, PluginDescriptor descr) {
super(manager, descr);
Collection c = manager.getRegistry().getPluginDescriptors();
Iterator it_c = c.iterator();
while (it_c.hasNext()){
PluginDescriptor pPluginDescriptor = (PluginDescriptor) it_c.next();
pluginList.add(pPluginDescriptor.getId());
Util.log("[helpgui] plug id " + pPluginDescriptor.getId());
Util.log("[helpgui] plug location " + pPluginDescriptor.getLocation());
Util.log("[helpgui] plug unique id " +pPluginDescriptor.getUniqueId());
}
}
/**
* @see org.java.plugin.Plugin()
*/
protected void doStart() throws Exception {
// no-op
}
/**
* @see org.java.plugin.Plugin()
*/
protected void doStop() throws Exception {
// no-op
}
public void init(Object pIhm) {
// Config file initialisation
String helpDir = null;;
String pluginDir = null;
String lang = null;
String helpPath;
//URL _urlBase = ((SalomeTMF) pIhm).getDocumentBase();
URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
helpPath = _urlBase.toString();
helpPath = helpPath.substring(0,helpPath.lastIndexOf("/"));
URL url_cfg = null;
try {
URL urlBase = new URL(helpPath);
url_cfg = new URL(urlBase +"/plugins/helpgui/cfg/CfgHelpGui.properties");
} catch (MalformedURLException mue) {
mue.printStackTrace();
}
try {
configFile = Util.getPropertiesFile(url_cfg);
}catch(Exception e){
try {
configFile = Util.getPropertiesFile("/plugins/helpgui/cfg/CfgHelpGui.properties");
}catch(Exception e1){
}
}
try {
helpDir = configFile.getProperty("HelpRoot");
pluginDir = configFile.getProperty("PluginPath");
lang = configFile.getProperty("lang");
}catch(Exception e){}
if (helpDir == null || helpDir.trim().equals("")){
helpDir = "docs/html";
}
if (pluginDir == null || pluginDir.trim().equals("")){
pluginDir = "plugins";
}
if(lang == null | lang.trim().equals("")){
lang = Locale.getDefault().getCountry().toLowerCase();
}
Util.log("[helpgui] base protocol is : " + _urlBase.getProtocol());
Util.log("[helpgui] help path : " + helpPath);
Util.log("[helpgui] help dir is : " + helpDir);
Util.log("[helpgui] plugins dir is : " + pluginDir);
Util.log("[helpgui] : lang is " + lang);
mainPanel = new MainPanel(helpPath, helpDir, pluginDir, lang, "crystal", pluginList);
}
/**
* Returns true if the plugin has menu items for "Tools" menu for tests
*
* @return true if the plugin has menu items for "Tools" menu for tests
*/
public boolean isActivableInTestToolsMenu() {
return false;
}
/**
* Returns true if the plugin has menu items for "Tools" menu for campaigns
*
* @return true if the plugin has menu items for "Tools" menu for campaigns
*/
public boolean isActivableInCampToolsMenu() {
return false;
}
/**
* Returns true if the plugin has menu items for "Tools" menu for data
* management
*
* @return true if the plugin has menu items for "Tools" menu for data
* management
*/
public boolean isActivableInDataToolsMenu() {
return false;
}
/**
* Returns true if the plugin uses or is activable in other UI components
* than these three menus true if the plugin uses or is activable in other
* UI components than these
*
* @return
*/
public boolean usesOtherUIComponents() {
return true;
}
/*
* Getting the UI components relative constants in which the plugin is
* activable or which it uses different from these three menus
*
* @see org.objectweb.salome_tmf.ihm.UICompCst @return A vector containing UI components
* constants
*/
public java.util.Vector getUsedUIComponents() {
Vector uiComponentsUsed = new Vector();
uiComponentsUsed.add(0,UICompCst.MAIN_TABBED_PANE);
return uiComponentsUsed;
}
/*
* Activates the plugin in static UI component This method will be called
* for each static UI component in the Vector returned by the previous
* method ( getUsedUIComponents() ). @param UIComponents
*/
public void activatePluginInStaticComponent(Integer uiCompCst) {
JTabbedPane salomeMainTabs = (JTabbedPane)SalomeTMFContext.getInstance().getUIComponent(uiCompCst);
salomeMainTabs.addTab("HelpGui plugin",mainPanel);
}
/*
* Activates the plugin in dynamic UI component This method will be called
* for each dynamic UI component in the Vector returned by the previous
* method ( getUsedUIComponents() ). @param UIComponents
*/
public void activatePluginInDynamicComponent(Integer uiCompCst) {
}
/**
* Retruns true if the plugin is freezable
*/
public boolean isFreezable() {
return false;
}
/**
* Freezes the plugin
*/
public void freeze() {
}
/**
* Unfreezes the plugin
*/
public void unFreeze() {
}
/**
* true if the plugin is freezed
*/
public boolean isFreezed() {
return false;
}
public void activatePluginInCampToolsMenu(javax.swing.JMenu jMenu) {
}
public void activatePluginInDataToolsMenu(javax.swing.JMenu jMenu) {
}
public void activatePluginInTestToolsMenu(javax.swing.JMenu jMenu) {
}
public void allPluginActived(ExtensionPoint commonExtensions, ExtensionPoint testDriverExtensions, ExtensionPoint scriptEngineExtensions, ExtensionPoint bugTrackerExtensions) {
}
}
|