TPTP 4.5.0 Platform Project
Internal API Specification

org.eclipse.tptp.platform.iac.administrator.internal.common
Class AdminUtil

java.lang.Object
  extended by org.eclipse.tptp.platform.iac.administrator.internal.common.AdminUtil

public class AdminUtil
extends java.lang.Object

Contains common util functions used in this plugin


Constructor Summary
AdminUtil()
           
 
Method Summary
static org.eclipse.swt.layout.GridData createFill()
          Creates a grid data object that occupies vertical and horizontal space.
static org.eclipse.swt.layout.GridData createHorizontalFill()
          Creates a grid data object that occupies horizontal space.
static org.eclipse.swt.layout.GridData createVerticalFill()
          Creates a grid data object that occupies vertical space.
static void generateConfigFile()
          Used to generate IAC's configuration file based on the options selected in the preference page
static java.lang.String getAttributeOfElement(org.w3c.dom.Document document, java.lang.String elementName, java.lang.String attributeName, int index)
          Used to get the value of an attribute of an element in the config file.
static java.lang.String getAttributeWithMoreDetails(org.w3c.dom.Document document, java.lang.String elementName, java.lang.String attributeToCheck, java.lang.String attributeValueToCheck, java.lang.String attributeToGet)
          Returns the value of the attribute specified in 'attributeToGet' that meets the following criterias: It's specified in the element called 'elementName' that contains the attribute 'attributeToCheck' with value 'attributeValueToCheck' In other words, it returns what's specified with the question mark below: <elementName attributeToCheck=attributeValueToCheck attributeToGet=?
static org.eclipse.jface.dialogs.MessageDialog getConfirmationDialog(org.eclipse.swt.widgets.Shell parentShell, java.lang.String title, java.lang.String message)
          Returns a confirmation dialog with the given parameters
static org.w3c.dom.Element getElement(org.w3c.dom.Document document, java.lang.String elementName, int index)
          Returns the element with the given specifications
static java.lang.String getElementValue(org.w3c.dom.Document document, java.lang.String elementName, int index)
          Return value of the first child of the element with the given specifications
static java.lang.String getIACBinFolder()
           
static java.lang.String getIACConfigFile()
           
static java.lang.String getIACExecutable()
           
static java.lang.String getIACHome()
           
static java.io.File[] getIACPlugins()
           
static java.lang.String getJVMExecutable()
           
static java.lang.String getJVMExecutable(java.lang.String jvmLocation)
           
static java.lang.String getJvmtiNativePath()
           
static java.lang.String getPluginsFolder()
           
static java.lang.String getShutdownCommand()
           
static boolean isConfigEmpty()
           
static boolean isConfigurationValid()
          This function checks to see whether the main config file and the config file for the execution framework are valid.
static boolean isIACConfigFileWritable()
           
static boolean isSupportedPlatform()
           
static void openErrorDialog(java.lang.String title, java.lang.String message)
           
static org.w3c.dom.Document parseFile(java.lang.String fileName)
          Provided for backward compatibility
static org.w3c.dom.Document parseFile(java.lang.String fileName, boolean validation)
          Used to parse the given XML file.
static boolean validString(java.lang.String stringToCheck)
          True if stringToCheck is not NULL or empty; false otherwise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminUtil

public AdminUtil()
Method Detail

validString

public static boolean validString(java.lang.String stringToCheck)
True if stringToCheck is not NULL or empty; false otherwise


parseFile

public static org.w3c.dom.Document parseFile(java.lang.String fileName,
                                             boolean validation)
Used to parse the given XML file. This is only used in the JUnits to parse and verify the config file

Parameters:
fileName - The absolute path of the XML file to parse
validation - DTD validation. set to true if DTD validation is required; false otherwise
Returns:
The parsed Document object

parseFile

public static org.w3c.dom.Document parseFile(java.lang.String fileName)
Provided for backward compatibility

Parameters:
fileName -
Returns:

getAttributeWithMoreDetails

public static java.lang.String getAttributeWithMoreDetails(org.w3c.dom.Document document,
                                                           java.lang.String elementName,
                                                           java.lang.String attributeToCheck,
                                                           java.lang.String attributeValueToCheck,
                                                           java.lang.String attributeToGet)
Returns the value of the attribute specified in 'attributeToGet' that meets the following criterias: It's specified in the element called 'elementName' that contains the attribute 'attributeToCheck' with value 'attributeValueToCheck' In other words, it returns what's specified with the question mark below: <elementName attributeToCheck=attributeValueToCheck attributeToGet=?>

Returns:
The value of the question mark above; empty string if it can't be found

getAttributeOfElement

public static java.lang.String getAttributeOfElement(org.w3c.dom.Document document,
                                                     java.lang.String elementName,
                                                     java.lang.String attributeName,
                                                     int index)
Used to get the value of an attribute of an element in the config file. If the attribute does not exist, an empty string is returned.

Parameters:
document - Document to look in
elementName - The name of the element the attribute belongs to
attributeName - The attribute we're interested in
index - Indicates which element we should look into, incase there are multiple elements with the name specified in elementName
Returns:
The value of the requested attribute, empty string if it doesn't exist

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Document document,
                                               java.lang.String elementName,
                                               int index)
Return value of the first child of the element with the given specifications

Parameters:
document - Document to look in
elementName - Name of the element
index - The index of the element. In case there are multiple elements with the given name in the document
Returns:
Element with the given specifications

getElement

public static org.w3c.dom.Element getElement(org.w3c.dom.Document document,
                                             java.lang.String elementName,
                                             int index)
Returns the element with the given specifications

Parameters:
document - Document to look in
elementName - Name of the element
index - The index of the element. In case there are multiple elements with the given name in the document
Returns:
Element with the given specifications

createFill

public static org.eclipse.swt.layout.GridData createFill()
Creates a grid data object that occupies vertical and horizontal space.


createHorizontalFill

public static org.eclipse.swt.layout.GridData createHorizontalFill()
Creates a grid data object that occupies horizontal space.


createVerticalFill

public static org.eclipse.swt.layout.GridData createVerticalFill()
Creates a grid data object that occupies vertical space.


getIACPlugins

public static java.io.File[] getIACPlugins()
Returns:
an array of Files, one for each non-jarred plugin that contains a config.jar file in its root
Throws:
java.io.IOException

generateConfigFile

public static void generateConfigFile()
Used to generate IAC's configuration file based on the options selected in the preference page


getIACHome

public static java.lang.String getIACHome()
Returns:
The absolute folder of IAC. This method IS platform dependent. Returns null if the absolute folder of IAC cannot be resolved. Callers should always check for the null value and handle it gracefully.

getPluginsFolder

public static java.lang.String getPluginsFolder()
Returns:
The absolute location of the plugins folder that should be used by IAC This should be the same "plugins" folder as the workbench

isConfigEmpty

public static boolean isConfigEmpty()
Returns:
true if IAC's config file needs to be generated (i.e. either IAC's config file doesn't exist or doesn't have anything in it).

getJVMExecutable

public static java.lang.String getJVMExecutable()
Returns:
The absolute location of the JVM executable for the workbench

getJVMExecutable

public static java.lang.String getJVMExecutable(java.lang.String jvmLocation)
Returns:
The absolute location of the JVM executable for the given JVM

getIACExecutable

public static java.lang.String getIACExecutable()
Returns:
Absolute location of IAC's executable (e.g. RAServer.exe). Null if IAC executable can't be resolved

getShutdownCommand

public static java.lang.String getShutdownCommand()
Returns:
The shutdown command that should be used to terminate IAC

getIACConfigFile

public static java.lang.String getIACConfigFile()
Returns:
Absolute location of IAC's config file

isIACConfigFileWritable

public static boolean isIACConfigFileWritable()
Returns:
true if IAC config file is readable and writable; if not exisit then try to create one.

getIACBinFolder

public static java.lang.String getIACBinFolder()
Returns:
Absolute location of IAC's bin folder. Returns null if IAC's bin folder can't be found. Callers should always check for the null value and handle it gracefully.

getConfirmationDialog

public static org.eclipse.jface.dialogs.MessageDialog getConfirmationDialog(org.eclipse.swt.widgets.Shell parentShell,
                                                                            java.lang.String title,
                                                                            java.lang.String message)
Returns a confirmation dialog with the given parameters


getJvmtiNativePath

public static java.lang.String getJvmtiNativePath()
Returns:
The absolute path of the JVMTI native files. Returns null if location of native files can't be resolved. Callers should always check for null.

isConfigurationValid

public static boolean isConfigurationValid()
This function checks to see whether the main config file and the config file for the execution framework are valid. It also checks to see whether the Workbench JVM matches the JVM specified in IAC's config file. This is done to make sure that IAC's config file is never in an invalid state.

Returns:
True iff the main config file and the config file for the execution framework are valid AND workbench JVM matches the JVM specified in IAC's config file; false otherwise

isSupportedPlatform

public static boolean isSupportedPlatform()

openErrorDialog

public static void openErrorDialog(java.lang.String title,
                                   java.lang.String message)

TPTP 4.5.0 Platform Project
Internal API Specification