Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jpicedt.ui.util
Class RunExternalCommand  view RunExternalCommand download RunExternalCommand.java

java.lang.Object
  extended byjava.lang.Thread
      extended byjpicedt.ui.util.RunExternalCommand
All Implemented Interfaces:
java.lang.Runnable

public class RunExternalCommand
extends java.lang.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 :
- {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

Nested Class Summary
private static class RunExternalCommand.Customizer
          A Customizer for the configuration of external commands preferences.
 class RunExternalCommand.DlgBoxDisplayProcessIOStream
          An inner class implementing a JDialog to display external process inputStream and send keyboard events to process outputStream
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static java.lang.String addonDir
           
private  java.lang.String commandLine
           
private  java.lang.String commandToRun
           
private  jpicedt.graphic.ContentType contentType
           
static java.lang.String DEFAULT_DVI_COMMAND
          default commands parameters
static java.lang.String DEFAULT_DVIPS_COMMAND
          default commands parameters
static java.lang.String DEFAULT_GS_COMMAND
          default commands parameters
static java.lang.String DEFAULT_LATEX_COMMAND
          default commands parameters
static java.lang.String DEFAULT_USER1_COMMAND
          default commands parameters
static java.lang.String DEFAULT_USER2_COMMAND
          default commands parameters
private  jpicedt.graphic.model.Drawing drawing
           
static java.lang.String DVIPS
          static field defining an external commands, and also used by ActionDispatcher
static java.lang.String DVIVIEWER
          static field defining an external commands, and also used by ActionDispatcher
static java.lang.String GHOSTVIEW
          static field defining an external commands, and also used by ActionDispatcher
static java.lang.String KEY_DVIPS
          key used to fetch command parameters from a Properties object
static java.lang.String KEY_DVIVIEWER
          key used to fetch command parameters from a Properties object
static java.lang.String KEY_GHOSTVIEW
          key used to fetch command parameters from a Properties object
static java.lang.String KEY_LATEX
          key used to fetch command parameters from a Properties object
static java.lang.String KEY_USER1
          key used to fetch command parameters from a Properties object
static java.lang.String KEY_USER2
          key used to fetch command parameters from a Properties object
static java.lang.String LATEX
          static field defining an external commands, and also used by ActionDispatcher
private  java.io.PrintStream printStream
           
private  java.lang.Process proc
           
private static java.io.File tmpFile
           
private static java.lang.String tmpFilePrefix
           
private static java.lang.String tmpPath
           
static java.lang.String USER1
          static field defining an external commands, and also used by ActionDispatcher
static java.lang.String USER2
          static field defining an external commands, and also used by ActionDispatcher
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RunExternalCommand(jpicedt.graphic.model.Drawing drawing, jpicedt.graphic.ContentType contentType, java.lang.String commandToRun)
           
 
Method Summary
private  java.lang.String buildCommandLine(java.lang.String command)
          Build the real command line by replacing occurences of special symbols ({f}, {p},...) in the given string by their actual value
static void cleanTmpDir()
          Delete files created by JPicEdt or programms called by JPicEdt (LaTeX, dvips,...).
static jpicedt.graphic.toolkit.AbstractCustomizer createCustomizer(java.util.Properties preferences)
           
static void createTmpFile()
          Create a new tmp file if it doesn't exit yet
static java.lang.String getAddonDir()
          Return the add-ons directory w/o trailing "/"
 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, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, 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

LATEX

public static final java.lang.String LATEX
static field defining an external commands, and also used by ActionDispatcher

See Also:
Constant Field Values

DVIVIEWER

public static final java.lang.String DVIVIEWER
static field defining an external commands, and also used by ActionDispatcher

See Also:
Constant Field Values

DVIPS

public static final java.lang.String DVIPS
static field defining an external commands, and also used by ActionDispatcher

See Also:
Constant Field Values

GHOSTVIEW

public static final java.lang.String GHOSTVIEW
static field defining an external commands, and also used by ActionDispatcher

See Also:
Constant Field Values

USER1

public static final java.lang.String USER1
static field defining an external commands, and also used by ActionDispatcher

See Also:
Constant Field Values

USER2

public static final java.lang.String USER2
static field defining an external commands, and also used by ActionDispatcher

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

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

drawing

private jpicedt.graphic.model.Drawing drawing

contentType

private jpicedt.graphic.ContentType contentType

proc

private java.lang.Process proc

printStream

private java.io.PrintStream printStream

commandToRun

private java.lang.String commandToRun

commandLine

private java.lang.String commandLine

tmpFile

private static java.io.File tmpFile

tmpPath

private static java.lang.String tmpPath

tmpFilePrefix

private static java.lang.String tmpFilePrefix

addonDir

private static java.lang.String addonDir
Constructor Detail

RunExternalCommand

public RunExternalCommand(jpicedt.graphic.model.Drawing drawing,
                          jpicedt.graphic.ContentType contentType,
                          java.lang.String commandToRun)
Since:
jPicEdt 1.2
Method Detail

buildCommandLine

private java.lang.String buildCommandLine(java.lang.String command)
Build the real command line by replacing occurences of special symbols ({f}, {p},...) in the given string by their actual value

Since:
PicEdt 1.2

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

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.IOException
Create a new tmp file if it doesn't exit yet


createCustomizer

public static jpicedt.graphic.toolkit.AbstractCustomizer createCustomizer(java.util.Properties preferences)