blob: 7cf8359b1142b46e5a841fc31ba8fb70e492801c (
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
|
/*****************************************************************************
* Copyright (c) 2014 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
/**
* @author Vincent Lorenzo
*
*/
public class CollapseAndExpandTreeHandler extends AbstractParametricTreeTableHandler {
/** the name of the parameter used by this handler */
public static final String COLLAPSED_DEPTH_ARG_NAME = "treeAction"; //$NON-NLS-1$
private CollapseAndExpandActionsEnum actionId;
/**
* Constructor.
*
* @param parameterId
*/
public CollapseAndExpandTreeHandler() {
super(COLLAPSED_DEPTH_ARG_NAME);
}
/**
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param arg0
* @return
* @throws ExecutionException
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
getTreeNattableModelManager().doCollapseExpandAction(this.actionId, null);
return null;
}
/**
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
*
* @param evaluationContext
*/
@Override
public void setEnabled(Object evaluationContext) {
super.setEnabled(evaluationContext);
if (isEnabled() && this.actionId == null) {
setBaseEnabled(false);
return;
}
if (isEnabled()) {
switch (this.actionId) {
case COLLAPSE_ALL_FROM_SELECTION:
case COLLAPSE_ONE_LEVEL:
case EXPAND_ALL_FROM_SELECTION:
case EXPAND_ONE_LEVEL:
if (getFullSelectedRowsIndex(evaluationContext).isEmpty()) {
setBaseEnabled(false);
}
break;
default:
// nothing to do
break;
}
}
}
/**
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractParametricTreeTableHandler#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
*
* @param config
* @param propertyName
* @param data
* @throws CoreException
*/
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
super.setInitializationData(config, propertyName, data);
this.actionId = CollapseAndExpandActionsEnum.valueOf(getParameterValue());
}
}
|