]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/CellEditor.java
Spreadsheet changes
[simantics/platform.git] / bundles / org.simantics.spreadsheet / src / org / simantics / spreadsheet / CellEditor.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.spreadsheet;
13
14 import java.util.List;
15 import java.util.function.Consumer;
16
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;
21
22 public interface CellEditor<O> {
23
24     public interface Transaction<O> {
25
26         void setContext(Object context);
27
28         Object getContext();
29
30         void add(O operation);
31
32         /*
33          * Applies the operations collected with this transaction
34          * 
35          */
36         void commit();
37
38         boolean isOperationMode();
39
40         List<Object> needSynchronization();
41
42         void needSynchronization(Object synchronizable);
43     }
44
45     /*
46      * Sets the given property of the given cell
47      * 
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 
53      */
54     <T> void edit(Transaction<O> transaction, String location, String property, T value, Binding binding, Consumer<?> callback);
55     /*
56      * Edits the given cell using the given textual input
57      * 
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
61      */
62     void edit(Transaction<O> transaction, String location, Variant variant, Consumer<?> callback);
63
64     void copy(Transaction<O> transaction, String location, MutableVariant variant, Consumer<?> callback);
65
66     /*
67      * Creates a new transaction object
68      * 
69      */
70     Transaction<O> startTransaction(OperationMode mode);
71
72 }