Ejemplo n.º 1
0
 private boolean validateFields() {
   if (Utils.safeString(nameTextBox.getValue()).equals("")) {
     MessageBox.alert(textMessages.error(), textMessages.mustEnterName(), null);
     return false;
   }
   if (Utils.safeString(nameTextBox.getValue()).length() > Group.LENGTH_NAME) {
     MessageBox.alert(textMessages.error(), textMessages.tooLongName(), null);
     return false;
   }
   return true;
 }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  protected void handleEvent(AppEvent event) {
    if (event.getType() == AppEvents.AuditEventEntryView) {

      searchCriteria = null;
      currentEntity = Registry.get(Constants.ENTITY_ATTRIBUTE_MODEL);

      initUI();

      if (Registry.get(Constants.AUDIT_EVENT_TYPE_CODES) != null) {
        List<AuditEventTypeWeb> auditEventTypes =
            (List<AuditEventTypeWeb>) Registry.get(Constants.AUDIT_EVENT_TYPE_CODES);
        /*
         * for (AuditEventTypeWeb type : auditEventTypes) { Info.display("Information", "Event Types: "+
         * type.getAuditEventTypeCd() + ", " + type.getAuditEventTypeName()); }
         */
        eventTypesStore.removeAll();
        eventTypesStore.add(auditEventTypes);
      }

    } else if (event.getType() == AppEvents.Logout) {

      Dispatcher.get().dispatch(AppEvents.Logout);

    } else if (event.getType() == AppEvents.AuditEventReceived) {

      // Info.display("Information", "EventReceived");
      store.removeAll();

      AuditEventEntryListWeb events = (AuditEventEntryListWeb) event.getData();
      if (events.getAuditEventEntries() != null) {
        store.add(events.getAuditEventEntries());
      }

      grid.getSelectionModel().select(0, true);
      grid.getSelectionModel().deselect(0);

      status.hide();
      searchButton.unmask();

    } else if (event.getType() == AppEvents.EntityByIdRequest) {

      RecordWeb record = (RecordWeb) event.getData();

      if (record != null) {
        identifierStore.removeAll();

        buildRefRecordInfoDialog();
        refRecordInfoDialog.show();

        displayEntityRecord(attributeFieldMap, record);
        displayEntityIdentifier(record);
      }

    } else if (event.getType() == AppEvents.Error) {
      String message = event.getData();
      MessageBox.alert("Information", "Failure: " + message, null);
    }
  }
Ejemplo n.º 3
0
  /**
   * Display an Alert Message in the Application
   *
   * @param title
   * @param message
   */
  public static void alertMessage(String title, String message) {
    MessageBox.alert(
        title,
        message,
        new Listener<MessageBoxEvent>() {

          @Override
          public void handleEvent(MessageBoxEvent be) {}
        });
  }
Ejemplo n.º 4
0
  @SuppressWarnings("unchecked")
  @Override
  protected void handleEvent(AppEvent event) {

    if (event.getType() == AppEvents.ProfileView) {
      initUI();
      clearFormFields(false);

      updateUser = Registry.get(Constants.LOGIN_USER);
      displayRecords(updateUser);

    } else if (event.getType() == AppEvents.ProfileUpdateComplete) {

      status.hide();
      submitButton.unmask();

      updateUser = (UserWeb) event.getData();
      Registry.register(Constants.LOGIN_USER, updateUser);

      MessageBox.alert("Information", "User profile was successfully updated", listenInfoMsg);

    } else if (event.getType() == AppEvents.ProfileVarifyPasswordSuccess) {

      UserWeb user = copyUserFromGUI(updateUser);
      controller.handleEvent(new AppEvent(AppEvents.ProfileUpdateInitiate, user));

    } else if (event.getType() == AppEvents.ProfileVarifyPasswordFailure) {

      status.hide();
      submitButton.unmask();

      MessageBox.alert("Information", "Incorrect current password", listenInfoMsg);

    } else if (event.getType() == AppEvents.Error) {
      status.hide();
      submitButton.unmask();

      String message = event.getData();
      MessageBox.alert("Information", "Failure: " + message, listenFailureMsg);
    }
  }
Ejemplo n.º 5
0
 @Override
 public void componentSelected(ButtonEvent ce) {
   List<BeanModel> selectedModels = deviceContentTree.getSelectionModel().getSelectedItems();
   for (BeanModel beanModel : selectedModels) {
     if (beanModel.getBean() instanceof DeviceCommand) {
       List<CommandRefItem> commandRefItems = device.getCommandRefItems();
       for (CommandRefItem commandRefItem : commandRefItems) {
         if (commandRefItem.getDeviceCommand() == beanModel.getBean()) {
           MessageBox.alert(
               "Warn",
               "The command cann't be delete, because it was refrenced by other sensor, switch or slider.",
               null);
           return;
         }
       }
       device.getDeviceCommands().remove(beanModel.getBean());
     } else if (beanModel.getBean() instanceof Sensor) {
       List<SensorRefItem> sensorRefItems = device.getSensorRefItems();
       for (SensorRefItem sensorRefItem : sensorRefItems) {
         if (sensorRefItem.getSensor() == beanModel.getBean()) {
           MessageBox.alert(
               "Warn",
               "The sensor cann't be delete, because it was refrenced by other switch or slider.",
               null);
           return;
         }
       }
       device.getSensors().remove(beanModel.getBean());
     } else if (beanModel.getBean() instanceof Slider) {
       device.getSliders().remove(beanModel.getBean());
     } else if (beanModel.getBean() instanceof Switch) {
       deviceContentTree.getStore().remove(beanModel);
       device.getSwitchs().remove(beanModel.getBean());
     }
     deviceContentTree.getStore().remove(beanModel);
   }
 }
Ejemplo n.º 6
0
 private boolean validateFields() {
   if (!(Utils.safeString(password2TextBox.getValue()))
       .equals(Utils.safeString(password1TextBox.getValue()))) {
     MessageBox.alert(textMessages.error(), textMessages.passwordsNotMatch(), null);
     return false;
   }
   if (Utils.safeString(password1TextBox.getValue()).length()
       > UserAuthnPassword.LENGTH_PASSWORD) {
     MessageBox.alert(textMessages.error(), textMessages.tooLongPassword(), null);
     return false;
   }
   if (Utils.safeString(usernameTextBox.getValue()).equals("")) {
     MessageBox.alert(textMessages.error(), textMessages.mustEnterUsername(), null);
     return false;
   }
   if (Utils.safeString(usernameTextBox.getValue()).length() > User.LENGTH_USERNAME) {
     MessageBox.alert(textMessages.error(), textMessages.tooLongUsername(), null);
     return false;
   }
   if (Utils.safeString(fullnameTextBox.getValue()).equals("")) {
     MessageBox.alert(textMessages.error(), textMessages.mustEnterFullName(), null);
     return false;
   }
   if (Utils.safeString(fullnameTextBox.getValue()).length() > User.LENGTH_FULLNAME) {
     MessageBox.alert(textMessages.error(), textMessages.tooLongFullName(), null);
     return false;
   }
   if (Utils.safeString(emailTextBox.getValue()).equals("")) {
     MessageBox.alert(textMessages.error(), textMessages.mustEnterEmail(), null);
     return false;
   }
   if (Utils.safeString(emailTextBox.getValue()).length() > User.LENGTH_EMAIL) {
     MessageBox.alert(textMessages.error(), textMessages.tooLongEmail(), null);
     return false;
   }
   if (!Utils.isValidEmail(Utils.safeString(emailTextBox.getValue()))) {
     MessageBox.alert(textMessages.error(), textMessages.invalidEmail(), null);
     return false;
   }
   return true;
 }
Ejemplo n.º 7
0
 public static void show(String command, String param) {
   if (command.equals(AJAX)) {
     MessageBox.alert(title + "AJAX error", "The browser doesn't support the AJAX object!", null)
         .setIcon(MessageBox.ERROR);
   } else if (command.equals(SEMANTIC_ANNOTATION)) {
     MessageBox.alert(
         title + "Semantic Annotation warning",
         "The highlighted keyword doe not correspond to the chosen entity! Do you want to do the annotation anyway?",
         null);
   } else if (command.equals(EMPTY_URI)) {
     MessageBox.alert(title + "Empty URI warning", "The empty string is not a valid URI!", null);
   } else if (command.equals(INVALID_URI)) {
     MessageBox.alert(title + "Invalid URI warning", "The typed string is not a valid URI!", null);
   } else if (command.equals(ANNOTATION_SELECTION)) {
     MessageBox.alert(
         title + "Annotation warning", "You should select the text before annotating.", null);
   } else if (command.equals(WATSON_SELECTION)) {
     MessageBox.alert(
         title + "Watson warning",
         "You should highlight a term from the text, before querying Watson.",
         null);
   } else if (command.equals(TERM_ALREADY_RETRIEVED)) {
     MessageBox.alert(
         title + "Watson warning", "The keyword \"" + param + "\" is already retrieved!", null);
   } else if (command.equals(NO_WATSON_RESULT)) {
     MessageBox.info(
         title + "Watson info", "Watson returned no search results for this keyword!", null);
   } else if (command.equals(STORE_SUCCESS)) {
     MessageBox.info(
         title + "Repository info",
         "Successfully save to the repository. The URI is " + param,
         null);
   } else if (command.equals(STORE_FAIL)) {
     MessageBox.alert(title + "Repository warning", "Fail to save to the repository", null);
   } else if (command.equals(DIV_ELEMENT)) {
     MessageBox.alert(
         title + "Annotation warning", "Your selection will breakup the HTML code.", null);
   } else if (command.equals(EXISTINGID)) {
     MessageBox.alert(
         title + "Existing Id warning",
         "Please choose a different name! This element id already exists.",
         null);
   } else if (command.equals(DELETEMREF)) {
     MessageBox.alert(
         title + "Delete",
         "Please delete the entity node in order to remove the model reference.",
         null);
   } else if (command.equals(ADDMREF)) {
     MessageBox.alert(
         title + "Model reference",
         "You can add model reference only to input and output elements.",
         null);
   } else if (command.equals(ADDMREF1)) {
     MessageBox.alert(
         title + "Model reference",
         "You can add model reference only to service and operation elements.",
         null);
   } else if (command.equals(ADDLFSCHEMA)) {
     MessageBox.alert(
         title + "Schema mapping",
         "You can add lifting and lowering schemas only to input and output elements.",
         null);
   }
 }
Ejemplo n.º 8
0
  @Override
  public void handleEvent(BaseEvent be) {
    // TODO Auto-generated method stub

    if (be.getType().equals(Events.Select)) {
      // 会员充值
      if (be.getSource().equals(addfinace)) {
        AddFinace_acc addfinace_acc = new AddFinace_acc();
        addfinace_acc.setIsnew(0);
        addfinace_acc.showDialog();
      }
      if (be.getSource().equals(d.getButtonById(Dialog.NO))) {
        close();
      } else if (be.getSource().equals(d.getButtonById(Dialog.YES))) {
        passwordc_t.clearInvalid();

        String passwordc = (passwordc_t.getValue() == null ? "" : passwordc_t.getValue());
        String password = (password_t.getValue() == null ? "" : password_t.getValue());
        if ((!passwordc.equals(password))) {

          passwordc_t.markInvalid("两次录入密码不一致");
          MessageBox.alert("提示", "两次密码录入不一致", null);
          return;
        }
        if (w.isValid()) {

          CommandSyncContainer list = new CommandSyncContainer();
          CommandSyncsql commandsql = new CommandSyncsql();

          // 保存
          commandsql.getV().addAll(store._trySave(0));
          // 更新ccode
          /** 不得已才如此操作,因为ccode的ccode字段是与其他操作管理的字段,和ccodepanel里的做法一直, 默认与icode同值 */
          GWT.log(
              "update ccode set ccode =icode where s_cardno='"
                  + cardno_t.getValue()
                  + "' and cname='"
                  + cname_t.getValue()
                  + "'",
              null);
          commandsql
              .getV()
              .add(
                  "update ccode set ccode =icode where s_cardno='"
                      + cardno_t.getValue()
                      + "' and cname='"
                      + cname_t.getValue()
                      + "'");

          list.add(commandsql);

          final com.base.myproject.client.tools.GreetingServiceAsync greetingService =
              GWT.create(com.base.myproject.client.tools.GreetingService.class);
          greetingService.SendCommandSync(
              list,
              new AsyncCallback<CommandSyncReturnObject>() {
                public void onFailure(Throwable caught) {
                  Window.alert("网络连接不稳定,请稍后重试!");
                }

                public void onSuccess(CommandSyncReturnObject cyro) {

                  System.out.println("成功:" + cyro.getMessage() + cyro.isB() + cyro.getRetrunstr());
                  if (cyro.isB()) {
                    Info.display("", "保存成功", "");
                    addfinace.setEnabled(true);
                    // close();
                  } else {
                    MessageBox.alert("错误", "保存错误!" + cyro.getMessage(), null);
                  }
                }
              });

          // store.trySave(0);
          d.getButtonById(Dialog.YES).setEnabled(false);
        } else MessageBox.alert("禁止", "请检查录入是否正确!", null);
      }

    } else if (be.getType().equals(Events.Change)) {
      if (be.getSource().equals(cardno_t)) {

        final com.base.myproject.client.tools.GreetingServiceAsync greetingService =
            GWT.create(com.base.myproject.client.tools.GreetingService.class);
        greetingService.getDataSet(
            "select count(*) as c from ccode where s_cardno='" + cardno_t.getValue() + "'",
            new AsyncCallback<DataSet>() {

              @Override
              public void onFailure(Throwable caught) {}

              @Override
              public void onSuccess(DataSet result) {

                if (Integer.parseInt(result.getValue(0, "c")) > 0) {
                  Validator v =
                      new Validator() {

                        @Override
                        public String validate(Field<?> field, String value) {

                          return "已经存在相同卡号的用户";
                        }
                      };

                  cardno_t.setValidator(v);

                } else {
                  cardno_t.setValidator(null);
                }
                cardno_t.validate();
              }
            });

      } else if (be.getSource().equals(cname_t)) {

        final com.base.myproject.client.tools.GreetingServiceAsync greetingService =
            GWT.create(com.base.myproject.client.tools.GreetingService.class);
        greetingService.getDataSet(
            "select count(*) as c from ccode where cname='" + cname_t.getValue() + "'",
            new AsyncCallback<DataSet>() {

              @Override
              public void onFailure(Throwable caught) {}

              @Override
              public void onSuccess(DataSet result) {

                if (Integer.parseInt(result.getValue(0, "c")) > 0) {
                  Validator v =
                      new Validator() {

                        @Override
                        public String validate(Field<?> field, String value) {

                          return "已经存在相同名字的用户";
                        }
                      };

                  cname_t.setValidator(v);
                } else {
                  cname_t.setValidator(null);
                }

                cname_t.validate();
              }
            });
      }
      //			else if (name.equals("s_cardno")) {
      //				ccode_t.setFireChangeEventOnSetValue(true);
      //				ccode_t.setValue(icode_t.getValue());
      //				ccode_t.setFireChangeEventOnSetValue(false);
      //			}
    }
  }