diff options
Diffstat (limited to 'client')
4 files changed, 160 insertions, 64 deletions
diff --git a/client/src/com/vaadin/client/ui/VProgressBar.java b/client/src/com/vaadin/client/ui/VProgressBar.java new file mode 100644 index 0000000000..3eb8725520 --- /dev/null +++ b/client/src/com/vaadin/client/ui/VProgressBar.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * 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.vaadin.client.ui; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.HasEnabled; +import com.google.gwt.user.client.ui.Widget; + +/** + * Widget for showing the current progress of a long running task. + * <p> + * The default mode is to show the current progress internally represented by a + * floating point value between 0 and 1 (inclusive). The progress bar can also + * be in an indeterminate mode showing an animation indicating that the task is + * running but without providing any information about the current progress. + * + * @since 7.1 + * @author Vaadin Ltd + */ +public class VProgressBar extends Widget implements HasEnabled { + + public static final String CLASSNAME = "v-progressindicator"; + Element wrapper = DOM.createDiv(); + Element indicator = DOM.createDiv(); + + protected boolean indeterminate = false; + protected float state = 0.0f; + private boolean enabled; + + public VProgressBar() { + setElement(DOM.createDiv()); + getElement().appendChild(wrapper); + setStyleName(CLASSNAME); + wrapper.appendChild(indicator); + indicator.setClassName(CLASSNAME + "-indicator"); + wrapper.setClassName(CLASSNAME + "-wrapper"); + } + + public void setIndeterminate(boolean indeterminate) { + this.indeterminate = indeterminate; + setStyleName(CLASSNAME + "-indeterminate", indeterminate); + } + + public void setState(float state) { + final int size = Math.round(100 * state); + indicator.getStyle().setWidth(size, Unit.PCT); + } + + public boolean isIndeterminate() { + return indeterminate; + } + + public float getState() { + return state; + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void setEnabled(boolean enabled) { + this.enabled = enabled; + setStyleName("v-disabled", !enabled); + + } + +} diff --git a/client/src/com/vaadin/client/ui/VProgressIndicator.java b/client/src/com/vaadin/client/ui/VProgressIndicator.java index d6b25cb016..500a5def30 100644 --- a/client/src/com/vaadin/client/ui/VProgressIndicator.java +++ b/client/src/com/vaadin/client/ui/VProgressIndicator.java @@ -16,59 +16,13 @@ package com.vaadin.client.ui; -import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.HasEnabled; -import com.google.gwt.user.client.ui.Widget; - -public class VProgressIndicator extends Widget implements HasEnabled { - - public static final String CLASSNAME = "v-progressindicator"; - Element wrapper = DOM.createDiv(); - Element indicator = DOM.createDiv(); - - protected boolean indeterminate = false; - protected float state = 0.0f; - private boolean enabled; - - public VProgressIndicator() { - setElement(DOM.createDiv()); - getElement().appendChild(wrapper); - setStyleName(CLASSNAME); - wrapper.appendChild(indicator); - indicator.setClassName(CLASSNAME + "-indicator"); - wrapper.setClassName(CLASSNAME + "-wrapper"); - } - - public void setIndeterminate(boolean indeterminate) { - this.indeterminate = indeterminate; - setStyleName(CLASSNAME + "-indeterminate", indeterminate); - } - - public void setState(float state) { - final int size = Math.round(100 * state); - indicator.getStyle().setWidth(size, Unit.PCT); - } - - public boolean isIndeterminate() { - return indeterminate; - } - - public float getState() { - return state; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void setEnabled(boolean enabled) { - this.enabled = enabled; - setStyleName("v-disabled", !enabled); - - } +/** + * + * @author Vaadin Ltd + * + * @deprecated as of 7.1, renamed to VProgressBar + */ +@Deprecated +public class VProgressIndicator extends VProgressBar { } diff --git a/client/src/com/vaadin/client/ui/progressindicator/ProgressBarConnector.java b/client/src/com/vaadin/client/ui/progressindicator/ProgressBarConnector.java new file mode 100644 index 0000000000..91f3da5323 --- /dev/null +++ b/client/src/com/vaadin/client/ui/progressindicator/ProgressBarConnector.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * 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.vaadin.client.ui.progressindicator; + +import com.vaadin.client.communication.StateChangeEvent; +import com.vaadin.client.ui.AbstractFieldConnector; +import com.vaadin.client.ui.VProgressBar; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.progressindicator.ProgressBarState; +import com.vaadin.ui.ProgressBar; + +/** + * Connector for {@link VProgressBar}. + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Connect(ProgressBar.class) +public class ProgressBarConnector extends AbstractFieldConnector { + + public ProgressBarConnector() { + super(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + getWidget().setIndeterminate(getState().indeterminate); + getWidget().setState(getState().state); + } + + @Override + public ProgressBarState getState() { + return (ProgressBarState) super.getState(); + } + + @Override + public VProgressBar getWidget() { + return (VProgressBar) super.getWidget(); + } + +}
\ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java b/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java index ac5c3f5f6b..9e14f082e0 100644 --- a/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java +++ b/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java @@ -18,15 +18,23 @@ package com.vaadin.client.ui.progressindicator; import com.google.gwt.user.client.Timer; import com.vaadin.client.communication.StateChangeEvent; -import com.vaadin.client.ui.AbstractFieldConnector; -import com.vaadin.client.ui.VProgressIndicator; +import com.vaadin.client.ui.VProgressBar; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.progressindicator.ProgressIndicatorServerRpc; import com.vaadin.shared.ui.progressindicator.ProgressIndicatorState; import com.vaadin.ui.ProgressIndicator; +/** + * Connector for {@link VProgressBar} with polling support. + * + * @since 7.0 + * @author Vaadin Ltd + * @deprecated as of 7.1, use {@link ProgressBarConnector} combined with server + * push or UI polling. + */ @Connect(ProgressIndicator.class) -public class ProgressIndicatorConnector extends AbstractFieldConnector { +@Deprecated +public class ProgressIndicatorConnector extends ProgressBarConnector { @Override public ProgressIndicatorState getState() { @@ -45,8 +53,6 @@ public class ProgressIndicatorConnector extends AbstractFieldConnector { @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - getWidget().setIndeterminate(getState().indeterminate); - getWidget().setState(getState().state); if (isEnabled()) { poller.scheduleRepeating(getState().pollingInterval); @@ -60,9 +66,4 @@ public class ProgressIndicatorConnector extends AbstractFieldConnector { super.onUnregister(); poller.cancel(); } - - @Override - public VProgressIndicator getWidget() { - return (VProgressIndicator) super.getWidget(); - } } |