public abstract class NodeResourceBundle extends java.lang.Object implements ResourceBundleWrapper, java.io.Closeable, TextBufferListener
ResourceBundleWrapper must extend NodeResourceBundle
so that the ResourceBundleManager can properly work with their implementation.
ResourceBundleManager attempts to create a resource bundle it will
use the NodeFactory to create a Node instance for the URL
that contains the data. The ResourceBundleManager will create an instance
of the implementation class using a no argument constructor and will then call
setResourceBundleNode to set the Node created by the
NodeFactory| Modifier and Type | Class and Description |
|---|---|
protected static class |
NodeResourceBundle.OperationType |
protected static class |
NodeResourceBundle.SearchType
SearchType (ALL_KEYS, EXACT_MATCH, CONTAINS_MATCH, METADATA_MATCH or CONTAINS_KEY)
|
ResourceBundleWrapper.KeyInfoEDIT_BEGIN_ATTRIBUTE, EDIT_END_ATTRIBUTE, EOL_TYPE_ATTRIBUTE, MODIFIED_ATTRIBUTE, READ_ONLY_ATTRIBUTE, RELOAD_END_ATTRIBUTE, RELOAD_START_ATTRIBUTE| Constructor and Description |
|---|
NodeResourceBundle() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
addEntry(java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
Adds a new entry (value, and optional metadata) into the resource
bundle and returns an automatically generated resource bundle key.
|
ResourceBundleOperationResult |
addEntryNoDialog(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
This method only needs to be overridden if writing into the override bundle.
|
void |
addResourceBundleListener(ResourceBundleListener listener)
Adds a
ResourceBundleListener to this resource bundle |
boolean |
allowsCreateResource()
Determines whether the bundle allows resources to be created or updated
via the select text resource ui
|
boolean |
allowsQueryType(ResourceBundleConstants.QueryTypes queryType)
Gets whether the specified query type is allowed by the bundle
|
void |
attributeUpdate(TextBuffer buffer,
int attribute)
Provides notification regarding a change to one of the buffer
attributes.
|
void |
beginEditorListening(Editor editor)
Signals the
NodeResourceBundle to begin listening to the
changes made in the editor in case it makes changes to the file the
resource bundle is based on. |
void |
close()
Called when the resource bundle is being closed by the
ResourceBundleManager |
void |
createBaseDocument()
Creates the base document for the resource bundle.
|
void |
delete()
Deletes the resource bundle
|
void |
endEditorListening(Editor editor)
Signals the
NodeResourceBundle to stop listening to the
editor. |
protected void |
fireKeyAdded(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifiying all
ResourceBundleListeners that
a key has been added |
protected void |
fireKeyChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all
ResourceBundleListeners that
a key has been changed |
protected void |
fireKeyRemoved(java.lang.String key)
Convenience method for notifying all
ResourceBundleListeners that
a key has been removed |
protected void |
fireMetadataChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all
ResourceBundleListeners that
the metadata for a key has been changed |
protected void |
fireTextChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all
ResourceBundleListeners that
the text for a key has been changed |
protected void |
fireUnknownChange() |
java.lang.String |
getBundleId()
Gets the bundle id for this resource bundle
|
ResourceBundleKeyGenerator |
getKeyGenerator()
Gets the
ResourceBundleKeyGenerator |
protected java.lang.String |
getMessageText(NodeResourceBundle.OperationType opType,
java.lang.String key) |
Node |
getResourceBundleNode()
Gets the
Node that represents the resource bundle |
ResourceBundleConstants.SearchMode |
getSearchMode()
Gets the search mode the bundle should use
|
java.lang.String |
getTooltipText()
Gets a string that can be used as a tool tip
|
ResourceBundleConstants.BundleTypes |
getType()
Gets the type of resource bundle
|
void |
insertUpdate(TextBuffer buffer,
int offset,
int count,
char[] insertedData)
Provides notification about an insertion into the
TextBuffer. |
protected static boolean |
isHeadless() |
protected boolean |
preUpdateValidation(java.lang.String key,
java.lang.String text,
boolean showWarningDialog)
Does basic validation of key and text and provides a warning dialog to let
the user know that they are modifying an existing key.
|
void |
removeResourceBundleListener(ResourceBundleListener listener)
Removes the specified
ResourceBundleListener from this resource bundle |
void |
removeUpdate(TextBuffer buffer,
int offset,
int count,
char[] removedData)
Provides notification about a removal from the
TextBuffer. |
protected void |
sendEditorChanges() |
void |
setBundleId(java.lang.String bundleId)
Sets the bundle id for this resource bundle
|
void |
setKeyGenerator(ResourceBundleKeyGenerator keyGenerator)
Sets the
ResourceBundleKeyGenerator |
void |
setResourceBundleNode(Node resourceBundleNode)
Sets the
Node that represents the resource bundle |
void |
setType(java.lang.String type)
Sets the identifier for the type of resource bundle
(for example: listResourceBundleId for list resource bundles,
propertiesBundleId for properties resource bundles, or
xliffResourceBundleId for xliff resource bundles
|
protected void |
showReadOnlyDialog() |
protected boolean |
showWarningDialog(java.lang.String key,
java.lang.String text,
NodeResourceBundle.OperationType opType)
Displays a warning message that a key is about to be overwritten
|
java.lang.String |
toString()
Gets a string that can be used for display purposes
|
ResourceBundleOperationResult |
updateEntryNoDialog(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
This should be overridden by classes that implement NodeResourceBundle.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddEntry, deleteEntry, findKeysByMetaData, findKeysByText, findKeysLikeKey, findKeysLikeText, getMetadata, getString, keySet, updateEntrypublic void setBundleId(java.lang.String bundleId)
setBundleId in interface ResourceBundleWrapperbundleId - string that identifies this bundlepublic java.lang.String getBundleId()
getBundleId in interface ResourceBundleWrapperpublic void setType(java.lang.String type)
type - string which identifies the type of bundlepublic ResourceBundleConstants.BundleTypes getType()
public void close()
throws java.io.IOException
ResourceBundleManagerclose in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void delete()
throws java.io.IOException
java.io.IOException - if the delete failspublic java.lang.String addEntry(java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
addEntry in interface ResourceBundleWrappertext - The text to be translated.metadata - Any associated metadata about the translation string.
This parameter may be nulljava.lang.NullPointerException - If text is nullpublic ResourceBundleOperationResult addEntryNoDialog(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
addEntryNoDialog in interface ResourceBundleWrapperkey - The key name to use in the resource bundle.text - The text to be translated.metadata - Any associated metadata about the translation string
This parameter may be nullprotected boolean preUpdateValidation(java.lang.String key,
java.lang.String text,
boolean showWarningDialog)
public ResourceBundleOperationResult updateEntryNoDialog(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata) throws java.lang.NullPointerException
updateEntryNoDialog in interface ResourceBundleWrapperkey - The key to updatetext - The new text for the given keymetadata - Any metadata to change. Existing metadata is merged with
the new metadata, unless there is a key with a null value, then the
existing metadata for that key is removed. If metadata is
null then the existing metadata will be unchanged.java.lang.NullPointerExceptionpublic Node getResourceBundleNode()
Node that represents the resource bundlepublic void setResourceBundleNode(Node resourceBundleNode)
Node that represents the resource bundleresourceBundleNode - the node that represents the resource bundlepublic void setKeyGenerator(ResourceBundleKeyGenerator keyGenerator)
ResourceBundleKeyGeneratorsetKeyGenerator in interface ResourceBundleWrapperkeyGenerator - the resource bundle key generatorpublic ResourceBundleKeyGenerator getKeyGenerator()
ResourceBundleKeyGeneratorgetKeyGenerator in interface ResourceBundleWrapperpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getTooltipText()
public boolean allowsCreateResource()
public ResourceBundleConstants.SearchMode getSearchMode()
public boolean allowsQueryType(ResourceBundleConstants.QueryTypes queryType)
queryType - supported types are ResourceBundleConstants.QueryType.ALL,
ResourceBundleConstants.QueryType.KEY, ResourceBundleContants.QueryType.TEXT,
and ResourceBundleContants.QueryType.COMMENTpublic void addResourceBundleListener(ResourceBundleListener listener) throws java.lang.NullPointerException
ResourceBundleListener to this resource bundleaddResourceBundleListener in interface ResourceBundleWrapperlistener - the listener to addjava.lang.NullPointerExceptionResourceBundleListener,
ResourceBundleEventpublic void removeResourceBundleListener(ResourceBundleListener listener) throws java.lang.NullPointerException
ResourceBundleListener from this resource bundleremoveResourceBundleListener in interface ResourceBundleWrapperlistener - the listener to removejava.lang.NullPointerExceptionResourceBundleListener,
ResourceBundleEventpublic void createBaseDocument()
protected static boolean isHeadless()
protected java.lang.String getMessageText(NodeResourceBundle.OperationType opType, java.lang.String key)
protected void showReadOnlyDialog()
protected boolean showWarningDialog(java.lang.String key,
java.lang.String text,
NodeResourceBundle.OperationType opType)
key - the key that will be overwrittentext - the text that will be used to overwrite the existing textopType - the type of operation being performedpublic void beginEditorListening(Editor editor)
NodeResourceBundle to begin listening to the
changes made in the editor in case it makes changes to the file the
resource bundle is based on. The default implementation listens to changes
in the text buffer and sets the hasChanged to true when there
are changes.editor - the editor to begin listening topublic void endEditorListening(Editor editor)
NodeResourceBundle to stop listening to the
editor. text buffer the resource bundle is based on because the node has been
closed in an Editor.editor - the editor to stop listening toprotected void sendEditorChanges()
protected void fireKeyAdded(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
ResourceBundleListeners that
a key has been addedkey - the key that has been addedtext - the text for the keymetadata - the metadata for the keyprotected void fireKeyRemoved(java.lang.String key)
ResourceBundleListeners that
a key has been removedkey - the key that has been removedprotected void fireKeyChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
ResourceBundleListeners that
a key has been changedkey - the key that has been changedtext - the text for the key that has been changedmetadata - the metadata for the key that has been changedprotected void fireTextChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
ResourceBundleListeners that
the text for a key has been changedkey - the key that has been changedtext - the text for the key that has been changedmetadata - the metadata for the key that has been changedprotected void fireUnknownChange()
protected void fireMetadataChanged(java.lang.String key,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.String> metadata)
ResourceBundleListeners that
the metadata for a key has been changedkey - the key that has been changedtext - the text for the key that has been changedmetadata - the metadata for the key that has been changedpublic void insertUpdate(TextBuffer buffer, int offset, int count, char[] insertedData)
TextBufferListenerTextBuffer.insertUpdate in interface TextBufferListenerbuffer - the TextBuffer that changed.offset - the offset where the insert took placecount - the number of characters inserted (insertedData.length)insertedData - an array of the removed characters.public void removeUpdate(TextBuffer buffer, int offset, int count, char[] removedData)
TextBufferListenerTextBuffer.removeUpdate in interface TextBufferListenerbuffer - the TextBuffer that changed.offset - the offset of the first removed character.count - the number of characters removed (removedData.length)removedData - an array of the removed characterspublic void attributeUpdate(TextBuffer buffer, int attribute)
TextBufferListenerattributeUpdate in interface TextBufferListenerbuffer - the TextBuffer that changed.attribute - the attribute that changed