com.google.gwt.user.client.ui.LazyPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client Show documentation
Show all versions of vaadin-client Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.user.client.ui;
/**
* Convenience class to help lazy loading. The bulk of a LazyPanel is not
* instantiated until {@link #setVisible}(true) or {@link #ensureWidget} is
* called.
*
*
Example
{@example com.google.gwt.examples.LazyPanelExample}
*/
public abstract class LazyPanel extends SimplePanel {
public LazyPanel() {
}
/**
* Create the widget contained within the {@link LazyPanel}.
*
* @return the lazy widget
*/
protected abstract Widget createWidget();
/**
* Ensures that the widget has been created by calling {@link #createWidget}
* if {@link #getWidget} returns null
. Typically it is not
* necessary to call this directly, as it is called as a side effect of a
* setVisible(true)
call.
*/
public void ensureWidget() {
Widget widget = getWidget();
if (widget == null) {
widget = createWidget();
setWidget(widget);
}
}
@Override
/*
* Sets whether this object is visible. If visible
is
* true
, creates the sole child widget if necessary by calling
* {@link #ensureWidget}.
*
* @param visible true
to show the object, false
to
* hide it
*/
public void setVisible(boolean visible) {
if (visible) {
ensureWidget();
}
super.setVisible(visible);
}
}