【发布时间】:2012-07-24 08:54:06
【问题描述】:
我为我的项目创建日期小部件。
n 对对象的 setProperty 和 getProperty 使用相同的小部件。
public TextBox getTimeTxtbx() {
// TODO Auto-generated method stub
timebx =new TextBox();
timebx.setReadOnly(true);
final PopupPanel popupPanel=new PopupPanel(true);
final DatePicker datePicker=new DatePicker();
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
public void onValueChange(ValueChangeEvent<Date> event) {
// TODO Auto-generated method stub
Date date=event.getValue();
timebx.setText(DateTimeFormat.getFormat("EEE MMM dd HH:mm:ss z yyyy").format(date));
popupPanel.hide();
}
});
popupPanel.setWidget(datePicker);
timebx.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
String strDate = timebx.getText();
System.out.println(" strDate " +strDate);
DateTimeFormat format = DateTimeFormat.getFormat("[EEE MMM dd HH:mm:ss z yyyy]");
try {
Date selDate = (Date)format.parse(strDate);
datePicker.setValue(selDate, true);
} catch(Exception pe){
// setting current date
System.out.println("error" +pe);
datePicker.setValue(new Date(), true);
}
int x=timebx.getAbsoluteLeft();
int y=timebx.getAbsoluteTop();
popupPanel.setPopupPosition(x, y+20);
popupPanel.show();
}
});
return timebx;
}
public void setTimebx(String string) {
// TODO Auto-generated method stub
timebx.setText(string);
}
我在不同 gui 类的 flexTable 中添加这个小部件
flexTable.setWidget(i, j,textBoxDisplay.getTimeTxtbx());
textBoxDisplay.setTimebx(customProperty.getValues().toString());
在 flexTable 中,上面的代码位于 iterator 内,并被称为 Twice。
如图片中所示:testDate 收到日期。
当我点击 testDate 时,Received On 的值发生了变化
编辑
public ListBox getBooleanBox() {
// TODO Auto-generated method stub
selectBoolean = new ListBox(false);
//selectBoolean.setName(title);
selectBoolean.setStyleName("cmis-Customproperties-TextBox");
selectBoolean.setSize("150px", "20px");
selectBoolean.addItem("True","True");
selectBoolean.addItem("False", "False");
return selectBoolean;
}
public void setBooleanBox(String value){
int itemCount = selectBoolean.getItemCount();
for(int i = 0 ;i < itemCount;i++){
if(selectBoolean.getItemText(i).equalsIgnoreCase(value)){
selectBoolean.setSelectedIndex(i);
}
}
}
添加弹性表
customPropertyTabel.setWidget(i, j,textBoxDisplay.getBooleanBox());
textBoxDisplay.setBooleanBox(removeSymbol(customProperty.getValues().toString()));
这工作得很好。 我得到了正确的值。
【问题讨论】:
-
@Keppil 当我单击 testDate 的文本框时,弹出窗口位于 ReceivedOn 的文本框上,并且 receivedOn 文本框的值发生了变化
标签: java gwt gwt2 gwt-widgets