| 1 | |
package org.kuali.student.common.ui.client.widgets; |
| 2 | |
|
| 3 | |
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
| 4 | |
|
| 5 | |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
| 6 | |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
| 7 | |
import com.google.gwt.user.client.ui.Composite; |
| 8 | |
import com.google.gwt.user.client.ui.HasText; |
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
public class CheckBoxTextArea extends Composite implements HasText{ |
| 17 | |
HasText master; |
| 18 | 0 | KSTextArea slave = new KSTextArea(); |
| 19 | 0 | KSCheckBox checkBox = new KSCheckBox(); |
| 20 | 0 | public CheckBoxTextArea(HasText master, String checkBoxText){ |
| 21 | 0 | this.master = master; |
| 22 | 0 | VerticalFlowPanel flowPanel = new VerticalFlowPanel(); |
| 23 | |
|
| 24 | 0 | flowPanel.add(checkBox); |
| 25 | 0 | flowPanel.add(slave); |
| 26 | 0 | super.initWidget(flowPanel); |
| 27 | |
|
| 28 | 0 | checkBox.setStyleName("CheckBoxTextArea-CheckBox"); |
| 29 | 0 | slave.setStyleName("CheckBoxTextArea-TextArea"); |
| 30 | |
|
| 31 | |
|
| 32 | 0 | checkBox.addValueChangeHandler(new ValueChangeHandler(){ |
| 33 | |
@Override |
| 34 | |
public void onValueChange(ValueChangeEvent event) { |
| 35 | 0 | if(checkBox.getValue() == true){ |
| 36 | 0 | slave.setVisible(false); |
| 37 | |
}else{ |
| 38 | 0 | slave.setVisible(true); |
| 39 | |
} |
| 40 | 0 | } |
| 41 | |
}); |
| 42 | 0 | checkBox.setValue(true); |
| 43 | 0 | checkBox.setText(checkBoxText); |
| 44 | 0 | } |
| 45 | |
@Override |
| 46 | |
public String getText() { |
| 47 | 0 | if(checkBox.getValue() == true){ |
| 48 | 0 | return master.getText(); |
| 49 | |
}else{ |
| 50 | 0 | return slave.getText(); |
| 51 | |
} |
| 52 | |
} |
| 53 | |
|
| 54 | |
@Override |
| 55 | |
public void setText(String text) { |
| 56 | 0 | if(master.getText().equals(text)){ |
| 57 | 0 | checkBox.setValue(true); |
| 58 | |
}else{ |
| 59 | 0 | checkBox.setValue(false); |
| 60 | 0 | slave.setText(text); |
| 61 | |
} |
| 62 | 0 | } |
| 63 | |
} |