Skip to content

Commit

Permalink
493143: TreeViewerColumnBuilder does not use custom weight for firstcol
Browse files Browse the repository at this point in the history
Change-Id: Id057e17fe2c02964280a99899e652df7ff27ffe2
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493143
  • Loading branch information
LorenzoBettini committed May 7, 2016
1 parent 09b62c2 commit 0e4b033
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,22 @@ protected void buildTreeViewer(TreeViewer treeViewer, EClass eClass, List<EStruc
Layout layout = layoutHelper.adjustForTableLayout(treeViewer);

int i = 0;

createMainTreeViewerColumn(treeViewer, layout, defaultWeight);
createMainTreeViewerColumn(treeViewer, layout, customWeightOrDefaultWeight(i++));

for (EStructuralFeature eStructuralFeature : typeFeatures) {
int weight = defaultWeight;
if (weights.size() > i) {
weight = weights.get(i++);
}

buildTreeViewerColumn(treeViewer, layout,
(eClass != null ? eClass : eStructuralFeature.getEContainingClass()),
eStructuralFeature,
weight);
customWeightOrDefaultWeight(i++));
}
}

private int customWeightOrDefaultWeight(int i) {
int weight = defaultWeight;
if (weights.size() > i) {
weight = weights.get(i);
}
return weight;
}

protected TreeViewerColumn buildTreeViewerColumn(TreeViewer treeViewer, Layout layout, EClass eClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ class TreeViewerColumnBuilderTest extends AbstractViewerTest {
buildAndFillTreeViewer(
createInjector(new EmfParsleyGuiceModuleForTesting() {
override valueTableColumnWeights() {
#[5, 2]
#[5, 2, 4]
}
}),
testContainer.classesForControls,
testPackage.classForControls
)
syncExecVoid[
treeViewer.tree.getLayout.tableLayoutColumnData => [
// the first column is the tree so we skip it
get(1).assertColumnWeight(5)
get(2).assertColumnWeight(2)
// the first column is the tree
get(0).assertColumnWeight(5)
get(1).assertColumnWeight(2)
get(2).assertColumnWeight(4)
// 3 is the default one
get(3).assertColumnWeight(3)
]
Expand Down

0 comments on commit 0e4b033

Please sign in to comment.