示例#1
0
 private void deleteDetails() {
   SmsPurEnqDtlDM save = new SmsPurEnqDtlDM();
   if (tblSmsEnqDtl.getValue() != null) {
     save = beanPurEnqDtlDM.getItem(tblSmsEnqDtl.getValue()).getBean();
     listEnqDtls.remove(save);
     enqDtlresetFields();
     loadPurDtl();
     btndelete.setEnabled(false);
   }
 }
 public void valueChange(ValueChangeEvent event) {
   Property property = event.getProperty();
   if (property == fileTable) {
     currentFile = (DocumentObject) fileTable.getValue();
     setEnableButtonsBySelection(currentFile != null);
   }
 }
 public void onRemoveUser() {
   // check if a user is selected in the table
   Table userList = this.view.getUserList();
   Object selected = userList.getValue();
   if (selected != null) {
     this.container.removeItem(selected);
   }
 }
 public String getCurrentUriFragment() {
   String fragment = URI_FRAGMENT_PREFIX;
   Object itemId = itemTable.getValue();
   if (itemId != null) {
     String auctionItemId = (String) itemContainer.getContainerProperty(itemId, "id").getValue();
     fragment += auctionItemId;
   }
   return fragment;
 }
示例#5
0
 private void editSmsPurDetail() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Editing the selected record");
   hlUserInputLayout.setVisible(true);
   if (tblSmsEnqDtl.getValue() != null) {
     SmsPurEnqDtlDM purEnqDtlDM = beanPurEnqDtlDM.getItem(tblSmsEnqDtl.getValue()).getBean();
     lsProduct.setValue(null);
     Long prodid = purEnqDtlDM.getProductId();
     Collection<?> prodids = lsProduct.getItemIds();
     for (Iterator<?> iterator = prodids.iterator(); iterator.hasNext(); ) {
       Object itemId = (Object) iterator.next();
       BeanItem<?> item = (BeanItem<?>) lsProduct.getItem(itemId);
       // Get the actual bean and use the data
       ProductDM st = (ProductDM) item.getBean();
       if (prodid != null && prodid.equals(st.getProdid())) {
         lsProduct.select(itemId);
       }
     }
     if (cbUom.getValue() != null) {
       cbUom.setReadOnly(false);
       cbUom.setValue(purEnqDtlDM.getProductUom());
       cbUom.setReadOnly(true);
     }
     if (tfEnqQty.getValue() != null) {
       tfEnqQty.setValue(purEnqDtlDM.getEnquiryQty().toString());
     }
     if (purEnqDtlDM.getRemarks() != null) {
       taEnqDtlRem.setValue(purEnqDtlDM.getRemarks().toString());
     }
     if (purEnqDtlDM.getEnqDtlStaus() != null) {
       cbEnqDtlStatus.setValue(purEnqDtlDM.getEnqDtlStaus());
     }
   }
 }
  @Override
  public void buttonClick(ClickEvent event) {
    if (event.getButton().equals(btnCrearUsuario)) {
      Usuario object = new Usuario();
      object.setUsuario(txtUsuario.getValue().toString());
      object.setNombres(txtNombres.getValue().toString());
      object.setApePat(txtApellidoPaterno.getValue().toString());
      object.setApeMat(txtApellidoMaterno.getValue().toString());

      object.setRol((Rol) cmbRol.getValue());
      object.setCargo(
          txtCargo.getValue() != null ? txtCargo.getValue().toString() : StringUtils.EMPTY);
      object.setDescCargo(
          txtCargoDescripcion.getValue() != null
              ? txtCargoDescripcion.getValue().toString()
              : StringUtils.EMPTY);
      object.setOficina((Dependencia) cmbOficina.getValue());
      object.setPolicia((Policia) cmbPolicia.getValue());

      if (flagNuevoUsuario) {
        String randomPassword = RandomUtil.createWord(8);
        object.setClave(randomPassword);
        usuarioService.crear(object);
      } else {
        object.setClave(clave);
        Item item = tblUsuarios.getItem(tblUsuarios.getValue());
        object.setId((Long) item.getItemProperty("id").getValue());
        usuarioService.actualizar(object);
      }
      refrescar();
    } else if (event.getButton().equals(btnEliminarUsuario)) {
      ConfirmDialog.show(
          getApplication().getMainWindow(),
          "¿Seguro de Eliminar el Registro?",
          new ConfirmDialog.Listener() {
            private static final long serialVersionUID = 1L;

            public void onClose(ConfirmDialog dialog) {
              if (dialog.isConfirmed()) {
                Item item = tblUsuarios.getItem(tblUsuarios.getValue());
                usuarioService.eliminarXId((Long) item.getItemProperty("id").getValue());
                refrescar();
              }
            }
          });
    } else if (event.getButton().equals(btnAgregarPolicia)) {
      cargarWindowRegistroPolicia();
    }
  }
示例#7
0
 private void saveEnqDtl() {
   logger.info(
       "Company ID : " + companyid + " | User Name : " + username + " > " + "Saving Data... ");
   try {
     int count = 0;
     String[] split =
         lsProduct.getValue().toString().replaceAll("\\[", "").replaceAll("\\]", "").split(",");
     for (String obj : split) {
       if (obj.trim().length() > 0) {
         for (SmsPurEnqDtlDM smsPurEnqDtlDM : listEnqDtls) {
           if (smsPurEnqDtlDM.getProductId().equals(Long.valueOf(obj.trim()))) {
             count++;
             break;
           }
         }
         if (tblSmsEnqDtl.getValue() != null) {
           count = 0;
         }
         if (count == 0) {
           SmsPurEnqDtlDM enqDtlObj = new SmsPurEnqDtlDM();
           if (tblSmsEnqDtl.getValue() != null) {
             enqDtlObj = beanPurEnqDtlDM.getItem(tblSmsEnqDtl.getValue()).getBean();
             listEnqDtls.remove(enqDtlObj);
           }
           if (lsProduct.getValue() != null) {
             enqDtlObj.setProductId(Long.valueOf(obj.trim()));
             enqDtlObj.setPordName(
                 serviceProduct
                     .getProductList(
                         null, Long.valueOf(obj.trim()), null, null, null, null, null, "P")
                     .get(0)
                     .getProdname());
           }
           if (cbUom.getValue() != null) {
             cbUom.setReadOnly(false);
             enqDtlObj.setProductUom(cbUom.getValue().toString());
             cbUom.setReadOnly(true);
           }
           enqDtlObj.setRemarks(taEnqDtlRem.getValue().toString());
           if (tfEnqQty.getValue() != null && tfEnqQty.getValue().trim().length() > 0) {
             enqDtlObj.setEnquiryQty(Long.valueOf(tfEnqQty.getValue()));
           }
           if (cbEnqDtlStatus.getValue() != null) {
             enqDtlObj.setEnqDtlStaus((cbEnqDtlStatus.getValue().toString()));
           }
           enqDtlObj.setLastUpdateddt(DateUtils.getcurrentdate());
           enqDtlObj.setLastUpdatedby(username);
           listEnqDtls.add(enqDtlObj);
           loadPurDtl();
           btnaddSpec.setCaption("Add");
           count = 0;
         } else {
           lsProduct.setComponentError(new UserError("Product Already Exist.."));
         }
       }
     }
     enqDtlresetFields();
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
 }
  public EditVehicleWindow(final VehicleView parent, final long vehID) {
    super("Edycja pojazdu");
    FormLayout newVehicleLayout = new FormLayout();
    final FieldGroup fields = new FieldGroup();
    Table vehiclesList = parent.getVehiclesList();
    fields.setBuffered(true);

    String fieldName = "";
    fieldName = VehicleView.BRAND;
    TextField fieldBRAND = new TextField(fieldName);
    fieldBRAND.setValue(
        (String)
            vehiclesList
                .getContainerProperty(vehiclesList.getValue(), VehicleView.BRAND)
                .getValue());
    fieldBRAND.addValidator(
        new StringLengthValidator("Niepoprawna długość pola marka", 3, 64, false));
    fieldBRAND.addValidator(
        new RegexpValidator("^[\\p{L}0-9- ]*$", "Model zawiera nie właściwe znaki"));
    fieldBRAND.setWidth("20em");
    fieldBRAND.setRequired(true);
    fieldBRAND.setRequiredError("Pole Model jest wymagane");
    fieldBRAND.setImmediate(true);
    newVehicleLayout.addComponent(fieldBRAND);
    fields.bind(fieldBRAND, fieldName);

    fieldName = VehicleView.COLOUR;
    TextField fieldCOLOUR = new TextField(fieldName);
    fieldCOLOUR.setValue(
        (String)
            vehiclesList
                .getContainerProperty(vehiclesList.getValue(), VehicleView.COLOUR)
                .getValue());
    fieldCOLOUR.addValidator(
        new StringLengthValidator("Niepoprawna długość pola Kolor nadwozia", 3, 64, false));
    fieldCOLOUR.addValidator(
        new RegexpValidator("^[\\p{L}]*$", "pole Kolor nadwozia zawiera niewłaściwe znaki"));
    fieldCOLOUR.setWidth("20em");
    fieldCOLOUR.setRequired(true);
    fieldCOLOUR.setRequiredError("Pole Kolor nadwozia jest wymagane");
    fieldCOLOUR.setImmediate(true);
    newVehicleLayout.addComponent(fieldCOLOUR);
    fields.bind(fieldCOLOUR, fieldName);

    fieldName = VehicleView.MAX_LOAD;
    TextField fieldMAX_LOAD = new TextField(fieldName);
    fieldMAX_LOAD.setValue(
        vehiclesList
            .getContainerProperty(vehiclesList.getValue(), VehicleView.MAX_LOAD)
            .getValue()
            .toString());
    fieldMAX_LOAD.setConverter(Integer.class);
    fieldMAX_LOAD.setConversionError("Wprowadzona wartość nie jest liczbą");
    fieldMAX_LOAD.addValidator(
        new IntegerRangeValidator("Niewłaściwa wartość ładowności", 0, Integer.MAX_VALUE));
    fieldMAX_LOAD.setWidth("20em");
    fieldMAX_LOAD.setRequired(true);
    fieldMAX_LOAD.setRequiredError("Pole Ładowność jest wymagane");
    fieldMAX_LOAD.setImmediate(true);
    newVehicleLayout.addComponent(fieldMAX_LOAD);
    fields.bind(fieldMAX_LOAD, fieldName);

    fieldName = VehicleView.REGISTRATION_NR;
    TextField fieldREGISTRATION_NR = new TextField(fieldName);
    fieldREGISTRATION_NR.setValue(
        (String)
            vehiclesList
                .getContainerProperty(vehiclesList.getValue(), VehicleView.REGISTRATION_NR)
                .getValue());
    fieldREGISTRATION_NR.addValidator(
        new StringLengthValidator("Niepoprawna długość pola Nr rejestracyjny", 4, 12, false));
    fieldREGISTRATION_NR.addValidator(
        new RegexpValidator("^[A-Z0-9-]+$", "pole Kolor zawiera nie właściwe znaki"));
    fieldREGISTRATION_NR.setWidth("20em");
    fieldREGISTRATION_NR.setRequired(true);
    fieldREGISTRATION_NR.setRequiredError("Pole Nr rejestracyjny jest wymagane");
    fieldREGISTRATION_NR.setImmediate(true);
    newVehicleLayout.addComponent(fieldREGISTRATION_NR);
    fields.bind(fieldREGISTRATION_NR, fieldName);

    Button changeDriver = new Button("Zatwierdź");
    Button cancel = new Button("Anuluj");
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(changeDriver);
    hl.addComponent(cancel);
    newVehicleLayout.addComponent(hl);
    cancel.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent event) {
            close();
          }
        });
    changeDriver.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent event) {

            Vehicle veh = new Vehicle();
            veh.setId(vehID);
            veh.setBrand((String) fields.getField(VehicleView.BRAND).getValue());
            veh.setColour((String) fields.getField(VehicleView.COLOUR).getValue());

            Integer truckLoad = null;
            try {
              truckLoad =
                  Integer.parseInt(fields.getField(VehicleView.MAX_LOAD).getValue().toString());
            } catch (NumberFormatException e) {
              Notification delayNot = new Notification("Proszę wypełnić pola poprawnie");
              delayNot.setDelayMsec(1000);
              delayNot.show(Page.getCurrent());
              return;
            }
            veh.setTruckload(truckLoad);
            veh.setRegistrationNumber(
                (String) fields.getField(VehicleView.REGISTRATION_NR).getValue());

            Boolean valOk = true;
            Collection colFields = fields.getFields();
            for (Object o : colFields) {
              Field fi = (Field) o;
              try {
                fi.validate();
              } catch (Validator.InvalidValueException e) {
                Notification delayNot = new Notification("Proszę wypełnić pola poprawnie");
                delayNot.setDelayMsec(1000);
                delayNot.show(Page.getCurrent());
                valOk = false;
                break;
              }
            }

            if (valOk) {
              veh = ReceiveVehicle.changeVehicle(veh);
              if (veh == null) {
                Notification.show("Nie wprowadzono zmian");
                close();
                return;
              }
              Notification.show("Wprowadzono zmiany");
              parent.refreshDataSource();
              close();
            }
          }
        });

    addCloseListener(
        new Window.CloseListener() {
          @Override
          public void windowClose(Window.CloseEvent e) {
            parent.setEnabled(true);
          }
        });
    parent.setEnabled(false);

    setContent(newVehicleLayout);

    setResizable(false);

    setDraggable(false);

    center();
  }