Skip to content

Commit

Permalink
resize of TreeViewer columns now happens only if the column size is 0 (
Browse files Browse the repository at this point in the history
…#168)

also adds a method to force the resize.

fix #166

Signed-off-by: Didier Vojtisek <didier.vojtisek@inria.fr>
  • Loading branch information
dvojtise committed May 12, 2020
1 parent c0df365 commit 948c7ad
Showing 1 changed file with 19 additions and 3 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Inria and others.
* Copyright (c) 2017, 2020 Inria 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
Expand All @@ -16,10 +16,26 @@
public class TreeViewerHelper
{

/**
* resize all the columns of the tree viewer to their preferred sizes
* @param viewer
* @param force, if false, the resize happens only if the column size is 0
*/
public static void resizeColumns(TreeViewer viewer, boolean force)
{
for (TreeColumn tc : viewer.getTree().getColumns()) {
if(tc.getWidth() == 0 || force )
tc.pack();
}
}

/**
* resize all the columns of the tree viewer to their preferred sizes if their size is 0
* @param viewer
*/
public static void resizeColumns(TreeViewer viewer)
{
for (TreeColumn tc : viewer.getTree().getColumns())
tc.pack();
resizeColumns(viewer, false);
}

}

0 comments on commit 948c7ad

Please sign in to comment.