Class CmsMessageBundleEditorModel

java.lang.Object
org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorModel

public class CmsMessageBundleEditorModel extends 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.
  • Field Details

  • Constructor Details

  • Method Details

    • 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

      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

      Returns the configured bundle, or the provided default bundle.
      Parameters:
      defaultMessages - the default bundle
      locale - 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, CmsException
      Returns 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

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

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

      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(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(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

      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

      public boolean setLocale(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.