removde switchbutton causing troubles to other widgets

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-widgets@76932 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-06-10 14:28:36 +00:00
parent 7c7d21ef51
commit 66f072e61d
6 changed files with 1 additions and 236 deletions

13
pom.xml
View File

@ -40,18 +40,7 @@
<version>${gwtVersion}</version>
<!-- "provided" so that we don't deploy -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<scope>provided</scope>
</dependency>
</dependency>
</dependencies>
<build>
<resources>

View File

@ -1,14 +1,10 @@
package org.gcube.portlets.user.gcubewidgets.client;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import org.gcube.portlets.user.gcubewidgets.client.switchbutton.SwitchButton;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
@ -28,21 +24,7 @@ public class WidgetFactory implements EntryPoint {
* This is the entry point method.
*/
public void onModuleLoad() {
//showIOSButton();
}
private void showIOSButton() {
SwitchButton test = new SwitchButton(false);
test.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log(event.getValue()+"");
}
});
RootPanel.get().add(test);
}
private void showSample() {
//
PushButton button = new PushButton("Click me");

View File

@ -1,137 +0,0 @@
package org.gcube.portlets.user.gcubewidgets.client.switchbutton;
import static com.google.gwt.query.client.GQuery.$;
import org.gcube.portlets.user.gcubewidgets.client.elements.Div;
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.css.CSS;
import com.google.gwt.query.client.css.Length;
import com.google.gwt.query.client.css.RGBColor;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HasName;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.Widget;
public class SwitchButton extends Composite implements HasName, HasValue<Boolean>{
private static SwitchButtonUiBinder uiBinder = GWT
.create(SwitchButtonUiBinder.class);
interface SwitchButtonUiBinder extends UiBinder<Widget, SwitchButton> {
}
@UiField FocusPanel switchContainer;
@UiField Div switcherButton;
@UiField Span labelOff;
@UiField Span labelOn;
private String name;
private Boolean value;
private Boolean valueChangeHandlerInitialized = Boolean.FALSE;
public SwitchButton() {
name = DOM.createUniqueId();
initWidget(uiBinder.createAndBindUi(this));
value = false;
$(switcherButton).css(CSS.LEFT.with(Length.px(-1)));
ensureDomEventHandlers();
}
public SwitchButton(boolean initialValue) {
this();
setValue(initialValue);
}
@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) {
// Is this the first value change handler? If so, time to add handlers
if (!valueChangeHandlerInitialized) {
valueChangeHandlerInitialized = true;
}
return addHandler(handler, ValueChangeEvent.getType());
}
@Override
public Boolean getValue() {
return value;
}
/**
* Checks or unchecks the switch button box, firing {@link ValueChangeEvent} if
* appropriate.
* <p>
* Note that this <em>does not</em> set the value property of the checkbox
* input element wrapped by this widget. For access to that property, see
* {@link #setFormValue(String)}
*
* @param value true to set on, false to set off; null value implies false
*/
@Override
public void setValue(Boolean value) {
if (value == null) {
value = Boolean.FALSE;
}
Boolean oldValue = getValue();
if (value.equals(oldValue)) {
return;
}
this.value = value;
if (!value) {
$(switcherButton).animate("left: -1", 250);
labelOff.setStyleName("switch-button-label on");
labelOn.setStyleName("switch-button-label off");
} else {
$(switcherButton).animate("left: 12", 250);
labelOff.setStyleName("switch-button-label off");
labelOn.setStyleName("switch-button-label on");
}
}
/**
* Checks or unchecks the switch button box, firing {@link ValueChangeEvent} if
* appropriate.
* <p>
*
* @param value true to set on, false to set off; null value implies false
* @param fireEvents If true, and value has changed, fire a
* {@link ValueChangeEvent}
*/
@Override
public void setValue(Boolean value, boolean fireEvents) {
setValue(value);
if (fireEvents) {
ValueChangeEvent.fire(this, value);
}
}
protected void ensureDomEventHandlers() {
switchContainer.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
setValue(!value);
ValueChangeEvent.fire(SwitchButton.this, getValue());
}
});
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
}

View File

@ -1,14 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:e="urn:import:org.gcube.portlets.user.gcubewidgets.client.elements"
xmlns:w="urn:import:org.gcube.portlets.user.gcubewidgets.client.switchbutton"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<e:Span styleName="switch-button-label on" ui:field="labelOff">OFF</e:Span>
<g:FocusPanel ui:field="switchContainer" styleName="switch-button-background">
<e:Div ui:field="switcherButton" styleName="switch-button-button"></e:Div>
</g:FocusPanel>
<e:Span styleName="switch-button-label off" ui:field="labelOn">ON</e:Span>
<div style="clear: left;"></div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -5,7 +5,6 @@
*/ /****** PANELS STYLES *******/
@import url(normalize.css);
@import url(switchbutton.css);
/* Use it for your portlet main Panel */
.gcube_panel {

View File

@ -1,54 +0,0 @@
/* Switch Button */
.switch-button-label {
float: left;
font-size: 10pt;
cursor: pointer;
}}
.switch-button-label.off {
color: #adadad;
}
.switch-button-label.on {
color: #0088CC;
}
.switch-button-background {
float: left;
position: relative;
background: #ccc;
border: 1px solid #aaa;
margin: 1px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
width: 25px;
height: 11px;
outline-style: none; /* this avoid the tabindex property to sorround this element with a (maybe dotted) rectangle*/
}
.switch-button-button {
position: absolute;
width: 12px;
height: 11px;
left: 12px;
top : -1px;
background: #FAFAFA;
border: 1px solid #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}