Issue with Tree grid [message #1241379] |
Fri, 07 February 2014 17:20  |
Eclipse User |
|
|
|
Hi,
From the tree grid example, I try to use natTable to show a tree.
I have a full tree data structure, where compare between Item are based on an unique ID.
My data structure is an EMF one.
Issue is some items appears many times at the same level of my tree.
Where I expected :
A - B
- C
- D
I obtained :
A - B
- C
A - D
My formatter is the same than the example one, minor the EMF differences :
/**
* Construct path from root to current element.
*
* @param pPath The list which will contain path
* @param pElement The element for which path will be constructed
*/
@Override
public void getPath(final List<EObject> pPath, final EObject pElement) {
pPath.add(pElement);
EObject vParent = pElement.eContainer();
while (vParent != null) {
pPath.add(vParent);
vParent = vParent.eContainer();
}
Collections.reverse(pPath);
}
This is the results of the pretty printer in example
- Model@7d94be61 (UUID: 13f6a062-e007-40a6-aa3f-7cc7d25603e2)
SystemEvent@5d6ddc5 (UUID: _1u2cCPmxEeKDk4RlwuVRlA)
- Container@305f12b0 (UUID: 4e4ae8d1-9259-40a3-905c-91cedd5bd786)
- Block@59ce4e28 (UUID: 051b33e8-0d76-43e9-bb7a-1f822cec7a41)
LocalEvent@5a22c38f (UUID: _1u2cAvmxEeKDk4RlwuVRlA)
- Block@59ce4e28 (UUID: 051b33e8-0d76-43e9-bb7a-1f822cec7a41)
- Port@776d5227 (UUID: _1u10_vmxEeKDk4RlwuVRlA)
FailureMode@2a2cbbb2 (UUID: _1u10__mxEeKDk4RlwuVRlA)
FailureMode@62fb343d (UUID: _1u2cAfmxEeKDk4RlwuVRlA)
- Port@776d5227 (UUID: _1u10_vmxEeKDk4RlwuVRlA)
FailureMode@5ed6b8bf (UUID: _1u2cAPmxEeKDk4RlwuVRlA)
- Block@2078afe (UUID: 0c3b5384-7ad0-416c-a32d-24336394d139)
LocalEvent@2ef8eeee (UUID: _1u10_PmxEeKDk4RlwuVRlA)
- Port@7fe2f29e (UUID: _1u10-PmxEeKDk4RlwuVRlA)
FailureMode@ca6a4aa (UUID: _1u10-fmxEeKDk4RlwuVRlA)
FailureMode@71f5890d (UUID: _1u10-_mxEeKDk4RlwuVRlA)
FailureMode@10849b63 (UUID: _1u10-vmxEeKDk4RlwuVRlA)
Port@7fe2f29e (UUID: _1u10-PmxEeKDk4RlwuVRlA)
- Port@3d362abc (UUID: _1u109PmxEeKDk4RlwuVRlA)
FailureMode@2f2fbc09 (UUID: _1u109fmxEeKDk4RlwuVRlA)
- Port@3d362abc (UUID: _1u109PmxEeKDk4RlwuVRlA)
FailureMode@66e20b12 (UUID: _1u109vmxEeKDk4RlwuVRlA)
FailureMode@244ff83 (UUID: _1u109_mxEeKDk4RlwuVRlA)
- Block@31c3f99f (UUID: 3bf54ab6-ebe3-46c8-815a-9c90f51af189)
LocalEvent@7ed9bdbf (UUID: _1u1N5PmxEeKDk4RlwuVRlA)
- Block@31c3f99f (UUID: 3bf54ab6-ebe3-46c8-815a-9c90f51af189)
- Port@39394f3f (UUID: _1u0m1PmxEeKDk4RlwuVRlA)
FailureMode@1118d061 (UUID: _1u0m1vmxEeKDk4RlwuVRlA)
- Port@39394f3f (UUID: _1u0m1PmxEeKDk4RlwuVRlA)
FailureMode@7418990b (UUID: _1u0m1_mxEeKDk4RlwuVRlA)
FailureMode@6181ce72 (UUID: _1u0m1fmxEeKDk4RlwuVRlA)
- Port@7ae7dcb8 (UUID: _1u1N4PmxEeKDk4RlwuVRlA)
FailureMode@4e43290c (UUID: _1u1N4vmxEeKDk4RlwuVRlA)
- Port@7ae7dcb8 (UUID: _1u1N4PmxEeKDk4RlwuVRlA)
FailureMode@c4bf312 (UUID: _1u1N4fmxEeKDk4RlwuVRlA)
FailureMode@1b3bfaf8 (UUID: _1u1N4_mxEeKDk4RlwuVRlA)
- Block@93887a9 (UUID: b577ad36-0dc7-48e1-a46e-5925ec030e7f)
LocalEvent@4e82972c (UUID: _1u108vmxEeKDk4RlwuVRlA)
- Block@93887a9 (UUID: b577ad36-0dc7-48e1-a46e-5925ec030e7f)
- Port@5e526cf9 (UUID: _1u1N5vmxEeKDk4RlwuVRlA)
FailureMode@6259d602 (UUID: _1u1N6fmxEeKDk4RlwuVRlA)
- Port@5e526cf9 (UUID: _1u1N5vmxEeKDk4RlwuVRlA)
FailureMode@2cd72b45 (UUID: _1u1N6PmxEeKDk4RlwuVRlA)
FailureMode@75707fcf (UUID: _1u1N5_mxEeKDk4RlwuVRlA)
- Port@77f14fbf (UUID: _1u1N6vmxEeKDk4RlwuVRlA)
FailureMode@494b05ae (UUID: _1u1N7fmxEeKDk4RlwuVRlA)
FailureMode@3fae4173 (UUID: _1u1N7PmxEeKDk4RlwuVRlA)
FailureMode@3aac21e (UUID: _1u1N6_mxEeKDk4RlwuVRlA)
- Port@5c620819 (UUID: _1u1N7vmxEeKDk4RlwuVRlA)
FailureMode@2801d0b1 (UUID: _1u1N7_mxEeKDk4RlwuVRlA)
FailureMode@1c36c02c (UUID: _1u108fmxEeKDk4RlwuVRlA)
FailureMode@f2c28fc (UUID: _1u108PmxEeKDk4RlwuVRlA)
- Barrier@5f92f1f8 (UUID: _bUNrQPnoEeKfcKMjO25DyQ)
FailureMode@7ea115d7 (UUID: _bUf_IvnoEeKfcKMjO25DyQ)
FailureMode@284c01cd (UUID: _bUf_IPnoEeKfcKMjO25DyQ)
FailureMode@160a4e66 (UUID: _bUf_IfnoEeKfcKMjO25DyQ)
Barrier@5f92f1f8 (UUID: _bUNrQPnoEeKfcKMjO25DyQ)
Line 4 & 6 should be only "one line" for me.
Any clue about what is wrong?
Thx for help,
Tony
|
|
|
|
|
|
|
|
|
|
Re: Issue with Tree grid [message #1243056 is a reply to message #1242350] |
Mon, 10 February 2014 08:06  |
Eclipse User |
|
|
|
Hi,
I finally solve my problem with this kind of comparator :
@Override
public int compare(final EObject pO1, final EObject pO2) {
int vReturnValue = 0;
if (pO1 != null && pO2 != null) {
// First compare parent
EObject vParent1 = pO1.eContainer();
EObject vParent2 = pO2.eContainer();
vReturnValue = compare(vParent1, vParent2);
// If the parent is the same, compare UUID
if (vReturnValue == 0) {
String vUUID1 = ((IAbstractIdentifiedObject) pO1).getUUID();
String vUUID2 = ((IAbstractIdentifiedObject) pO2).getUUID();
vReturnValue = vUUID1.compareTo(vUUID2);
}
} else if (pO1 == null && pO2 == null) {
vReturnValue = 0;
} else if (pO1 == null && pO2 != null) {
vReturnValue = -1;
} else if (pO1 != null && pO2 == null) {
vReturnValue = 1;
}
return vReturnValue;
}
I have to set this comparator in my SortedList constructor, too.
Tony
|
|
|
Powered by
FUDForum. Page generated in 0.30208 seconds