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

项目:sigmah    文件:Forms.java   
/**
 * Wraps the given {@code widget} with a ScollPanel and builds an
 * {@link AdapterField} for it.
 * 
 * @param label
 *            The field label. If {@code blank}, label separator is
 *            automatically disabled.
 * @param widget
 *            The widget wrapped into the scroll panel and into the adapter
 *            field.
 * @param width
 *            Width of the given widget.
 * @param height
 *            Height of the scroll panel.
 * @return The field.
 */
public static AdapterField adapterWithScrollbars(final String label, final IsWidget widget, final int width,
        final int height) {

    final ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setWidget(Widget.asWidgetOrNull(widget));
    scrollPanel.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            scrollPanel.setWidth(width + "px");
        }
    });
    scrollPanel.setHeight(height + "px");

    return adapter(label, scrollPanel);

}
项目:LAS    文件:IESafeImage.java   
/**
 * @see com.google.gwt.user.client.ui.Image#setUrl(com.google.gwt.safehtml.shared
 *      .SafeUri)
 */
@Override
public void setUrl(final SafeUri url) {
    if ( isHiddenAndAttached() ) {
        super.setUrl(url);
    } else {
        // Do this later to avoid problems in IE
        hide();
        this.addAttachHandler(new AttachEvent.Handler() {
            @Override
            public void onAttachOrDetach(AttachEvent event) {
                setUrl(url);
            }
        });
    }
}
项目:gwt-olcs    文件:OLCesiumPanel.java   
public OLCesiumPanel(OLCesiumOptions options) {
    super();
    final Element element = getElement();
    // Some strange, but ol-cesium set style for div's elements to absolute. Fix this.
    element.getStyle().setProperty("position", "relative");
    options.target = element;
    RootPanel.getBodyElement().appendChild(element);
    olCesium = new OLCesium(options);
    super.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {
            if (!attachEvent.isAttached()) {
                element.removeAllChildren();
                element.removeFromParent();
            }
        }
    });
}
项目:dataworks-zeus    文件:OwnerJobTrend.java   
public OwnerJobTrend(){
    date=new DateField();
    date.setEditable(false);
    date.setAllowBlank(false);
    date.setValue(new Date());

    HorizontalLayoutContainer form=new HorizontalLayoutContainer();
    form.add(new FieldLabel(date,"日期"),new HorizontalLayoutData());
    form.add(submit,new HorizontalLayoutData());

    container.add(form,new VerticalLayoutData(1,30));
    container.addAttachHandler(new Handler() {
        public void onAttachOrDetach(AttachEvent event) {
            submit.fireEvent(new SelectEvent());
        }
    });
}
项目:dataworks-zeus    文件:RunningJobTrend.java   
public RunningJobTrend(){
    start=new DateField();
    start.setEditable(false);
    start.setValue(new Date(new Date().getTime()-7*24*60*60*1000L));
    end=new DateField();
    end.setEditable(false);
    end.setValue(new Date());
    HorizontalLayoutContainer form=new HorizontalLayoutContainer();
    form.add(new FieldLabel(start, "起始日期"),new HorizontalLayoutData(0.3,1));
    form.add(new FieldLabel(end,"截止日期"),new HorizontalLayoutData(0.3, 1));
    form.add(submit,new HorizontalLayoutData(-1,-1));

    container.add(form,new VerticalLayoutData(1, 30));

    container.addAttachHandler(new Handler() {
        public void onAttachOrDetach(AttachEvent event) {
            submit.fireEvent(new SelectEvent());
        }
    });
}
项目:gwt-material    文件:MaterialWidget.java   
/**
 * Add an {@code AttachHandler} for attachment events.
 *
 * @param handler Attach event handler.
 * @param oneTime Only execute this handler once, then detach handler.
 * @return The events handler registration.
 */
public HandlerRegistration addAttachHandler(final AttachEvent.Handler handler, boolean oneTime) {
    if (!oneTime) {
        return addAttachHandler(handler);
    } else {
        final HandlerRegistration[] registration = {null};
        registration[0] = addAttachHandler(event -> {
            handler.onAttachOrDetach(event);

            if (registration[0] != null) {
                registration[0].removeHandler();
            }
        });
        return registration[0];
    }
}
项目:daris    文件:ArchiveEntryImagePanel.java   
public ArchiveEntryImagePanel(ArchiveEntryCollectionRef arc,
        ArchiveEntry entry) {

    _arc = arc;
    _entry = entry;

    _ap = new AbsolutePanel();
    _ap.fitToParent();
    _ap.setOverflow(Overflow.HIDDEN);
    initWidget(_ap);

    addAttachHandler(new Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                loadImage();
            }
        }
    });

}
项目:appformer    文件:GridLienzoPanel.java   
private void setupDefaultHandlers() {
    //Prevent DOMElements scrolling into view when they receive the focus
    domElementContainer.addDomHandler(new ScrollHandler() {

                                          @Override
                                          public void onScroll(final ScrollEvent scrollEvent) {
                                              domElementContainer.getElement().setScrollTop(0);
                                              domElementContainer.getElement().setScrollLeft(0);
                                          }
                                      },
                                      ScrollEvent.getType());
    addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(final AttachEvent event) {
            if (event.isAttached()) {
                onResize();
            }
        }
    });
    addMouseDownHandler((e) -> setFocus(true));
}
项目:appformer    文件:LockManagerImpl.java   
@Override
public void acquireLockOnDemand() {
    if (lockTarget == null) {
        return;
    }

    final Widget widget = getLockTargetWidget();
    final Element element = widget.getElement();
    acquireLockOnDemand(element);

    widget.addAttachHandler(new AttachEvent.Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            // Handle widget reattachment/reparenting
            if (event.isAttached()) {
                acquireLockOnDemand(element);
            }
        }
    });
}
项目:qafe-platform    文件:WindowViewImpl.java   
@Override
public void setContent(Widget widget) {
    if (widget instanceof LayoutPanel) {
        mainPanel = (LayoutPanel)widget;
        mainPanel.insert(headerPanel, 0);
        if (toolbar != null) {
            setToolbar(toolbar);
        }
    }

    mainPanel.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            // The mainPanel is the widget which being added and not this view, 
            // so the onAttach and onDetach of the view will not be invoked
            if (event.isAttached()) {
                onAttach();
            } else {
                onDetach(); 
            }
        }
    });
}
项目:rtgov-ui    文件:DateTimePicker.java   
/**
 * Called after construction.
 */
@PostConstruct
protected void postConstruct() {
    addAttachHandler(new Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                cid = generateUniqueCid();
                getElement().addClassName(cid);
                initPicker(cid,DEFAULT_DATE_TIME_FORMAT);
            } else {
                removePicker(cid);
            }
        }
    });
}
项目:rtgov-ui    文件:ToggleSwitch.java   
/**
 * Called after construction.
 */
@PostConstruct
protected void postConstruct() {
    addAttachHandler(new Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                cid = generateUniqueCid();
                getElement().addClassName(cid);
                init(cid);
            } else {
                remove(cid);
            }
        }
    });
}
项目:zeus3    文件:OwnerJobTrend.java   
public OwnerJobTrend(){
    date=new DateField();
    date.setEditable(false);
    date.setAllowBlank(false);
    date.setValue(new Date());

    HorizontalLayoutContainer form=new HorizontalLayoutContainer();
    form.add(new FieldLabel(date,"日期"),new HorizontalLayoutData());
    form.add(submit,new HorizontalLayoutData());

    container.add(form,new VerticalLayoutData(1,30));
    container.addAttachHandler(new Handler() {
        public void onAttachOrDetach(AttachEvent event) {
            submit.fireEvent(new SelectEvent());
        }
    });
}
项目:zeus3    文件:RunningJobTrend.java   
public RunningJobTrend(){
    start=new DateField();
    start.setEditable(false);
    start.setValue(new Date(new Date().getTime()-7*24*60*60*1000L));
    end=new DateField();
    end.setEditable(false);
    end.setValue(new Date());
    HorizontalLayoutContainer form=new HorizontalLayoutContainer();
    form.add(new FieldLabel(start, "起始日期"),new HorizontalLayoutData(0.3,1));
    form.add(new FieldLabel(end,"截止日期"),new HorizontalLayoutData(0.3, 1));
    form.add(submit,new HorizontalLayoutData(-1,-1));

    container.add(form,new VerticalLayoutData(1, 30));

    container.addAttachHandler(new Handler() {
        public void onAttachOrDetach(AttachEvent event) {
            submit.fireEvent(new SelectEvent());
        }
    });
}
项目:ahome-touch    文件:WidgetComponent.java   
protected void addWidgetDetachHandler() {
    if (this.widget != null) {
        detachHandler = this.widget.addAttachHandler(new AttachEvent.Handler() {
            boolean detaching = false;

            @Override
            public void onAttachOrDetach(AttachEvent event) {
                if (!detaching) {
                    detaching = true;
                    if (!event.isAttached() && getParent() instanceof HasWidgets) {
                        ((HasWidgets) getParent()).remove((Widget) event.getSource());
                    }
                    widget = null;
                    if (detachHandler != null) {
                        detachHandler.removeHandler();
                        detachHandler = null;
                    }
                    setParentWidget(null);
                    removeFromParent();
                }
            }
        });
    }
}
项目:mechaverse    文件:SimulationPresenter.java   
public SimulationPresenter(final String simulationId, final String instanceId,
    final long iteration, ManagerClientFactory clientFactory) {
  this.notificationBar = clientFactory.getNotificationBar();
  this.view = clientFactory.getSimulationView();

  view.addAttachHandler(new AttachEvent.Handler() {
    @Override
    public void onAttachOrDetach(AttachEvent event) {
      if (event.isAttached()) {
        loadState(simulationId, instanceId, iteration);
        addScrollHandler();
      } else {
        updateTimer.cancel();
        if (scrollHandler != null) {
          scrollHandler.removeHandler();
          scrollHandler = null;
        }
      }
    }
  });
}
项目:atom    文件:StringFormattedLobView.java   
@Override
protected boolean createFieldWidget() {
    initWidget(uiBinder.createAndBindUi(this));
    field = textArea;
    toolbar.initToolBar(textArea);

    textArea.addAttachHandler(new Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            AtomTools.log(Level.FINE, "textArea.onAttachOrDetach - " + event.toDebugString(), this);
            fixIFrameDefaultFont(true);
        }
    });

    fixIFrameDefaultFont(true);

    return false;
}
项目:gantt    文件:GanttConnector.java   
private void updateVerticalScrollGridDelegation() {
    // register scroll handler to Gantt widget
    ganttScrollHandlerRegistration = getWidget().addDomHandler(ganttScrollHandler, ScrollEvent.getType());

    scrollDelegateHandlerRegistration = delegateScrollGridTarget.addScrollHandler(gridScrollDelegateTargetHandler);

    // add detach listener to unregister scroll handler when its
    // detached.
    delegateScrollGridTarget.addAttachHandler(new Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (!event.isAttached() && scrollDelegateHandlerRegistration != null) {
                scrollDelegateHandlerRegistration.removeHandler();
            }
        }
    });
}
项目:gantt    文件:GanttConnector.java   
private void updateVerticalScrollTableDelegation() {
    // register scroll handler to Gantt widget
    ganttScrollHandlerRegistration = getWidget().addDomHandler(ganttScrollHandler, ScrollEvent.getType());

    // register a scroll handler to 'delegation' scroll panel.
    scrollDelegateHandlerRegistration = delegateScrollPanelTarget.addScrollHandler(scrollDelegateTargetHandler);

    // add detach listener to unregister scroll handler when its
    // detached.
    delegateScrollPanelTarget.addAttachHandler(new Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (!event.isAttached() && scrollDelegateHandlerRegistration != null) {
                scrollDelegateHandlerRegistration.removeHandler();
            }
        }
    });
}
项目:drools-wb    文件:GuidedDecisionTableEditorViewImpl.java   
public GuidedDecisionTableEditorViewImpl() {
    initWidget( uiBinder.createAndBindUi( this ) );

    //Disable LockManager's default "Lock on Demand" behaviour
    container.getElement().setAttribute( "data-uf-lock",
                                         "false" );

    addAttachHandler( new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach( final AttachEvent event ) {
            if ( event.isAttached() ) {
                getElement().getParentElement().getStyle().setHeight( 100.0, Style.Unit.PCT );
                getElement().getParentElement().getStyle().setWidth( 100.0, Style.Unit.PCT );
            }
        }
    } );
}
项目:overlord-commons    文件:DateBox.java   
/**
 * Called after construction.
 */
@PostConstruct
protected void postConstruct() {
    addAttachHandler(new Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                cid = generateUniqueCid();
                getElement().addClassName(cid);
                initPicker(cid);
            } else {
                removePicker(cid);
            }
        }
    });
}
项目:gwt-esri    文件:TimeSlider.java   
/**
 * Creates a new TimeSlider object.
 * 
 * @param params - Parameters for the time slider object.
 * @param loadHandler - handler to fire when dijit is created.  All method calls will fail untill this
 * event fires. 
 */ 
public TimeSlider(Parameters params, DijitLoadHandler handler) {

    if( !assertLoaded() ) return; 

    loadHandler = handler;
    parameters = params;

    initWidget(panel);

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if( event.isAttached() && jso == null ) {
                jso = _create(parameters, panel.getElement());
                if( loadHandler != null ) loadHandler.onLoad();
            }
        }
    });

}
项目:gwt-esri    文件:AttributeInspector.java   
/**
 * Creates a new Attribute Inspector object.
 * 
 * @param params - input parameters
 */
public  AttributeInspector(Parameters params) {

    if( !assertLoaded() ) return; 

    parameters = params;

    initWidget(panel);

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if(jso == null ) jso = create(parameters);
        }
    });

}
项目:gwt-esri    文件:Editor.java   
/**
 * Creates a new Editor object.
 * 
 * @param params - Parameters that define the functionality of the editor widget. Create a
 * new settings object to pass to the widget
 */
public Editor(Parameters params) {

    if( !assertLoaded() ) return; 

    parameters = params;

    initWidget(panel);

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if( jso == null ) jso = create(parameters);
        }
    });

}
项目:gwt-esri    文件:Legend.java   
/**
 * Creates a new Legend dijit. Should be called after all the layers have been loaded in the map, 
 * typically in the map's onLayerAddResult event.
 * 
 * @param params - Parameters used to configure the dijit. See the list below for details. 
 */
public  Legend(Parameters params) {

    if( !assertLoaded() ) return; 

    parameters = params;

    initWidget(panel);

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if( jso == null ) jso = create(parameters);
        }
    });

}
项目:gwt-esri    文件:TemplatePicker.java   
/**
 * Creates a new TemplatePicker object that displays a gallery of templates
 * from the input feature layers or items. A symbol and label is displayed
 * for each template. The symbol is defined by the template's feature type.
 * The label is the template's name.
 * 
 * @param params - FeatureLayers or items are required all other parameters
 * are optional. See options list.
 */
public TemplatePicker(Parameters params) {

    if( !assertLoaded() ) return; 

    parameters = params;

    initWidget(panel);

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if( jso == null ) jso = create(parameters);
        }
    });

}
项目:gwt-esri    文件:BasemapGallery.java   
/**
 * Creates a new BasemapGallery dijit.
 * 
 * @param params - Parameters used to configure the widgit. See the list below for details.
 */
public BasemapGallery(Parameters params) {

    if( !assertLoaded() ) return; 

    initWidget(panel);

    parameters = params;

    addAttachHandler(new Handler(){
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if( jso == null ) jso = create(parameters);
        }
    });

}
项目:empiria.player    文件:ConnectionStyleCheckerHandler.java   
@Override
public void onAttachOrDetach(AttachEvent event) {
    if (!wasChecked) {
        checkStylesAndShowError();
        wasChecked = true;
    }
}
项目:empiria.player    文件:VideoPlayerAttachHandler.java   
@Override
public void onAttachOrDetach(AttachEvent event) {
    if (event.isAttached()) {
        final HandlerRegistration pauseHandlerRegistration = registerPauseHandlerOnPageChange();
        this.handlerRegistration = Optional.of(pauseHandlerRegistration);
    } else {
        clearHandler();
    }
}
项目:empiria.player    文件:VideoPlayerAttachHandlerTest.java   
@Test
public void shouldRegisterHandlerAtFirstAttachEvent() {
    // given
    AttachEvent attachEvent = mock(AttachEvent.class);
    when(attachEvent.isAttached()).thenReturn(Boolean.TRUE);
    HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(eventsBus.addHandler(eq(PlayerEvent.getType(PlayerEventTypes.PAGE_CHANGE)), any(AutoPauseOnPageChangeHandler.class))).thenReturn(
            handlerRegistration);

    // when
    testObj.onAttachOrDetach(attachEvent);

    // then
    verify(eventsBus).addHandler(eq(PlayerEvent.getType(PlayerEventTypes.PAGE_CHANGE)), any(AutoPauseOnPageChangeHandler.class));
}
项目:empiria.player    文件:VideoPlayerAttachHandlerTest.java   
@Test
public void shouldRemoveHandlerAtSecondAttachEvent() {
    // given
    HandlerRegistration handlerRegistration = callFirstAttachEvent();
    AttachEvent event = mock(AttachEvent.class);
    when(event.isAttached()).thenReturn(Boolean.FALSE);

    // when
    testObj.onAttachOrDetach(event);

    // then
    verify(handlerRegistration).removeHandler();
}
项目:empiria.player    文件:VideoPlayerAttachHandlerTest.java   
private HandlerRegistration callFirstAttachEvent() {
    AttachEvent attachEvent = mock(AttachEvent.class);
    when(attachEvent.isAttached()).thenReturn(Boolean.TRUE);
    HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(eventsBus.addHandler(eq(PlayerEvent.getType(PlayerEventTypes.PAGE_CHANGE)), any(AutoPauseOnPageChangeHandler.class))).thenReturn(
            handlerRegistration);

    testObj.onAttachOrDetach(attachEvent);

    return handlerRegistration;
}
项目:LAS    文件:IESafeImage.java   
@Override
public void setResource(final ImageResource resource) {
    if ( isHiddenAndAttached() ) {
        super.setResource(resource);
    } else {
        // Do this later to avoid problems in IE
        hide();
        this.addAttachHandler(new AttachEvent.Handler() {
            @Override
            public void onAttachOrDetach(AttachEvent event) {
                setResource(resource);
            }
        });
    }
}
项目:gwt-cs    文件:CesiumWidgetPanel.java   
public CesiumWidgetPanel(CesiumWidgetOptions options) {
    super();
    Element element = getElement();
    RootPanel.getBodyElement().appendChild(element);
    _cesiumWidget = new CesiumWidget(element, options);
    super.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {
            if (!attachEvent.isAttached()) {
                _cesiumWidget.destroy();
            }
        }
    });
}
项目:gwt-cs    文件:ViewerPanel.java   
public ViewerPanel(ViewerOptions options) {
    super();
    Element element = getElement();
    RootPanel.getBodyElement().appendChild(element);
    _viewer = new Viewer(element, options);
    super.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent attachEvent) {
            if (!attachEvent.isAttached()) {
                _viewer.destroy();
            }
        }
    });
}
项目:VaadinSpringShiroMongoDB    文件:ResetButtonForTextFieldConnector.java   
@Override
public void onAttachOrDetach(AttachEvent attachEvent) {
    if (attachEvent.isAttached()) {
        textField.getElement().getParentElement()
                .insertAfter(resetButtonElement, textField.getElement());
        updateResetButtonVisibility();
        addResetButtonClickListener(resetButtonElement);
    } else {
        Element parentElement = resetButtonElement.getParentElement();
        if (parentElement != null) {
            parentElement.removeChild(resetButtonElement);
        }
        removeResetButtonClickListener(resetButtonElement);
    }
}
项目:dataworks-zeus    文件:CodeMirror.java   
public CodeMirror(final CodeMirrorConfig config){
    setElement(DOM.createDiv());
    addAttachHandler(new Handler() {
        public void onAttachOrDetach(AttachEvent event) {
            if(event.isAttached()){
                cm=create(getElement(), config.toJsObject(CodeMirror.this));
            }
        }
    });
    sinkEvents(Event.MOUSEEVENTS|Event.ONCLICK);
}
项目: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    文件:MaterialTooltip.java   
public void setAttribute(String attr, String value) {
    if (widget != null) {
        AttachEvent.Handler handler = event -> {
            widget.getElement().setAttribute(attr, value);
        };
        if (widget.isAttached()) {
            handler.onAttachOrDetach(null);
        } else {
            EventHelper.onAttachOnce(widget, handler);
        }
    }
}
项目:gwt-material    文件:Text.java   
@Override
protected void onAttach() {
    if (isAttached()) {
        throw new IllegalStateException("Text is already attached!");
    }
    isAttached = true;
    onLoad();
    AttachEvent.fire(this, isAttached);
}