Class RunExternalCommand
- java.lang.Object
-
- java.lang.Thread
-
- jpicedt.ui.util.RunExternalCommand
-
- All Implemented Interfaces:
java.lang.Runnable
public class RunExternalCommand extends java.lang.ThreadA 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 :
- {f} : tmp file name w/o extension (the user need to specify explicitely any extension required by the external program)
- {p} : tmp file path including trailing separator
- {i} : jPicEdt add-ons dir, that is : "jpicedt.home/add-ons" (trailing separtor excluded)Ex : kghostview {p}{f}.ps or {i}run_latex.bat {p}{f}
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...), 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.10.2.1 2007/09/02 11:56:30 reynal Exp $
- Author:
- Sylvain Reynal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRunExternalCommand.DlgBoxDisplayProcessIOStreamAn inner class implementing a JDialog to display external process inputStream and send keyboard events to process outputStream
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBITMAP_CREATIONstatic field defining an external bitmap creation command, and also used by ActionLocalizerstatic java.lang.StringDEFAULT_BITMAP_CREATION_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_DVI_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_DVIPS_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_GS_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_LATEX_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_USER1_COMMANDdefault commands parametersstatic java.lang.StringDEFAULT_USER2_COMMANDdefault commands parametersstatic java.lang.StringDVIPSstatic field defining an external "dvips" command, and also used by ActionLocalizerstatic java.lang.StringDVIVIEWERstatic field defining an external "xdvi" (or similar) command, and also used by ActionLocalizerstatic java.lang.StringGHOSTVIEWstatic field defining an external "gv" (or similar) command, and also used by ActionLocalizerstatic booleanisGUIstatic java.lang.StringKEY_BITMAP_CREATIONkey used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_DVIPSkey used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_DVIVIEWERkey used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_GHOSTVIEWkey used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_LATEXkey used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_USER1key used to fetch command parameters from a Properties objectstatic java.lang.StringKEY_USER2key used to fetch command parameters from a Properties objectstatic java.lang.StringLATEXstatic field defining an external "latex" command, and also used by ActionLocalizerstatic java.lang.StringUSER1static field defining an external user command, and also used by ActionLocalizerstatic java.lang.StringUSER2static field defining an external user command, and also used by ActionLocalizer
-
Constructor Summary
Constructors Constructor Description RunExternalCommand(Drawing drawing, ContentType contentType, java.lang.String commandToRun)RunExternalCommand(Drawing drawing, ContentType contentType, java.lang.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcleanTmpDir()Delete files created by JPicEdt or programms called by JPicEdt (LaTeX, dvips,...).static AbstractCustomizercreateCustomizer(java.util.Properties preferences)static voidcreateTmpFile()Create a new tmp file if it doesn't exit yetstatic java.lang.StringgetAddonDir()Return the add-ons directory w/o trailing "/"static java.io.FilegetTmpFile()static java.lang.StringgetTmpFilePrefix()static java.lang.StringgetTmpPath()voidrun()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, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
LATEX
public static final java.lang.String LATEX
static field defining an external "latex" command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
DVIVIEWER
public static final java.lang.String DVIVIEWER
static field defining an external "xdvi" (or similar) command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
DVIPS
public static final java.lang.String DVIPS
static field defining an external "dvips" command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
GHOSTVIEW
public static final java.lang.String GHOSTVIEW
static field defining an external "gv" (or similar) command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
USER1
public static final java.lang.String USER1
static field defining an external user command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
USER2
public static final java.lang.String USER2
static field defining an external user command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
BITMAP_CREATION
public static final java.lang.String BITMAP_CREATION
static field defining an external bitmap creation command, and also used by ActionLocalizer- See Also:
- Constant Field Values
-
KEY_LATEX
public static final java.lang.String KEY_LATEX
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_DVIVIEWER
public static final java.lang.String KEY_DVIVIEWER
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_DVIPS
public static final java.lang.String KEY_DVIPS
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_GHOSTVIEW
public static final java.lang.String KEY_GHOSTVIEW
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_USER1
public static final java.lang.String KEY_USER1
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_USER2
public static final java.lang.String KEY_USER2
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
KEY_BITMAP_CREATION
public static final java.lang.String KEY_BITMAP_CREATION
key used to fetch command parameters from a Properties object- See Also:
- Constant Field Values
-
DEFAULT_LATEX_COMMAND
public static final java.lang.String DEFAULT_LATEX_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_DVI_COMMAND
public static final java.lang.String DEFAULT_DVI_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_DVIPS_COMMAND
public static final java.lang.String DEFAULT_DVIPS_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_GS_COMMAND
public static final java.lang.String DEFAULT_GS_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_USER1_COMMAND
public static final java.lang.String DEFAULT_USER1_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_USER2_COMMAND
public static final java.lang.String DEFAULT_USER2_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
DEFAULT_BITMAP_CREATION_COMMAND
public static final java.lang.String DEFAULT_BITMAP_CREATION_COMMAND
default commands parameters- See Also:
- Constant Field Values
-
isGUI
public static boolean isGUI
-
-
Constructor Detail
-
RunExternalCommand
public RunExternalCommand(Drawing drawing, ContentType contentType, java.lang.String commandToRun)
- Parameters:
drawing- The target document upon which the command will actscontentType- the content-type used to format the documentcommandToRun- one of the predefined constant fields (e.g. LATEX, DVIVIEWER, DVIPS or GHOSTVIEW)- Since:
- jPicEdt 1.2
-
RunExternalCommand
public RunExternalCommand(Drawing drawing, ContentType contentType, java.lang.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 actscontentType- the content-type used to format the documentcmdLine- 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 java.io.File getTmpFile()
-
getTmpPath
public static java.lang.String getTmpPath()
-
getTmpFilePrefix
public static java.lang.String getTmpFilePrefix()
-
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:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.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 java.lang.String getAddonDir()
Return the add-ons directory w/o trailing "/"
-
createTmpFile
public static void createTmpFile() throws java.io.IOExceptionCreate a new tmp file if it doesn't exit yet- Throws:
java.io.IOException
-
createCustomizer
public static AbstractCustomizer createCustomizer(java.util.Properties preferences)
- Returns:
- an AbstractCustomizer suited for editing Properties related to external commands
-
-