Class TagEditHelper


  • public class TagEditHelper
    extends java.lang.Object
    Class that helps PropertiesDialog add and edit tag values.
    Since:
    5633
    • Constructor Detail

      • TagEditHelper

        public TagEditHelper​(javax.swing.JTable tagTable,
                             javax.swing.table.DefaultTableModel propertyData,
                             java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Integer>> valueCount)
        Constructs a new TagEditHelper.
        Parameters:
        tagTable - tag table
        propertyData - table model
        valueCount - tag value count
    • Method Detail

      • getDataKey

        public final java.lang.String getDataKey​(int viewRow)
        Finds the key from given row of tag editor.
        Parameters:
        viewRow - index of row
        Returns:
        key of tag
      • containsDataKey

        boolean containsDataKey​(java.lang.String key)
        Determines if the given tag key is already used (by all selected primitives, not just some of them)
        Parameters:
        key - the key to check
        Returns:
        true if the key is used by all selected primitives (key not unset for at least one primitive)
      • getDataValues

        public final java.util.Map<java.lang.String,​java.lang.Integer> getDataValues​(int viewRow)
        Finds the values from given row of tag editor.
        Parameters:
        viewRow - index of row
        Returns:
        map of values and number of occurrences
      • addTag

        public void addTag()
        Open the add selection dialog and add a new key/value to the table (and to the dataset, of course).
      • editTag

        public void editTag​(int row,
                            boolean focusOnKey)
        Edit the value in the tags table row.
        Parameters:
        row - The row of the table from which the value is edited.
        focusOnKey - Determines if the initial focus should be set on key instead of value
        Since:
        5653
      • getChangedKey

        public java.lang.String getChangedKey()
        If during last editProperty call user changed the key name, this key will be returned Elsewhere, returns null.
        Returns:
        The modified key, or null
      • getAutocompletionKeys

        private static java.util.List<java.lang.String> getAutocompletionKeys​(java.lang.String key)
        For a given key k, return a list of keys which are used as keys for auto-completing values to increase the search space.
        Parameters:
        key - the key k
        Returns:
        a list of keys
      • loadTagsIfNeeded

        public void loadTagsIfNeeded()
        Load recently used tags from preferences if needed.
      • saveTagsIfNeeded

        public void saveTagsIfNeeded()
        Store recently used tags in preferences if needed.
      • resetSelection

        public void resetSelection()
        Forget recently selected primitives to allow GC.
        Since:
        14509
      • cacheRecentTags

        private void cacheRecentTags()
        Update cache of recent tags used for displaying tags.
      • getEditItem

        public static java.lang.String getEditItem​(AutoCompComboBox<AutoCompletionItem> cb)
        Returns the edited item with whitespaces removed
        Parameters:
        cb - the combobox
        Returns:
        the edited item with whitespaces removed
        Since:
        18173
      • getSelectedOrEditItem

        public static java.lang.String getSelectedOrEditItem​(AutoCompComboBox<AutoCompletionItem> cb)
        Returns the selected item or the edited item as string
        Parameters:
        cb - the combobox
        Returns:
        the selected item or the edited item as string
        Since:
        18173
      • warnSelectionChanged

        private static boolean warnSelectionChanged()
        Warn user about a selection change
        Returns:
        true if the user wants to apply the tag change to the old selection
      • warnOverwriteKey

        private static boolean warnOverwriteKey​(java.lang.String action,
                                                java.lang.String togglePref)
        Warns user about a key being overwritten.
        Parameters:
        action - The action done by the user. Must state what key is changed
        togglePref - The preference to save the checkbox state to
        Returns:
        true if the user accepts to overwrite key, false otherwise