Package org.omegat.gui.scripting
Class ScriptItem
java.lang.Object
org.omegat.gui.scripting.ScriptItem
- All Implemented Interfaces:
Comparable<ScriptItem>
A script file in the script list is represented as ScriptListFile to allow
for localization, description and reordering.
-
Constructor Summary
ConstructorsConstructorDescriptionScriptItem(@NotNull File scriptFile) Constructs a new ScriptItem based on the provided script file.ScriptItem(@NotNull String scriptSource) Creates a new ScriptItem with the specified script source. -
Method Summary
Modifier and TypeMethodDescriptionint@Nullable FilegetFile()@NotNull StringThe name of the file containing the script when the item was created from the file.@NotNull ResourceBundleWhen the properties file is provided, it returns a resource bundle for the script item.The name of the script when it is created from a file.getText()Generates a tooltip text for the script item by combining its script name and description.voidUpdates the text content of the script associated with this ScriptItem.toString()
-
Constructor Details
-
ScriptItem
Creates a new ScriptItem with the specified script source.- Parameters:
scriptSource- the source code of the script. This must not be null.
-
ScriptItem
Constructs a new ScriptItem based on the provided script file. This constructor initializes the ScriptItem with a reference to the script file and prepares any associated resources, such as a ResourceBundle for localization.- Parameters:
scriptFile- the script file to be associated with this ScriptItem. This file must not be null and should represent the source of the script.
-
-
Method Details
-
getResourceBundle
When the properties file is provided, it returns a resource bundle for the script item. Otherwise, it returns an empty resource bundle, which raises MissingResourceException when the resource is requested.- Returns:
- the resource bundle for this script item
-
getScriptName
The name of the script when it is created from a file. If the script provides a resource bundle for localization, it returns the name from the bundle. Otherwise, it returns the name of the file.- Returns:
- the name of the script
-
getFileName
The name of the file containing the script when the item was created from the file. Otherwise, it is the name of the editor script.- Returns:
- the name of the file containing the script
-
getFile
-
getDescription
-
getToolTip
Generates a tooltip text for the script item by combining its script name and description. If the description is empty, only the script name is returned.- Returns:
- the tooltip text representing the script item, combining its name and description, or just the name if the description is empty
-
getText
- Throws:
IOException
-
setText
Updates the text content of the script associated with this ScriptItem. If the source file exists, the provided text is processed for line breaks and optionally includes a BOM before being written to the file. If the source file is null, an exception is thrown.- Parameters:
text- the new text content to be written to the script's source file. This parameter must not be null.- Throws:
IOException- if the source file does not exist or an error occurs while writing to the file.
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ScriptItem>
-