]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.spreadsheet / src / org / simantics / spreadsheet / CellEditor.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.spreadsheet;\r
13 \r
14 import java.util.List;\r
15 import java.util.function.Consumer;\r
16 \r
17 import org.simantics.databoard.binding.Binding;\r
18 import org.simantics.databoard.binding.mutable.MutableVariant;\r
19 import org.simantics.databoard.binding.mutable.Variant;\r
20 import org.simantics.spreadsheet.ClientModel.OperationMode;\r
21 \r
22 public interface CellEditor<O> {\r
23     \r
24         public interface Transaction<O> {\r
25             \r
26             void setContext(Object context);\r
27             \r
28             Object getContext();\r
29             \r
30             void add(O operation);\r
31             \r
32                 /*\r
33                  * Applies the operations collected with this transaction\r
34                  * \r
35                  */\r
36             void commit();\r
37             \r
38             boolean isOperationMode();\r
39         \r
40         List<Object> needSynchronization();\r
41 \r
42         void needSynchronization(Object synchronizable);\r
43         }\r
44         \r
45         /*\r
46          * Sets the given property of the given cell\r
47          * \r
48          * @param transaction a combined transaction, null for immediate change\r
49          * @param location a cell location e.g. 'A1'\r
50          * @param property the name of the property\r
51          * @param value the property value\r
52          * @param binding used for serializing the value \r
53          */\r
54         <T> void edit(Transaction<O> transaction, String location, String property, T value, Binding binding, Consumer<?> callback);\r
55         /*\r
56          * Edits the given cell using the given textual input\r
57          * \r
58          * @param transaction a combined transaction, null for immediate change\r
59          * @param location a cell location e.g. 'A1'\r
60          * @param value a text describing the change\r
61          */\r
62     void edit(Transaction<O> transaction, String location, Variant variant, Consumer<?> callback);\r
63 \r
64     void copy(Transaction<O> transaction, String location, MutableVariant variant, Consumer<?> callback);\r
65     \r
66         /*\r
67          * Creates a new transaction object\r
68          * \r
69          */\r
70     Transaction<O> startTransaction(OperationMode mode);\r
71     \r
72 }\r