| /*=============================================================================# |
| # Copyright (c) 2012, 2021 Original NatTable 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 NatTable authors and others - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.ecommons.waltable.edit; |
| |
| import org.eclipse.statet.ecommons.waltable.layer.ILayer; |
| import org.eclipse.statet.ecommons.waltable.layer.cell.ILayerCell; |
| import org.eclipse.statet.ecommons.waltable.layer.event.ILayerEventHandler; |
| |
| |
| /** |
| * Event handler for handling {@link InlineCellEditEvent}s. |
| * Used to activate editors for inline editing. |
| * |
| * @see InlineCellEditEvent |
| * @see EditSelectionCommandHandler |
| */ |
| public class InlineCellEditEventHandler implements ILayerEventHandler<InlineCellEditEvent> { |
| |
| /** |
| * The layer this event handler is associated with. Needed for the conversion of |
| * cell position coordinates.Usually this is a grid layer because this is the main |
| * cause for this event handler is needed. |
| */ |
| private final ILayer layer; |
| |
| /** |
| * @param layer The layer this event handler is associated with. Needed for |
| * the conversion of cell position coordinates. |
| */ |
| public InlineCellEditEventHandler(final ILayer layer) { |
| this.layer= layer; |
| } |
| |
| @Override |
| public Class<InlineCellEditEvent> getLayerEventClass() { |
| return InlineCellEditEvent.class; |
| } |
| |
| @Override |
| public void handleLayerEvent(final InlineCellEditEvent event) { |
| if (event.convertToLocal(this.layer)) { |
| final ILayerCell cell= this.layer.getCellByPosition(event.getColumnPosition(), event.getRowPosition()); |
| EditController.editCell(cell, event.getParent(), event.getInitialValue(), event.getConfigRegistry()); |
| } |
| } |
| } |