/*
* :tabSize=2:indentSize=2:noTabs=true:
* :folding=explicit:collapseFolds=1:
*
* Copyright (C) 2009 Chaniel AB, Thomas Dilts 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more
* information, surf to www.lazy8.nu or email support@lazy8.nu
*/
package nu.lazy8.ledger.main;
//{{{ imports
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.JDialog;
import javax.swing.JFrame;
import infoviewer.InfoViewer;
import nu.lazy8.util.gen.Fileio;
import nu.lazy8.util.gen.SetupInfo;
import nu.lazy8.util.gen.Translator;
import org.gjt.sp.jedit.gui.DockableWindowManager;
import org.gjt.sp.util.Log;
//}}}
/**
* Description of the Class
*
* @author Lazy Eight Data HB, Thomas Dilts
* @created den 5 mars 2002
*/
public class Lazy8Ledger {
//{{{ +Lazy8Ledger() : <init>
/**
*Constructor for the Lazy8Ledger object
*/
public Lazy8Ledger() { }//}}}
//{{{ +_ShowContextHelp(JFrame, String, String)_ : void
/**
* Description of the Method
*
* @param viewChild Description of the Parameter
* @param filename Description of the Parameter
* @param extention Description of the Parameter
*/
public static void ShowContextHelp(JFrame viewChild, String filename, String extention) {
if (filename != null && filename.length() != 0
&& SetupInfo.getBoolProperty(SetupInfo.SHOW_CONTEXTHELP)) {
org.gjt.sp.jedit.View view=null;
if(viewChild==null)
view=org.gjt.sp.jedit.jEdit.getFirstView();
else
view=((org.gjt.sp.jedit.View) viewChild);
String urlString = "";
try {
URL urltmp = Fileio.getURL(filename + "." +
SetupInfo.getProperty(SetupInfo.PRESENT_LANGUAGE) + ".html", "doc");
if (urltmp == null) {
//if it cant be found, then just get english as the default
urltmp = Fileio.getURL(filename + ".en.html", "doc");
}
urlString = urltmp.toString();
if (extention != null && extention.length() != 0) {
urlString = urlString + "#" + extention;
}
DockableWindowManager mgr = view.getDockableWindowManager();
InfoViewer iv = (InfoViewer) mgr.getDockable("infoviewer");
if (iv == null) {
return;
}
iv.gotoURL(new URL(urlString), true, -1);
} catch (Exception e) {
Log.log(Log.ERROR, "ShowContextHelp", "could not find helpfile="
+ urlString + " : error=" + e);
}
}
}//}}}
//{{{ +_ShowHelp(JFrame, String, String)_ : void
/**
* Description of the Method
*
* @param viewChild Description of the Parameter
* @param filename Description of the Parameter
* @param extention Description of the Parameter
*/
public static void ShowHelp(JFrame viewChild, String filename, String extention) {
if (filename != null && filename.length() != 0 && viewChild != null) {
String urlString = "";
try {
URL urltmp = Fileio.getURL(filename + "." +
SetupInfo.getProperty(SetupInfo.PRESENT_LANGUAGE) + ".html", "doc");
if (urltmp == null) {
//if it cant be found, then just get english as the default
urltmp = Fileio.getURL(filename + ".en.html", "doc");
}
urlString = urltmp.toString();
if (extention != null && extention.length() != 0) {
urlString = urlString + "#" + extention;
}
infoviewer.InfoViewerPlugin.openURL((org.gjt.sp.jedit.View) viewChild, urlString);
//viewChild.requestFocus();
} catch (Exception e) {
Log.log(Log.ERROR, "ShowContextHelp", "could not find helpfile="
+ urlString + " : error=" + e);
}
}
}//}}}
//{{{ +_ShowTutorial(org.gjt.sp.jedit.View)_ : void
/**
* Description of the Method
*
* @param view Description of the Parameter
*/
public static void ShowTutorial(org.gjt.sp.jedit.View view) {
JDialog jd = new JDialog(view, Translator.getTranslation("Tutorial"), false);
InfoViewer iv = new InfoViewer(view, "");
String urlString = null;
int inset = 100;
try {
URL urltmp = Fileio.getURL("tutorialmain." +
SetupInfo.getProperty(SetupInfo.PRESENT_LANGUAGE) + ".html", "tutorial");
if (urltmp == null) {
//if it cant be found, then just get english as the default
urltmp = Fileio.getURL("tutorialmain.en.html", "tutorial");
}
urlString = urltmp.toString();
iv.gotoURL(urlString);
jd.getContentPane().add(iv);
jd.pack();
Rectangle rv = new Rectangle();
if (view != null) {
view.getBounds(rv);
jd.setSize((int) (rv.width - inset), (int) (rv.height - inset));
jd.setLocationRelativeTo(view);
} else {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
jd.setBounds(inset / 2, inset / 2,
screenSize.width - inset,
screenSize.height - inset);
}
jd.setVisible(true);
} catch (Exception e) {
Log.log(Log.ERROR, "ShowTutorial", "could not find helpfile="
+ urlString + " : error=" + e);
}
}//}}}
}