blob: 0cb9c0405efe98a85f367e58f90a39f3e92646e7 (
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
|
/*****************************************************************************
* Copyright (c) 2016 CEA LIST and others.
*
* 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:
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.customization.nattableconfiguration.utils;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ILabelProvider;
/**
* The editing support specific for the nattable configuration wizard which allow to use the label provider to get the value.
*/
public abstract class NattableConfigurationEditingSupport extends EditingSupport {
/**
* The label provider used.
*/
protected ILabelProvider labelProvider;
/**
* Constructor.
*
* @param viewer
* The viewer.
* @param labelProvider
* The label provider to use.
*/
public NattableConfigurationEditingSupport(final ColumnViewer viewer, final ILabelProvider labelProvider) {
super(viewer);
this.labelProvider = labelProvider;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
*/
@Override
protected CellEditor getCellEditor(final Object element) {
return null;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
*/
@Override
protected boolean canEdit(Object element) {
return true;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
*/
@Override
protected Object getValue(final Object element) {
return labelProvider.getText(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
*/
@Override
protected abstract void setValue(final Object element, final Object value);
}
|