Java 类com.google.gwt.user.client.ui.HasEnabled 实例源码

项目:gwtbootstrap3    文件:InputToggleButtonGwt.java   
@Override
public <T extends UIObject & HasEnabled> void checkEnabled(T button) {
    final Element label = button.getElement();
    final InputElement input = InputElement.as(label.getFirstChildElement());
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertFalse(input.isDisabled());
    button.setEnabled(false);
    assertTrue(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertTrue(input.isDisabled());
    button.setEnabled(true);
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    assertFalse(input.isDisabled());
}
项目:gwt-material    文件:WavesMixin.java   
@Override
public void setWaves(WavesType waves) {
    uiObject.removeStyleName(Waves.WAVES_STYLE);
    if (this.waves != null) {
        uiObject.removeStyleName(this.waves.getCssName());
    }

    this.waves = waves;

    if (waves != null) {
        boolean enabled = !(uiObject instanceof HasEnabled) || ((HasEnabled) uiObject).isEnabled();
        if (enabled) {
            uiObject.addStyleName(Waves.WAVES_STYLE);
        }

        uiObject.addStyleName(waves.getCssName());
        if (enabled) {
            Waves.detectAndApply(uiObject);
        }
    }
}
项目:gwt-material    文件:ReadOnlyMixin.java   
@Override
public void setReadOnly(boolean readOnly) {
    uiObject.removeStyleName(CssName.READ_ONLY);
    if (readOnly) {
        if (uiObject instanceof HasEnabled) {
            ((HasEnabled) uiObject).setEnabled(false);
        }
        uiObject.addStyleName(CssName.READ_ONLY);
        target.getElement().setAttribute("readonly", "");
    } else {
        if (uiObject instanceof HasEnabled) {
            ((HasEnabled) uiObject).setEnabled(true);
        }
        target.getElement().removeAttribute("readonly");
        uiObject.removeStyleName(CssName.READ_ONLY);
    }
}
项目:gwt-material    文件:ReadOnlyMixin.java   
@Override
public void setToggleReadOnly(boolean value) {
    uiObject.removeStyleName(CssName.READ_ONLY_TOGGLE);
    if (value) {
        uiObject.addStyleName(CssName.READ_ONLY_TOGGLE);
        if (uiObject instanceof HasEnabled && !((HasEnabled) uiObject).isEnabled()) {
            ((HasEnabled) uiObject).setEnabled(true);
        }
        $(target).off("mousedown");
        $(uiObject).mousedown((e, param1) -> {
            setReadOnly(false);
            return true;
        });

        $(target).off("blur");
        $(target).blur((e, param1) -> {
            setReadOnly(true);
            return true;
        });
    }
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
protected <H extends HasAllKeyHandlers & HasEnabled> void checkKeyEvents(H widget) {
    // Key Down
    final boolean[] isKeyDownFired = {false};
    widget.addKeyDownHandler(keyDownEvent -> isKeyDownFired[0] = true);
    fireKeyDownEvent(widget);

    // Key Up
    final boolean[] isKeyUpFired = {false};
    widget.addKeyUpHandler(keyUpEvent -> isKeyUpFired[0] = true);
    fireKeyUpEvent(widget);

    // Key Press
    final boolean[] isKeyPressFired = {false};
    widget.addKeyPressHandler(keyPressEvent -> isKeyPressFired[0] = true);
    fireKeyPressEvent(widget);

    assertEquals(widget.isEnabled(), isKeyDownFired[0]);
    assertEquals(widget.isEnabled(), isKeyUpFired[0]);
    assertEquals(widget.isEnabled(), isKeyPressFired[0]);
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
protected <H extends UIObject & HasEnabled> void checkEnabled(HasEnabled widget, H target, boolean checkElement) {
    final Element element = target.getElement();
    if(checkElement) {
        assertFalse(element.hasClassName(CssName.DISABLED));
        assertFalse(element.hasAttribute(CssName.DISABLED));
    }
    widget.setEnabled(true);
    if(checkElement) {
        assertFalse(element.hasClassName(CssName.DISABLED));
        assertFalse(element.hasAttribute(CssName.DISABLED));
    }
    assertEquals(widget.isEnabled(), true);
    widget.setEnabled(false);
    if(checkElement) {
        assertTrue(element.hasClassName(CssName.DISABLED));
        assertTrue(element.hasAttribute(CssName.DISABLED));
    }
    assertEquals(target.isEnabled(), false);
}
项目:gerrit    文件:ProjectInfoScreen.java   
private void enableForm(boolean isOwner) {
  state.setEnabled(isOwner);
  submitType.setEnabled(isOwner);
  setEnabledForUseContentMerge();
  newChangeForAllNotInTarget.setEnabled(isOwner);
  if (enableSignedPush != null) {
    enableSignedPush.setEnabled(isOwner);
  }
  descTxt.setEnabled(isOwner);
  contributorAgreements.setEnabled(isOwner);
  signedOffBy.setEnabled(isOwner);
  requireChangeID.setEnabled(isOwner);
  rejectImplicitMerges.setEnabled(isOwner);
  privateByDefault.setEnabled(isOwner);
  maxObjectSizeLimit.setEnabled(isOwner);
  enableReviewerByEmail.setEnabled(isOwner);
  matchAuthorToCommitterDate.setEnabled(isOwner);

  if (pluginConfigWidgets != null) {
    for (Map<String, HasEnabled> widgetMap : pluginConfigWidgets.values()) {
      for (HasEnabled widget : widgetMap.values()) {
        widget.setEnabled(isOwner);
      }
    }
  }
}
项目:qafe-platform    文件:SetPropertyHandler.java   
private void handleEnabled(UIObject uiObject, String propertyValue, String propertyType) {
    boolean value = Boolean.valueOf(propertyValue).booleanValue();
    if (QAMLConstants.PROPERTY_DISABLED.equals(propertyType)) {
        value = !value;
    }
    if (uiObject instanceof HasEnabled) {
        HasEnabled hasEnabled = (HasEnabled)uiObject;
        hasEnabled.setEnabled(value);
    } else if (uiObject instanceof HasWidgets) {
        SetMaskHelper.setMaskEnable(uiObject.getElement().getAttribute(QAMLConstants.PROPERTY_ID), value, true);
        DOM.setElementPropertyBoolean(uiObject.getElement(), QAMLConstants.PROPERTY_DISABLED, !value);
    } else if (uiObject instanceof QSuggestBox) {
        QSuggestBox suggestField = (QSuggestBox)uiObject;
        suggestField.getTextBox().setEnabled(value);
    } else if (uiObject instanceof SpreadsheetCell) {
        SpreadsheetCell cell = (SpreadsheetCell) uiObject;
        cell.setEditable(value);
    }
}
项目:gwt-bean-validators    文件:AbstractBeanValidationEditorDriver.java   
@Override
public final boolean validate() {
  boolean valid = false;
  final T object = this.flush();
  if (!this.hasErrors()) {
    final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    final Set<ConstraintViolation<T>> violations;
    if (this.validationGroups == null) {
      violations = validator.validate(object);
    } else {
      violations = validator.validate(object, this.validationGroups);
    }
    this.setConstraintViolations(new ArrayList<ConstraintViolation<?>>(violations));
    valid = !this.hasErrors();
  }
  if (this.submitButton instanceof HasEnabled && this.checkTime != CheckTimeEnum.ON_SUBMIT) {
    ((HasEnabled) this.submitButton)
        .setEnabled(valid && (this.submitUnchanged || this.isDirty()));
  }
  return valid;
}
项目:gwt-material    文件:EnabledMixin.java   
public void setEnabled(MaterialWidget widget, boolean enabled) {
    setEnabled(enabled);

    if(isPropagateToChildren()) {
        for (Widget child : widget.getChildren()) {
            if (child instanceof MaterialWidget) {
                ((MaterialWidget) child).setEnabled(enabled);
            } else if (child instanceof HasEnabled) {
                ((HasEnabled) child).setEnabled(enabled);
            }
        }
    }
}
项目:gwt-material    文件:MaterialDropDown.java   
@Override
public HandlerRegistration addSelectionHandler(final SelectionHandler<Widget> handler) {
    return addHandler((SelectionHandler<Widget>) event -> {
        Widget widget = event.getSelectedItem();
        if (widget instanceof HasEnabled && ((HasEnabled) widget).isEnabled() && isEnabled()) {
            handler.onSelection(event);
        }
    }, SelectionEvent.getType());
}
项目:gwt-material    文件:WidgetTestCase.java   
public static <H extends HasValueChangeHandlers & HasValue & HasEnabled & HasAttachHandlers> void checkValueChangeEvent(
        H widget, Object value, Object secondValue) {
    assertNotSame(value, secondValue);
    // Widget must be enabled before firing the event
    widget.setEnabled(true);
    assertTrue(widget.isEnabled());
    // Ensure the widget is attached to the root panel
    assertTrue(widget.isAttached());
    // Register value change handler that listens when the widget
    // set the value
    final boolean[] isValueChanged = {false};
    widget.addValueChangeHandler(event -> isValueChanged[0] = true);
    // By default setValue(boolean) will not fire the value change event.
    widget.setValue(value);
    assertEquals(value, widget.getValue());
    // Expected result : false
    assertFalse(isValueChanged[0]);
    // Calling setValue(value, fireEvents) with fireEvents set to false
    widget.setValue(secondValue, false);
    // Expected result : secondValue
    assertEquals(secondValue, widget.getValue());
    // Expected result : false
    assertFalse(isValueChanged[0]);
    // Calling setValue(value, fireEvents) with fireEvents set to true
    widget.setValue(value, true);
    // Expected result : true
    assertTrue(isValueChanged[0]);
    // Expected result : value
    assertEquals(value, widget.getValue());
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
protected <H extends HasAllFocusHandlers & HasEnabled> void checkFocusAndBlurEvents(H widget) {
    // Check Focus
    final boolean[] isFocusFired = {false};
    widget.addFocusHandler(focusEvent -> isFocusFired[0] = true);
    fireFocusEvent(widget);

    // Check Blur
    final boolean[] isBlurFired = {false};
    widget.addBlurHandler(blurEvent -> isBlurFired[0] = true);
    fireBlurEvent(widget);

    assertEquals(widget.isEnabled(), isFocusFired[0]);
    assertEquals(widget.isEnabled(), isBlurFired[0]);
}
项目:qafe-platform    文件:RendererHelper.java   
public static void addDisabledInfo(ComponentGVO vo, UIObject ui) {
    if (vo != null && ui != null) {
        if (ui instanceof HasEnabled) {
            boolean enabled = !vo.isDisabled();
            HasEnabled hasEnabled = (HasEnabled)ui;
            hasEnabled.setEnabled(enabled);
        } else if (vo.isDisabled().booleanValue()) {
            DOM.setElementAttribute(getElement(ui), "disabled", "true");
        }
    }
}
项目:qafe-platform    文件:QChoiceHelper.java   
public void setEnabled(boolean enabled) {
    this.enabled = enabled;
    List<Widget> items = getItems();
    if (items == null) {
        return;
    }
    for (Widget item : items) {
        if (item instanceof HasEnabled) {
            HasEnabled hasEnabled = (HasEnabled)item;
            hasEnabled.setEnabled(enabled);
        }
    }
}
项目:qafe-platform    文件:AbstractComponentRenderer.java   
protected void initAvailablitiy(ComponentGVO component, UIObject widget, String uuid, String parent, String context) {
    if (component == null) {
        return;
    }
    if (widget == null) {
        return;
    }
    if (widget instanceof HasEnabled) {
        HasEnabled availability = (HasEnabled)widget;
        boolean enabled = !component.isDisabled();
        availability.setEnabled(enabled);
    }
}
项目:gwt-bean-validators    文件:AbstractDecorator.java   
@Override
public boolean isEnabled() {
  if (this.contents.getWidget() instanceof HasEnabled) {
    ((HasEnabled) this.contents.getWidget()).isEnabled();
  }
  return false;
}
项目:gwtbootstrap3    文件:BaseGwt.java   
public <T extends UIObject & HasEnabled> void checkEnabled(T button) {
    final Element label = button.getElement();
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
    button.setEnabled(false);
    assertTrue(label.hasClassName(Styles.DISABLED));
    assertTrue(label.hasAttribute(Styles.DISABLED));
    button.setEnabled(true);
    assertFalse(label.hasClassName(Styles.DISABLED));
    assertFalse(label.hasAttribute(Styles.DISABLED));
}
项目:gwt-upload    文件:SingleUploader.java   
private void setEnabledButton(boolean b) {
  if (button != null) {
    // HasEnabled is only available after gwt-2.1.x
    if (button instanceof HasEnabled) {
      ((HasEnabled)button).setEnabled(b);
    } else if (button instanceof Button) {
      ((Button)button).setEnabled(b);
    }
  }
}
项目:gwt-material    文件:MaterialWidgetTestCase.java   
protected <H extends UIObject & HasEnabled> void checkEnabled(HasEnabled widget, H target) {
    checkEnabled(widget, target, true);
}
项目:appformer    文件:PropertyEditorFieldOptionUtils.java   
public static void disable(final Widget fieldWidget) {
    if (fieldWidget instanceof HasEnabled) {
        ((HasEnabled) fieldWidget).setEnabled(false);
    }
}
项目:qafe-platform    文件:QTreeItem.java   
public boolean isEnabled() {
    return ((HasEnabled)label).isEnabled();
}
项目:qafe-platform    文件:QTreeItem.java   
public void setEnabled(boolean enabled) {
    ((HasEnabled)label).setEnabled(enabled);
}
项目:gwt-bean-validators    文件:AbstractDecorator.java   
@Override
public void setEnabled(final boolean penabled) {
  if (this.contents.getWidget() instanceof HasEnabled) {
    ((HasEnabled) this.contents.getWidget()).setEnabled(penabled);
  }
}
项目:gwtutil    文件:PreventingCallback.java   
public PreventingCallback(HasEnabled widget) {
    this.widget = widget;
    widget.setEnabled(false);
}
项目:gwt-d3    文件:TestSessionContainer.java   
public void started(final boolean f) {
    ((HasEnabled) runButton).setEnabled(!f);
    ((HasEnabled) stopButton).setEnabled(f);
}