Class EditUtils


  • public final class EditUtils
    extends Object
    Helper class for retrieving information regarding editing of selected cells.
    • Method Detail

      • getLastSelectedCell

        public static ILayerCell getLastSelectedCell​(SelectionLayer selectionLayer)
        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection from.
        Returns:
        The last cell of the current selection in the specified SelectionLayer. Will return null if there is no selection.
      • activateLastSelectedCellEditor

        public static boolean activateLastSelectedCellEditor​(SelectionLayer selectionLayer,
                                                             IConfigRegistry configRegistry,
                                                             boolean byTraversal)
        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        configRegistry - The IConfigRegistry needed to access the configured ICellEditor.
        byTraversal - true if the activation is triggered by traversal, false if not
        Returns:
        true if the current selected cell contains an editor that should be activated, false if not
      • allCellsEditable

        public static boolean allCellsEditable​(SelectionLayer selectionLayer,
                                               IConfigRegistry configRegistry)
        For every cell that is selected it is checked whether the cell is editable or not.

        In case a IRowSelectionModel is in use, only the selection anchor is checked.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        configRegistry - The IConfigRegistry needed to access the configured IEditableRules.
        Returns:
        true if all selected cells are editable, false if at least one cell is not editable.
      • allCellsEditable

        public static boolean allCellsEditable​(SelectionLayer selectionLayer,
                                               IUniqueIndexLayer upperLayer,
                                               IConfigRegistry configRegistry)
        For every cell that is selected it is checked whether the cell is editable or not.

        In case a IRowSelectionModel is in use, only the selection anchor is checked.

        Note:
        Converts the SelectionLayer based cells to the given upperLayer to be able to inspect the cells if that layer on top of the SelectionLayer adds information that needs to be inspected for editing checks, e.g. a tree layer.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        upperLayer - The layer on top of the given SelectionLayer to which the selection should be converted to. Can be null which causes the resulting selected cells to be related to the SelectionLayer.
        configRegistry - The IConfigRegistry needed to access the configured IEditableRules.
        Returns:
        true if all selected cells are editable, false if at least one cell is not editable.
        Since:
        1.6
      • allCellsEditable

        public static boolean allCellsEditable​(Collection<ILayerCell> selectedCells,
                                               IConfigRegistry configRegistry)
        For every selected cell it is checked whether the cell is editable or not. If the collection of selected cells is null or empty, this method will also return true.
        Parameters:
        selectedCells - The collection of selected cells that should be checked.
        configRegistry - The IConfigRegistry needed to access the configured IEditableRules.
        Returns:
        true if all selected cells are editable, false if at least one cell is not editable.
      • isCellEditable

        public static boolean isCellEditable​(PositionCoordinate cellCoords,
                                             IConfigRegistry configRegistry)
        Checks if the cell at the specified coordinates is editable or not.
        Parameters:
        cellCoords - The coordinates of the cell to check the editable state, related to the given ILayer
        configRegistry - The IConfigRegistry needed to access the configured IEditableRules.
        Returns:
        true if the cell is editable, false if not
        Since:
        1.6
      • isEditorSame

        public static boolean isEditorSame​(SelectionLayer selectionLayer,
                                           IConfigRegistry configRegistry)
        Checks if all selected cells have the same ICellEditor configured. This is needed for the multi edit feature to determine if a multi edit is possible.
        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        configRegistry - The IConfigRegistry needed to access the configured ICellEditors.
        Returns:
        true if all selected cells have the same ICellEditor configured, false if at least one cell has another ICellEditor configured.
      • isEditorSame

        public static boolean isEditorSame​(SelectionLayer selectionLayer,
                                           IUniqueIndexLayer upperLayer,
                                           IConfigRegistry configRegistry)
        Checks if all selected cells have the same ICellEditor configured. This is needed for the multi edit feature to determine if a multi edit is possible.

        Note:
        Converts the SelectionLayer based cells to the given upperLayer to be able to inspect the cells if that layer on top of the SelectionLayer adds information that needs to be inspected for editing checks, e.g. a tree layer.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        upperLayer - The layer on top of the given SelectionLayer to which the selection should be converted to. Can be null which causes the resulting selected cells to be related to the SelectionLayer.
        configRegistry - The IConfigRegistry needed to access the configured ICellEditors.
        Returns:
        true if all selected cells have the same ICellEditor configured, false if at least one cell has another ICellEditor configured.
        Since:
        1.6
      • isEditorSame

        public static boolean isEditorSame​(Collection<ILayerCell> selectedCells,
                                           IConfigRegistry configRegistry)
        Checks if all selected cells have the same ICellEditor configured. This is needed for the multi edit feature to determine if a multi edit is possible. If the collection of selected cells is null or empty, this method will also return true.
        Parameters:
        selectedCells - The collection of selected cells that should be checked.
        configRegistry - The IConfigRegistry needed to access the configured ICellEditors.
        Returns:
        true if all selected cells have the same ICellEditor configured, false if at least one cell has another ICellEditor configured.
      • isConverterSame

        public static boolean isConverterSame​(SelectionLayer selectionLayer,
                                              IConfigRegistry configRegistry)
        Checks if all selected cells have the same IDisplayConverter configured. This is needed for the multi edit feature to determine if a multi edit is possible.

        Let's assume there are two columns, one containing an Integer, the other a Date. Both have a TextCellEditor configured, so if only the editor is checked, the multi edit dialog would open. On committing a changed value an error would occur because of wrong conversion.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        configRegistry - The IConfigRegistry needed to access the configured IDisplayConverters.
        Returns:
        true if all selected cells have the same IDisplayConverter configured, false if at least one cell has another IDisplayConverter configured.
      • isConverterSame

        public static boolean isConverterSame​(SelectionLayer selectionLayer,
                                              IUniqueIndexLayer upperLayer,
                                              IConfigRegistry configRegistry)
        Checks if all selected cells have the same IDisplayConverter configured. This is needed for the multi edit feature to determine if a multi edit is possible.

        Let's assume there are two columns, one containing an Integer, the other a Date. Both have a TextCellEditor configured, so if only the editor is checked, the multi edit dialog would open. On committing a changed value an error would occur because of wrong conversion.

        Note:
        Converts the SelectionLayer based cells to the given upperLayer to be able to inspect the cells if that layer on top of the SelectionLayer adds information that needs to be inspected for editing checks, e.g. a tree layer.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        upperLayer - The layer on top of the given SelectionLayer to which the selection should be converted to. Can be null which causes the resulting selected cells to be related to the SelectionLayer.
        configRegistry - The IConfigRegistry needed to access the configured IDisplayConverters.
        Returns:
        true if all selected cells have the same IDisplayConverter configured, false if at least one cell has another IDisplayConverter configured.
        Since:
        1.6
      • isConverterSame

        public static boolean isConverterSame​(Collection<ILayerCell> selectedCells,
                                              IConfigRegistry configRegistry)
        Checks if all selected cells have the same IDisplayConverter configured. This is needed for the multi edit feature to determine if a multi edit is possible. If the collection of selected cells is null or empty, this method will also return true.

        Let's assume there are two columns, one containing an Integer, the other a Date. Both have a TextCellEditor configured, so if only the editor is checked, the multi edit dialog would open. On committing a changed value an error would occur because of wrong conversion.

        Parameters:
        selectedCells - The collection of selected cells that should be checked.
        configRegistry - The IConfigRegistry needed to access the configured IDisplayConverters.
        Returns:
        true if all selected cells have the same IDisplayConverter configured, false if at least one cell has another IDisplayConverter configured.
      • isValueSame

        public static boolean isValueSame​(SelectionLayer selectionLayer)
        Checks if all selected cells contain the same canonical value. This is needed for multi edit to know if the editor should be initialised with the value that is shared amongst all cells.
        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        Returns:
        true if all cells contain the same value, false if at least one cell contains another value.
      • isValueSame

        public static boolean isValueSame​(SelectionLayer selectionLayer,
                                          IUniqueIndexLayer upperLayer)
        Checks if all selected cells contain the same canonical value. This is needed for multi edit to know if the editor should be initialised with the value that is shared amongst all cells.

        Note:
        Converts the SelectionLayer based cells to the given upperLayer to be able to inspect the cells if that layer on top of the SelectionLayer adds information that needs to be inspected for editing checks, e.g. a tree layer.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        upperLayer - The layer on top of the given SelectionLayer to which the selection should be converted to. Can be null which causes the resulting selected cells to be related to the SelectionLayer.
        Returns:
        true if all cells contain the same value, false if at least one cell contains another value.
        Since:
        1.6
      • isValueSame

        public static boolean isValueSame​(Collection<ILayerCell> selectedCells)
        Checks if all selected cells contain the same canonical value. This is needed for multi edit to know if the editor should be initialized with the value that is shared amongst all cells. If the collection of selected cells is null or empty, this method will also return true.
        Parameters:
        selectedCells - The collection of selected cells that should be checked.
        Returns:
        true if all cells contain the same value, false if at least one cell contains another value.
      • getSelectedCellsForEditing

        public static Collection<ILayerCell> getSelectedCellsForEditing​(SelectionLayer selectionLayer)
        Returns the collection of selected ILayerCells that are eligible for editing. This method is used for multi edit support, to ensure the editing also with row selection.

        In case of cell selection, simply all selected cells are returned.

        In case a IRowSelectionModel is configured, the selected cells in correlation to the selection anchor are returned. This means, in case only one row is selected, the selection anchor is returned. In case multiple rows are selected, the cells at the column position of the selection anchor for all selected rows are returned.

        Parameters:
        selectionLayer - The SelectionLayer to retrieve the current selection.
        Returns:
        The selected ILayerCells that are eligible for editing.