ucar.unidata.idv
Class ArgsManager

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.ArgsManager
All Implemented Interfaces:
ActionListener, EventListener, IdvConstants

public class ArgsManager
extends IdvManager

This manages the parsing and processing of the command line arguments to the IDV. If an IDV application needs to add custom command line arguments then you need to do:

Author:
IDV development team

Field Summary
 List argDisplayB64Xml
          A list of the base 64 encoded in line display xml files
 List argXidvFiles
          A list (String) of the bundle sources (files and/or urls) passed in on the command line.
 List b64Bundles
          A list of the base 64 encoded in line bundles.
protected  List fileMappingFiles
          Holds the set files arguments
protected  List fileMappingIds
          Holds the set files arguments
 List installPlugins
          List of plugins
protected  String jythonCode
          Jython code that should be evaluated at startup time
protected  boolean listResources
          Should we list out the resources for debugging
protected  boolean noGui
          Should any guis be shown
protected  List persistentCommandLineArgs
          This holds the command line arguments that should be written out in saved jnlp files (e.g., .properties)
 List plugins
          List of plugins
protected  boolean printJnlpBundles
          Shuold the embedded bundles in jnlp files be printed out
static int RUNNABLE_MAX_TRIES
          How many times to try to run the initial runnables
 List scriptingFiles
          List of isl files
 String testArchive
          The name of the test archive when we are in test archive writing mode
 String testDir
          The name of the test directory when we are in test archive writing mode
 boolean testEval
          Created when we see the -testeval command line argument.
 boolean testMode
          Created when we see the -test command line argument.
static String USAGE_MESSAGE
          usage message
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_TIMEZONE, FILE_VMSTATE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, NULL_STRING, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_HISTORY, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAXIMAGESIZE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Constructor Summary
ArgsManager(IntegratedDataViewer idv, String[] args)
          Create the manager with the given idv and command line arguments.
 
Method Summary
protected  boolean checkArg(String arg, String lookingFor, String[] args, int idx, int howManyMore)
          A utility method for checking the argument array.
 String getCollabHostName()
          Get the host name for the collab server
 int getCollabPort()
          Port for collab server
 boolean getDoCollabServer()
          Should we start up a collab server
 String getFixedTimeString()
          the fixed time index string
 List getInitCatalogs()
          Method to return the initial catalogs
 boolean getIslInteractive()
          Is isl interactive mode
 boolean getIsOffScreen()
          running in offscreen mode
 boolean getNoGui()
          Should we create any GUIs
 String[] getOriginalArgs()
          Get the very original command line arguments.
protected  String getUsageMessage()
          Return the command line usage message.
protected  void initDone()
          Called by the IDV when its initialization is complete.
static boolean isBundleFile(String name)
           
static boolean isDisplayXmlFile(String name)
          Helper method to determine if the given filename is a display xml file
static boolean isIslFile(String name)
          Helper method to determine if the given filename is an isl file
static boolean isJnlpFile(String name)
          Helper method to determine if the given filename is a jnlp file
static boolean isRbiFile(String name)
          Helper method to determine if the given filename is a resource bundle file
static boolean isXidvFile(String name)
          Helper method to determine if the given filename is a xidv bundle file
static boolean isZidvFile(String name)
          is file a zidv file
protected  String msg(String arg, String desc)
          Utility to format the usage message line
protected  int parseArg(String arg, String[] args, int idx)
          Check the argument given by the arg parameter.
 void parseArgs()
          Parse the command line arguments.
protected  void parseArgs(String[] args)
          Parse the given argument array.
protected  String[] preprocessArgs(String[] args)
          Check for any .jnlp files in the command line.
protected  void processInitialBundles()
          Gets called by the IDV to process the set of initial files, e.g., default bundles, command line bundles, jnlp files, etc.
 void processInstanceArgs(String[] args)
          Process the command line argument we got passed form another instance of the idv
 void setIsOffScreen(boolean v)
          set running in offscreen mode
 void usage(String err)
          Print out the command line usage message and exit
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getJythonManager, getPersistenceManager, getPreferenceManager, getProperty, getProperty, getProperty, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getStore, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
actionPerformed, close, doMakeContents, getContents, getDialog, getFrame, getWindow, getWindowTitle, isShowing, removeAll, setWindowTitle, shouldMakeDialog, show, show, showModal, toFront, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USAGE_MESSAGE

public static final String USAGE_MESSAGE
usage message

See Also:
Constant Field Values

RUNNABLE_MAX_TRIES

public static final int RUNNABLE_MAX_TRIES
How many times to try to run the initial runnables

See Also:
Constant Field Values

listResources

protected boolean listResources
Should we list out the resources for debugging


persistentCommandLineArgs

protected List persistentCommandLineArgs
This holds the command line arguments that should be written out in saved jnlp files (e.g., .properties)


testMode

public boolean testMode
Created when we see the -test command line argument. Turns on testings.


testEval

public boolean testEval
Created when we see the -testeval command line argument.


testArchive

public String testArchive
The name of the test archive when we are in test archive writing mode


testDir

public String testDir
The name of the test directory when we are in test archive writing mode


noGui

protected boolean noGui
Should any guis be shown


jythonCode

protected String jythonCode
Jython code that should be evaluated at startup time


argXidvFiles

public List argXidvFiles
A list (String) of the bundle sources (files and/or urls) passed in on the command line.


argDisplayB64Xml

public List argDisplayB64Xml
A list of the base 64 encoded in line display xml files


b64Bundles

public List b64Bundles
A list of the base 64 encoded in line bundles. This argument is mostly used for the jnlp files that hold a bundle From the IdvConstants.ARG_B64BUNDLE argument.


plugins

public List plugins
List of plugins


installPlugins

public List installPlugins
List of plugins


printJnlpBundles

protected boolean printJnlpBundles
Shuold the embedded bundles in jnlp files be printed out


scriptingFiles

public List scriptingFiles
List of isl files


fileMappingIds

protected List fileMappingIds
Holds the set files arguments


fileMappingFiles

protected List fileMappingFiles
Holds the set files arguments

Constructor Detail

ArgsManager

public ArgsManager(IntegratedDataViewer idv,
                   String[] args)
Create the manager with the given idv and command line arguments. This just sets some state, it does not yet parse the arguments. The IDV needs to call parseArgs()

Parameters:
idv - The IDV
args - Command line arguments
Method Detail

getOriginalArgs

public String[] getOriginalArgs()
Get the very original command line arguments. The ones before we pre-process them.

Returns:
The command line args

getInitCatalogs

public List getInitCatalogs()
Method to return the initial catalogs

Returns:
List of urls for the catalogs to show at start up time

initDone

protected void initDone()
Called by the IDV when its initialization is complete. This method will popup the chooser manager if needed, run any initRunnables, and run any event capture files.


isDisplayXmlFile

public static boolean isDisplayXmlFile(String name)
Helper method to determine if the given filename is a display xml file

Parameters:
name - The file name
Returns:
Is the file a display xml file

isXidvFile

public static boolean isXidvFile(String name)
Helper method to determine if the given filename is a xidv bundle file

Parameters:
name - The file name
Returns:
Is the file a bundle file

isBundleFile

public static boolean isBundleFile(String name)

isIslFile

public static boolean isIslFile(String name)
Helper method to determine if the given filename is an isl file

Parameters:
name - The file name
Returns:
Is the file a bundle file

isZidvFile

public static boolean isZidvFile(String name)
is file a zidv file

Parameters:
name - file
Returns:
is zidv

isRbiFile

public static boolean isRbiFile(String name)
Helper method to determine if the given filename is a resource bundle file

Parameters:
name - The file name
Returns:
Is the file a resource bundle file

isJnlpFile

public static boolean isJnlpFile(String name)
Helper method to determine if the given filename is a jnlp file

Parameters:
name - The file name
Returns:
Is the file a jnlp file

getNoGui

public boolean getNoGui()
Should we create any GUIs

Returns:
The no gui flag

usage

public void usage(String err)
Print out the command line usage message and exit

Parameters:
err - The usage message

msg

protected String msg(String arg,
                     String desc)
Utility to format the usage message line

Parameters:
arg - arg
desc - desc
Returns:
Formatted message

getIslInteractive

public boolean getIslInteractive()
Is isl interactive mode

Returns:
isl interactive

getUsageMessage

protected String getUsageMessage()
Return the command line usage message. Can be overwritten by derived classes to add in their own usage message.

Returns:
The usage message

preprocessArgs

protected String[] preprocessArgs(String[] args)
Check for any .jnlp files in the command line. If there are any then recurse and process the command line arguments in the jnlp file.

Parameters:
args - The incoming argument array
Returns:
The preprocessed argument array

parseArgs

public void parseArgs()
               throws Exception
Parse the command line arguments.

Throws:
Exception - When something untoward happens

parseArgs

protected void parseArgs(String[] args)
                  throws Exception
Parse the given argument array. If there are any errors then call usage (which will exit).

Parameters:
args - The command line arguments
Throws:
Exception - When something untoward happens

checkArg

protected boolean checkArg(String arg,
                           String lookingFor,
                           String[] args,
                           int idx,
                           int howManyMore)
A utility method for checking the argument array. If arg not equal to lookingFor then simply return false. Else make sure that the given args array has at least howManyMore entries ahead of the given idx. If not then fail by calling usage.

Parameters:
arg - The current value in the args array
lookingFor - The flag we are looking for
args - The full args array
idx - The index of the current arg
howManyMore - If arg==lookingFor then this is how many more values the lookingFor flag requires. If there are not that many left in the args array then call usage and exit
Returns:
Does the given arg match the given lookingFor value

parseArg

protected int parseArg(String arg,
                       String[] args,
                       int idx)
                throws Exception
Check the argument given by the arg parameter. The idx parameter points to the next unprocessed entry in the args array. If the argument requires one or more values in the args array then increment idx accordingly. Return idx.

Parameters:
arg - The current argument we are looking at
args - The full args array
idx - The index into args that we are looking at
Returns:
The idx of the last value in the args array we look at. i.e., if the flag arg does not require any further values in the args array then don't increment idx. If arg requires one more value then increment idx by one. etc.
Throws:
Exception - When something untoward happens

processInitialBundles

protected void processInitialBundles()
                              throws VisADException,
                                     RemoteException
Gets called by the IDV to process the set of initial files, e.g., default bundles, command line bundles, jnlp files, etc.

Throws:
VisADException - When something untoward happens
RemoteException - When something untoward happens

processInstanceArgs

public void processInstanceArgs(String[] args)
Process the command line argument we got passed form another instance of the idv

Parameters:
args - command line args

getCollabHostName

public String getCollabHostName()
Get the host name for the collab server

Returns:
collab server name

getDoCollabServer

public boolean getDoCollabServer()
Should we start up a collab server

Returns:
start up a collab server

getCollabPort

public int getCollabPort()
Port for collab server

Returns:
collab server port

getFixedTimeString

public String getFixedTimeString()
the fixed time index string

Returns:
fixed time string - for later

getIsOffScreen

public boolean getIsOffScreen()
running in offscreen mode

Returns:
is offscreen

setIsOffScreen

public void setIsOffScreen(boolean v)
set running in offscreen mode

Parameters:
v - offscreen