Skip to content

Package: ECPCellEditor

ECPCellEditor

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.edit.spi.swt.table;
16:
17: import org.eclipse.core.databinding.DataBindingContext;
18: import org.eclipse.core.databinding.UpdateValueStrategy;
19: import org.eclipse.core.databinding.property.value.IValueProperty;
20: import org.eclipse.emf.ecore.EStructuralFeature;
21: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
22: import org.eclipse.swt.graphics.Image;
23:
24: /**
25: * <p>
26: * A common super interface for all CellEditors contributed to ECP.
27: * </p>
28: * <p>
29: * See the {@link ECPCellEditorComparator} interface for an optional extension to the {@link ECPCellEditor}.
30: * </p>
31: *
32: * @author Eugen Neufeld
33: * @since 1.5
34: *
35: */
36: public interface ECPCellEditor {
37:         /**
38:          * RAP theming variable.
39:          */
40:         String CUSTOM_VARIANT = "org.eclipse.rap.rwt.customVariant"; //$NON-NLS-1$
41:
42:         /**
43:          * Indicator for an alternative copy string.
44:          *
45:          * @since 1.11
46:          */
47:         String COPY_STRING_ALTERNATIVE = "org.eclipse.emf.ecp.edit.spi.swt.table.copyStringAlternative"; //$NON-NLS-1$
48:
49:         /**
50:          * Returns the {@link IValueProperty} for this cell editor which is used by the table to create an
51:          * {@link org.eclipse.core.databinding.observable.value.IObservableValue IObservableValue}.
52:          *
53:          * @return the {@link IValueProperty} for this cell editor
54:          */
55:         IValueProperty getValueProperty();
56:
57:         /**
58:          * Instantiates this cell editor. This allows the cell editor to use
59:          * {@link org.eclipse.emf.ecp.view.spi.context.ViewModelService ViewModelServices}.
60:          *
61:          * @param feature the {@link EStructuralFeature} displayed in this cell editor
62:          * @param viewModelContext the {@link ViewModelContext} used for the current view
63:          */
64:         void instantiate(EStructuralFeature feature, ViewModelContext viewModelContext);
65:
66:         /**
67:          * The SWT style bits.
68:          *
69:          * @return the style
70:          */
71:         int getStyle();
72:
73:         /**
74:          * This returns the String which will be shown in the table when no cell editor is open.
75:          *
76:          * @param value the Object to get the formated String for
77:          * @return the formated String
78:          */
79:         String getFormatedString(Object value);
80:
81:         /**
82:          * This returns the Image which will be shown in the table when no cell editor is open.
83:          *
84:          * @param value the Object to get the Image for
85:          * @return the image
86:          */
87:         Image getImage(Object value);
88:
89:         /**
90:          * The returned value is used for layouting the table columns. The value is a relative column weight. A column
91:          * containing text has a weight of 100. Please consider this when defining you weight. E.g if you return 200 your
92:          * column will be twice the width of a text column.
93:          *
94:          * @return the relative column width
95:          */
96:         int getColumnWidthWeight();
97:
98:         /**
99:          * This {@link UpdateValueStrategy} will be used as the target to model strategy during data binding.
100:          *
101:          * @param databindingContext The {@link DataBindingContext} used by this strategy
102:          * @return the strategy
103:          * @since 1.6
104:          */
105:         UpdateValueStrategy getTargetToModelStrategy(DataBindingContext databindingContext);
106:
107:         /**
108:          * This {@link UpdateValueStrategy} will be used as the model to target strategy during data binding.
109:          *
110:          * @param databindingContext The {@link DataBindingContext} used by this strategy
111:          * @return the strategy
112:          * @since 1.6
113:          */
114:         UpdateValueStrategy getModelToTargetStrategy(DataBindingContext databindingContext);
115:
116:         /**
117:          * Sets editable state of the cell editor.
118:          *
119:          * @param editable <code>true</code> if editable, <code>false</code> otherwise
120:          */
121:         void setEditable(boolean editable);
122:
123:         /**
124:          * Returns the minimum width of the cell editor.
125:          *
126:          * @return the minimum width
127:          * @since 1.6
128:          */
129:         int getMinWidth();
130: }