http://www.jpicedt.org

jpicedt.ui.util
Class RunExternalCommand

java.lang.Object
  extended by java.lang.Thread
      extended by jpicedt.ui.util.RunExternalCommand
All Implemented Interfaces:
Runnable

public class RunExternalCommand
extends Thread

A class implementing methods for calling external processes like latex, (x)dvi, ghostscript… on the current picture file (e.g. the active internal frame)

A "tmp" file is generated on-the-fly in the "tmp" directory of the underlying platform, This tmp file contains an adequate preamble (e.g. \\usepackage{epic}) depending on current options, and LaTeX commands (or PsTricks or eepic commands) corresponding to each object found in the given picture.

These command lines may include the following special symbols:

E.g.: kghostview {p}{f}.ps or "{i}\windows\miktex\jlatex.bat" "{p}" {f} "{d}"

Since we don't want to resort on platform dependent tricks (working dirs, PATH variables, root directory names differing on UNIX and Win32 systems, latex command line which might also differ, aso&helllip;), the better thing the user could do is to write one batch/shell script per process he wants to launch, then provide the names of these scripts to PicEdt.

Scripts are easy to write on UNIX/Window platforms, and very likely on MacOS platforms by using AppleScript.

Since:
PicEdt 1.2
Version:
$Id: RunExternalCommand.java,v 1.19 2013/03/27 06:50:11 vincentb1 Exp $
Author:
Sylvain Reynal

Nested Class Summary
static class RunExternalCommand.Command
          Enum for predefined external commands
 class RunExternalCommand.DlgBoxDisplayProcessIOStream
          An inner class implementing a JDialog to display external process inputStream and send keyboard events to process outputStream
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static boolean isGUI
           
static EnumSet<RunExternalCommand.Command> TeX_COMMANDS
          members of Command enum that are TeX related external commands
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RunExternalCommand(Drawing drawing, ContentType contentType, RunExternalCommand.Command commandToRun, MDIManager mdimgr)
           
RunExternalCommand(Drawing drawing, ContentType contentType, String cmdLine, boolean isWriteTmpTeXfile)
          Mostly for debugging purpose, or when used outside the jpicedt.ui package (since then JPicEdt.preferences are no longer available).
 
Method Summary
static void cleanTmpDir()
          Delete files created by JPicEdt or programms called by JPicEdt (LaTeX, dvips,…).
static AbstractCustomizer createCustomizer(Properties preferences)
           
static void createTmpFile()
          Create a new tmp file if it doesn't exit yet
static String getAddonDir()
           
static File getTmpFile()
           
static String getTmpFilePrefix()
           
static String getTmpPath()
           
 void openUI()
           
 void run()
          run an external process as a thread (overloading Thread.run() method) we then pipe the process std output to a JTextArea
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TeX_COMMANDS

public static final EnumSet<RunExternalCommand.Command> TeX_COMMANDS
members of Command enum that are TeX related external commands


isGUI

public static boolean isGUI
Constructor Detail

RunExternalCommand

public RunExternalCommand(Drawing drawing,
                          ContentType contentType,
                          RunExternalCommand.Command commandToRun,
                          MDIManager mdimgr)
Parameters:
drawing - The target document upon which the command will acts
contentType - the content-type used to format the document
commandToRun - one of the predefined constant fields (e.g. LATEX, DVIVIEWER, DVIPS or GHOSTVIEW)
Since:
jPicEdt 1.2

RunExternalCommand

public RunExternalCommand(Drawing drawing,
                          ContentType contentType,
                          String cmdLine,
                          boolean isWriteTmpTeXfile)
Mostly for debugging purpose, or when used outside the jpicedt.ui package (since then JPicEdt.preferences are no longer available).

Parameters:
drawing - The target document upon which the command will acts
contentType - the content-type used to format the document
cmdLine - a string containing the command to be executed (e.g. "ext_prod.sh {p} latex {f}")
Since:
jPicEdt 1.4pre5
Method Detail

getTmpFile

public static File getTmpFile()

getTmpPath

public static String getTmpPath()

getTmpFilePrefix

public static String getTmpFilePrefix()

openUI

public void openUI()

run

public void run()
run an external process as a thread (overloading Thread.run() method) we then pipe the process std output to a JTextArea

Specified by:
run in interface Runnable
Overrides:
run in class Thread
Since:
PicEdt 1.2

cleanTmpDir

public static void cleanTmpDir()
Delete files created by JPicEdt or programms called by JPicEdt (LaTeX, dvips,…).


getAddonDir

public static String getAddonDir()
Returns:
the add-ons directory w/o trailing "/"

createTmpFile

public static void createTmpFile()
                          throws IOException
Create a new tmp file if it doesn't exit yet

Throws:
IOException - if an error occurs

createCustomizer

public static AbstractCustomizer createCustomizer(Properties preferences)
Returns:
an AbstractCustomizer suited for editing Properties related to external commands

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org