Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0cd68bbc92776c1c8cdc1049466ce18ddedc6f4f (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
/*****************************************************************************
 * Copyright (c) 2014, 2016 CEA LIST, Esterel Technologies SAS 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
 *   Sebastien Bordes (Esterel Technologies SAS) - Bug 497738
 *
 *****************************************************************************/

package org.eclipse.papyrus.infra.nattable.manager.axis;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.ResourceSetListener;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.nattable.listener.UpdateTableContentListener;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IdAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
import org.eclipse.papyrus.infra.nattable.utils.AxisComparator;
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.EventListHelper;
import org.eclipse.papyrus.infra.nattable.utils.FillingConfigurationUtils;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.providers.CompoundFilteredRestrictedContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;

import ca.odell.glazedlists.EventList;

/**
 * @author VL222926
 *
 */
public class CompositeAxisManagerForEventList extends AbstractAxisManagerForEventList implements IAxisManagerForEventList, ICompositeAxisManager {

	/**
	 * the id of this manager
	 */
	@SuppressWarnings("unused")
	private static final String MANAGER_ID = "org.eclipse.papyrus.infra.nattable.composite.axis.manager.event.list"; //$NON-NLS-1$

	/**
	 * the sub managers
	 */
	protected List<IAxisManagerForEventList> subManagers;

	/**
	 * the comparator used to sort the axis
	 */
	protected Comparator<Object> axisComparator;

	/**
	 * the resouce set listener
	 */
	private ResourceSetListener resourceSetListener;

	/**
	 * Constructor.
	 *
	 */
	public CompositeAxisManagerForEventList(final EventList<Object> eventList) {
		setEventList(eventList);
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManagerForEventList#addListeners()
	 *
	 */
	@Override
	protected void addListeners() {
		this.resourceSetListener = new UpdateTableContentListener(getTableManager(), this);
		if (null != getTableEditingDomain()) {
			getTableEditingDomain().addResourceSetListener(this.resourceSetListener);
		}
	}


	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#setSubAxisManager(java.util.List)
	 *
	 * @param managers
	 */
	@Override
	public final void setSubAxisManager(final List<IAxisManager> managers) {
		throw new UnsupportedOperationException("Use setSubAxisManagers(List<IAxisManagerForEventList> manager)"); //$NON-NLS-1$
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#init(org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager, org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation,
	 *      org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider)
	 *
	 * @param manager
	 * @param rep
	 * @param provider
	 */
	@Override
	public void init(INattableModelManager manager, AxisManagerRepresentation rep, AbstractAxisProvider provider) {
		super.init(manager, rep, provider);
		for (final IAxis current : getRepresentedContentProvider().getAxis()) {
			if (current instanceof ITreeItemAxis) {
				EventListHelper.addToEventList(eventList, current);
			}
		}
	}

	/**
	 * @param subManagers
	 *            the subManagers to set
	 */
	public void setSubManagers(List<IAxisManagerForEventList> subManagers) {
		this.subManagers = subManagers;
		for (IAxisManagerForEventList current : subManagers) {
			current.setEventList(eventList);
		}
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#dispose()
	 *
	 */
	@Override
	public void dispose() {
		for (final IAxisManager current : this.subManagers) {
			current.dispose();
		}
		this.subManagers.clear();
		this.axisComparator = null;
		super.dispose();
	}


	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#removeListeners()
	 *
	 */
	@Override
	protected void removeListeners() {
		if (null != getTableEditingDomain() && null != resourceSetListener) {
			getTableEditingDomain().removeResourceSetListener(this.resourceSetListener);
		}
		this.resourceSetListener = null;
		super.removeListeners();
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canBeUsedAsRowManager()
	 *
	 * @return
	 */
	@Override
	public boolean canBeUsedAsRowManager() {
		boolean answer = true;
		final Iterator<IAxisManagerForEventList> iter = this.subManagers.iterator();
		while (iter.hasNext() && answer) {
			answer = iter.next().canBeUsedAsRowManager();
		}
		return answer;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canBeUsedAsColumnManager()
	 *
	 * @return
	 */
	@Override
	public boolean canBeUsedAsColumnManager() {
		boolean answer = true;
		final Iterator<IAxisManagerForEventList> iter = this.subManagers.iterator();
		while (iter.hasNext() && answer) {
			answer = iter.next().canBeUsedAsColumnManager();
		}
		return answer;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canCreateAxisElement(java.lang.String)
	 *
	 * @param elementId
	 * @return
	 */
	@Override
	public boolean canCreateAxisElement(String elementId) {
		boolean canCreateAxisElement = false;
		for (IAxisManager manager : subManagers) {
			canCreateAxisElement |= manager.canCreateAxisElement(elementId);
		}
		return canCreateAxisElement;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(TransactionalEditingDomain, java.util.Collection)
	 *
	 * @param domain
	 * @param objectToAdd
	 * @return
	 */
	@Override
	public Command getAddAxisCommand(final TransactionalEditingDomain domain, final Collection<Object> objectToAdd) {
		if (FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(this.tableManager.getTable(), 0)) {
			return null;
		}
		final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
		for (final IAxisManager current : this.subManagers) {
			final Command tmp = current.getAddAxisCommand(domain, objectToAdd);
			if (tmp != null) {
				cmd.append(tmp);
			}
		}
		if (cmd.isEmpty()) {
			return null;
		}
		return cmd;
	}

	/**
	 * 
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.util.Collection, int)
	 *
	 * @param domain
	 * @param objectToAdd
	 * @param index
	 * @return
	 */
	@Override
	public Command getAddAxisCommand(final TransactionalEditingDomain domain, final Collection<Object> objectToAdd, final int index) {
		if (FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(this.tableManager.getTable(), 0)) {
			return null;
		}
		final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
		for (final IAxisManager current : this.subManagers) {
			final Command tmp = current.getAddAxisCommand(domain, objectToAdd, index);
			if (tmp != null) {
				cmd.append(tmp);
			}
		}
		if (cmd.isEmpty()) {
			return null;
		}
		return cmd;
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManagerForEventList#initializeManagedObjectList()
	 *
	 */
	@Override
	protected void initializeManagedObjectList() {
		// nothing to do
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getComplementaryAddAxisCommand(TransactionalEditingDomain, java.util.Collection)
	 *
	 * @param domain
	 * @param objectToAdd
	 * @return
	 */
	@Override
	public Command getComplementaryAddAxisCommand(final TransactionalEditingDomain domain, final Collection<Object> objectToAdd) {
		final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
		for (final IAxisManager current : this.subManagers) {
			final Command tmp = current.getComplementaryAddAxisCommand(domain, objectToAdd);
			if (tmp != null) {
				cmd.append(tmp);
			}
		}
		if (cmd.isEmpty()) {
			return null;
		}
		return cmd;
	}

	/**
	 * 
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getComplementaryAddAxisCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.util.Collection, int)
	 *
	 * @param domain
	 * @param objectToAdd
	 * @param index
	 * @return
	 */
	@Override
	public Command getComplementaryAddAxisCommand(final TransactionalEditingDomain domain, final Collection<Object> objectToAdd, final int index) {
		final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
		for (final IAxisManager current : this.subManagers) {
			final Command tmp = current.getComplementaryAddAxisCommand(domain, objectToAdd, index);
			if (tmp != null) {
				cmd.append(tmp);
			}
		}
		if (cmd.isEmpty()) {
			return null;
		}
		return cmd;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#isAllowedContents(java.lang.Object)
	 *
	 * @param object
	 * @return
	 */
	@Override
	public boolean isAllowedContents(Object object) {
		for (final IAxisManager current : this.subManagers) {
			if (current.isAllowedContents(object)) {
				return true;
			}
		}
		return false;
	}



	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canMoveAxis()
	 *
	 * @return
	 */
	@Override
	public boolean canMoveAxis() {
		for (final IAxisManager current : this.subManagers) {
			if (!current.canMoveAxis() || current.isDynamic()) {
				return false;
			}
		}
		return true;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#sortAxisByName(boolean, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
	 */
	@Override
	public void sortAxisByName(boolean alphabeticOrder, final IConfigRegistry configRegistry, final boolean isRowsSort) {
		if (canMoveAxis()) {
			final List<IAxis> axis = new ArrayList<IAxis>(getRepresentedContentProvider().getAxis());
			Collections.sort(axis, new AxisComparator(alphabeticOrder, configRegistry));
			final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(getRepresentedContentProvider());
			final AbstractEditCommandRequest request = new SetRequest(domain, getRepresentedContentProvider(), NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), axis);
			final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(getRepresentedContentProvider());
			final ICommand cmd = provider.getEditCommand(request);
			domain.getCommandStack().execute(new ReorderAxisCommandWrapper(new GMFtoEMFCommandWrapper(cmd), isRowsSort));
		}
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#createPossibleAxisContentProvider(boolean)
	 *
	 * @param isRestricted
	 * @return a contents provider for this axis or <code>null</code> if it is not allowed
	 */
	@Override
	public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {

		CompoundFilteredRestrictedContentProvider compoundContentProvider = null;
		for (final IAxisManager current : this.subManagers) {
			IRestrictedContentProvider contentProvider = current.createPossibleAxisContentProvider(isRestricted);
			if (contentProvider != null) {
				if (compoundContentProvider == null) {
					compoundContentProvider = new CompoundFilteredRestrictedContentProvider();
				}
				compoundContentProvider.add(contentProvider);
			}
		}
		return compoundContentProvider;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getDestroyAxisCommand(TransactionalEditingDomain, java.util.Collection)
	 *
	 * @param domain
	 * @param objectToDestroy
	 * @return
	 */
	@Override
	public Command getDestroyAxisCommand(TransactionalEditingDomain domain, Collection<Object> objectToDestroy) {
		final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_DestroyAxisCommand);
		for (final IAxisManager current : this.subManagers) {
			final Command tmp = current.getDestroyAxisCommand(domain, objectToDestroy);
			if (tmp != null) {
				cmd.append(tmp);
			}
		}
		if (cmd.isEmpty()) {
			return null;
		}
		return cmd;
	}




	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isSlave()
	 *
	 * @return
	 *         <code>true</code> if one of the encapsulated manager is a slave
	 */
	@Override
	public boolean isSlave() {
		for (final IAxisManager manager : this.subManagers) {
			if (manager.isSlave()) {
				return true;
			}
		}
		return false;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isDynamic()
	 *
	 * @return
	 *         <code>true</code> if one of the embedded axis manager is dynamic
	 */
	@Override
	public boolean isDynamic() {
		for (final IAxisManager manager : this.subManagers) {
			if (manager.isDynamic()) {
				return true;
			}
		}
		return false;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDropAxisElement(java.util.Collection)
	 *
	 * @param objectsToAdd
	 * @return
	 */
	@Override
	public boolean canDropAxisElement(Collection<Object> objectsToAdd) {
		for (final IAxisManager current : this.subManagers) {
			if (current.canDropAxisElement(objectsToAdd)) {
				return true;
			}
		}
		return false;
	}


	/**
	 *
	 * @param elementToMove
	 * @param newIndex
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#moveAxis(java.lang.Object, int)
	 */
	@Override
	public void moveAxis(Object elementToMove, int newIndex) {
		if (!isDynamic() && elementToMove instanceof IAxis) {
			final TransactionalEditingDomain domain = getTableEditingDomain();
			if (null != domain) {
				final List<Object> newAxisOrder = new ArrayList<Object>(getRepresentedContentProvider().getAxis());
				newAxisOrder.remove(elementToMove);
				newAxisOrder.add(newIndex, elementToMove);
	
				domain.getCommandStack().execute(getSetNewAxisOrderCommand(newAxisOrder));
			}
		}
	}

	@Override
	public boolean canEditAxisHeader(final NatEventData axisIndex) {
		if (canEditAxisHeader()) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canEditAxisHeader()
	 *
	 * @return
	 */
	@Override
	public boolean canEditAxisHeader() {
		for (final IAxisManager current : this.subManagers) {
			if (!current.canEditAxisHeader()) {
				return false;
			}
		}
		return true;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getElementAxisName(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
	 *
	 * @param axis
	 * @return
	 */
	@Override
	public String getElementAxisName(final IAxis axis) {
		final AxisManagerRepresentation manager = axis.getManager();
		for (final IAxisManager man : this.subManagers) {
			if (man.getAxisManagerRepresentation() == manager) {
				return man.getElementAxisName(axis);
			}
		}
		if (canEditAxisHeader()) {
			return null;
		} else {
			throw new UnsupportedOperationException();
		}
	}

	/**
	 *
	 * @param axis
	 *            an axis
	 * @return
	 * 		the axis manager managing this axis
	 * 
	 * @Deprecated since Eclipse Mars, use getSubAxisManagerFor instead
	 */
	@Deprecated
	protected IAxisManager getAxisManager(final IAxis axis) {
		final AxisManagerRepresentation rep = axis.getManager();
		for (final IAxisManager man : this.subManagers) {
			if (man.getAxisManagerRepresentation() == rep) {
				return man;
			}
		}
		return null;// must be impossible
	}

	/**
	 *
	 * @param axis
	 *            an axis
	 * @return
	 * 		the axis manager managing this axis
	 */
	public IAxisManager getSubAxisManagerFor(final IAxis axis) {
		final AxisManagerRepresentation rep = axis.getManager();
		for (final IAxisManager man : this.subManagers) {
			if (man.getAxisManagerRepresentation() == rep) {
				return man;
			}
		}
		return null;// must be impossible
	}


	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDestroyAxis(java.lang.Integer)
	 *
	 * @param axisPosition
	 * @return
	 */
	@Override
	public boolean canDestroyAxis(final Integer axisPosition) {
		final List<Object> elements = getElements();
		final Object element = elements.get(axisPosition);
		if (element instanceof IAxis) {
			return getSubAxisManagerFor((IAxis) element).canDestroyAxis(axisPosition);
		}
		// not yet managed
		return false;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
	 *
	 * @param axisPosition
	 * @return
	 */
	@Override
	public boolean canDestroyAxisElement(Integer axisPosition) {
		final List<Object> elements = getElements();
		final Object element = elements.get(axisPosition);
		if (element instanceof IAxis) {
			return getSubAxisManagerFor((IAxis) element).canDestroyAxisElement(axisPosition);
		} else if (subManagers.size() == 1) {
			return subManagers.get(0).canDestroyAxisElement(axisPosition);
		}
		// not yet managed
		return false;
	}


	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(TransactionalEditingDomain, java.lang.Integer)
	 *
	 * @param domain
	 * @param axisPosition
	 * @return
	 */
	@Override
	public Command getDestroyAxisElementCommand(TransactionalEditingDomain domain, Integer axisPosition) {
		final List<Object> elements = getElements();
		final Object element = elements.get(axisPosition);
		if (element instanceof IAxis) {
			return getSubAxisManagerFor((IAxis) element).getDestroyAxisElementCommand(domain, axisPosition);
		} else if (subManagers.size() == 1) {
			return subManagers.get(0).getDestroyAxisElementCommand(domain, axisPosition);
		}
		// not yet managed
		return UnexecutableCommand.INSTANCE;
	}

	@Override
	public boolean canBeSavedAsConfig() {
		boolean canBeSavedAsConfig = true;
		for (IAxisManager manager : subManagers) {
			canBeSavedAsConfig &= manager.canBeSavedAsConfig();
		}
		return canBeSavedAsConfig;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAdapter(java.lang.Class)
	 *
	 * @param adapter
	 * @return
	 */
	@Override
	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
		for (final IAxisManager current : this.subManagers) {
			if (current.getClass() == adapter) {
				return current;
			}
		}
		return super.getAdapter(adapter);
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#isInSortedState()
	 *
	 * @return
	 */
	@Override
	public boolean isInSortedState() {
		return this.axisComparator != null;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#setAxisComparator(java.util.Comparator)
	 *
	 * @param comp
	 */
	@Override
	// seem not used now
	public void setAxisComparator(final Comparator<Object> comp) {
		this.axisComparator = comp;
		if (this.axisComparator != null) {
			List<Object> displayedElement = getElements();
			synchronized (displayedElement) {
				Collections.sort(displayedElement, comp);
				getTableManager().refreshNatTable();// useful?
			}
		} else {
			getTableManager().updateAxisContents(getRepresentedContentProvider());
		}
	}



	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#isAlreadyManaged(java.lang.Object)
	 *
	 * @param object
	 * @return
	 */
	@Override
	public boolean isAlreadyManaged(final Object object) {
		for (final IAxisManager current : this.subManagers) {
			if (current.isAlreadyManaged(object)) {
				return true;
			}
		}
		return false;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#getSetNewAxisOrderCommand(java.util.List)
	 *
	 * @param newOrder
	 * @return
	 */
	@Override
	public Command getSetNewAxisOrderCommand(final List<Object> newOrder) {
		if (canMoveAxis() && !isDynamic()) {
			return new ReorderAxisCommandWrapper(new RecordingCommand(getTableEditingDomain()) {

				@Override
				protected void doExecute() {
					final TreeMap<Integer, IAxis> order = new TreeMap<Integer, IAxis>();
					final AbstractAxisProvider provider = getRepresentedContentProvider();
					for (int i = 0; i < provider.getAxis().size(); i++) {
						final IAxis currentAxis = provider.getAxis().get(i);
						int index = newOrder.indexOf(currentAxis);
						if (index != -1) {
							order.put(Integer.valueOf(index), currentAxis);
						} else {
							Object resolvedObject = AxisUtils.getRepresentedElement(currentAxis);
							if (currentAxis instanceof IdAxis) {
								resolvedObject = getResolvedPath((IdAxis) currentAxis);
							}
							index = newOrder.indexOf(resolvedObject);
							if (index == -1) {
								throw new IndexOutOfBoundsException("A reordered element can't be resolved"); //$NON-NLS-1$
							}
							order.put(Integer.valueOf(index), currentAxis);
						}
					}

					final List<IAxis> newValues = new ArrayList<IAxis>();
					newValues.addAll(order.values());
					SetCommand.create(getTableEditingDomain(), provider, NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), newValues).execute();
				}
			});
		}
		return null;
	}


	/**
	 *
	 * @param axisManagerId
	 *            an axis
	 * @return
	 * 		the axis manager managing it
	 * 
	 * @deprecated since Eclipse Mars, use getSubAxisManagerFor instead
	 */
	@Deprecated
	protected IAxisManager findAxisManager(final IAxis axis) {
		final String axisManagerId = axis.getManager().getAxisManagerId();
		for (final IAxisManager currentManager : this.subManagers) {
			if (currentManager.getAxisManagerRepresentation().getAxisManagerId().equals(axisManagerId)) {
				return currentManager;
			}
		}
		return null;
	}


	/**
	 *
	 * @param idAxis
	 *            an idAxis
	 * @return
	 * 		the resolved path or the {@link String} represented by the idAxis if the path can't be resolved
	 */
	protected Object getResolvedPath(final IdAxis idAxis) {
		final String path = idAxis.getElement();
		final IAxisManager manager = getSubAxisManagerFor(idAxis);
		if (manager instanceof IIdAxisManager) {
			final Object resolvedElement = ((IIdAxisManager) manager).resolvedPath(path);
			if (resolvedElement != null) {
				return resolvedElement;
			}
		}
		return path;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManagerForEventList#manageSetNotification(org.eclipse.emf.common.notify.Notification)
	 *
	 * @param notification
	 */
	@Override
	protected void manageSetNotification(Notification notification) {
		propagateEvent(notification);
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManagerForEventList#manageUnsetNotification(org.eclipse.emf.common.notify.Notification)
	 *
	 * @param notification
	 */
	@Override
	protected void manageUnsetNotification(Notification notification) {
		propagateEvent(notification);
	}

	@Override
	protected void manageAddNotification(final Notification notification) {
		final Object newValue = notification.getNewValue();
		if (newValue instanceof IAxis && ((IAxis) newValue).eContainer() == getRepresentedContentProvider()) {
			EventListHelper.addToEventList(eventList, newValue);
		}
		propagateEvent(notification);
	}



	@Override
	protected void manageAddManyNotification(final Notification notification) {
		final Object newValue = notification.getNewValue();
		if (newValue instanceof Collection<?>) {
			for (Object current : (Collection<?>) newValue) {
				if (current instanceof IAxis && ((IAxis) current).eContainer() == getRepresentedContentProvider()) {
					EventListHelper.addToEventList(eventList, current);
				}
			}

		}
		propagateEvent(notification);
	}

	@Override
	protected void manageMoveNotification(final Notification notification) {
		propagateEvent(notification);
	}

	@Override
	protected void manageRemoveNotification(final Notification notification) {
		final Object oldValue = notification.getOldValue();
		propagateEvent(notification);
		if (oldValue instanceof IAxis) {
			EventListHelper.removeFromEventList(eventList, oldValue);
		}
	}

	@Override
	protected void manageRemoveManyNotification(final Notification notification) {
		final Object oldValue = notification.getNewValue();
		propagateEvent(notification);
		if (oldValue instanceof Collection<?>) {
			for (Object current : (Collection<?>) oldValue) {
				if (current instanceof IAxis) {
					EventListHelper.removeFromEventList(eventList, current);
				}
			}

		}
	}

	/**
	 * This method propagates the notification to the submanagers in order to update the event list
	 *
	 * @param notification
	 *            a notification
	 *
	 */
	protected void propagateEvent(Notification notification) {
		for (final IAxisManager current : this.subManagers) {
			if (current instanceof IAxisManagerForEventList) {
				((IAxisManagerForEventList) current).manageEvent(notification);
			}
		}
		// must not be done here -> to many refresh are done
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#updateAxisContents()
	 * @deprecated must be removed from the API
	 */
	@Override
	@Deprecated
	public void updateAxisContents() {
		// nothing to do
	}

	/**
	 * @see org.eclipse.papyrus.infra.nattable.manager.axis.ITreeItemAxisManagerForEventList#treeFillingConfigurationHaveChanged()
	 *
	 */
	@Override
	public void fillingConfigurationsHaveChanged() {
		for (final IAxisManager current : this.subManagers) {
			if (current instanceof IAxisManagerForEventList) {
				((IAxisManagerForEventList) current).fillingConfigurationsHaveChanged();
			}
		}
		// required
		getTableManager().refreshNatTable();
	}
}

Back to the top