Community
Participate
Working Groups
The little test program works as expected if I use the old Eclipse Luna jars: org.eclipse.core.commands_3.6.100.v20140528-1422.jar org.eclipse.equinox.common_3.6.200.v20130402-1505.jar org.eclipse.jface_3.10.2.v20141021-1035.jar org.eclipse.swt.gtk.linux.x86_64_3.103.2.v20150203-1351.jar org.eclipse.swt_3.103.2.v20150203-1313.jar but if I switch to the ones provided with Eclipse Mars: org.eclipse.core.commands_3.7.0.v20150422-0725.jar org.eclipse.equinox.common_3.7.0.v20150402-1709.jar org.eclipse.jface_3.11.0.v20150602-1400.jar org.eclipse.swt.gtk.linux.x86_64_3.104.0.v20150528-0211.jar org.eclipse.swt_3.104.0.v20150528-0211.jar the behavior breaks. The content of the TreeViewer only shows one entry repeatedly The entry that is shown depends on the line you click on. All very wrong and disturbing. I don't know if this affects other versions than mine (Linux (Kubuntu 15.04, KDE Plasma 5.2.2, Qt 5.4.1, Kernel 3.19.0-22, 64 bit) Here is the test program: import java.util.ArrayList; import java.util.List; import org.eclipse.jface.layout.TreeColumnLayout; import org.eclipse.jface.viewers.ColumnPixelData; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StyledCellLabelProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; public class JFaceTreeBug { public class GameRefsTreeContentProvider implements ITreeContentProvider { private List<GameRef> gameRefs; @Override public void dispose() { } @SuppressWarnings("unchecked") @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.gameRefs = (List<GameRef>)newInput; } @Override public Object[] getElements(Object inputElement) { return gameRefs.toArray(); } @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof GameRef){ GameRef gameRef = (GameRef)parentElement; if (gameRef.getGames() != null){ return gameRef.getGames().toArray(); } } return null; } @Override public Object getParent(Object element) { if (element instanceof Game){ return ((Game)element).getParent(); } return null; } @Override public boolean hasChildren(Object element) { if (this.getChildren(element)!=null && this.getChildren(element).length > 0) return true; return false; } } public class Game { private String name; private GameRef parent; public Game(String name, GameRef parent) { super(); setName(name); setParent(parent); } public String getName() { return name; } public void setName(String name) { this.name = name; } public GameRef getParent() { return parent; } public void setParent(GameRef parent) { this.parent = parent; this.getParent().getGames().add(this); } } public class GameRef { private String name; private List<Game> games; public GameRef(String name) { super(); this.name = name; this.games = new ArrayList<>(); } public List<Game> getGames() { return games; } public String getName() { return name; } } public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Hello, world!"); shell.setLayout(new RowLayout()); final Composite composite = new Composite(shell, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; composite.setLayout(gridLayout); Label label = new Label(composite, SWT.SHADOW_NONE); label.setText("Tree"); final Composite referenceGamesTreeCmpst = new Composite(composite, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, true, 1, 1); gd.grabExcessVerticalSpace = true; gd.minimumHeight = 190; gd.heightHint = 250; gd.widthHint = 1008; referenceGamesTreeCmpst.setLayoutData(gd); //Add TreeColumnLayout TreeColumnLayout layout = new TreeColumnLayout(); referenceGamesTreeCmpst.setLayout(layout); TreeViewer treeViewer = new TreeViewer(referenceGamesTreeCmpst, SWT.BORDER); Tree tree = treeViewer.getTree(); tree.setHeaderVisible(true); TreeViewerColumn tvColName = new TreeViewerColumn(treeViewer, SWT.NONE); tvColName.getColumn().setText("name"); layout.setColumnData(tvColName.getColumn(), new ColumnPixelData(70, true, true)); tvColName.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { if (cell.getElement() instanceof Game){ cell.setText(((Game)cell.getElement()).getName()); } else if (cell.getElement() instanceof GameRef){ cell.setText(((GameRef)cell.getElement()).getName()); } super.update(cell); } }); TreeViewerColumn tvColType = new TreeViewerColumn(treeViewer, SWT.NONE); tvColType.getColumn().setText("type"); layout.setColumnData(tvColType.getColumn(), new ColumnPixelData(70, true, true)); tvColType.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { if (cell.getElement() instanceof Game){ cell.setText("game"); } else if (cell.getElement() instanceof GameRef){ cell.setText("ref game"); } super.update(cell); } }); JFaceTreeBug test = new JFaceTreeBug(); List<GameRef> gameRefs = new ArrayList<>(); GameRef gr1 = test.new GameRef("ref 1"); GameRef gr2 = test.new GameRef("ref 2"); Game g11 = test.new Game("g11", gr1); Game g12 = test.new Game("g12", gr1); Game g21 = test.new Game("g21", gr2); gameRefs.add(gr1); gameRefs.add(gr2); treeViewer.setContentProvider(test.new GameRefsTreeContentProvider()); treeViewer.setInput(gameRefs); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in the event queue display.sleep(); } } display.dispose(); } }
Created attachment 255666 [details] Screen shot running I20150805-2000 I got the following screenshot using the latest I build I20150805-2000 Please let me know whether this is expected result I am using Ubuntu 15.10 with Unity desktop
This is how it should look when the tree is fully expanded, yes. I will attach what i see.
Created attachment 255667 [details] after start on mars 4.5
Created attachment 255668 [details] after selecting second tree node on mars 4.5
Created attachment 255669 [details] after selecting second then first tree node on mars 4.5
I forgot to mention, that I use the RCP/RAP developer edition of Eclipse, not the standard edition. I don't know if that makes a difference. In them moment I can't moce to mars because of this. I maintain a couple of RCP applications the use TreeView and they are affected by this. Strangely, all TreeViewers within the IDE itself look fine and seem to work normally.
I am able to reproduce this problem in Mars release. This problem is not reproducible in 4.6 M1 (which will be released by this week). We will identify the fix and push it to 4.5.1
Thank you. that is good news.
Probably fix for bug 466499 .
Hi Alex, Can you please review the code and push it to maintenance branch https://git.eclipse.org/r/#/c/53470/ Thanks Sravan
*** This bug has been marked as a duplicate of bug 466499 ***
*** Bug 475502 has been marked as a duplicate of this bug. ***