Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ae658dbbbf493eb29db1ed44f31792d9feac1a47 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
/*****************************************************************************
 * Copyright (c) 2012, 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *  Christian W. Damus (CEA) - bug 402525
 *  Christian W. Damus (CEA) - bug 430880
 *  Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.ResourceSetListener;
import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand;
//import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowHeaderComposite;
import org.eclipse.nebula.widgets.nattable.filterrow.IFilterStrategy;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
import org.eclipse.nebula.widgets.nattable.print.command.PrintCommand;
import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand;
import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand;
import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent;
import org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent;
import org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand;
import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand;
import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.command.CommandIds;
import org.eclipse.papyrus.infra.nattable.command.UpdateFilterMapCommand;
import org.eclipse.papyrus.infra.nattable.comparator.ObjectNameAndPathComparator;
import org.eclipse.papyrus.infra.nattable.configuration.CellEditorAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.ClearSelectionUIBindingConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.CornerConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.FilterRowAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.FilterRowCustomConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.RowSortModelConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.TableClickSortConfiguration;
import org.eclipse.papyrus.infra.nattable.configuration.TablePopupMenuConfiguration;
import org.eclipse.papyrus.infra.nattable.dataprovider.AbstractCompositeDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnIndexHeaderDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnLabelHeaderDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.CompositeColumnHeaderDataProvider;
import org.eclipse.papyrus.infra.nattable.dataprovider.CompositeRowHeaderDataProvider;
import org.eclipse.papyrus.infra.nattable.display.converter.ObjectNameAndPathDisplayConverter;
import org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration;
import org.eclipse.papyrus.infra.nattable.layer.FilterRowHeaderComposite;
import org.eclipse.papyrus.infra.nattable.layer.PapyrusGridLayer;
import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.ColumnHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.listener.NatTableDropListener;
import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EStructuralFeatureAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.FeatureIdAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.LocalTableHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.BooleanValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NamedStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestyleFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StringListValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.StringValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
import org.eclipse.papyrus.infra.nattable.provider.PapyrusNatTableToolTipProvider;
import org.eclipse.papyrus.infra.nattable.provider.TableSelectionProvider;
import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
import org.eclipse.papyrus.infra.nattable.selection.ISelectionExtractor;
import org.eclipse.papyrus.infra.nattable.sort.IPapyrusSortModel;
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.DefaultSizeUtils;
import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
import org.eclipse.papyrus.infra.nattable.utils.LocationValue;
import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableGridRegion;
import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
import org.eclipse.papyrus.infra.services.decoration.DecorationService;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.ui.util.EclipseCommandUtils;
import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.services.IDisposable;

/**
 *
 * This class allows to create, configure and manipulate the NatTable Widget
 *
 */
public abstract class AbstractNattableWidgetManager implements INattableModelManager, NavigationTarget, IAdaptable {

	/**
	 * we need to keep it to be able to remove listener (required when we destroy the context of the table)
	 *
	 * The editing domain to use to edit context element
	 */
	protected TransactionalEditingDomain contextEditingDomain;

	/**
	 * we need to keep it to be able to remove listener (required when we destroy the context of the table)
	 *
	 * The editing domain to use to edit table elements
	 */
	protected TransactionalEditingDomain tableEditingDomain;

	/**
	 * the managed table
	 */
	private Table table;

	/**
	 * we need to keep it, to be able to remove the listener on it, when the table is destroying
	 */
	private EObject tableContext;

	/**
	 * the nattable widget
	 */
	protected NatTable natTable;

	/**
	 * the grid layer
	 */
	private GridLayer gridLayer;

	/**
	 * the columnHeaderLayerStack
	 */
	private ColumnHeaderLayerStack columnHeaderLayerStack;

	/**
	 * @return the rowHeaderLayerStack
	 */
	public ColumnHeaderLayerStack getColumnHeaderLayerStack() {
		return columnHeaderLayerStack;
	}

	/**
	 * the rowHeaderLayerStack
	 */
	private RowHeaderLayerStack rowHeaderLayerStack;

	/**
	 * @return the rowHeaderLayerStack
	 */
	public RowHeaderLayerStack getRowHeaderLayerStack() {
		return rowHeaderLayerStack;
	}

	/**
	 * the selection provider
	 */
	private TableSelectionProvider selectionProvider;

	private IFilterStrategy<Object> filterStrategy;

	/**
	 * the body layer stack
	 */
	private BodyLayerStack bodyLayerStack;

	private ILayerListener resizeAxisListener;

	private ILayerListener resizeRowHeaderListener;

	private ILayerListener resizeColumnHeaderListener;

	private AbstractCompositeDataProvider columnHeaderDataProvider;

	private AbstractCompositeDataProvider rowHeaderDataProvider;

	private BodyDataProvider bodyDataProvider;

	/**
	 * the composite layer providing the filter row in the column header
	 */
	protected FilterRowHeaderComposite<?> filterColumnHeaderComposite;

	/**
	 * the sort model used for rows
	 */
	protected IPapyrusSortModel rowSortModel;

	private ISelectionExtractor selectionExtractor;

	/**
	 * this listener is used to update value in nattable layer
	 */
	private ResourceSetListener resourceSetListener;

	/**
	 * the filter configuration
	 */
	private FilterRowAxisConfiguration filterConfiguration;

	/**
	 * the cell editor axis configuration
	 */
	private CellEditorAxisConfiguration cellAxisConfiguration;

	/**
	 *
	 * Constructor.
	 *
	 * @param table
	 *            the model of the table
	 */
	public AbstractNattableWidgetManager(final Table table, final ISelectionExtractor selectionExtractor) {
		this.table = table;
		this.tableContext = table.getContext();
		this.selectionExtractor = selectionExtractor;
		this.tableEditingDomain = TableEditingDomainUtils.getTableEditingDomain(table);
		this.contextEditingDomain = TableEditingDomainUtils.getTableContextEditingDomain(table);
	}

	/**
	 * Returns the EditingDomain associated to the table
	 *
	 * @return
	 */
	protected final TransactionalEditingDomain getTableEditingDomain() {
		return this.tableEditingDomain;
	}

	/**
	 * Returns the EditingDomain associated to the context
	 *
	 * @return
	 */
	protected final TransactionalEditingDomain getContextEditingDomain() {
		return this.contextEditingDomain;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#createNattable(org.eclipse.swt.widgets.Composite, int, org.eclipse.ui.IWorkbenchPartSite)
	 *
	 * @param parent
	 * @param style
	 * @param site
	 * @return
	 */
	@Override
	public NatTable createNattable(final Composite parent, final int style, final IWorkbenchPartSite site) {
		this.bodyDataProvider = new BodyDataProvider(this);


		this.bodyLayerStack = new BodyLayerStack(this.bodyDataProvider, this);

		columnHeaderDataProvider = new CompositeColumnHeaderDataProvider(this);
		final IDataProvider indexColumnProvider = new ColumnIndexHeaderDataProvider(this);
		final IDataProvider labelColumnProvider = new ColumnLabelHeaderDataProvider(this);
		columnHeaderDataProvider.addDataProvider(indexColumnProvider);
		columnHeaderDataProvider.addDataProvider(labelColumnProvider);

		// this.columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
		// this.columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
		// this.columnHeaderLayerStack = new ColumnHeaderLayerStack(this.columnHeaderDataProvider, this.bodyLayerStack, this.bodyDataProvider, getRowSortModel());
		this.columnHeaderLayerStack = new ColumnHeaderLayerStack(this, indexColumnProvider, labelColumnProvider, this.bodyLayerStack, getRowSortModel());

		this.rowHeaderLayerStack = createRowHeaderLayerStack(this.bodyLayerStack);
		rowHeaderDataProvider = new CompositeRowHeaderDataProvider(this);
		rowHeaderDataProvider.addDataProvider(this.rowHeaderLayerStack.getIndexDataProvider());
		rowHeaderDataProvider.addDataProvider(this.rowHeaderLayerStack.getLabelDataProvider());



		// final IDataProvider cornerDataProvider = new DefaultCornerDataProvider(this.columnHeaderDataProvider, this.rowHeaderDataProvider);
		final IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);


		// create the filter layer, configRegistry can be null for our usecase
		this.filterStrategy = createFilterStrategy();
		this.filterColumnHeaderComposite = new FilterRowHeaderComposite<Object>(this.filterStrategy, columnHeaderLayerStack, columnHeaderDataProvider, this);

		// init the filter visibility
		this.filterColumnHeaderComposite.setFilterRowVisible(HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(this.table).isDisplayFilter());

		final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), this.rowHeaderLayerStack, filterColumnHeaderComposite);
		cornerLayer.addConfiguration(new CornerConfiguration(this));

		this.gridLayer = new PapyrusGridLayer(TransactionUtil.getEditingDomain(tableContext), this.bodyLayerStack, filterColumnHeaderComposite, this.rowHeaderLayerStack, cornerLayer);
		this.gridLayer.addConfiguration(new DefaultPrintBindings());
		this.natTable = new NatTable(parent, this.gridLayer, false);

		// we register nattable configuration
		registerPopupMenuConfiguration(this.natTable);

		addClickSortConfiguration(this.natTable);
		this.natTable.addConfiguration(new FilterRowCustomConfiguration());
		this.natTable.addConfiguration(new RowSortModelConfiguration(getRowSortModel()));
		this.natTable.addConfiguration(new ClearSelectionUIBindingConfiguration());
		// we register some information in the config registry of the nattable widget
		IConfigRegistry configRegistry = this.natTable.getConfigRegistry();

		// could be done by config file!
		configRegistry.registerConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, AbstractNattableWidgetManager.this, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
		configRegistry.registerConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, getContextLabelProviderService(), DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
		// commented because seems generate several bugs with edition
		// newRegistry.registerConfigAttribute( CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter(), DisplayMode.NORMAL, GridRegion.BODY);

		// configuration used by filter
		ObjectNameAndPathDisplayConverter converter = new ObjectNameAndPathDisplayConverter(getContextLabelProviderService());
		configRegistry.registerConfigAttribute(NattableConfigAttributes.OBJECT_NAME_AND_PATH_DISPLAY_CONVERTER, converter, DisplayMode.NORMAL, NattableConfigAttributes.OBJECT_NAME_AND_PATH_DISPLAY_CONVERTER_ID);
		configRegistry.registerConfigAttribute(NattableConfigAttributes.OBJECT_NAME_AND_PATH_COMPARATOR, new ObjectNameAndPathComparator(converter), DisplayMode.NORMAL, NattableConfigAttributes.OBJECT_NAME_AND_PATH_COMPARATOR_ID);

		// register the decoration service
		configRegistry.registerConfigAttribute(NattableConfigAttributes.DECORATION_SERVICE_CONFIG_ATTRIBUTE, getDecorationService(), DisplayMode.NORMAL, NattableConfigAttributes.DECORATION_SERVICE_ID);

		this.natTable.setConfigRegistry(configRegistry);
		this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable));
		this.natTable.configure();

		// we create editors and filter configuration, we can not add it to a layer, because the configuration must be updated after add/move axis and invert axis
		this.filterConfiguration = new FilterRowAxisConfiguration();
		this.cellAxisConfiguration = new CellEditorAxisConfiguration();
		configureFilters();
		configureCellAxisEditor();


		// initialize the table by checking all its applied styles
		initTableAxis();
		initTableHeaders();
		initTableMerge();

		addColumnReorderListener(this.bodyLayerStack.getColumnReorderLayer());
		addAxisResizeListener(this.bodyLayerStack);
		addColumnHeaderResizeListener(this.columnHeaderLayerStack);
		addRowHeaderResizeListener(this.rowHeaderLayerStack);
		addDragAndDropSupport(this.natTable);

		this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer());
		createAndRegisterMenuManagerAndSelectionProvider(this.natTable, site, this.selectionProvider);


		new PapyrusNatTableToolTipProvider(this.natTable, GridRegion.BODY, GridRegion.COLUMN_HEADER, GridRegion.ROW_HEADER);
		initResourceSetListener();
		return this.natTable;
	}

	/**
	 * Register the menu configuration for the table
	 *
	 * @param natTable
	 *            the nattable to configure
	 */
	protected void registerPopupMenuConfiguration(final NatTable natTable) {
		natTable.addConfiguration(new TablePopupMenuConfiguration());
	}

	/**
	 * Configure the row sort selecting column header
	 *
	 * @param natTable
	 *            the nattable widget
	 */
	protected void addClickSortConfiguration(NatTable natTable) {
		natTable.addConfiguration(new TableClickSortConfiguration());
	}

	/**
	 * @return
	 * 		the filter strategy to use
	 */
	protected abstract IFilterStrategy<Object> createFilterStrategy();


	/**
	 * TODO : should be refactored with resourceset used in NattableModelManager
	 */
	private void initResourceSetListener() {
		// resourceSetListener used to capture table style modification
		// these events can be used to undo/redo previous actions
		resourceSetListener = new ResourceSetListener() {

			@Override
			public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
				return null;
			}

			@Override
			public void resourceSetChanged(ResourceSetChangeEvent event) {

				for (final Notification notification : event.getNotifications()) {
					// filter the events to only let through the changes on the current table resource
					Table notifiedTable = findTable(notification);
					if (getTable().equals(notifiedTable)) {

						Display.getDefault().asyncExec(new Runnable() {

							@Override
							public void run() {

								Object notifier = notification.getNotifier();
								Object feature = notification.getFeature();
								Object newValue = notification.getNewValue();
								Object oldValue = notification.getOldValue();
								if (notifier instanceof LocalTableHeaderAxisConfiguration) {
									boolean onColumnOnModel = getTable().getLocalColumnHeaderAxisConfiguration() == notifier;
									boolean isInverted = table.isInvertAxis();

									if (feature == NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayFilter() && newValue instanceof Boolean) {
										if ((onColumnOnModel && !isInverted) || (!onColumnOnModel && isInverted)) {
											AbstractNattableWidgetManager.this.filterColumnHeaderComposite.setFilterRowVisible(((Boolean) newValue).booleanValue());
											natTable.refresh();
										}
									}
								} else if (notifier instanceof Table && feature == NattablePackage.eINSTANCE.getTable_InvertAxis()) {
									// TODO : replace the listener and its action done in NattableModelManger by this one
									AbstractNattableWidgetManager.this.filterColumnHeaderComposite.setFilterRowVisible(HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(getTable()).isDisplayFilter());
									natTable.refresh();
								} else if (notifier instanceof IAxis || notifier instanceof StringValueStyle || notifier instanceof StringListValueStyle) {
									boolean refreshFilter = false;
									IAxis axisToRefresh = null;
									if (notifier instanceof IAxis) {
										axisToRefresh = (IAxis) notifier;
										if (oldValue instanceof NamedStyle && IFilterConfiguration.FILTER_VALUE_TO_MATCH.equals(((NamedStyle) oldValue).getName())) {
											// we need to replay the filter
											refreshFilter = true;
										} else if (newValue instanceof NamedStyle && IFilterConfiguration.FILTER_VALUE_TO_MATCH.equals(((NamedStyle) newValue).getName())) {
											refreshFilter = true;
										}
									}
									if ((notifier instanceof StringValueStyle || notifier instanceof StringListValueStyle) && IFilterConfiguration.FILTER_VALUE_TO_MATCH.equals(((NamedStyle) notifier).getName())) {
										EObject container = ((NamedStyle) notifier).eContainer();
										if (container instanceof IAxis) {
											axisToRefresh = (IAxis) container;
											refreshFilter = true;
										}
									}
									if (refreshFilter && axisToRefresh != null) {
										// we need to update the filter map value (manage Undo/Redo for example)
										int index = -1;
										if (table.isInvertAxis() && getRowElementsList().contains(axisToRefresh)) {
											index = getRowElementsList().indexOf(axisToRefresh);
										} else if (!table.isInvertAxis() && getColumnElementsList().contains(axisToRefresh)) {
											index = getColumnElementsList().indexOf(axisToRefresh);
										}
										if (index != -1) {
											filterColumnHeaderComposite.doCommand(new UpdateFilterMapCommand(index));
										}

									}
								}
							}
						});
					}
				}
			}

			@Override
			public boolean isPrecommitOnly() {
				return false;
			}

			@Override
			public boolean isPostcommitOnly() {
				return false;
			}

			@Override
			public boolean isAggregatePrecommitListener() {
				return false;
			}

			@Override
			public NotificationFilter getFilter() {
				// this filter only lets through the notifications pertaining to the table
				// the first three conditions handle the modification, the add and the remove of styles
				// the last seven handle the modified or created objects containing those styles
				return ((NotificationFilter.createEventTypeFilter(Notification.SET))
						.or(NotificationFilter.createEventTypeFilter(Notification.ADD))
						.or(NotificationFilter.createEventTypeFilter(Notification.REMOVE)))
								.and((NotificationFilter.createNotifierTypeFilter(BooleanValueStyle.class))
										.or(NotificationFilter.createNotifierTypeFilter(IntValueStyle.class))
										.or(NotificationFilter.createNotifierTypeFilter(Style.class))
										.or(NotificationFilter.createNotifierTypeFilter(EObjectAxis.class))
										.or(NotificationFilter.createNotifierTypeFilter(FeatureIdAxis.class))
										.or(NotificationFilter.createNotifierTypeFilter(EStructuralFeatureAxis.class))
										.or(NotificationFilter.createNotifierTypeFilter(LocalTableHeaderAxisConfiguration.class))
										.or(NotificationFilter.createNotifierTypeFilter(Table.class)));
				// return NotificationFilter.createNotifierTypeFilter(EObject.class);
			}
		};

		if (this.tableEditingDomain != null) {
			this.tableEditingDomain.addResourceSetListener(resourceSetListener);
		}
	}

	/**
	 *
	 * @param notification
	 * @return
	 * 		The nearest table containing the style in order to verify the table's styled event's source
	 */
	protected static Table findTable(Notification notification) {
		if (notification.getNotifier() instanceof Table) {
			return (Table) notification.getNotifier();
		} else {
			Object notifier = notification.getNotifier();
			if (notifier instanceof EObject) {
				EObject container = ((EObject) notifier).eContainer();
				while (!(container instanceof Table) && container != null) {
					container = container.eContainer();
				}
				return (Table) container;
			}
			return null;
		}
	}

	/**
	 *
	 * @param bodyLayerStack
	 *            the body layer stack to use
	 *
	 * @return
	 * 		the row header layer stack to use
	 */
	protected RowHeaderLayerStack createRowHeaderLayerStack(BodyLayerStack bodyLayerStack) {
		return new RowHeaderLayerStack(bodyLayerStack, this);
	}

	/**
	 * configure the cell editor used in the table
	 */
	protected final void configureCellAxisEditor() {
		this.cellAxisConfiguration.configureRegistry(this.natTable.getConfigRegistry());
	}

	/**
	 * configure the filters
	 */
	protected final void configureFilters() {
		this.filterConfiguration.configureRegistry(this.natTable.getConfigRegistry());
	}

	/**
	 *
	 * @return
	 * 		the label provider service
	 */
	private LabelProviderService getContextLabelProviderService() {
		try {
			ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(this.table.getContext());// get context and NOT get table for the usecase where the table is not in a resource
			return serviceRegistry.getService(LabelProviderService.class);
		} catch (ServiceException e) {
			Activator.log.error(e);
		}
		return null;
	}

	/**
	 *
	 * @return
	 * 		the decoration service
	 */
	protected DecorationService getDecorationService() {
		try {
			ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(this.table.getContext());// get context and NOT get table for the usecase where the table is not in a resource
			return serviceRegistry.getService(DecorationService.class);
		} catch (ServiceException e) {
			Activator.log.error(e);
		}
		return null;
	}

	/**
	 *
	 * @param natTable
	 * @return
	 *
	 * @deprecated since Papyrus 1.3 (Eclipse Neon)
	 */
	@Deprecated
	public MenuManager createMenuManager(final NatTable natTable) {
		return createAndRegisterMenuManagerAndSelectionProvider(natTable, null, this.selectionProvider);
	}

	/**
	 *
	 * @param natTable
	 * @param site
	 * @param selectionProvider
	 *
	 * @return
	 * 		This method creates the MenuManager used for theBody of the table and register it, with the selection provider in the {@link IWorkbenchPartSite} of the editor when not <code>null</code>
	 */
	public MenuManager createAndRegisterMenuManagerAndSelectionProvider(final NatTable natTable, final IWorkbenchPartSite site, ISelectionProvider selectionProvider) {
		final MenuManager menuManager = new MenuManager(MenuConstants.POPUP, MenuConstants.TABLE_POPUP_MENU_ID);
		// menuManager.setRemoveAllWhenShown(true);

		final Menu menu = menuManager.createContextMenu(this.natTable);

		this.natTable.setMenu(menu);
		if (site != null) {
			site.registerContextMenu(menuManager.getId(), menuManager, selectionProvider);
			site.setSelectionProvider(this.selectionProvider);
		}

		// we create the separator here, and not in the plugin.xml file in order to get the wanted order (in plugin.xml it seems depends on the order of plugin activation
		Separator separator = new Separator(MenuConstants.GENERAL_SEPARATOR_ID);
		separator.setVisible(false);// the first one is not visible
		menuManager.add(separator);

		separator = new Separator(MenuConstants.EDIT_SEPARATOR_ID);
		separator.setVisible(true);
		menuManager.add(separator);

		separator = new Separator(MenuConstants.CELL_SEPARATOR_ID);
		separator.setVisible(true);
		menuManager.add(separator);

		separator = new Separator(MenuConstants.ROWS_AND_COLUMNS_SEPARATOR_ID);
		separator.setVisible(true);
		menuManager.add(separator);

		separator = new Separator(MenuConstants.CREATIONS_SEPARATOR_ID);
		separator.setVisible(true);
		menuManager.add(separator);

		separator = new Separator(MenuConstants.TOOLS_SEPARATOR_ID);
		separator.setVisible(true);
		menuManager.add(separator);

		// commented to avoid to pollute the table menu with global contribution
		// separator = new Separator(MenuConstants.ADDITIONS_SEPARATOR_ID);
		// separator.setVisible(true);
		// menuManager.add(separator);

		return menuManager;
	}

	/**
	 * Enable the table to receive dropped elements
	 *
	 * @param nattable
	 *            the nattable widget in which we add the drag&drop support
	 */
	protected void addDragAndDropSupport(final NatTable nattable) {
		final int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
		final DropTarget target = new DropTarget(nattable, operations);
		final LocalTransfer localTransfer = LocalTransfer.getInstance();
		final LocalSelectionTransfer localSelectionTransfer = LocalSelectionTransfer.getTransfer();
		final Transfer[] types = new Transfer[] { localSelectionTransfer, localTransfer };
		target.setTransfer(types);
		final NatTableDropListener dropListener = createDropListener();
		target.addDropListener(dropListener);
	}

	protected NatTableDropListener createDropListener() {
		return new NatTableDropListener(this, this.selectionExtractor);
	}

	/**
	 * Add a listener on the column reorder layer in order to update the model
	 *
	 * @param columnReorderLayer
	 *            the column reorder layer
	 */
	private void addColumnReorderListener(final ColumnReorderLayer columnReorderLayer) {
		columnReorderLayer.addLayerListener(new ILayerListener() {


			@Override
			public void handleLayerEvent(final ILayerEvent event) {
				if (event instanceof ColumnReorderEvent) {
					ColumnReorderEvent columnReorderEvent = (ColumnReorderEvent) event;
					int start = -1;
					int end = columnReorderEvent.getBeforeToColumnPosition();
					for (Range range : columnReorderEvent.getBeforeFromColumnPositionRanges()) {
						start = range.start;
						break;
					}

					if (start != -1) {
						final List<IAxis> allAxis = AbstractNattableWidgetManager.this.getColumnAxisManager().getRepresentedContentProvider().getAxis();

						// This solve an index difference between moving
						// a column from right to left and moving a
						// column from left to right
						if (start >= 0 && start < end && columnReorderEvent.isReorderToLeftEdge()) {
							end--;
						}

						final IAxis axisToMove = allAxis.get(start);
						if (axisToMove != null) {
							moveColumnElement(axisToMove, end);
						}
					}
				}
			}
		});
	}

	/**
	 * Add a listener on the body itself in order to update the model
	 *
	 * @param bodyLayerStack
	 *            the table's body layer
	 */
	private void addAxisResizeListener(final BodyLayerStack bodyLayerStack) {
		resizeAxisListener = new ILayerListener() {

			@Override
			public void handleLayerEvent(ILayerEvent event) {
				// both events are considered as a body change and therefore we need to check each possibility
				if (event instanceof ColumnResizeEvent || event instanceof RowResizeEvent) {
					final CompositeCommand resizeCommand = new CompositeCommand("resize IAxis' width or height"); //$NON-NLS-1$
					TransactionalEditingDomain tableDomain = TableEditingDomainUtils.getTableEditingDomain(table);
					if (tableDomain == null) {
						return;
					}

					if (event instanceof ColumnResizeEvent) {
						// get the index of the first column modified by the user
						// the assumption is that the user changes only one column at a time in order to resize to its liking
						int resizedColumnPosition = getRangeStart(event);
						// get the resized value from this column
						int newColumnSize = columnHeaderLayerStack.getColumnWidthByPosition(resizedColumnPosition);
						// get the associated object
						Object currentColumnObject = getColumnElement(resizedColumnPosition); // INattableModelManager -> ITableAxisElementProvider.getColumnElement
						if (currentColumnObject instanceof IAxis) {
							// the object is now the Axis in which the style will be applied
							IAxis currentColumnIAxis = (IAxis) currentColumnObject;
							if (currentColumnIAxis.eContainer() != null) {
								IntValueStyle value = (IntValueStyle) currentColumnIAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
								if (value != null && value.getIntValue() != newColumnSize) {
									// Constructs a new request to set the value of a structural feature in a model element
									SetRequest resizeColumnRequest = new SetRequest(tableDomain, value, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newColumnSize);
									// initialize the feature value if none before and replace the value if another existed prior to the resize
									SetValueCommand resizeColumnCommand = new SetValueCommand(resizeColumnRequest);
									resizeCommand.add(resizeColumnCommand);

								} else if (value == null && newColumnSize != DefaultSizeUtils.getDefaultCellWidth()) {
									// the element does not have any predefined width value attached to its resource so we create it
									value = NattablestyleFactory.eINSTANCE.createIntValueStyle();
									value.setIntValue(newColumnSize);
									value.setName(NamedStyleConstants.AXIS_WIDTH);
									SetRequest initColumnSizeRequest = new SetRequest(tableDomain, currentColumnIAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), value);
									SetValueCommand resizeColumnCommand = new SetValueCommand(initColumnSizeRequest);
									resizeCommand.add(resizeColumnCommand);

								}
							}
						}

					}

					// the process is the same for this event
					else if (event instanceof RowResizeEvent) {
						int resizedRowPosition = getRangeStart(event);
						int newRowSize = rowHeaderLayerStack.getRowHeightByPosition(resizedRowPosition);
						Object currentRowObject = getRowElement(resizedRowPosition);
						if (currentRowObject instanceof IAxis) {
							IAxis currentRowIAxis = (IAxis) currentRowObject;
							if (currentRowIAxis.eContainer() != null) {
								IntValueStyle value = (IntValueStyle) currentRowIAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_HEIGHT);
								if (value != null && value.getIntValue() != newRowSize) {
									SetRequest resizeRowRequest = new SetRequest(tableDomain, value, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newRowSize);
									SetValueCommand resizeRowCommand = new SetValueCommand(resizeRowRequest);
									resizeCommand.add(resizeRowCommand);

								} else if (value == null && newRowSize != DefaultSizeUtils.getDefaultCellHeight()) {
									value = NattablestyleFactory.eINSTANCE.createIntValueStyle();
									value.setIntValue(newRowSize);
									value.setName(NamedStyleConstants.AXIS_HEIGHT);
									SetRequest initRowSizeRequest = new SetRequest(tableDomain, currentRowIAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), value);
									SetValueCommand resizeRowCommand = new SetValueCommand(initRowSizeRequest);
									resizeCommand.add(resizeRowCommand);

								}
							}
						}
					}
					if (!resizeCommand.isEmpty()) {
						tableDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(resizeCommand));
					}

				}
			}
		};

		bodyLayerStack.addLayerListener(resizeAxisListener);

	}


	/**
	 * This method is used to get the position of the row or column being modified
	 *
	 * @param event
	 * @return
	 */
	private int getRangeStart(ILayerEvent event) {
		int start = -1;
		if (event instanceof ColumnResizeEvent) {
			ColumnResizeEvent resizeEvent = (ColumnResizeEvent) event;
			// only one element is handled at a time so the start value won't be overwritten
			for (Range current : resizeEvent.getColumnPositionRanges()) {
				start = current.start;
			}
		}
		if (event instanceof RowResizeEvent) {
			RowResizeEvent resizeEvent = (RowResizeEvent) event;
			for (Range current : resizeEvent.getRowPositionRanges()) {
				start = current.start;
			}
		}
		return start;
	}


	/**
	 * Add a listener to the column's header layer in order to update the model
	 *
	 * @param columnHeaderLayerStack
	 */
	private void addColumnHeaderResizeListener(final ColumnHeaderLayerStack columnHeaderLayerStack) {
		resizeColumnHeaderListener = new ILayerListener() {

			@Override
			public void handleLayerEvent(ILayerEvent event) {
				if (event instanceof RowResizeEvent) {
					// get the new values from the index and label headers
					int newHeaderIndexHeight = columnHeaderLayerStack.getColumnIndexDataLayer().getRowHeightByPosition(0);
					int newHeaderLabelHeight = columnHeaderLayerStack.getColumnLabelDataLayer().getRowHeightByPosition(0);
					// get the position of the header being modified
					int resizedHeaderPosition = getRangeStart(event);

					// verify that the event is handled properly
					if (resizedHeaderPosition != -1) {
						final CompositeCommand resizeColumnHeaderCommand = new CompositeCommand("resize ColumnHeader's height"); //$NON-NLS-1$
						TransactionalEditingDomain tableDomain = TableEditingDomainUtils.getTableEditingDomain(table);
						// create a blank variable as its contents can change if the table is inverted or not
						LocalTableHeaderAxisConfiguration localColumnHeaderAxis = null;

						if (!getTable().isInvertAxis()) {
							if (getTable().getLocalColumnHeaderAxisConfiguration() != null) {
								localColumnHeaderAxis = getTable().getLocalColumnHeaderAxisConfiguration();
							} else if (newHeaderIndexHeight != DefaultSizeUtils.getDefaultCellHeight() || newHeaderLabelHeight != DefaultSizeUtils.getDefaultCellHeight()) {
								TableHeaderAxisConfiguration columnHeaderAxis;
								// create the blank feature that will host the new local header
								EStructuralFeature localHeaderFeature = null;
								columnHeaderAxis = getTable().getTableConfiguration().getColumnHeaderAxisConfiguration();
								localColumnHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(columnHeaderAxis);
								localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();

								// commands used to modify the notation file and create the new local header
								IEditCommandRequest initLocalColumnHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localColumnHeaderAxis);
								IElementEditService localColumnHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
								resizeColumnHeaderCommand.add(localColumnHeaderAxisProvider.getEditCommand(initLocalColumnHeaderAxis));
							}

						} else {
							if (getTable().getLocalRowHeaderAxisConfiguration() != null) {
								// as the axis are inverted the row headers are now the column headers
								localColumnHeaderAxis = getTable().getLocalRowHeaderAxisConfiguration();
							} else if (newHeaderIndexHeight != DefaultSizeUtils.getDefaultCellHeight() || newHeaderLabelHeight != DefaultSizeUtils.getDefaultCellHeight()) {
								// the behavior is now the same as usual
								TableHeaderAxisConfiguration columnHeaderAxis;
								EStructuralFeature localHeaderFeature = null;
								columnHeaderAxis = getTable().getTableConfiguration().getRowHeaderAxisConfiguration();
								localColumnHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(columnHeaderAxis);
								localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();

								IEditCommandRequest initLocalColumnHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localColumnHeaderAxis);
								IElementEditService localColumnHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
								resizeColumnHeaderCommand.add(localColumnHeaderAxisProvider.getEditCommand(initLocalColumnHeaderAxis));
							}

						}
						
						// If this index is not display, increment the resized header position to corresponding to the label
						if(null != localColumnHeaderAxis && !localColumnHeaderAxis.isDisplayIndex()){
							resizedHeaderPosition++;
						}


						// manipulate the index layer and as the variables are now fixed this part is common to both the inverted and not inverted case
						if (resizedHeaderPosition == 0 && localColumnHeaderAxis != null) {
							IntValueStyle valueIndex = (IntValueStyle) localColumnHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.COLUMN_INDEX_HEIGHT);
							if (valueIndex != null && valueIndex.getIntValue() != newHeaderIndexHeight) {
								// the variable to be edited already exists
								SetRequest resizeRowHeaderIndex = new SetRequest(tableDomain, valueIndex, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderIndexHeight);
								SetValueCommand resizeColumnHeaderIndexCommand = new SetValueCommand(resizeRowHeaderIndex);
								resizeColumnHeaderCommand.add(resizeColumnHeaderIndexCommand);
							} else if (valueIndex == null && newHeaderIndexHeight != DefaultSizeUtils.getDefaultCellHeight()) {
								// if the variable does not exist, it is created
								valueIndex = NattablestyleFactory.eINSTANCE.createIntValueStyle();
								valueIndex.setIntValue(newHeaderIndexHeight);
								valueIndex.setName(NamedStyleConstants.COLUMN_INDEX_HEIGHT);

								SetRequest initRowHeaderIndexSizeRequest = new SetRequest(tableDomain, localColumnHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueIndex);
								SetValueCommand resizeColumnHeaderIndexCommand = new SetValueCommand(initRowHeaderIndexSizeRequest);
								resizeColumnHeaderCommand.add(resizeColumnHeaderIndexCommand);
							}
						}

						// manipulate the label layer and as the variables are now fixed this part is common to both the inverted and not inverted case
						if (resizedHeaderPosition == 1 && localColumnHeaderAxis != null) {
							IntValueStyle valueLabel = (IntValueStyle) localColumnHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.COLUMN_LABEL_HEIGHT);
							if (valueLabel != null && valueLabel.getIntValue() != newHeaderLabelHeight) {
								// the variable to be edited already exists
								SetRequest resizeRowHeaderLabel = new SetRequest(tableDomain, valueLabel, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderLabelHeight);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(resizeRowHeaderLabel);
								resizeColumnHeaderCommand.add(resizeRowHeaderLabelCommand);
							} else if (valueLabel == null && newHeaderLabelHeight != DefaultSizeUtils.getDefaultCellHeight()) {
								// if the variable does not exist, it is created
								valueLabel = NattablestyleFactory.eINSTANCE.createIntValueStyle();
								valueLabel.setIntValue(newHeaderLabelHeight);
								valueLabel.setName(NamedStyleConstants.COLUMN_LABEL_HEIGHT);

								SetRequest initRowHeaderLabelSizeRequest = new SetRequest(tableDomain, localColumnHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueLabel);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(initRowHeaderLabelSizeRequest);
								resizeColumnHeaderCommand.add(resizeRowHeaderLabelCommand);
							}
						}

						// all the commands are executed and the variables and their local headers are created or updated
						if (resizeColumnHeaderCommand.canExecute() && !resizeColumnHeaderCommand.isEmpty()) {
							tableDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(resizeColumnHeaderCommand));
						}
					}
				}
			}
		};

		columnHeaderLayerStack.addLayerListener(resizeColumnHeaderListener);

	}


	/**
	 * Add a listener to the row's header layer in order to update the model
	 *
	 * @param rowHeaderLayerStack
	 */
	private void addRowHeaderResizeListener(final RowHeaderLayerStack rowHeaderLayerStack) {
		resizeRowHeaderListener = new ILayerListener() {

			// the behavior of this method is exactly the same as the one before
			@Override
			public void handleLayerEvent(ILayerEvent event) {
				if (event instanceof ColumnResizeEvent) {
					
					// Calculate the width of the index column and of the label column (depending to its position)
					int newHeaderIndexWidth = rowHeaderLayerStack.getRowIndexDataLayer().getColumnWidthByPosition(0);
					int newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(0);
					int resizedHeaderPosition = getRangeStart(event);

					if (resizedHeaderPosition != -1) {
						final CompositeCommand resizeRowHeaderCommand = new CompositeCommand("resize RowHeader's width"); //$NON-NLS-1$
						TransactionalEditingDomain tableDomain = TableEditingDomainUtils.getTableEditingDomain(table);
						if (tableDomain == null) {
							return;
						}
						LocalTableHeaderAxisConfiguration localRowHeaderAxis = null;


						if (!getTable().isInvertAxis()) {
							if (getTable().getLocalRowHeaderAxisConfiguration() != null) {
								localRowHeaderAxis = getTable().getLocalRowHeaderAxisConfiguration();
							} else if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
									TableHeaderAxisConfiguration rowHeaderAxis;
									EStructuralFeature localHeaderFeature = null;
									rowHeaderAxis = getTable().getTableConfiguration().getRowHeaderAxisConfiguration();
									localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
									localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
	
									IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
									IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
									resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
							}

						} else {
							if (getTable().getLocalColumnHeaderAxisConfiguration() != null) {
								localRowHeaderAxis = getTable().getLocalColumnHeaderAxisConfiguration();
							} else if (newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth() || newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
									TableHeaderAxisConfiguration rowHeaderAxis;
									EStructuralFeature localHeaderFeature = null;
									rowHeaderAxis = getTable().getTableConfiguration().getColumnHeaderAxisConfiguration();
									localRowHeaderAxis = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration(rowHeaderAxis);
									localHeaderFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
	
									IEditCommandRequest initLocalRowHeaderAxis = new SetRequest(tableDomain, table, localHeaderFeature, localRowHeaderAxis);
									IElementEditService localRowHeaderAxisProvider = ElementEditServiceUtils.getCommandProvider(table);
									resizeRowHeaderCommand.add(localRowHeaderAxisProvider.getEditCommand(initLocalRowHeaderAxis));
							}

						}
						
						// If this index is not display, increment the resized header position to corresponding to the label
						if(null != localRowHeaderAxis && !localRowHeaderAxis.isDisplayIndex()){
							resizedHeaderPosition++;
						}
						
						// Recalculate the initial label width to compare with the correct one
						newHeaderLabelWidth = rowHeaderLayerStack.getRowLabelDataLayer().getColumnWidthByPosition(resizedHeaderPosition-1);

						if (resizedHeaderPosition == 0 && localRowHeaderAxis != null) {
							IntValueStyle valueIndex = (IntValueStyle) localRowHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.ROW_INDEX_WIDTH);
							if (valueIndex != null && valueIndex.getIntValue() != newHeaderIndexWidth) {
								SetRequest resizeRowHeaderIndex = new SetRequest(tableDomain, valueIndex, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderIndexWidth);
								SetValueCommand resizeRowHeaderIndexCommand = new SetValueCommand(resizeRowHeaderIndex);
								resizeRowHeaderCommand.add(resizeRowHeaderIndexCommand);
							} else if (valueIndex == null && newHeaderIndexWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
								valueIndex = NattablestyleFactory.eINSTANCE.createIntValueStyle();
								valueIndex.setIntValue(newHeaderIndexWidth);
								valueIndex.setName(NamedStyleConstants.ROW_INDEX_WIDTH);

								SetRequest initRowHeaderIndexSizeRequest = new SetRequest(tableDomain, localRowHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueIndex);
								SetValueCommand resizeRowHeaderIndexCommand = new SetValueCommand(initRowHeaderIndexSizeRequest);
								resizeRowHeaderCommand.add(resizeRowHeaderIndexCommand);
							}
						}

						if (resizedHeaderPosition == 1 && localRowHeaderAxis != null) {
							IntValueStyle valueLabel = (IntValueStyle) localRowHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.ROW_LABEL_WIDTH);
							if (valueLabel != null && valueLabel.getIntValue() != newHeaderLabelWidth) {
								SetRequest resizeRowHeaderLabel = new SetRequest(tableDomain, valueLabel, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderLabelWidth);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(resizeRowHeaderLabel);
								resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
							} else if (valueLabel == null && newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
								valueLabel = NattablestyleFactory.eINSTANCE.createIntValueStyle();
								valueLabel.setIntValue(newHeaderLabelWidth);
								valueLabel.setName(NamedStyleConstants.ROW_LABEL_WIDTH);

								SetRequest initRowHeaderLabelSizeRequest = new SetRequest(tableDomain, localRowHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueLabel);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(initRowHeaderLabelSizeRequest);
								resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
							}
						}
						
						if(resizedHeaderPosition > 1 && null != localRowHeaderAxis){
							final StringBuilder nameStyle = new StringBuilder(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH);
							nameStyle.append(resizedHeaderPosition);
							nameStyle.append(NamedStyleConstants.ROW_LABEL_POSITION_SUFFIX_WIDTH);
							
							IntValueStyle valueLabel = (IntValueStyle) localRowHeaderAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), nameStyle.toString());
							if (valueLabel != null && valueLabel.getIntValue() != newHeaderLabelWidth) {
								SetRequest resizeRowHeaderLabel = new SetRequest(tableDomain, valueLabel, NattablestylePackage.eINSTANCE.getIntValueStyle_IntValue(), newHeaderLabelWidth);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(resizeRowHeaderLabel);
								resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
							} else if (valueLabel == null && newHeaderLabelWidth != DefaultSizeUtils.getDefaultRowHeaderWidth()) {
								valueLabel = NattablestyleFactory.eINSTANCE.createIntValueStyle();
								valueLabel.setIntValue(newHeaderLabelWidth);
								valueLabel.setName(nameStyle.toString());

								SetRequest initRowHeaderLabelSizeRequest = new SetRequest(tableDomain, localRowHeaderAxis, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), valueLabel);
								SetValueCommand resizeRowHeaderLabelCommand = new SetValueCommand(initRowHeaderLabelSizeRequest);
								resizeRowHeaderCommand.add(resizeRowHeaderLabelCommand);
							}
						}


						if (resizeRowHeaderCommand.canExecute() && !resizeRowHeaderCommand.isEmpty()) {
							tableDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(resizeRowHeaderCommand));
						}
					}
				}
			}
		};

		rowHeaderLayerStack.addLayerListener(resizeRowHeaderListener);

	}

	/**
	 *
	 * @param event
	 *            an event
	 * @return
	 * 		a LocationValue for the point, which contains informations about this location (TableGridRegion, row and column index, row and column
	 *         elements, the cell, the point and its translation).
	 *         Some of these values can be <code>null</code> or not depending of the region of the table
	 */
	@Override
	public LocationValue getLocationInTheTable(final Point absolutePoint) {
		final Point widgetPoint = this.natTable.toControl(absolutePoint.x, absolutePoint.y);
		TableGridRegion kind = TableGridRegion.UNKNOWN;
		int columnPosition = this.natTable.getColumnPositionByX(widgetPoint.x);
		int columnIndex = this.natTable.getColumnIndexByPosition(columnPosition);
		int rowPosition = this.natTable.getRowPositionByY(widgetPoint.y);
		int rowIndex = this.natTable.getRowIndexByPosition(rowPosition);
		final ILayerCell cell = this.natTable.getCellByPosition(columnPosition, rowPosition);
		Object columnObject = null;
		Object rowObject = null;
		if (rowIndex == -1 && columnIndex == -1) {
			kind = TableGridRegion.UNKNOWN;
		} else if (rowIndex == -1) {
			kind = TableGridRegion.AFTER_ROW_HEADER;
		} else if (columnIndex == -1) {
			kind = TableGridRegion.AFTER_COLUMN_HEADER;
		} else {
			if (cell != null) {
				LabelStack label = cell.getConfigLabels();
				if (label.hasLabel(GridRegion.ROW_HEADER)) {
					kind = TableGridRegion.ROW_HEADER;

				} else if (label.hasLabel(GridRegion.COLUMN_HEADER)) {
					kind = TableGridRegion.COLUMN_HEADER;

				} else if (label.hasLabel(GridRegion.CORNER)) {
					kind = TableGridRegion.CORNER;
				} else if (label.hasLabel(GridRegion.BODY)) {
					kind = TableGridRegion.CELL;
					columnObject = getColumnElement(columnIndex);
					rowObject = getRowElement(rowIndex);
				}
			}
		}
		return new LocationValue(absolutePoint, widgetPoint, kind, cell, columnIndex, rowIndex, columnObject, rowObject);
	}


	public GridLayer getGridLayer() {
		return this.gridLayer;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#print()
	 *
	 */
	@Override
	public void print() {
		this.natTable.doCommand(new TurnViewportOffCommand());
		this.natTable.doCommand(new PrintCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
		this.natTable.doCommand(new TurnViewportOnCommand());
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#selectAll()
	 *
	 */
	@Override
	public void selectAll() {
		this.natTable.doCommand(new SelectAllCommand());
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#exportToXLS()
	 *
	 */
	@Override
	public void exportToXLS() {
		this.natTable.doCommand(new ExportCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
	}

	public void copyToClipboard() {
		this.natTable.doCommand(new CopyDataToClipboardCommand("\t", System.getProperty("line.separator"), this.natTable.getConfigRegistry())); //$NON-NLS-1$ //$NON-NLS-2$
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getBodyLayerStack()
	 *
	 * @return
	 */
	@Override
	public BodyLayerStack getBodyLayerStack() {
		return this.bodyLayerStack;
	}

	@Override
	public void dispose() {
		if (this.bodyDataProvider != null) {
			this.bodyLayerStack.removeLayerListener(resizeAxisListener);
			this.bodyLayerStack.dispose();
			this.bodyLayerStack = null;
			this.bodyDataProvider.dispose();
			this.bodyDataProvider = null;
		}
		if (this.rowHeaderDataProvider != null) {
			this.rowHeaderLayerStack.removeLayerListener(resizeRowHeaderListener);
			this.rowHeaderLayerStack.dispose();
			this.rowHeaderLayerStack = null;
			this.rowHeaderDataProvider.dispose();
			this.rowHeaderDataProvider = null;
		}
		if (this.columnHeaderDataProvider != null) {
			this.columnHeaderLayerStack.removeLayerListener(resizeColumnHeaderListener);
			this.columnHeaderLayerStack.dispose();
			this.columnHeaderLayerStack = null;
			this.columnHeaderDataProvider.dispose();
			this.columnHeaderDataProvider = null;
		}

		if (this.tableEditingDomain != null && this.resourceSetListener != null) {
			this.tableEditingDomain.removeResourceSetListener(this.resourceSetListener);
			this.tableEditingDomain = null;
		}
		if (this.filterStrategy instanceof IDisposable) {
			((IDisposable) this.filterStrategy).dispose();
		}
		this.cellAxisConfiguration = null;
		this.filterConfiguration = null;
		this.tableEditingDomain = null;
		this.contextEditingDomain = null;
		this.tableContext = null;
		if (this.natTable != null) {
			this.natTable.dispose();
		}
	}

	public EObject getTableContext() {
		return this.tableContext;
	}

	@Override
	public Table getTable() {
		return this.table;
	}

	protected abstract IPapyrusSortModel getRowSortModel();

	/**
	 *
	 * Handles the selections from the model explorer to the table when the link is activated
	 *
	 * @see org.eclipse.papyrus.infra.nattable.utils.AxisUtils
	 * @see org.eclipse.nebula.widgets.nattable.selection.SelectionLayer
	 *
	 * @param elementList
	 */
	@Override
	public boolean revealElement(Object element) {

		return revealElement(Collections.singleton(element));
	}

	@Override
	public boolean revealElement(Collection<?> elements) {

		boolean selectObject = false;
		SelectionLayer selectionLayer = bodyLayerStack.getSelectionLayer();
		List<Object> rowObjects = getRowElementsList();
		List<Object> columnObjects = getColumnElementsList();

		// clear the selectionLayer to avoid the previous selections to mess with the current
		selectionLayer.clear();

		for (int rowIndex = 0; rowIndex < rowObjects.size(); rowIndex++) {
			List<Object> toFind = new ArrayList<Object>(elements);
			for (Object object : elements) {
				Object realObject = AxisUtils.getRepresentedElement(object);
				if (!realObject.equals(object)) { // getRepresentedElement can return the axis itself
					toFind.add(realObject);
				}
			}

			Object currentAxisObject = rowObjects.get(rowIndex);
			Object currentRealObject = AxisUtils.getRepresentedElement(currentAxisObject);
			if (toFind.contains(currentRealObject)) {
				selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, rowIndex, false, true));
				// we remove the found object from the cloned elementList as they are already selected
				toFind.remove(currentRealObject);
				selectObject = true;
			}
			if (toFind.isEmpty()) {
				// all objects are selected
				return selectObject;
			}
		}

		for (int columnIndex = 0; columnIndex < columnObjects.size(); columnIndex++) {
			List<Object> toFind = new ArrayList<Object>(elements);
			for (Object object : elements) {
				Object realObject = AxisUtils.getRepresentedElement(object);
				if (!realObject.equals(object)) { // getRepresentedElement can return the axis itself
					toFind.add(realObject);
				}
			}

			Object currentAxisObject = columnObjects.get(columnIndex);
			Object currentRealObject = AxisUtils.getRepresentedElement(currentAxisObject);
			if (toFind.contains(currentRealObject)) {
				selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, columnIndex, 0, false, true));
				// we remove the found object from the cloned elementList as they are already selected
				toFind.remove(currentRealObject);
				selectObject = true;
			}
			if (toFind.isEmpty()) {
				// all objects are selected
				return selectObject;
			}
		}

		return selectObject;
	}


	/**
	 *
	 * Handles the initialization of the table's body resize styles, on opening, based on the previous changes made by the user.
	 *
	 */
	protected void initTableAxis() {
		DataLayer tableBodyLayer = getBodyLayerStack().getBodyDataLayer();
		// notation lists represent the elements that are instantiated in their table instance inside the model.notation file
		List<IAxis> notationColumnsAxisList = getTable().getCurrentColumnAxisProvider().getAxis();
		List<IAxis> notationRowsAxisList = getTable().getCurrentRowAxisProvider().getAxis();
		// actual number of displayed elements when looking at the table editor
		int actualColumnAxisElements = getTableAxisElementProvider().getColumnElementsList().size();
		int actualRowAxisElements = getTableAxisElementProvider().getRowElementsList().size();
		// value, width or height, of the resized column or row
		IntValueStyle value = null;

		// we go through all the elements to find those which have been modified
		for (int index = 0; index < notationColumnsAxisList.size(); index++) {
			IAxis currentColumnAxis = notationColumnsAxisList.get(index);
			// we need both to detect and use the correct value, width or height, of the handled element as the user could have modified the table when the axis was inverted
			if (!getTable().isInvertAxis()) {
				int axisWidth = tableBodyLayer.getColumnWidthByPosition(index);
				value = (IntValueStyle) currentColumnAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
				if (value != null) {
					// we set the size of the axis in the graphical representation
					tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
				} else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth()) {
					// resets the size in case of an undo to the default table
					tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
				}
			} else {
				int axisHeight = tableBodyLayer.getRowHeightByPosition(index);
				value = (IntValueStyle) currentColumnAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_HEIGHT);
				if (value != null) {
					tableBodyLayer.setRowHeightByPosition(index, value.getIntValue());
				} else if (axisHeight != DefaultSizeUtils.getDefaultCellHeight()) {
					tableBodyLayer.setRowHeightByPosition(index, DefaultSizeUtils.getDefaultCellHeight());
				}
			}
		}

		for (int index = 0; index < notationRowsAxisList.size(); index++) {
			IAxis currentRowAxis = notationRowsAxisList.get(index);
			if (!getTable().isInvertAxis()) {
				int axisHeight = tableBodyLayer.getRowHeightByPosition(index);
				value = (IntValueStyle) currentRowAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_HEIGHT);
				if (value != null) {
					tableBodyLayer.setRowHeightByPosition(index, value.getIntValue());
				} else if (axisHeight != DefaultSizeUtils.getDefaultCellHeight()) {
					tableBodyLayer.setRowHeightByPosition(index, DefaultSizeUtils.getDefaultCellHeight());
				}
			} else {
				int axisWidth = tableBodyLayer.getColumnWidthByPosition(index);
				value = (IntValueStyle) currentRowAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.AXIS_WIDTH);
				if (value != null) {
					tableBodyLayer.setColumnWidthByPosition(index, value.getIntValue());
				} else if (axisWidth != DefaultSizeUtils.getDefaultCellWidth()) {
					tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
				}
			}
		}

		// this method is used to resize by default. In the actual state, only the rows, representing the table's core elements, are missing from the notation file
		if (notationRowsAxisList.size() == 0) {
			if (getTable().isInvertAxis()) {
				for (int index = 0; index < actualColumnAxisElements; index++) {
					tableBodyLayer.setColumnWidthByPosition(index, DefaultSizeUtils.getDefaultCellWidth());
				}

			} else if (!getTable().isInvertAxis()) {
				for (int index = 0; index < actualRowAxisElements; index++) {
					tableBodyLayer.setRowHeightByPosition(index, DefaultSizeUtils.getDefaultCellHeight());
				}

			}
		}

	}


	/**
	 *
	 * Handles the initialization of the table's headers resize styles, on opening, based on the previous changes made by the user.
	 *
	 */
	protected void initTableHeaders() {
		DataLayer tableRowIndexHeaderLayer = rowHeaderLayerStack.getRowIndexDataLayer();
		DataLayer tableRowLabelHeaderLayer = rowHeaderLayerStack.getRowLabelDataLayer();
		DataLayer tableColumnIndexHeaderLayer = columnHeaderLayerStack.getColumnIndexDataLayer();
		DataLayer tableColumnLabelHeaderLayer = columnHeaderLayerStack.getColumnLabelDataLayer();
		AbstractHeaderAxisConfiguration rowHeader = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisConfigurationUsedInTable(getTable());
		AbstractHeaderAxisConfiguration columnHeader = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(getTable());

		// handles the initialization for the column headers,
		// check if the the user saved the table with an inverted axis or not as it would change the type of style required for resize,
		// it is important to note that AbstractHeaderAxisConfigurationUsedInTable already handles the invertAxis parameter to return the correct Axis (column/row)
		IntValueStyle valueColumnIndex = (IntValueStyle) columnHeader.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.COLUMN_INDEX_HEIGHT);
		// check if the user has previously entered a value for it, if not resets to the default
		if (valueColumnIndex != null) {
			tableColumnIndexHeaderLayer.setRowHeightByPosition(0, valueColumnIndex.getIntValue());
		} else {
			tableColumnIndexHeaderLayer.setRowHeightByPosition(0, DefaultSizeUtils.getDefaultCellHeight());
		}

		// same here
		IntValueStyle valueColumnLabel = (IntValueStyle) columnHeader.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.COLUMN_LABEL_HEIGHT);
		if (valueColumnLabel != null) {
			tableColumnLabelHeaderLayer.setRowHeightByPosition(0, valueColumnLabel.getIntValue());
		} else {
			tableColumnLabelHeaderLayer.setRowHeightByPosition(0, DefaultSizeUtils.getDefaultCellHeight());
		}

		// same behavior but with the row headers
		IntValueStyle valueRowIndex = (IntValueStyle) rowHeader.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.ROW_INDEX_WIDTH);
		if (valueRowIndex != null) {
			tableRowIndexHeaderLayer.setColumnWidthByPosition(0, valueRowIndex.getIntValue());
		} else {
			tableRowIndexHeaderLayer.setColumnWidthByPosition(0, DefaultSizeUtils.getDefaultRowHeaderWidth());
		}

		IntValueStyle valueRowLabel = (IntValueStyle) rowHeader.getNamedStyle(NattablestylePackage.eINSTANCE.getIntValueStyle(), NamedStyleConstants.ROW_LABEL_WIDTH);
		if (valueRowLabel != null) {
			tableRowLabelHeaderLayer.setColumnWidthByPosition(0, valueRowLabel.getIntValue());
		} else {
			tableRowLabelHeaderLayer.setColumnWidthByPosition(0, DefaultSizeUtils.getDefaultRowHeaderWidth());
		}
		
		// Manage the style for the header with index > 1
		for(final Style style : rowHeader.getStyles()){
			if(style instanceof IntValueStyle){
				final String styleName = ((IntValueStyle) style).getName();
				if(styleName.startsWith(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH)){
					//Calculate the position contained in the name of the style
					String styleNameWithoutPrefix = styleName.replace(NamedStyleConstants.ROW_LABEL_POSITION_PREFIX_WIDTH, "");
					String styleNameWithoutSuffix = styleNameWithoutPrefix.replace(NamedStyleConstants.ROW_LABEL_POSITION_SUFFIX_WIDTH, "");
					// Remove 1 because the column position start at 0
					int position = Integer.parseInt(styleNameWithoutSuffix)-1;
					
					// Don't try to set a width of a position which not existing
					if(position < tableRowLabelHeaderLayer.getColumnCount()){
						tableRowLabelHeaderLayer.setColumnWidthByPosition(position, ((IntValueStyle)style).getIntValue());
					}
				}
			}
		}

	}


	/**
	 *
	 * Handles the initialization of the table's cell merges, on opening, based on the previous changes made by the user.
	 *
	 */
	protected void initTableMerge() {
		// clears the previous spanning (== merge) behavior that would interfere with the new one
		clearTableSpan();

		// the four booleans that indicate the type of merge currently used in the table: all columns, all rows, selected rows, selected columns
		BooleanValueStyle valueRow = (BooleanValueStyle) HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisConfigurationUsedInTable(getTable())
				.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_ROWS);
		BooleanValueStyle valueColumn = (BooleanValueStyle) HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(getTable())
				.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_COLUMNS);
		boolean mergeSelectedRows = getToMergeRowBoolean();
		boolean mergeSelectedColumns = getToMergeColumnBoolean();

		// notation lists represent the elements that are instantiated in their table instance inside the model.notation file
		List<IAxis> notationColumnsAxisList = getTable().getCurrentColumnAxisProvider().getAxis();
		List<IAxis> notationRowsAxisList = getTable().getCurrentRowAxisProvider().getAxis();
		// list of the selected Axis indexes
		List<Integer> selectedAxisIndex = new ArrayList<Integer>();

		// the two conditions below handle the merge of all the columns/rows
		if (valueRow != null && valueRow.isBooleanValue()) {
			// it is important to note that AbstractHeaderAxisConfigurationUsedInTable already handles the invertAxis parameter to return the correct Header (column/row)
			bodyLayerStack.getBodyLayerSpanProvider().setAutoColumnSpan(true);
		}
		if (valueColumn != null && valueColumn.isBooleanValue()) {
			bodyLayerStack.getBodyLayerSpanProvider().setAutoRowSpan(true);
		}

		// the two conditions below handle the merge of the selected columns/rows
		if (mergeSelectedRows) {
			// check the axis' boolean to know if it has to be merged or not in the selection
			if (!getTable().isInvertAxis()) {
				for (int index = 0; index < notationRowsAxisList.size(); index++) {
					IAxis currentAxis = notationRowsAxisList.get(index);
					BooleanValueStyle currentAxisMergeBoolean = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_ROWS);
					if (currentAxisMergeBoolean != null && currentAxisMergeBoolean.isBooleanValue()) {
						selectedAxisIndex.add(index);
					}
				}
			} else {
				// this behavior checks the merge boolean, if any, as the rows are now columns and vice versa
				for (int index = 0; index < notationColumnsAxisList.size(); index++) {
					IAxis currentAxis = notationColumnsAxisList.get(index);
					BooleanValueStyle currentAxisMergeBoolean = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_ROWS);
					if (currentAxisMergeBoolean != null && currentAxisMergeBoolean.isBooleanValue()) {
						selectedAxisIndex.add(index);
					}
				}
			}

			// the spanning can now be set correctly
			bodyLayerStack.getBodyLayerSpanProvider().setAutoColumnSpan(true);
			bodyLayerStack.getBodyLayerSpanProvider().addAutoSpanningRowPositions(selectedAxisIndex.toArray(new Integer[selectedAxisIndex.size()]));
		}
		// same behavior for the column axis
		if (mergeSelectedColumns) {
			if (!getTable().isInvertAxis()) {
				for (int index = 0; index < notationColumnsAxisList.size(); index++) {
					IAxis currentAxis = notationColumnsAxisList.get(index);
					BooleanValueStyle currentAxisMergeBoolean = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_COLUMNS);
					if (currentAxisMergeBoolean != null && currentAxisMergeBoolean.isBooleanValue()) {
						selectedAxisIndex.add(index);
					}
				}
			} else {
				for (int index = 0; index < notationRowsAxisList.size(); index++) {
					IAxis currentAxis = notationRowsAxisList.get(index);
					BooleanValueStyle currentAxisMergeBoolean = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_COLUMNS);
					if (currentAxisMergeBoolean != null && currentAxisMergeBoolean.isBooleanValue()) {
						selectedAxisIndex.add(index);
					}
				}
			}

			bodyLayerStack.getBodyLayerSpanProvider().setAutoRowSpan(true);
			bodyLayerStack.getBodyLayerSpanProvider().addAutoSpanningColumnPositions(selectedAxisIndex.toArray(new Integer[selectedAxisIndex.size()]));
		}
	}


	/**
	 * Clears the merge behavior currently used in the table
	 */
	protected void clearTableSpan() {
		bodyLayerStack.getBodyLayerSpanProvider().clearAutoSpanningColumnPositions();
		bodyLayerStack.getBodyLayerSpanProvider().clearAutoSpanningRowPositions();
		bodyLayerStack.getBodyLayerSpanProvider().setAutoColumnSpan(false);
		bodyLayerStack.getBodyLayerSpanProvider().setAutoRowSpan(false);
	}


	/**
	 *
	 * @return
	 * 		The boolean indicating that some row axis are to be merged in the selection
	 */
	protected boolean getToMergeRowBoolean() {
		// for(IAxis currentAxis : getTable().getCurrentRowAxisProvider().getAxis()) {
		// the above test does not allow a quick switch between invertAxis and not as the provider will deliver the same list in both states
		for (Object currentObject : getRowElementsList()) {
			if (currentObject instanceof IAxis) {
				IAxis currentAxis = (IAxis) currentObject;
				BooleanValueStyle axisToMerge = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_ROWS);
				if (axisToMerge != null && axisToMerge.isBooleanValue()) {
					// one axis has a merge boolean to true hence the table was previously merged
					return true;
				}
			}
		}
		return false;
	}

	/**
	 *
	 * @return
	 * 		The boolean indicating that some column axis are to be merged in the selection
	 */
	protected boolean getToMergeColumnBoolean() {
		// for(IAxis currentAxis : getTable().getCurrentColumnAxisProvider().getAxis()) {
		// the above test does not allow a quick switch between invertAxis and not as the provider will deliver the same list in both states
		for (Object currentObject : getColumnElementsList()) {
			if (currentObject instanceof IAxis) {
				IAxis currentAxis = (IAxis) currentObject;
				BooleanValueStyle axisToMerge = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_COLUMNS);
				if (axisToMerge != null && axisToMerge.isBooleanValue()) {
					// one axis has a merge boolean to true hence the table was previously merged
					return true;
				}
			}
		}
		return false;
	}

	/**
	 *
	 * @return
	 * 		The boolean indicating if the toggle of the currently used menu is to be set to true or not.
	 *         i.e. if the current selection is the same that the previously merged selection
	 */
	protected boolean getToggleStateSelectedRows() {
		// the size of the selection used to see if an axis has been selected
		int selectionSize = bodyLayerStack.getSelectionLayer().getFullySelectedRowPositions().length;
		// fetch the merge booleans of the selected rows and return false if the selection does not match the previously merged rows
		for (int index : bodyLayerStack.getSelectionLayer().getFullySelectedRowPositions()) {
			Object currentObject = getRowElement(index);
			if (getRowElement(index) instanceof IAxis) {
				IAxis currentAxis = (IAxis) currentObject;
				BooleanValueStyle axisToMerge = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_ROWS);
				if ((axisToMerge != null && !axisToMerge.isBooleanValue()) || (axisToMerge == null)) {
					return false;
				}
			}
		}

		// as the user may have selected only a cell or a column, those cases must be taken into account
		if (selectionSize > 0) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 *
	 * @return
	 * 		The boolean indicating if the toggle of the currently used menu is to be set to true or not.
	 *         i.e. if the current selection is the same that the previously merged selection
	 */
	protected boolean getToggleStateSelectedColumns() {
		// the size of the selection used to see if an axis has been selected
		int selectionSize = bodyLayerStack.getSelectionLayer().getFullySelectedColumnPositions().length;
		// fetch the merge booleans of the selected rows and return false if the selection does not match the previously merged columns
		for (int index : bodyLayerStack.getSelectionLayer().getFullySelectedColumnPositions()) {
			Object currentObject = getColumnElement(index);
			if (getColumnElement(index) instanceof IAxis) {
				IAxis currentAxis = (IAxis) currentObject;
				BooleanValueStyle axisToMerge = (BooleanValueStyle) currentAxis.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_IN_SELECTED_COLUMNS);
				if ((axisToMerge != null && !axisToMerge.isBooleanValue()) || (axisToMerge == null)) {
					return false;
				}
			}
		}

		// as the user may have selected only a cell or a column, those cases must be taken into account
		if (selectionSize > 0) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 *
	 * @return
	 * 		The boolean indicating if the toggle of the currently used menu is to be set to true or not.
	 *         i.e. if the current selection is the same that the previously merged selection
	 */
	protected boolean getToggleStateAllRows() {
		BooleanValueStyle mergeRows = (BooleanValueStyle) HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisConfigurationUsedInTable(getTable())
				.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_ROWS);
		if (mergeRows != null && mergeRows.isBooleanValue()) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * this method is used to update the state of the toggle actions for table
	 */
	protected void updateToggleActionState() {
		final ICommandService commandService = EclipseCommandUtils.getCommandService();
		if (commandService != null) {
			final AbstractHeaderAxisConfiguration columnAxisConfiguration = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(getTable());

			// update the header configuration
			org.eclipse.core.commands.Command command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_FILTER_ID);
			EclipseCommandUtils.updateToggleCommandState(command, columnAxisConfiguration.isDisplayFilter());
		}
	}

	/**
	 *
	 * @return
	 * 		The boolean indicating if the toggle of the currently used menu is to be set to true or not.
	 *         i.e. if the current selection is the same that the previously merged selection
	 */
	protected boolean getToggleStateAllColumns() {
		BooleanValueStyle mergeColumns = (BooleanValueStyle) HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisConfigurationUsedInTable(getTable())
				.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.MERGE_COLUMNS);
		if (mergeColumns != null && mergeColumns.isBooleanValue()) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 *
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
	 *
	 * @param adapter
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public Object getAdapter(Class adapter) {
		if (adapter == TableSelectionProvider.class) {
			return this.selectionProvider;
		}
		if (adapter == TableSelectionWrapper.class) {
			ISelection selection = this.selectionProvider.getSelection();
			if (selection instanceof TableStructuredSelection) {
				return ((TableStructuredSelection) selection).getAdapter((TableSelectionWrapper.class));
			}
		}
		if (adapter == TableStructuredSelection.class) {
			ISelection selection = this.selectionProvider.getSelection();
			if (selection instanceof TableStructuredSelection) {
				return selection;
			}
		}
		return null;

	}

	/**
	 *
	 * @return
	 * 		a {@link TableStructuredSelection} representing the current selection of the table or <code>null</code> when there is no selection
	 */
	public final TableStructuredSelection getSelectionInTable() {
		ISelection selection = this.selectionProvider.getSelection();
		if (selection instanceof TableStructuredSelection) {
			return (TableStructuredSelection) selection;
		}
		return null;
	}

	/**
	 *
	 * @return
	 * 		a map representing index of fully selected rows linked to the associated element
	 *
	 *         The returned value can't be <code>null</code>
	 */
	protected final Map<Integer, Object> getFullySelectedRows() {
		TableStructuredSelection selection = getSelectionInTable();
		if (selection != null) {
			TableSelectionWrapper selectionWrapper = (TableSelectionWrapper) selection.getAdapter(TableSelectionWrapper.class);
			if (selectionWrapper != null) {
				return selectionWrapper.getFullySelectedRows();
			}
		}
		return Collections.emptyMap();
	}

	/**
	 *
	 * @return
	 * 		a map representing index of fully selected columns linked to the associated element
	 *
	 *         The returned value can't be <code>null</code>
	 */
	protected final Map<Integer, Object> getFullySelectedColumns() {
		TableStructuredSelection selection = getSelectionInTable();
		if (selection != null) {
			TableSelectionWrapper selectionWrapper = (TableSelectionWrapper) selection.getAdapter(TableSelectionWrapper.class);
			if (selectionWrapper != null) {
				return selectionWrapper.getFullySelectedColumns();
			}
		}
		return Collections.emptyMap();
	}

}

Back to the top