com.izforge.izpack.panels.userinput.field.search
Class SearchField

java.lang.Object
  extended by com.izforge.izpack.panels.userinput.field.Field
      extended by com.izforge.izpack.panels.userinput.field.search.SearchField

public class SearchField
extends Field

Search field.

Author:
Tim Anderson

Constructor Summary
SearchField(SearchFieldConfig config, InstallData installData)
          Constructs a SearchField.
 
Method Summary
 String getCheckFilename()
          Returns the filename to check the existence of.
 List<String> getChoices()
          Returns the search choices.
 List<String> getChoices(List<String> choices)
          Returns the search choices depending on a given list of pre-selected choices.
 String getFilename()
          Returns the name of the file to search for.
 String getResult(String item)
          Return the result of the search according to result type.
 ResultType getResultType()
          Returns the result type.
 int getSelectedIndex()
          Returns the index of the selected choice.
 SearchType getType()
          Returns the search type.
 boolean pathMatches(String path)
          check whether the given path matches
static String resolveEnvValue(String path, Map<String,String> env)
          Resolve Windows environment variables
 
Methods inherited from class com.izforge.izpack.panels.userinput.field.Field
getDefaultValue, getDescription, getDescription, getInitialValue, getInstallData, getLabel, getLabel, getOmitFromAuto, getOsModels, getPacks, getProcessors, getSize, getSummaryKey, getTooltip, getValue, getVariable, isConditionTrue, isEffectiveDisplayHidden, isEffectiveReadonly, replaceVariables, setSaving, setValue, setVariable, validate, validate, wrapDefaultValue, wrapInitialValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchField

public SearchField(SearchFieldConfig config,
                   InstallData installData)
Constructs a SearchField.

Parameters:
config - the field configuration
installData - the installation data
Throws:
IzPackException - if the field cannot be read
Method Detail

getFilename

public String getFilename()
Returns the name of the file to search for.

Returns:
the name of the file to search for. May be null if searching for directories

getCheckFilename

public String getCheckFilename()
Returns the filename to check the existence of.

This is used when searching for directories; the file name is appended to a directory to determine if the correct directory has been located.

Returns:
the filename to to check the existence of. May be null

getType

public SearchType getType()
Returns the search type.

Returns:
the search type

getResultType

public ResultType getResultType()
Returns the result type.

Returns:
the result type

getChoices

public List<String> getChoices()
Returns the search choices. Checks whether a placeholder item is in the combobox and resolve the paths automatically: /usr/lib/* searches all folders in usr/lib to find /usr/lib/*/lib/tools.jar

Returns:
the search choices

getChoices

public List<String> getChoices(List<String> choices)
Returns the search choices depending on a given list of pre-selected choices. Checks whether a placeholder item is in the combobox and resolve the paths automatically: /usr/lib/* searches all folders in usr/lib to find /usr/lib/*/lib/tools.jar

Returns:
the search choices

getSelectedIndex

public int getSelectedIndex()
Returns the index of the selected choice.

Returns:
the selected index or -1 if no choice is selected

resolveEnvValue

public static String resolveEnvValue(String path,
                                     Map<String,String> env)
Resolve Windows environment variables

Parameters:
path - - eg: "%JAVA_HOME%\\bin"
env - - System.getenv() (or forced config for testing)

pathMatches

public boolean pathMatches(String path)
check whether the given path matches


getResult

public String getResult(String item)
Return the result of the search according to result type.

Sometimes, the whole path of the file is wanted, sometimes only the directory where the file is in, sometimes the parent directory.

Returns:
null on error


Copyright © 2018. All rights reserved.