Exemplo n.º 1
0
 public void onClose() {
   final PTInstruction instruction = new PTInstruction();
   instruction.setObjectID(id);
   instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
   instruction.put(HANDLER.KEY, HANDLER.KEY_.CLOSE_HANDLER);
   uiService.sendDataToServer(instruction);
 }
Exemplo n.º 2
0
 @Override
 public void update(final PTInstruction update, final UIService uiService) {
   if (update.containsKey(PROPERTY.OPEN)) {
     window = open(url, name, features);
     if (window != null) {
       checkWindowAlive();
     }
   } else if (update.containsKey(PROPERTY.TEXT)) {
     onDataReceived(window, update.getString(PROPERTY.TEXT));
   } else if (update.containsKey(PROPERTY.CLOSE)) {
     close(window);
   }
 }
Exemplo n.º 3
0
 @Override
 public void update(final PTInstruction update, final UIService uiService) {
   final long commandID = update.getLong(PROPERTY.COMMAND_ID);
   if (update.containsKey(PROPERTY.STOP)) {
     // Stop the command
     commandByIDs.remove(commandID).cancel();
   } else if (update.containsKey(PROPERTY.FIXDELAY)) {
     // Fix-delay
     // Wait for execution terminated before scheduling again
     final SchedulerCommand previousCmd = commandByIDs.remove(commandID);
     if (previousCmd != null) previousCmd.cancel();
     final int delay = update.getInt(PROPERTY.FIXDELAY);
     final FixDelayCommand command =
         new FixDelayCommand(uiService, update.getObjectID(), commandID, delay);
     Scheduler.get().scheduleFixedDelay(command, delay);
     commandByIDs.put(commandID, command);
   } else if (update.containsKey(PROPERTY.FIXRATE)) {
     // Fix-rate
     final SchedulerCommand previousCmd = commandByIDs.remove(commandID);
     if (previousCmd != null) previousCmd.cancel();
     final int delay = update.getInt(PROPERTY.FIXRATE);
     final FixRateCommand command =
         new FixRateCommand(uiService, update.getObjectID(), commandID, delay);
     Scheduler.get().scheduleFixedDelay(command, delay);
     commandByIDs.put(commandID, command);
   }
 }
Exemplo n.º 4
0
  @Override
  public void addHandler(final PTInstruction addHandler, final UIService uiService) {

    if (HANDLER.KEY_.DATE_VALUE_CHANGE_HANDLER.equals(addHandler.getString(HANDLER.KEY))) {
      final DateBox dateBox = cast();
      final TextBox textBox = dateBox.getTextBox();
      dateBox.addValueChangeHandler(
          new ValueChangeHandler<Date>() {

            @Override
            public void onValueChange(final ValueChangeEvent<Date> event) {
              triggerEvent(addHandler, uiService, dateBox);
            }
          });
      textBox.addValueChangeHandler(
          new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(final ValueChangeEvent<String> event) {
              triggerEvent(addHandler, uiService, dateBox);
            }
          });
    } else {
      super.addHandler(addHandler, uiService);
    }
  }
Exemplo n.º 5
0
  @Override
  public void create(final PTInstruction create, final UIService uiService) {

    final PTDatePicker datePicker =
        (PTDatePicker) uiService.getPTObject(create.getLong(PROPERTY.PICKER));

    init(create, uiService, new MyDateBox(datePicker.cast(), null, DEFAULT_FORMAT));
  }
Exemplo n.º 6
0
  @Override
  public void update(final PTInstruction update, final UIService uiService) {
    final MyDateBox dateBox = cast();

    if (update.containsKey(PROPERTY.VALUE)) {
      dateBox.getTextBox().setText(update.getString(PROPERTY.VALUE));
    } else if (update.containsKey(PROPERTY.DATE_FORMAT)) {
      final DefaultFormat format =
          new DefaultFormat(DateTimeFormat.getFormat(update.getString(PROPERTY.DATE_FORMAT)));
      dateBox.setFormat(format);
    } else if (update.containsKey(PROPERTY.DATE_FORMAT_PATTERN)) {
      dateBox.setFormat(
          new DefaultFormat(
              DateTimeFormat.getFormat(update.getString(PROPERTY.DATE_FORMAT_PATTERN))));
    } else if (update.containsKey(PROPERTY.ENABLED)) {
      dateBox.setEnabled(update.getBoolean(PROPERTY.ENABLED));
    } else if (update.containsKey(PROPERTY.MONTH)) {
      dateBox.setDefaultMonth(update.getString(PROPERTY.MONTH));
    } else {
      super.update(update, uiService);
    }
  }
Exemplo n.º 7
0
  @Override
  public void create(final PTInstruction create, final UIService uiService) {

    this.id = create.getObjectID();
    this.uiService = uiService;

    if (create.containsKey(PROPERTY.URL)) url = create.getString(PROPERTY.URL);
    else url = GWT.getHostPageBaseURL() + "?wid=" + create.getObjectID();

    if (create.containsKey(PROPERTY.NAME)) name = create.getString(PROPERTY.NAME);
    else name = "";

    if (create.containsKey(PROPERTY.FEATURES)) features = create.getString(PROPERTY.FEATURES);
    else features = "";
  }
Exemplo n.º 8
0
  protected void triggerEvent(
      final PTInstruction addHandler, final UIService uiService, final DateBox dateBox) {
    final PTInstruction instruction = new PTInstruction();
    instruction.setObjectID(addHandler.getObjectID());
    instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
    instruction.put(HANDLER.KEY, HANDLER.KEY_.DATE_VALUE_CHANGE_HANDLER);
    instruction.put(PROPERTY.VALUE, dateBox.getTextBox().getText());

    uiService.sendDataToServer(dateBox, instruction);
  }
Exemplo n.º 9
0
    @Override
    public boolean execute() {

      if (cancelled) return false;

      final PTInstruction instruction = new PTInstruction();
      instruction.setObjectID(schedulerID);
      instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
      instruction.put(HANDLER.KEY, HANDLER.KEY_.SCHEDULER);
      instruction.put(PROPERTY.ID, commandID);
      instruction.put(PROPERTY.FIXDELAY, delay);

      uiService.triggerEvent(instruction);

      return false;
    }