Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java @ 862:c9549074ecd1
Parse Artifact's 'background-processing' attribute and lock the UI if this attribute is true.
flys-client/trunk@2669 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 07 Sep 2011 13:57:28 +0000 |
parents | |
children | 43f520f923a8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LoadingPanel.java Wed Sep 07 13:57:28 2011 +0000 @@ -0,0 +1,107 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.Timer; + +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.Positioning; +import com.smartgwt.client.types.VerticalAlignment; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.shared.model.Artifact; + + +public class LoadingPanel extends Canvas { + + public static final int UPDATE_INTERVAL = 1000 * 5; + + protected CollectionView parent; + protected Artifact artifact; + + protected HLayout dialog; + protected Label msg; + + protected int i; + + + public LoadingPanel(CollectionView parent, Artifact artifact) { + super(); + + this.parent = parent; + this.artifact = artifact; + this.msg = new Label(); + this.dialog = createDialog(); + + this.i = 0; + + initLayout(); + startTimer(); + } + + + private void initLayout() { + setWidth("100%"); + setHeight("98%"); + setBackgroundColor("#22AAFF"); + setOpacity(50); + setPosition(Positioning.RELATIVE); + + parent.addChild(this); + parent.addChild(dialog); + dialog.moveTo(0, 20); + moveTo(0, 7); + } + + + protected HLayout createDialog() { + msg.setStyleName("loading-message"); + msg.setWidth(200); + msg.setHeight(100); + + dialog = new HLayout(); + dialog.setDefaultLayoutAlign(Alignment.CENTER); + dialog.setAlign(Alignment.CENTER); + dialog.setWidth100(); + dialog.setHeight100(); + dialog.setBorder("1px solid green"); + + dialog.addMember(msg); + + return dialog; + } + + + private void startTimer() { + Timer t = new Timer() { + @Override + public void run() { + update(); + } + }; + t.schedule(UPDATE_INTERVAL); + } + + + private void update() { + msg.setContents("This is update -> " + String.valueOf(i++)); + + // TODO FETCH ARTIFACT's DESCRIBE DOCUMENT AND REMOVE THIS LOADING PANEL + // IF IT IS NO LONGER IN BACKGROUND MODE! + + if (i == 5) { + finish(); + } + + startTimer(); + } + + + private void finish() { + parent.removeChild(this); + parent.removeChild(dialog); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :