Skip to main content
summaryrefslogtreecommitdiffstats
blob: f239a73bd7caf8034d97198a2e136f3b1a3cd302 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*****************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.cell;

import java.util.Map;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;

/**
 * The interface to implements for a cell manager
 * 
 * @author Vincent Lorenzo
 * 
 */
public interface ICellManager {

	/**
	 * The string displayed for Not_AVAILABLE
	 */
	public static final String NOT_AVALAIBLE = Messages.ICellManager_NotAvailable;

	/**
	 * 
	 * @param columnElement
	 *        the column element as described in the model (you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @return
	 */
	public boolean handles(final Object columnElement, final Object rowElement);


	/**
	 * 
	 * @param columnElement
	 *        the column element as described in the model (you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @param tableManager
	 *        the table manager
	 * @return
	 *         the value of the cell or {@value #NOT_AVALAIBLE} if the cell is meaningless for the couple of parameters
	 * 
	 *         THIS METHOD MUST NOT BE USED IN REPLACEMENT OF A SPECIFIC LABEL PROVIDER
	 */
	public Object getValue(final Object columnElement, final Object rowElement, final INattableModelManager tableManager);

	/**
	 * Set the newValue to the intersection of the 2 objects
	 * 
	 * @param domain
	 *        the editing domain
	 * @param columnElement
	 *        the column element as described in the model (so you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @param newValue
	 *        the new value
	 * @param tableManager
	 *        the table manager
	 */
	public void setValue(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager);

	/**
	 * 
	 * @param columnElement
	 *        the column element as described in the model (you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @return
	 *         <code>true</code> if the intersection of the 2 objects is editable
	 */
	public boolean isCellEditable(final Object columnElement, final Object rowElement);

	/**
	 * 
	 * @param domain
	 *        the editing domain
	 * @param columnElement
	 *        the column element as described in the model (you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @param newValue
	 *        the new value to set to the intersection of these 2 objects
	 * @param tableManager
	 * @return
	 *         the command to set the value
	 */
	public Command getSetValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager);

	/**
	 * 
	 * @param domain
	 *        the editing domain
	 * @param newValue
	 *        the newValue, represented by a String
	 * @param valueConverter
	 *        the solver used to resolve values
	 * @param columnElement
	 *        the columnElement
	 * @param rowElement
	 *        the rowElement
	 */
	public Command getSetStringValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final String newValue, final AbstractStringValueConverter valueConverter, final INattableModelManager tableManager);


	/**
	 * 
	 * @param tableManager
	 *        the table manager
	 * @param existingConverters
	 *        a map with the existing converters, to avoid to create them too often
	 * @param multiValueSeparator
	 *        the separator used for multi values
	 * @return
	 *         the class to use to converter the string into values. If the method create them, the method must add it to the map existingConverters
	 */
	public AbstractStringValueConverter getOrCreateStringValueConverterClass(INattableModelManager tableManager, final Map<Class<? extends AbstractStringValueConverter>, AbstractStringValueConverter> existingConverters, final String multiValueSeparator);

	/**
	 * This method is used when we are pasting element in detached mode
	 * 
	 * @param columnElement
	 *        the column element as described in the model (you must ignore the invert axis)
	 * @param rowElement
	 *        the row element as described in the model (you must ignore the invert axis)
	 * @param sharedMap
	 *        a map with shared elements
	 * @return
	 *         <code>true</code> if the intersection of the 2 objects is editable
	 */
	public boolean isCellEditable(final Object columnElement, final Object rowElement, final Map<?, ?> sharedMap);

	/**
	 * This method is used when we are pasting elements in detached mode
	 * 
	 * @param columnElement
	 *        the column element
	 * @param rowElement
	 *        the row element
	 * @param valueAsString
	 *        the value as string
	 * @param valueConverter
	 *        the value converter to use
	 * @param tableManager
	 *        the table manager
	 * @param sharedMap
	 *        a map with shared elements. The method may read/add elements to the shared map. These contributions will be managed by a paste post
	 *        action or by the paste manager itself
	 * 
	 */
	public void setStringValue(final Object columnElement, final Object rowElement, final String valueAsString, final AbstractStringValueConverter valueConverter, final INattableModelManager tableManager, final Map<?, ?> sharedMap);
}

Back to the top