Class CmsMessageBundleEditorModel


  • public class CmsMessageBundleEditorModel
    extends java.lang.Object
    The class contains the logic behind the message translation editor. In particular it reads / writes the involved files and provides the contents as IndexedContainer.
    • Method Detail

      • addDescriptor

        public boolean addDescriptor()
        Creates a descriptor for the currently edited message bundle.
        Returns:
        true if the descriptor could be created, false otherwise.
      • canAddKeys

        public boolean 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

        public void deleteDescriptorIfNecessary()
                                         throws CmsException
        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

        public java.util.Set<java.lang.Object> 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.
      • getContainerForCurrentLocale

        public com.vaadin.v7.data.util.IndexedContainer getContainerForCurrentLocale()
                                                                              throws java.io.IOException,
                                                                                     CmsException
        Returns the container filled according to the current locale.
        Returns:
        the container filled according to the current locale.
        Throws:
        java.io.IOException - thrown if reading a bundle resource fails.
        CmsException - thrown if reading a bundle resource fails.
      • getContextMenuForItem

        public CmsContextMenu getContextMenuForItem​(java.lang.Object itemId)
        Returns the context menu for the table item.
        Parameters:
        itemId - the table item.
        Returns:
        the context menu for the given item.
      • getEditableColumns

        public java.util.List<CmsMessageBundleEditorTypes.TablePropertygetEditableColumns​(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

        public java.lang.String getEditedFilePath()
        Returns the site path for the edited bundle file.
        Returns:
        the site path for the edited bundle file.
      • getEditMode

        public org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode getEditMode()
        Returns the current edit mode.
        Returns:
        the current edit mode.
      • getLocale

        public java.util.Locale getLocale()
        Returns the currently edited locale.
        Returns:
        the currently edited locale.
      • getLocales

        public java.util.Collection<java.util.Locale> getLocales()
        Returns the locales available for the specific resource.
        Returns:
        the locales available for the specific resource.
      • getSwitchedLocaleOnOpening

        public boolean 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

        public void handleChange​(java.lang.Object propertyId)
        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

        public boolean handleKeyDeletion​(java.lang.String key)
        Handles the deletion of a key.
        Parameters:
        key - the deleted key.
        Returns:
        true if the deletion was successful, false otherwise.
      • hasChanges

        public boolean hasChanges()
        Returns a flag, indicating if something was edited.
        Returns:
        a flag, indicating if something was edited.
      • hasDefaultValues

        public boolean hasDefaultValues()
        Returns a flag, indicating if the descriptor specifies any default values.
        Returns:
        flag, indicating if the descriptor specifies any default values.
      • hasDescriptionValues

        public boolean hasDescriptionValues()
        Returns a flag, indicating if the descriptor specifies any descriptions.
        Returns:
        a flag, indicating if the descriptor specifies any descriptions.
      • hasDescriptor

        public boolean hasDescriptor()
        Returns a flag, indicating if a bundle descriptor is present.
        Returns:
        flag, indicating if a bundle descriptor is present.
      • hasMasterMode

        public boolean 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

        public void publish()
        Publish the bundle resources directly.
      • save

        public void save()
                  throws CmsException
        Saves the messages for all languages that were opened in the editor.
        Throws:
        CmsException - thrown if saving fails.
      • saveAsPropertyBundle

        public void saveAsPropertyBundle()
                                  throws java.io.UnsupportedEncodingException,
                                         CmsException,
                                         java.io.IOException
        Saves the loaded XML bundle as property bundle.
        Throws:
        java.io.UnsupportedEncodingException - thrown if localizations from the XML bundle could not be loaded correctly.
        CmsException - thrown if any of the interactions with the VFS fails.
        java.io.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

        public boolean setLocale​(java.util.Locale locale)
        Set the currently edited locale.
        Parameters:
        locale - the currently edited locale.
        Returns:
        true if the locale could be set, false otherwise.
      • unlock

        public void unlock()
        Unlock all files opened for writing.