use of com.google.gwt.user.client.ui.TreeItem in project che by eclipse.
the class PreviewViewImpl method createTreeElement.
private void createTreeElement(final TreeItem root, String changeName, List<RefactoringPreview> children) {
FlowPanel element = new FlowPanel();
element.getElement().getStyle().setFloat(LEFT);
CheckBox itemCheckBox = new CheckBox();
itemCheckBox.setValue(true);
itemCheckBox.getElement().getStyle().setFloat(LEFT);
itemCheckBox.getElement().getStyle().setMarginTop(3, PX);
Label name = new Label(changeName);
name.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
delegate.onSelectionChanged(containerChanges.get(root));
root.setSelected(true);
}
});
name.getElement().getStyle().setFloat(LEFT);
element.add(itemCheckBox);
element.add(name);
root.setWidget(element);
element.getElement().getParentElement().getStyle().setMargin(1, PX);
itemCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
checkChildrenState(root, event.getValue());
checkParentState(root, event.getValue());
RefactoringPreview change = containerChanges.get(root);
change.setEnabled(event.getValue());
delegate.onEnabledStateChanged(change);
}
});
if (children.isEmpty()) {
return;
}
for (RefactoringPreview child : children) {
TreeItem treeItem = new TreeItem();
containerChanges.put(treeItem, child);
createTreeElement(treeItem, child.getText(), child.getChildrens());
root.addItem(treeItem);
}
}
use of com.google.gwt.user.client.ui.TreeItem in project gwt-test-utils by gwt-test-utils.
the class TreeTest method selectedOnFocusWidget.
@Test
public void selectedOnFocusWidget() {
// Given
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
public void onSelection(SelectionEvent<TreeItem> event) {
clickedTreeItem = event.getSelectedItem();
}
});
// When on item2 which wrap a Checkbox
tree.setSelectedItem(item2);
TreeItem selected = tree.getSelectedItem();
// Then
assertThat(clickedTreeItem).isEqualTo(item2);
assertThat(selected).isEqualTo(item2);
}
use of com.google.gwt.user.client.ui.TreeItem in project gwt-test-utils by gwt-test-utils.
the class TreeTest method beforeTreeTest.
@Before
public void beforeTreeTest() {
// Create a tree with a few items in it.
parent = new TreeItem(new SafeHtmlBuilder().appendEscaped("parent").toSafeHtml());
item0 = parent.addItem(new SafeHtmlBuilder().appendEscaped("item0").toSafeHtml());
item1 = parent.addItem(new SafeHtmlBuilder().appendEscaped("item1").toSafeHtml());
// Add a CheckBox to the tree
item2 = new TreeItem(new CheckBox("item2"));
parent.addItem(item2);
tree = new Tree();
tree.addItem(parent);
// Add it to the root panel.
RootPanel.get().add(tree);
assertThat(tree.isVisible()).isTrue();
clickedTreeItem = null;
}
use of com.google.gwt.user.client.ui.TreeItem in project gwt-test-utils by gwt-test-utils.
the class TreeTest method selected.
@Test
public void selected() {
// Given
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
public void onSelection(SelectionEvent<TreeItem> event) {
clickedTreeItem = event.getSelectedItem();
}
});
// When
tree.setSelectedItem(item1);
TreeItem selected = tree.getSelectedItem();
// Then
assertThat(clickedTreeItem).isEqualTo(item1);
assertThat(selected).isEqualTo(item1);
}
Aggregations