Java 类com.google.gwt.event.logical.shared.HasAttachHandlers 实例源码

项目:gwt-material    文件:EventHelper.java   
public static void onAttachOnce(HasAttachHandlers has, AttachEvent.Handler handler) {
    HandlerRegistration[] reg = new HandlerRegistration[1];
    reg[0] = has.addAttachHandler(event -> {
        if(event.isAttached()) {
            handler.onAttachOrDetach(event);

            if (reg[0] != null) {
                reg[0].removeHandler();
            }
        }
    });
}
项目: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());
}
项目:Peergos    文件:WindowBasedOrientationHelper.java   
CommandSet(HasAttachHandlers widget, Command portrait, Command landscape) {
  this.portraitCommand = portrait;
  this.landscapeCommand = landscape;

  attachEventReg = widget.addAttachHandler(this);
  active = widget.isAttached();
}
项目:Peergos    文件:WindowBasedOrientationHelper.java   
@Override
public HandlerRegistration setCommands(HasAttachHandlers widget, Command forPortrait,
    Command forLandscape) {
  assertLive();
  CommandSet commandSet = new CommandSet(widget, forPortrait, forLandscape);
  commandSets.add(commandSet);
  commandSet.fire();
  return commandSet;
}
项目:swarm    文件:WindowBasedOrientationHelper.java   
CommandSet(HasAttachHandlers widget, Command portrait, Command landscape) {
  this.portraitCommand = portrait;
  this.landscapeCommand = landscape;

  attachEventReg = widget.addAttachHandler(this);
  active = widget.isAttached();
}
项目:swarm    文件:WindowBasedOrientationHelper.java   
@Override
public HandlerRegistration setCommands(HasAttachHandlers widget, Command forPortrait,
    Command forLandscape) {
  assertLive();
  CommandSet commandSet = new CommandSet(widget, forPortrait, forLandscape);
  commandSets.add(commandSet);
  commandSet.fire();
  return commandSet;
}
项目:Peergos    文件:OrientationHelper.java   
/**
 * Set commands to run on orientation change, one for portrait and one for
 * landscape. The appropriate command is fired immediately if this method is
 * called while the widget is attached.
 * <p>
 * Commands are also fired each time the widget is attached. If that is not
 * desired a widget should call {@link HandlerRegistration#removeHandler()} on
 * the returned object when it detaches.
 * 
 * @param widget the widget to help
 * @param forPortrait command to run when on shift to portrait
 * @param forLandscape command to run when on shift to landscape
 * @return registration object to be used to stop and dereference the commands
 */
HandlerRegistration setCommands(HasAttachHandlers widget, Command forPortrait,
    Command forLandscape);
项目:swarm    文件:OrientationHelper.java   
/**
 * Set commands to run on orientation change, one for portrait and one for
 * landscape. The appropriate command is fired immediately if this method is
 * called while the widget is attached.
 * <p>
 * Commands are also fired each time the widget is attached. If that is not
 * desired a widget should call {@link HandlerRegistration#removeHandler()} on
 * the returned object when it detaches.
 * 
 * @param widget the widget to help
 * @param forPortrait command to run when on shift to portrait
 * @param forLandscape command to run when on shift to landscape
 * @return registration object to be used to stop and dereference the commands
 */
HandlerRegistration setCommands(HasAttachHandlers widget, Command forPortrait,
    Command forLandscape);