/*******************************************************************************
 * Copyright (c) 2012, 2020 Original authors and others.
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Original authors and others - initial API and implementation
 ******************************************************************************/
package org.eclipse.nebula.widgets.nattable.edit;

import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;

/**
 * Handles the updating of the data bean with the new value provided by the
 * {@link ICellEditor}.
 */
public interface ICellEditHandler {

    /**
     * Commit the new value and handle the selection in the current NatTable
     * after commit. This is necessary to support spreadsheet like behaviour,
     * e.g. after committing a value entered in a text editor by pressing tab,
     * the selection should move to the right. To avoid unnecessary dependencies
     * in the editors itself, this is handled in here.
     *
     * @param canonicalValue
     *            The value to commit.
     * @param direction
     *            The direction to move the selection after commit.
     * @return <code>true</code> if the data update succeeded,
     *         <code>false</code> if something went wrong
     */
    public boolean commit(Object canonicalValue, MoveDirectionEnum direction);
}
