blob: 14d00dcb92918bec841e9bbbe9ce53b008ddd153 (
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
|
/*****************************************************************************
* Copyright (c) 2013 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:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
/**
* Concrete handler to load column axis providers from the table's historic.
*
*/
public class LoadColumnAxisProvidersHandler extends AbstractLoadAxisProvidersHandler {
/**
* Get the EReference where the current column provider will be set.
*
*/
@Override
public EReference getCurrentAxisProviderEFeature() {
return NattablePackage.eINSTANCE.getTable_CurrentColumnAxisProvider();
}
/**
* Getter to obtain the current axis provider, in this case for columns.
*
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractLoadAxisProvidersHandler#getCurrentAxisProvider()
*
* @return
*/
@Override
public AbstractAxisProvider getCurrentAxisProvider() {
if (!this.getCurrentNattableModelManager().getTable().isInvertAxis()) {
return this.getCurrentNattableModelManager().getTable().getCurrentColumnAxisProvider();
} else {
return this.getCurrentNattableModelManager().getTable().getCurrentRowAxisProvider();
}
}
/**
* Getter to obtain the current axis provider, in this case for columns.
*
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractLoadAxisProvidersHandler#getAxisProvidersHistory()
*
* @return
*/
@Override
public EList<AbstractAxisProvider> getAxisProvidersHistory() {
if (!this.getCurrentNattableModelManager().getTable().isInvertAxis()) {
return this.getCurrentNattableModelManager().getTable().getColumnAxisProvidersHistory();
} else {
return this.getCurrentNattableModelManager().getTable().getRowAxisProvidersHistory();
}
}
/**
* This handler is enabled only if the concerned axis manager allows to save a configuration.
*
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
*
* @param evaluationContext
*/
@Override
public void setEnabled(Object evaluationContext) {
if (getCurrentNattableModelManager() != null && getCurrentNattableModelManager().getColumnAxisManager() != null) {
IAxisManager columnAxisManager = this.getCurrentNattableModelManager().getColumnAxisManager();
setBaseEnabled(columnAxisManager.canBeSavedAsConfig());
} else {
setBaseEnabled(false);
}
}
}
|