1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.spreadsheet;
14 import java.util.List;
15 import java.util.function.Consumer;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.databoard.binding.mutable.MutableVariant;
19 import org.simantics.databoard.binding.mutable.Variant;
20 import org.simantics.spreadsheet.ClientModel.OperationMode;
22 public interface CellEditor<O> {
24 public interface Transaction<O> {
26 void setContext(Object context);
30 void add(O operation);
33 * Applies the operations collected with this transaction
38 boolean isOperationMode();
40 List<Object> needSynchronization();
42 void needSynchronization(Object synchronizable);
46 * Sets the given property of the given cell
48 * @param transaction a combined transaction, null for immediate change
49 * @param location a cell location e.g. 'A1'
50 * @param property the name of the property
51 * @param value the property value
52 * @param binding used for serializing the value
54 <T> void edit(Transaction<O> transaction, String location, String property, T value, Binding binding, Consumer<?> callback);
56 * Edits the given cell using the given textual input
58 * @param transaction a combined transaction, null for immediate change
59 * @param location a cell location e.g. 'A1'
60 * @param value a text describing the change
62 void edit(Transaction<O> transaction, String location, Variant variant, Consumer<?> callback);
64 void copy(Transaction<O> transaction, String location, MutableVariant variant, Consumer<?> callback);
67 * Creates a new transaction object
70 Transaction<O> startTransaction(OperationMode mode);