org.uberfire.ext.widgets.common.client.common.DatePicker类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.uberfire.ext.widgets.common.client.common.DatePicker类的一些代码示例,展示了DatePicker类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DatePicker类的具体详情如下:
包路径:org.uberfire.ext.widgets.common.client.common.DatePicker
类名称:DatePicker

DatePicker介绍

[英]A DatePicker wrapping BS3's DatePicker component adding additional functionality required by KIE Workbench.; such as prevention of empty values and support for setting the date format with GWT's DateTimeFormat patterns.
[中]一个日期选择器,包装BS3的日期选择器组件,添加KIE Workbench所需的附加功能。;例如防止空值,支持使用GWT的DateTimeFormat模式设置日期格式。

代码示例

代码示例来源:origin: org.drools/drools-wb-guided-rule-editor-client

protected void initDatePickerByRuleAttribute(final DatePicker datePicker, final RuleAttribute ruleAttribute) {
  datePicker.addValueChangeHandler(event -> {
    final Date date = datePicker.getValue();
    final String sDate = (date == null ? null : DATE_FORMATTER.format(datePicker.getValue()));
    ruleAttribute.setValue(sDate);
  });
  datePicker.setFormat(DATE_FORMAT);
  datePicker.setValue(assertDateValue(ruleAttribute));
}

代码示例来源:origin: stackoverflow.com

DatePicker dtpckr = new DatePicker();
dtpckr.setMaxWidth(width);
dtpckr.setMinWidth(width);
dtpckr.setConverter(new StringConverter<LocalDate>() {
  private DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("yyyy/MM/dd");
  @Override
dtpckr.setPromptText("yyyy/MM/dd");
dtpckr.setValue(LocalDate.parse(defaultDate.toString(), DateTimeFormatter.ofPattern("yyyy/MM/dd")));
dtpckr.focusedProperty().addListener(new ChangeListener<Boolean>() {
  @Override
  public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
    if (!newValue){
      dtpckr.setValue(dtpckr.getConverter().fromString(dtpckr.getEditor().getText()));

代码示例来源:origin: org.uberfire/uberfire-widgets-commons

@Override
  public void onHide(HideEvent hideEvent) {
    final Date value = getDataPickerDate();
    if (!allowEmptyValues && value == null) {
      doSetValue(new Date(),
            true);
    } else {
      doSetValue(value,
            true);
    }
  }
});

代码示例来源:origin: stackoverflow.com

DatePicker picker = new DatePicker(this);
 picker.init(<year>, <monthOfYear>, <dayOfMonth>, new DatePicker.OnDateChangedListener() {
   @Override
   public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
     //set the value of the variable here 
   }
 });

代码示例来源:origin: stackoverflow.com

DatePicker nonEditableDatePicker = new DatePicker();
nonEditableDatePicker.getStyleClass().add("non-editable-datepicker");

代码示例来源:origin: stackoverflow.com

DatePicker selectDate = new DatePicker(this);
selectDate.setCalendarViewShown(false);

代码示例来源:origin: org.drools/drools-wb-guided-rule-editor-client

final DatePicker datePicker = new DatePicker(false);
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
  @Override
  public void onValueChange(ValueChangeEvent<Date> event) {
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(assertDateValue());

代码示例来源:origin: org.drools/drools-wb-guided-dtable-editor-client

private Widget makeDateSelector(final DTCellValue52 value) {
    //If read-only return a label
    if (isReadOnly) {
      Label dateLabel = new Label();
      dateLabel.setText(format.format(value.getDateValue()));
      return dateLabel;
    }

    final DatePicker datePicker = new DatePicker(allowEmptyValues);

    // Wire up update handler
    datePicker.addChangeDateHandler((e) -> value.setDateValue(datePicker.getValue()));

    datePicker.setFormat(DATE_FORMAT);
    datePicker.setValue(value.getDateValue());

    return datePicker;
  }
}

代码示例来源:origin: org.dashbuilder/dashbuilder-displayer-client

@Override
public Date getValue() {
  return input.getValue();
}

代码示例来源:origin: kiegroup/appformer

@Test
public void testSetFormat() {
  datePicker = new DatePicker(datePickerMock);
  String gwtDateFormat = "dd-MMM-yyyy";
  DateTimeFormat gwtDateTimeFormat = DateTimeFormat.getFormat(gwtDateFormat);
  datePicker.setLocaleName("en");
  datePicker.setFormat(gwtDateFormat);
  verify(datePickerMock).setLanguage(DatePickerLanguage.EN);
  verify(datePickerMock).setFormat(DatePickerFormatUtilities.convertToBS3DateFormat(gwtDateFormat));
  Date now = new Date();
  now = gwtDateTimeFormat.parse(gwtDateTimeFormat.format(now));
  datePicker.setValue(now);
  verify(textBox).setValue(gwtDateTimeFormat.format(now));
  when(textBox.getValue()).thenReturn(gwtDateTimeFormat.format(now));
  assertEquals(now,
         datePicker.getValue());
}

代码示例来源:origin: org.drools/drools-wb-guided-rule-editor-client

public DSLDateSelector(DSLVariableValue selectedDate) {
  // Wire up update handler
  datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
    @Override
    public void onValueChange(final ValueChangeEvent<Date> event) {
      updateSentence();
    }
  });
  datePicker.setFormat(DATE_FORMAT);
  datePicker.setValue(assertDateValue(selectedDate));
  //Wrap widget within a HorizontalPanel to add a space before and after the Widget
  HorizontalPanel hp = new HorizontalPanel();
  hp.add(new HTML("&nbsp;"));
  hp.add(datePicker);
  hp.add(new HTML("&nbsp;"));
  initWidget(hp);
}

代码示例来源:origin: stackoverflow.com

public class Controller implements Initializable {

  @FXML 
  DatePicker checkInDatePicker;

  ...

  @Override
  public void initialize(URL location, ResourceBundle resources) {
    checkInDatePicker.setValue(LocalDate.now());
  }
}

代码示例来源:origin: org.drools/drools-wb-guided-rule-editor-client

@Test
public void testDatePickerValueChangeHandler() {
  final DatePicker datePicker = mock(DatePicker.class);
  final Date datePickerValue = new Date();
  doReturn(datePickerValue).when(datePicker).getValue();
  factory.initDatePickerByRuleAttribute(datePicker, ruleAttribute);
  verify(datePicker).addValueChangeHandler(valueChangeHandlerArgumentCaptor.capture());
  valueChangeHandlerArgumentCaptor.getValue().onValueChange(null);
  // not robust verifications because of Date formatting / parsing is mocked by GwtMockito
  verify(ruleAttribute).setValue(anyString());
}

代码示例来源:origin: stackoverflow.com

import java.time.LocalDate;
import javafx.fxml.FXML;
import javafx.scene.control.DatePicker;
import com.main.controller.checker.DateChecker;
import com.main.controller.datautil.DataFetch;
import com.main.controller.datautil.DataStore;
import com.main.controller.util.Initilizable;

public class SearchCtrl implements Initilizable{

@FXML
private DatePicker check_in;

@FXML
private DatePicker check_out;

@Override
public void init() {        
  check_in.setValue(LocalDate.now());
  check_out.setValue(check_in.getValue().plusDays(1));
  DateChecker.setBeginDateBounds(check_in, check_out.getValue());
  DateChecker.setEndDateBounds(check_out, check_in.getValue());
  check_in.setOnAction( (event) ->   {DateChecker.setEndDateBounds(check_out, check_in.getValue());});
  datafine.setOnAction( (event) -> {DateChecker.setBeginDateBounds(check_in, check_out.getValue());});
}

代码示例来源:origin: stackoverflow.com

Label labelCompare = new Label();
Label labelCompare2 = new Label();
DatePicker datePicker = new DatePicker();
datePicker.setValue(localDate);
 @Override public void handle(ActionEvent e) {
  LocalDate localDate = datePicker.getValue();

代码示例来源:origin: org.drools/drools-wb-guided-rule-editor-client

@Test
public void testInitDatePickerByRuleAttribute() {
  final DatePicker datePicker = mock(DatePicker.class);
  final String attributeValue = "31-May-2018";
  doReturn(attributeValue).when(ruleAttribute).getValue();
  factory.initDatePickerByRuleAttribute(datePicker, ruleAttribute);
  // not robust verifications because of Date formatting / parsing is mocked by GwtMockito
  verify(datePicker).setFormat(any());
  verify(datePicker).setValue(notNull(Date.class));
}

代码示例来源:origin: stackoverflow.com

public class DatePickerExample implements EntryPoint {

 public void onModuleLoad() {
  // Create a date picker
  DatePicker datePicker = new DatePicker();
  final Label text = new Label();

  // Set the value in the text box when the user selects a date
  datePicker.addValueChangeHandler(new ValueChangeHandler() {
   public void onValueChange(ValueChangeEvent event) {
    Date date = event.getValue();
    String dateString = DateTimeFormat.getMediumDateFormat().format(date);
    text.setText(dateString);
   }
  });

  // Set the default value
  datePicker.setValue(new Date(), true);

  // Add the widgets to the page
  RootPanel.get().add(text);
  RootPanel.get().add(datePicker);
 }
}

代码示例来源:origin: stackoverflow.com

private final Locale myLocale = Locale.getDefault(Locale.Category.FORMAT);

@Override
public void start(Stage primaryStage) {
  DatePicker datePicker=new DatePicker();
  datePicker.setValue(LocalDate.now());
  datePicker.setOnShowing(e-> Locale.setDefault(Locale.Category.FORMAT,Locale.ENGLISH));
  datePicker.setOnHiding(e-> Locale.setDefault(Locale.Category.FORMAT,myLocale));
  datePicker.setOnAction(e-> Locale.setDefault(Locale.Category.FORMAT,myLocale));
  ...
}

代码示例来源:origin: stackoverflow.com

this.renderer = renderer;
this.datePicker = new DatePicker();
this.panel = new PopupPanel(true, true) {
  @Override
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
  public void onValueChange(ValueChangeEvent<Date> event) {
Date date = (viewData == null) ? lastValue : viewData;
if (date != null) {
  datePicker.setCurrentMonth(date);
datePicker.setValue(date);
panel.setPopupPositionAndShow(new PositionCallback() {
  public void setPosition(int offsetWidth, int offsetHeight) {

代码示例来源:origin: stackoverflow.com

private final Locale myLocale = Locale.getDefault(Locale.Category.FORMAT);

@Override
public void start(Stage primaryStage) {
  DatePicker datePicker=new DatePicker();
  datePicker.setValue(LocalDate.now());
  datePicker.setOnShowing(e-> Locale.setDefault(Locale.Category.FORMAT,Locale.ENGLISH));
  datePicker.setOnShown(e-> Locale.setDefault(Locale.Category.FORMAT,myLocale));
  ...
}

相关文章