private static void readScrollPosition(final Tree tree) { String left = WidgetLCAUtil.readPropertyValue(tree, "scrollLeft"); String top = WidgetLCAUtil.readPropertyValue(tree, "scrollTop"); if (left != null && top != null) { Object adapter = tree.getAdapter(ITreeAdapter.class); final ITreeAdapter treeAdapter = (ITreeAdapter) adapter; final int newScrollLeft = parsePosition(left); final int newScrollTop = parsePosition(top); final int oldScrollTop = treeAdapter.getScrollTop(); treeAdapter.setScrollLeft(newScrollLeft); treeAdapter.setScrollTop(newScrollTop); if (oldScrollTop != newScrollTop) { ProcessActionRunner.add( new Runnable() { public void run() { treeAdapter.checkAllData(tree); } }); } } }
private static void readSelection(final Tree tree) { String value = WidgetLCAUtil.readPropertyValue(tree, "selection"); if (value != null) { String[] values = value.split(","); TreeItem[] selectedItems = new TreeItem[values.length]; boolean validItemFound = false; for (int i = 0; i < values.length; i++) { selectedItems[i] = (TreeItem) WidgetUtil.find(tree, values[i]); if (selectedItems[i] != null) { validItemFound = true; } } if (!validItemFound) { selectedItems = new TreeItem[0]; } tree.setSelection(selectedItems); } }