use of com.google.gwt.user.client.ui.CheckBox in project che by eclipse.
the class PreviewViewImpl method checkChildrenState.
private void checkChildrenState(TreeItem treeItem, Boolean value) {
int childCount = treeItem.getChildCount();
if (childCount == 0) {
return;
}
for (int i = 0; i < childCount; i++) {
TreeItem childItem = treeItem.getChild(i);
if (!(childItem.getWidget() instanceof FlowPanel)) {
return;
}
FlowPanel childItemContainer = (FlowPanel) childItem.getWidget();
if (!(childItemContainer.getWidget(0) instanceof CheckBox)) {
return;
}
CheckBox childCheckBox = (CheckBox) childItemContainer.getWidget(0);
childCheckBox.setValue(value);
checkChildrenState(childItem, value);
}
}
use of com.google.gwt.user.client.ui.CheckBox in project che by eclipse.
the class PreviewViewImpl method checkParentState.
private void checkParentState(TreeItem treeItem, Boolean value) {
TreeItem parentItem = treeItem.getParentItem();
if (parentItem == null) {
return;
}
if (!(parentItem.getWidget() instanceof FlowPanel)) {
return;
}
FlowPanel parentChangeContainer = (FlowPanel) parentItem.getWidget();
if (!(parentChangeContainer.getWidget(0) instanceof CheckBox)) {
return;
}
CheckBox parentCheckBox = (CheckBox) parentChangeContainer.getWidget(0);
if (value && !parentCheckBox.getValue()) {
parentCheckBox.setValue(true);
checkParentState(parentItem, true);
}
}
use of com.google.gwt.user.client.ui.CheckBox 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.CheckBox in project gwt-test-utils by gwt-test-utils.
the class CheckBoxTest method visible.
@Test
public void visible() {
// Given
CheckBox cb = new CheckBox();
// Preconditions
assertThat(cb.isVisible()).isEqualTo(true);
// When
cb.setVisible(false);
// Then
assertThat(cb.isVisible()).isEqualTo(false);
}
use of com.google.gwt.user.client.ui.CheckBox in project gwt-test-utils by gwt-test-utils.
the class CheckBoxTest method html.
@Test
public void html() {
// Given
CheckBox cb = new CheckBox("<h1>foo</h1>", true);
// Preconditions
assertThat(cb.getHTML()).isEqualTo("<h1>foo</h1>");
// When
cb.setHTML("<h1>test</h1>");
// Then
assertThat(cb.getHTML()).isEqualTo("<h1>test</h1>");
assertThat(cb.getElement().getChild(1).getChildCount()).isEqualTo(1);
HeadingElement h1 = cb.getElement().getChild(1).getChild(0).cast();
assertThat(h1.getTagName()).isEqualTo("H1");
assertThat(h1.getInnerText()).isEqualTo("test");
}
Aggregations