Class CmsMessageBundleEditorModel
java.lang.Object
org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorModel
The class contains the logic behind the message translation editor.
In particular it reads / writes the involved files and provides the contents as
IndexedContainer
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Comparator that compares strings case insensitive.static final class
Wrapper for the configurable messages for the column headers of the message bundle editor.static final class
Extension ofProperties
to allow saving with keys alphabetically ordered and without time stamp as first comment. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The property for configuring the message bundle used for localizing the bundle descriptors entries. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Creates a descriptor for the currently edited message bundle.boolean
Returns a flag, indicating if keys can be added in the current edit mode.void
When the descriptor was added while editing, but the change was not saved, it has to be removed when the editor is closed.Returns the a set with all keys that are used at least in one translation.Returns the type of the currently edited bundle.getConfigurableMessages
(CmsMessages defaultMessages, Locale locale) Returns the configured bundle, or the provided default bundle.com.vaadin.v7.data.util.IndexedContainer
Returns the container filled according to the current locale.getContextMenuForItem
(Object itemId) Returns the context menu for the table item.Returns the editable columns for the current edit mode.getEditableColumns
(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Returns the editable columns for the provided edit mode.Returns the site path for the edited bundle file.org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode
Returns the current edit mode.Returns the currently edited locale.Returns the locales available for the specific resource.boolean
Returns a flag, indicating if the locale has been switched on opening.void
handleChange
(Object propertyId) Handles the change of a value in the current translation.org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorModel.KeyChangeResult
handleKeyChange
(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EntryChangeEvent event, boolean allLanguages) Handles a key change.boolean
handleKeyDeletion
(String key) Handles the deletion of a key.boolean
Returns a flag, indicating if something was edited.boolean
Returns a flag, indicating if the descriptor specifies any default values.boolean
Returns a flag, indicating if the descriptor specifies any descriptions.boolean
Returns a flag, indicating if a bundle descriptor is present.boolean
Returns a flag, indicating if a master edit mode is available.boolean
isShowOptionsColumn
(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Returns a flag, indicating if the options column (with add and delete option for rows) should be shown in the given edit mode.void
publish()
Publish the bundle resources directly.void
save()
Saves the messages for all languages that were opened in the editor.void
Saves the loaded XML bundle as property bundle.boolean
setEditMode
(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Set the edit mode.boolean
Set the currently edited locale.void
unlock()
Unlock all files opened for writing.
-
Field Details
-
PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION
The property for configuring the message bundle used for localizing the bundle descriptors entries.- See Also:
-
-
Constructor Details
-
CmsMessageBundleEditorModel
public CmsMessageBundleEditorModel(CmsObject cms, CmsResource resource) throws CmsException, IOException - Parameters:
cms
- theCmsObject
used for reading / writing.resource
- the file that is opened for editing.- Throws:
CmsException
- thrown if reading some of the involvedCmsResource
s is not possible.IOException
- initialization of a property bundle fails
-
-
Method Details
-
addDescriptor
Creates a descriptor for the currently edited message bundle.- Returns:
true
if the descriptor could be created,false
otherwise.
-
canAddKeys
Returns a flag, indicating if keys can be added in the current edit mode.- Returns:
- a flag, indicating if keys can be added in the current edit mode.
-
deleteDescriptorIfNecessary
When the descriptor was added while editing, but the change was not saved, it has to be removed when the editor is closed.- Throws:
CmsException
- thrown when deleting the descriptor resource fails
-
getAllUsedKeys
Returns the a set with all keys that are used at least in one translation.- Returns:
- the a set with all keys that are used at least in one translation.
-
getBundleType
Returns the type of the currently edited bundle.- Returns:
- the type of the currently edited bundle.
-
getConfigurableMessages
public CmsMessageBundleEditorModel.ConfigurableMessages getConfigurableMessages(CmsMessages defaultMessages, Locale locale) Returns the configured bundle, or the provided default bundle.- Parameters:
defaultMessages
- the default bundlelocale
- the preferred locale- Returns:
- the configured bundle or, if not found, the default bundle.
-
getContainerForCurrentLocale
public com.vaadin.v7.data.util.IndexedContainer getContainerForCurrentLocale() throws IOException, CmsExceptionReturns the container filled according to the current locale.- Returns:
- the container filled according to the current locale.
- Throws:
IOException
- thrown if reading a bundle resource fails.CmsException
- thrown if reading a bundle resource fails.
-
getContextMenuForItem
Returns the context menu for the table item.- Parameters:
itemId
- the table item.- Returns:
- the context menu for the given item.
-
getEditableColumns
Returns the editable columns for the current edit mode.- Returns:
- the editable columns for the current edit mode.
-
getEditableColumns
public List<CmsMessageBundleEditorTypes.TableProperty> getEditableColumns(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Returns the editable columns for the provided edit mode.- Parameters:
mode
- the edit mode.- Returns:
- the editable columns for the provided edit mode.
-
getEditedFilePath
Returns the site path for the edited bundle file.- Returns:
- the site path for the edited bundle file.
-
getEditMode
Returns the current edit mode.- Returns:
- the current edit mode.
-
getLocale
Returns the currently edited locale.- Returns:
- the currently edited locale.
-
getLocales
Returns the locales available for the specific resource.- Returns:
- the locales available for the specific resource.
-
getSwitchedLocaleOnOpening
Returns a flag, indicating if the locale has been switched on opening.- Returns:
- a flag, indicating if the locale has been switched on opening.
-
handleChange
Handles the change of a value in the current translation.- Parameters:
propertyId
- the property id of the column where the value has changed.
-
handleKeyChange
public org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorModel.KeyChangeResult handleKeyChange(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EntryChangeEvent event, boolean allLanguages) Handles a key change.- Parameters:
event
- the key change event.allLanguages
-true
for changing the key for all languages,false
if the key should be changed only for the current language.- Returns:
- result, indicating if the key change was successful.
-
handleKeyDeletion
Handles the deletion of a key.- Parameters:
key
- the deleted key.- Returns:
true
if the deletion was successful,false
otherwise.
-
hasChanges
Returns a flag, indicating if something was edited.- Returns:
- a flag, indicating if something was edited.
-
hasDefaultValues
Returns a flag, indicating if the descriptor specifies any default values.- Returns:
- flag, indicating if the descriptor specifies any default values.
-
hasDescriptionValues
Returns a flag, indicating if the descriptor specifies any descriptions.- Returns:
- a flag, indicating if the descriptor specifies any descriptions.
-
hasDescriptor
Returns a flag, indicating if a bundle descriptor is present.- Returns:
- flag, indicating if a bundle descriptor is present.
-
hasMasterMode
Returns a flag, indicating if a master edit mode is available.- Returns:
- a flag, indicating if a master edit mode is available.
-
isShowOptionsColumn
public boolean isShowOptionsColumn(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Returns a flag, indicating if the options column (with add and delete option for rows) should be shown in the given edit mode.- Parameters:
mode
- the edit mode for which the column option is requested.- Returns:
- a flag, indicating if the options column (with add and delete option for rows)
-
publish
Publish the bundle resources directly. -
save
Saves the messages for all languages that were opened in the editor.- Throws:
CmsException
- thrown if saving fails.
-
saveAsPropertyBundle
Saves the loaded XML bundle as property bundle.- Throws:
UnsupportedEncodingException
- thrown if localizations from the XML bundle could not be loaded correctly.CmsException
- thrown if any of the interactions with the VFS fails.IOException
- thrown if localizations from the XML bundle could not be loaded correctly.
-
setEditMode
public boolean setEditMode(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode mode) Set the edit mode.- Parameters:
mode
- the edit mode to set.- Returns:
- flag, indicating if the mode could be changed.
-
setLocale
Set the currently edited locale.- Parameters:
locale
- the currently edited locale.- Returns:
true
if the locale could be set,false
otherwise.
-
unlock
Unlock all files opened for writing.
-