Search in sources :

Example 21 with CheckBox

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);
    }
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 22 with CheckBox

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);
    }
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 23 with CheckBox

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);
    }
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Label(com.google.gwt.user.client.ui.Label) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)

Example 24 with CheckBox

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);
}
Also used : CheckBox(com.google.gwt.user.client.ui.CheckBox) Test(org.junit.Test)

Example 25 with CheckBox

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");
}
Also used : CheckBox(com.google.gwt.user.client.ui.CheckBox) HeadingElement(com.google.gwt.dom.client.HeadingElement) Test(org.junit.Test)

Aggregations

CheckBox (com.google.gwt.user.client.ui.CheckBox)36 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)9 Test (org.junit.Test)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Label (com.google.gwt.user.client.ui.Label)7 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)6 ListBox (com.google.gwt.user.client.ui.ListBox)5 TreeItem (com.google.gwt.user.client.ui.TreeItem)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Button (com.google.gwt.user.client.ui.Button)3 Grid (com.google.gwt.user.client.ui.Grid)3 HTML (com.google.gwt.user.client.ui.HTML)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 TextBox (com.google.gwt.user.client.ui.TextBox)3 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2