blob: 903ca5df9ea21c7ad4d909b4dfa4c4cd235767d4 (
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
|
/*****************************************************************************
* 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.celleditor.config;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
/**
*
* The abstract class to used for CellEditorFactory
*
*/
public abstract class AbstractCellEditorConfigurationFactory {
/**
* the id of the factory
*/
private String id;
/**
* the id of the extension point used to register contribution
*/
public static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.celleditor.configuration"; //$NON-NLS-1$
public static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
public static final String FACTORY_ID_ATTRIBUTE = "factoryId"; //$NON-NLS-1$
public static final String ORDER_ATTRIBUTE = "order"; //$NON-NLS-1$
/**
*
* @param id
* the id of the factory
*/
public void initFactory(String id) {
this.id = id;
}
/**
*
* @return
* the id of the factory
*/
public final String getFactoryId() {
return this.id;
}
/**
*
* @return
* the registered element for this factory
*/
public Collection<IConfigurationElement> getAllRegisteredCellEditorConfiguration() {
Collection<IConfigurationElement> elements = new ArrayList<IConfigurationElement>();
final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
for(final IConfigurationElement iConfigurationElement : configElements) {
final String current = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
if(current.equals(this.id)) {
elements.add(iConfigurationElement);
}
}
return elements;
}
/**
*
* @param editorId
* the editor id
* @return
* the configuration for this editor or <code>null</code> if the editor is not registered in this factory
*/
public abstract IAxisCellEditorConfiguration getCellEditorConfiguration(final String editorId);
/**
*
* @param table
* the table
* @param axisElement
* an eobject
* @return
* <code>true</code> if this factory allows to edit the object for this table
*/
public abstract boolean handles(final Table table, final Object axisElement);
/**
*
* @param table
* the table
* @param axisElement
* an eobject
* @return
* the cell editor configuration for the couple table - axisElement
*/
public abstract IAxisCellEditorConfiguration getCellEditorConfiguration(Table table, final Object axisElement);
}
|