Ejemplo n.º 1
0
  public FormEstadoSoporte() {

    super.setColumns(4);
    super.setRows(3);
    setSpacing(true);
    setMargin(true);
    setWidth("100%");

    this.txt_id_estado_soporte = new TextField("Id. Estado Soporte:");
    this.txt_nombre_esoporte = new TextField("Descripcion del Estado de Soporte: ");
    this.mensajes = new ArrayList<BarMessage>();

    pitm_esoporte.addItemProperty("id_estado_soporte", new ObjectProperty<Integer>(0));
    pitm_esoporte.addItemProperty("nombre_estado_soporte", new ObjectProperty<String>(""));
    pitm_esoporte.addItemProperty("sigla", new ObjectProperty<String>(""));

    this.binder_esoporte = new FieldGroup(this.pitm_esoporte);

    binder_esoporte.bind(this.txt_id_estado_soporte, "id_estado_soporte");
    binder_esoporte.bind(this.txt_nombre_esoporte, "nombre_estado_soporte");

    this.txt_nombre_esoporte.setRequired(true);
    this.txt_nombre_esoporte.addValidator(new NullValidator("No Nulo", false));
    this.txt_nombre_esoporte.addValidator(
        new StringLengthValidator(Messages.STRING_LENGTH_MESSAGE(3, 50), 3, 50, false));
    this.txt_id_estado_soporte.setEnabled(false);

    txt_id_estado_soporte.setWidth("90%");
    txt_nombre_esoporte.setWidth("90%");

    updateId();
    buildContent();
    Responsive.makeResponsive(this);
  }
Ejemplo n.º 2
0
  private Component AutoGeneratedLayoutDesign() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    // set parent Test Case manually without a field
    if (editmode == false && (clonemode == false)) {
      testsession.setParentcase(parentcase);
    }

    binder = new FieldGroup();
    //		BeanItem<Person> item = new BeanItem<Person>(person);		// takes item as argument
    //		item.addNestedProperty("address.street");	// Address info is not person but address to which
    // person is linked
    binder.setItemDataSource(newSessionItem); // link to data model to binder	
    //		binder.bindMemberFields(form);	// link to layout

    // GENERATE FIELDS
    //	for (Object propertyId : item.getItemPropertyIds()) {
    //		if(!"address".equals(propertyId)) {
    //			Field field = binder.buildAndBind(propertyId);
    //			layout.addComponent(field);
    //		}
    //	}

    // using bind() to determine what type of field is created yourself...
    title = new TextField();
    binder.bind(title, "title");
    title.setWidth(22, Unit.EM);
    title.setCaption("Title");
    title.focus();
    title.setImmediate(true);
    title.addValidator(new BeanValidator(TestSession.class, "title"));
    //		title.setValidationVisible(false);
    title.setNullRepresentation("");
    layout.addComponent(title);

    binder.setBuffered(true);

    // button layout
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addStyleName("buttons-margin-top");
    layout.addComponent(buttons);

    createButton = new Button("Create", this);
    if (editmode) createButton.setCaption("Save");
    createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    createButton.setClickShortcut(KeyCode.ENTER);

    cancelButton = new Button("Cancel", this);

    buttons.addComponents(createButton, cancelButton);
    buttons.setComponentAlignment(createButton, Alignment.MIDDLE_LEFT);
    buttons.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    return layout;
  }
Ejemplo n.º 3
0
 /** 提交绑定的fieldGroup */
 public void commitGroup() {
   try {
     scheduleEventFieldGroup.commit();
   } catch (CommitException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 4
0
 @Override
 protected Layout addFields(FieldGroup fieldGroup) {
   Layout l = super.addFields(fieldGroup);
   Field id = (Field) fieldGroup.getField("id");
   id.setRequired(true);
   id.setRequiredError(getApp().getMessage("errorMessage.req", id.getCaption()));
   String idValue = (String) fieldGroup.getItemDataSource().getItemProperty("id").getValue();
   // Hide prefix
   if (idValue != null) { // Means it is not a new sysconfig entry
     id.setReadOnly(false);
     idValue = prefix != null ? idValue.substring(prefix.length()) : idValue;
     id.setValue(idValue);
     id.setReadOnly(true);
   }
   return l;
 }
Ejemplo n.º 5
0
 private ContentType getNewEntity(FieldGroup binder) {
   final ContentTypeModel bean =
       ((BeanItem<ContentTypeModel>) binder.getItemDataSource()).getBean();
   Map<String, String> contentTypeVals = new HashMap<>();
   contentTypeVals.put("name", bean.getName());
   contentTypeVals.put("description", bean.getDescription());
   final ContentType contentType = ContentTypeFactory.getContentType(contentTypeVals);
   return contentType;
 }
Ejemplo n.º 6
0
  private TextField getTextField(String label, String field) {
    final TextField textField = new TextField(label);
    textField.setWidth(250, Unit.PIXELS);
    textField.setNullRepresentation("");
    textField.addValidator(new BeanValidator(AddressModel.class, field));
    textField.setImmediate(true);
    binder.bind(textField, field);

    return textField;
  }
Ejemplo n.º 7
0
 private void saveEditedForm(FieldGroup binder) {
   try {
     binder.commit();
     OperatingCostFacade.getOperatingCostService().merge(getEntity(binder));
     getHome();
     Notification.show("Record UPDATED!", Notification.Type.TRAY_NOTIFICATION);
   } catch (FieldGroup.CommitException e) {
     Notification.show("Values MISSING!", Notification.Type.TRAY_NOTIFICATION);
     getHome();
   }
 }
Ejemplo n.º 8
0
 private void saveEditedForm(FieldGroup binder) {
   try {
     binder.commit();
     contentTypeService.update(getUpdateEntity(binder));
     getHome();
     Notification.show("Record UPDATED!", Notification.Type.HUMANIZED_MESSAGE);
   } catch (FieldGroup.CommitException e) {
     Notification.show("Values MISSING!", Notification.Type.HUMANIZED_MESSAGE);
     getHome();
   }
 }
Ejemplo n.º 9
0
 private ContentType getUpdateEntity(FieldGroup binder) {
   final ContentTypeModel bean =
       ((BeanItem<ContentTypeModel>) binder.getItemDataSource()).getBean();
   final ContentType contentType =
       new ContentType.Builder()
           .name(bean.getName())
           .description(bean.getDescription())
           .id(table.getValue().toString())
           .build();
   return contentType;
 }
Ejemplo n.º 10
0
 @SuppressWarnings("unchecked")
 private Todo getFieldGroupTodo() {
   BeanItem<Todo> item = (BeanItem<Todo>) scheduleEventFieldGroup.getItemDataSource();
   Todo todo = item.getBean();
   // WW_TODO 保存是设置项目id和用户
   if (!StringTool.judgeBlank(todo.getProId())) {
     todo.setProId(projectId);
   }
   if (todo.getAssignedUser() == null) {
     todo.setAssignedUser(LoginHandler.getLoggedInUser().getId());
   }
   return todo;
 }
Ejemplo n.º 11
0
  private void initEditor() {

    editorLayout.addComponent(removeContactButton);

    /* User interface can be created dynamically to reflect underlying data. */
    for (String fieldName : fieldNames) {
      TextField field = new TextField(fieldName);
      editorLayout.addComponent(field);
      field.setWidth("100%");

      /*
       * We use a FieldGroup to connect multiple components to a data
       * source at once.
       */
      editorFields.bind(field, fieldName);
    }

    /*
     * Data can be buffered in the user interface. When doing so, commit()
     * writes the changes to the data source. Here we choose to write the
     * changes automatically without calling commit().
     */
    editorFields.setBuffered(false);
  }
Ejemplo n.º 12
0
 public boolean validate() {
   try {
     binder_Revaloriza.commit();
     return true;
   } catch (CommitException ex) {
     Map<Field<?>, InvalidValueException> invalid_fields = ex.getInvalidFields();
     Iterator<Field<?>> it = invalid_fields.keySet().iterator();
     while (it.hasNext()) {
       Field<?> key = (Field<?>) it.next();
       mensajes.add(
           new BarMessage(
               key.getCaption(),
               invalid_fields.get(key).getMessage() == ""
                   ? Messages.EMPTY_MESSAGE
                   : invalid_fields.get(key).getMessage()));
     }
     return false;
   }
 }
Ejemplo n.º 13
0
  private OperatingCost getEntity(FieldGroup binder) {
    final OperatingCostBean operatingCostsBean =
        ((BeanItem<OperatingCostBean>) binder.getItemDataSource()).getBean();
    final Person driver =
        PersonFacade.getPersonService().findById(operatingCostsBean.getDriverId());

    final OperatingCost operatingCosts =
        new OperatingCost.Builder(new Date())
            .fuelCost(operatingCostsBean.getFuelCost())
            .fuelLitres(operatingCostsBean.getFuelLitres())
            .oilCost(operatingCostsBean.getOilCost())
            .oilLitres(operatingCostsBean.getOilLitres())
            .speedometer(operatingCostsBean.getSpeedometer())
            .slipNo(operatingCostsBean.getSlipNo())
            .driver(driver)
            .id(operatingCostsBean.getId())
            .build();

    return operatingCosts;
  }
Ejemplo n.º 14
0
  private void saveForm(FieldGroup binder) {
    final PasswordModel bean =
        ((BeanItem<PasswordModel>) form.binder.getItemDataSource()).getBean();
    try {
      binder.commit();
      if (new PasswordCheckUtil().checkOldPassowrd(bean.getOldpassword())) {
        if (PasswordCheckUtil.comparePasswords(bean.getNewPassword(), bean.getRepeatPassword())) {
          changePassword(bean.getNewPassword());
          Notification.show("Your Password Has Been Changed!", Notification.Type.WARNING_MESSAGE);
        } else {
          Notification.show(
              "There is a Password Mismatch for the New Password",
              Notification.Type.WARNING_MESSAGE);
        }
      } else {
        Notification.show("Your Old Password is Wrong!", Notification.Type.WARNING_MESSAGE);
      }
      getHome();

    } catch (FieldGroup.CommitException e) {
      Notification.show("Values MISSING!", Notification.Type.TRAY_NOTIFICATION);
      getHome();
    }
  }
Ejemplo n.º 15
0
 public void update() {
   binder_esoporte.clear();
   this.txt_id_estado_soporte.setValue("0");
 }
  public GestionNotificacion() {
    super();
    setMargin(true);
    setSpacing(true);
    setSizeFull();
    HorizontalL h1 = new HorizontalL();
    id = new CampoRuc();
    razonSocial = new CampoRazonSocial();
    razonSocial.setWidth("320px");
    direccion = new CampoDireccion();
    direccion.setWidth("450px");
    correoElectronico = new CampoCorreoElectronico();
    correoElectronico.setWidth("260px");

    tipoIdentificacion = new ComboBox();
    tipoIdentificacion.addItem("04");
    tipoIdentificacion.addItem("05");
    tipoIdentificacion.addItem("06");
    tipoIdentificacion.addItem("07");
    tipoIdentificacion.addItem("08");
    tipoIdentificacion.setItemCaption("04", "RUC");
    tipoIdentificacion.setItemCaption("05", "CEDULA");
    tipoIdentificacion.setItemCaption("06", "PASAPORTE");
    tipoIdentificacion.setItemCaption("07", "CONSUMIDOR FINAL");
    tipoIdentificacion.setItemCaption("08", "IDENTIFICADOR EXTERIOR");
    tipoIdentificacion.setNullSelectionAllowed(false);
    tipoIdentificacion.setValue("04");
    tipoIdentificacion.setWidth("140px");

    h1.addComponent(tipoIdentificacion, id);
    h1.addComponent("Razón Social", razonSocial);
    // h1.addComponent("Dirección",direccion);
    h1.addComponent("Email", correoElectronico);
    botonAnadir = new BotonAnadir();

    addComponent(h1);
    setComponentAlignment(h1, Alignment.TOP_CENTER);
    HorizontalL h2 = new HorizontalL();
    h2.addComponent("direccion", direccion);
    h2.addComponent(botonAnadir);
    addComponent(h2);

    grid = new Grid();
    beanItemC = new BeanItemContainer<DemografiaCliente>(DemografiaCliente.class);
    grid.setContainerDataSource(beanItemC);
    //		DemografiaCliente d=new DemografiaCliente();
    //		beanItemC.addBean(d);
    grid.removeColumn("entidadEmisora");
    grid.getColumn("id").setHeaderCaption("Identificacion");
    grid.setColumnOrder("razonSocial", "identificacion", "direccion", "correoElectronico");
    grid.setSizeFull();
    grid.removeColumn("tipoIdentificacion");
    grid.removeColumn("id");
    botonCancelar = new BotonCancelar();

    addComponent(grid);
    addComponent(botonCancelar);
    setComponentAlignment(botonCancelar, Alignment.BOTTOM_RIGHT);
    setComponentAlignment(h2, Alignment.TOP_CENTER);
    setExpandRatio(h1, 1);
    setExpandRatio(h2, 1);
    setExpandRatio(grid, 8);
    setExpandRatio(botonCancelar, 1);
    nuevoDato = new DemografiaCliente();
    beanItem = new BeanItem<DemografiaCliente>(nuevoDato);
    fg = new FieldGroup();
    fg.setItemDataSource(beanItem);
  }
Ejemplo n.º 17
0
  private void initUI() {
    addStyleName(Reindeer.WINDOW_LIGHT);
    setModal(true);
    setHeight("90%");
    setWidth("60%");
    center();

    HorizontalLayout bottom = new HorizontalLayout();
    bottom.setStyleName(ExplorerLayout.THEME);
    bottom.setSizeFull();
    // bottom.setMargin(true);
    bottom.setSpacing(true);
    bottom.addStyleName(Runo.LAYOUT_DARKER);
    this.setContent(bottom);

    scheduleEventFieldGroup = new FieldGroup();
    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
      scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }

    line = new GridLayout(4, 20);
    line.addStyleName("v-gridlayout");
    line.setWidth("100%");
    line.setSpacing(true);
    line.setMargin(true);

    final Label lbTitle = CommonFieldHandler.createLable("计划名称:");
    line.addComponent(lbTitle);
    line.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
    final TextField txtTitle = new TextField();
    txtTitle.setWidth("80%");
    scheduleEventFieldGroup.bind(txtTitle, "name");
    line.addComponent(txtTitle, 1, 0, 3, 0);
    line.setComponentAlignment(txtTitle, Alignment.MIDDLE_LEFT);

    Label label2 = CommonFieldHandler.createLable("开始时间:");
    line.addComponent(label2, 0, 1, 0, 1);
    line.setComponentAlignment(label2, Alignment.MIDDLE_RIGHT);
    // 创建一个时间后台变化的listener
    BlurListener startTimeListener = createTimeReCountListener();
    DateField startDateField = CommonFieldHandler.createDateField("", false);
    scheduleEventFieldGroup.bind(startDateField, "startDate");
    startDateField.addBlurListener(startTimeListener);
    line.addComponent(startDateField, 1, 1, 1, 1);
    line.setComponentAlignment(startDateField, Alignment.MIDDLE_LEFT);

    Label label3 = CommonFieldHandler.createLable("估算时间:");
    line.addComponent(label3, 2, 1, 2, 1);
    line.setComponentAlignment(label3, Alignment.MIDDLE_RIGHT);
    HorizontalLayout hlay = new HorizontalLayout();
    final TextField estimateField = new TextField();
    estimateField.setValue("1");
    estimateField.setWidth("60px");
    estimateField.setNullSettingAllowed(false);
    BlurListener timeReCountListener = createTimeReCountListener();
    estimateField.addBlurListener(timeReCountListener);
    scheduleEventFieldGroup.bind(estimateField, "estimate");
    hlay.addComponent(estimateField);
    Map<Object, String> data = new HashMap();
    data.put(0, "天");
    data.put(1, "时");
    data.put(2, "分");
    // WW_TODO 估算时间单位
    ComboBox unit_cb = createComboBox(data, "55px");
    scheduleEventFieldGroup.bind(unit_cb, "estimateUnit");
    hlay.addComponent(unit_cb);
    line.addComponent(hlay, 3, 1, 3, 1);
    line.setComponentAlignment(hlay, Alignment.MIDDLE_LEFT);

    Label label4 = CommonFieldHandler.createLable("到期时间:");
    line.addComponent(label4, 0, 2, 0, 2);
    line.setComponentAlignment(label4, Alignment.MIDDLE_RIGHT);
    completionDateField = CommonFieldHandler.createDateField("", false);
    line.addComponent(completionDateField, 1, 2, 1, 2);
    line.setComponentAlignment(completionDateField, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(completionDateField, "completionDate");
    //		line.setExpandRatio(completionDateField, 1.0f);

    Label label6 = CommonFieldHandler.createLable("消耗时间:");
    line.addComponent(label6, 2, 2, 2, 2);
    line.setComponentAlignment(label6, Alignment.MIDDLE_RIGHT);
    TextField gs1 = new TextField();
    gs1.setValue("20%");
    gs1.setInputPrompt("50%");
    scheduleEventFieldGroup.bind(gs1, "useup");
    line.addComponent(gs1, 3, 2, 3, 2);
    line.setComponentAlignment(gs1, Alignment.MIDDLE_LEFT);

    Label label5 = CommonFieldHandler.createLable("优先级:");
    //		label.setWidth("80px");
    line.addComponent(label5, 0, 3, 0, 3);
    line.setComponentAlignment(label5, Alignment.MIDDLE_RIGHT);
    Map<Object, String> dtp = new HashMap();
    dtp.put(0, "底");
    dtp.put(1, "中");
    dtp.put(2, "高");
    ComboBox selectPriority = createComboBox(dtp, "100px");
    //		NativeSelect select = new NativeSelect();
    //		select.addItem("无");
    //		select.addItem("0(最低)");
    //		String itemId = "1(中)";
    //		select.addItem(itemId);
    //		select.addItem("2(高)");
    selectPriority.setNullSelectionAllowed(false);
    selectPriority.select(2);
    scheduleEventFieldGroup.bind(selectPriority, "priority");
    line.addComponent(selectPriority, 1, 3, 1, 3);
    line.setComponentAlignment(selectPriority, Alignment.MIDDLE_LEFT);

    Label label1 = CommonFieldHandler.createLable("完成百分比:");
    line.addComponent(label1, 2, 3, 2, 3);
    line.setComponentAlignment(label1, Alignment.MIDDLE_RIGHT);
    TextField tf = new TextField();
    tf.setInputPrompt("50%");
    line.addComponent(tf, 3, 3, 3, 3);
    line.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);

    Label label7 = CommonFieldHandler.createLable("关联日程:");
    line.addComponent(label7, 0, 4, 0, 4);
    line.setComponentAlignment(label7, Alignment.MIDDLE_RIGHT);
    CheckBox relatedCalendar_cb = new CheckBox();
    relatedCalendar_cb.setValue(false);
    line.addComponent(relatedCalendar_cb, 1, 4, 1, 4);
    line.setComponentAlignment(relatedCalendar_cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(relatedCalendar_cb, "relatedCalendar");

    Label lbStatus = CommonFieldHandler.createLable("计划状态:");
    lbStatus.setWidth("20px");
    line.addComponent(lbStatus, 2, 4, 2, 4);
    line.setComponentAlignment(lbStatus, Alignment.MIDDLE_RIGHT);
    Map<Object, String> sta = new HashMap();
    sta.put(0, "新建");
    sta.put(1, "完成");
    sta.put(2, "关闭");
    sta.put(3, "取消");
    ComboBox sectStatus = createComboBox(sta, "100px");
    sectStatus.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectStatus, "status");
    line.addComponent(sectStatus, 3, 4, 3, 4);
    line.setComponentAlignment(sectStatus, Alignment.MIDDLE_LEFT);

    Label label8 = CommonFieldHandler.createLable("关联外部任务:");
    label8.setWidth("20px");
    line.addComponent(label8, 0, 5, 0, 5);
    line.setComponentAlignment(label8, Alignment.MIDDLE_RIGHT);
    CheckBox cb = new CheckBox();
    cb.setValue(true);
    line.addComponent(cb, 1, 5, 1, 5);
    line.setComponentAlignment(cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(cb, "relatedTask");

    Label label9 = CommonFieldHandler.createLable("外部任务类型:");
    label9.setWidth("20px");
    line.addComponent(label9, 2, 5, 2, 5);
    line.setComponentAlignment(label9, Alignment.MIDDLE_RIGHT);
    Map<Object, String> oat = new HashMap();
    oat.put(0, "外包任务");
    oat.put(1, "外包任务-类型2");
    ComboBox select2 = createComboBox(oat, "150px");
    //		NativeSelect select2 = new NativeSelect();
    //		select2.addItem("外包任务");
    //		select2.addItem("外包任务-类型2");
    select2.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(select2, "type");
    line.addComponent(select2, 3, 5, 3, 5);
    line.setComponentAlignment(select2, Alignment.MIDDLE_LEFT);
    // select2.select("Timed");

    Label lbOwnGrp = CommonFieldHandler.createLable("计划分配团队:");
    lbOwnGrp.setWidth("20px");
    line.addComponent(lbOwnGrp, 0, 6, 0, 6);
    line.setComponentAlignment(lbOwnGrp, Alignment.MIDDLE_RIGHT);

    //		NativeSelect sectOwnGrp = new NativeSelect();
    Map<Object, String> groupsMap =
        teamService.queryTeamOfUser(LoginHandler.getLoggedInUser().getId());
    groupsMap.put("", "请选择");
    ComboBox sectOwnGrp = createComboBox(groupsMap, "150px");
    //		for (String p : groupsMap.keySet()) {
    //			String title = groupsMap.get(p);
    //			sectOwnGrp.addItem(p);
    //			sectOwnGrp.setItemCaption(p, title);
    //		}
    sectOwnGrp.setNullSelectionAllowed(false);
    ValueChangeListener valueChangeListener = createValueChangeListener();
    sectOwnGrp.addValueChangeListener(valueChangeListener);
    sectOwnGrp.setImmediate(true);
    scheduleEventFieldGroup.bind(sectOwnGrp, "assignedTeam");
    line.addComponent(sectOwnGrp, 1, 6, 1, 6);
    line.setComponentAlignment(sectOwnGrp, Alignment.MIDDLE_LEFT);

    final Label lbOwner = CommonFieldHandler.createLable("计划分配用户:");
    lbOwner.setWidth("20px");
    line.addComponent(lbOwner, 2, 6, 2, 6);
    line.setComponentAlignment(lbOwner, Alignment.MIDDLE_RIGHT);
    //		sectOwner = new NativeSelect();
    //		sectOwner.addItem("请选择");
    sectOwner.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectOwner, "assignedUser");
    line.addComponent(sectOwner, 3, 6, 3, 6);
    line.setComponentAlignment(sectOwner, Alignment.MIDDLE_LEFT);

    final Label lbDesc = CommonFieldHandler.createLable("计划描述:");
    lbDesc.setWidth("15px");
    line.addComponent(lbDesc, 0, 7, 0, 7);
    line.setComponentAlignment(lbDesc, Alignment.MIDDLE_RIGHT);
    final TextArea taDesc = CommonFieldHandler.createTextArea("");
    taDesc.setWidth("85%");
    taDesc.setHeight("290px");
    scheduleEventFieldGroup.bind(taDesc, "description");
    line.addComponent(taDesc, 1, 7, 3, 13);
    line.setComponentAlignment(taDesc, Alignment.MIDDLE_LEFT);

    //		CKEditorConfig config = new CKEditorConfig();

    final Button updateSave = new Button("保存");
    updateSave.addClickListener(
        new ClickListener() {
          @SuppressWarnings("unchecked")
          public void buttonClick(ClickEvent event) {
            // WW_TODO 修改保存到数据库
            Todo fieldGroupTodo = saveFieldGroupToDB();
            fireEvent(
                new SubmitEvent(
                    updateSave,
                    SubmitEvent.SUBMITTED,
                    scheduleEventFieldGroup.getItemDataSource()));

            // close popup window
            close();
            /*
             * Todo fieldGroupTodo = saveFieldGroupToDB(); //reflash current
             * Item copyBeanValueToContainer(hContainer,(BeanItem<Todo>)(
             * scheduleEventFieldGroup.getItemDataSource())); //刷新日历
             * main.refreshCalendarView(); Notification.show("保存成功",
             * Notification.Type.HUMANIZED_MESSAGE); //如果有外部流程,启动外部流程 if
             * (fieldGroupTodo.getRelatedTask()) { ViewToolManager
             * .showPopupWindow(new ActivityStartPopupWindow( "1111")); }
             */
            if (fieldGroupTodo.getRelatedTask()) {
              ViewToolManager.showPopupWindow(new ActivityStartPopupWindow("1111"));
            }
          }
        });
    line.addComponent(updateSave, 3, 14, 3, 14);
    line.setComponentAlignment(updateSave, Alignment.MIDDLE_RIGHT);
    //		line.setExpandRatio(updateSave, 1.0f);

    bottom.addComponent(line);
  }
  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();
  }
Ejemplo n.º 19
0
  public DateFields() {
    setMargin(true);

    Label h1 = new Label("Date Fields");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    row.setSpacing(true);
    addComponent(row);

    DateField date = new DateField("Default resolution");
    setDate(date);
    row.addComponent(date);

    date = new DateField("Error");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(date);

    date = new DateField("Error, borderless");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
    row.addComponent(date);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    row.addComponent(group);

    final DateField date2 = new DateField();
    group.addComponent(date2);

    Button today =
        new Button(
            "Today",
            new ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                date2.setValue(new Date());
              }
            });
    group.addComponent(today);

    date = new DateField("Default resolution, explicit size");
    setDate(date);
    row.addComponent(date);
    date.setWidth("260px");
    date.setHeight("60px");

    date = new DateField("Second resolution");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    row.addComponent(date);

    date = new DateField("Minute resolution");
    setDate(date);
    date.setResolution(Resolution.MINUTE);
    row.addComponent(date);

    date = new DateField("Hour resolution");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    row.addComponent(date);

    date = new DateField("Disabled");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    date.setEnabled(false);
    row.addComponent(date);

    date = new DateField("Day resolution");
    setDate(date);
    date.setResolution(Resolution.DAY);
    row.addComponent(date);

    date = new DateField("Month resolution");
    setDate(date);
    date.setResolution(Resolution.MONTH);
    row.addComponent(date);

    date = new DateField("Year resolution");
    setDate(date);
    date.setResolution(Resolution.YEAR);
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color1");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color2");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color3");
    row.addComponent(date);

    date = new DateField("Small");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_SMALL);
    row.addComponent(date);

    date = new DateField("Large");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_LARGE);
    row.addComponent(date);

    date = new DateField("Borderless");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
    row.addComponent(date);

    date = new DateField("Week numbers");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    date = new DateField("US locale");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    date.setLocale(new Locale("en", "US"));
    row.addComponent(date);

    date = new DateField("Custom format");
    setDate(date);
    date.setDateFormat("E dd/MM/yyyy");
    row.addComponent(date);

    date = new DateField("Tiny");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_TINY);
    row.addComponent(date);

    date = new DateField("Huge");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_HUGE);
    row.addComponent(date);

    date = new InlineDateField("Date picker");
    setDate(date);
    setDateRange(date);
    row.addComponent(date);

    date = new InlineDateField("Date picker with week numbers");
    setDate(date);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty("date", new ObjectProperty<Date>(getDefaultDate()));

    FormLayout form = new FormLayout();
    form.setMargin(false);

    FieldGroup binder = new FieldGroup(item);
    form.addComponent(binder.buildAndBind("Picker in read-only field group", "date"));
    binder.setReadOnly(true);

    row.addComponent(form);
  }
Ejemplo n.º 20
0
  public void buttonClick(ClickEvent event) {
    if (event.getButton() == createButton) {

      TestSession queriedSession = null;
      String wrongTitle = "";

      try {
        //						form.enableValidationMessages();
        //					title.setValidationVisible(true);

        // commit the fieldgroup
        binder.commit();

        // check SESSION title doesnt exist for THIS SESSION
        int id = 0;
        boolean titleOK = true;
        id = newSessionItem.getBean().getId(); // testsession.getId();
        // System.out.println("parentCase.getSessions() : " + parentcase.getSessions());
        for (TestSession s : parentcase.getSessions()) { // sessions.getItemIds()
          // System.out.println("Existing title -> new title : " + s.getTitle() + "->" +
          // testsession.getTitle());
          // System.out.println("Existing id -> new id : " + s.getId() + "->" + id);
          if (s.getTitle().equals(testsession.getTitle()) && !(s.getId() == id)) {
            testsession.setTitle(prevTitle);
            if (clonemode != true && editmode == true) {
              sessions.addEntity(testsession);
            }
            wrongTitle = s.getTitle();

            titleOK = false;
            break;
          }
        }

        if (titleOK == true) {
          // System.out.println("TITLE WAS FINE. EDITING");

          // add NEW bean object to db through jpa container
          if (editmode == false && (clonemode == false)) {

            // add to container
            sessions.addEntity(newSessionItem.getBean()); // jpa container

            // add created item to tree (after retrieving db generated id)
            EntityManager em =
                Persistence.createEntityManagerFactory("mbpet").createEntityManager();
            Query query =
                em.createQuery(
                    "SELECT OBJECT(t) FROM TestSession t WHERE t.title = :title AND t.parentcase = :parentcase");
            //		            query.setParameter("title", newsession.getTitle());
            query.setParameter("title", testsession.getTitle());
            query.setParameter("parentcase", testsession.getParentcase()); // MainView.sessionUser
            queriedSession = (TestSession) query.getSingleResult();
            //				            queriedSession = (TestSession) query.setParameter("title",
            // testsession.getTitle()).getSingleResult();
            // System.out.println("the generated id is: " + queriedSession.getId());
            id = queriedSession.getId(); // here is the id we need for tree

            // create session directory for test and reports
            new FileSystemUtils()
                .createSessionTestDir(
                    testsession.getParentcase().getOwner().getUsername(),
                    testsession.getParentcase().getTitle(),
                    testsession.getTitle());

            // create default parameters object
            new ParametersEditor(sessions.getItem(id).getEntity());

            // create empty adapter object
            new AdapterEditor(sessions.getItem(id).getEntity());

            // create empty adapterXML object
            new AdapterXMLEditor(sessions.getItem(id).getEntity());

            // create default models
            ModelUtils modelUtils = new ModelUtils();
            modelUtils.createDefaultModel(
                "user_types", sessions.getItem(id).getEntity()); // currmodel.getParentsession(),
            modelUtils.createDefaultModel(
                "normal_user", sessions.getItem(id).getEntity()); // currmodel.getParentsession(),

            // add to tree in right order
            if (tree.hasChildren(parentcase.getId())) {
              sortAddToTree(id);
            } else {
              tree.addItem(id);
              tree.setParent(id, parentcase.getId());
              tree.setChildrenAllowed(id, false);
              tree.setItemCaption(
                  id, sessions.getItem(id).getEntity().getTitle()); // newsession.getTitle()
              tree.expandItem(parentcase.getId());
              tree.select(id);
            }

            // update parent Case to add Session to testCase List<Session> sessions
            parentcase.addSession(queriedSession);
            testcases.addEntity(parentcase);
            //              	  	List<TestSession> listofsessions = parentCase.getSessions();
            //              	  	listofsessions.add(queriedSession);
            //	//sessions.getItem(id).getEntity()
            //              	  	parentCase.setSessions(listofsessions);

            //									System.out.println("WHAT IS NEW LIST OF SESSIONS: "
            //													+ parentcase.getSessions()); // testing purposes
            //									for (TestSession s : parentcase.getSessions()) {
            //										System.out.println(s.getId() + " - "
            //												+ s.getTitle()); // testing purposes
            //									}

          } else if (editmode == true) {
            // EDIT existing object

            //								// commit the fieldgroup
            //								binder.commit();

            // 1 UPDATE parentcase reference
            parentcase.updateSessionData(sessions.getItem(testsession.getId()).getEntity());

            // System.out.println("Test session is now: " + testsession.getTitle());

            // 2 UPDATE container
            sessions.addEntity(newSessionItem.getBean());
            // System.out.println("Entity is now: " +
            // sessions.getItem(testsession.getId()).getEntity().getTitle());

            // 3 UPDATE tree title
            tree.setItemCaption(
                testsession.getId(), sessions.getItem(testsession.getId()).getEntity().getTitle());

            // 4. UPDATE models (maybe not necessary)
            //
            //	ModelEditorTable.modelsTable.setContainerDataSource(ModelEditorTable.modelsTable.getContainerDataSource());
            //			              	  	for (Model m : testsession.getModels()) {
            //
            //	m.setParentsession(sessions.getItem(testsession.getId()).getEntity());
            //			              	  		System.out.println("Sessions' model's session title: " +
            // m.getParentsession().getTitle());
            ////
            //	m.updateSessionData(sessions.getItem(testsession.getId()).getEntity());
            //			              	  	}

            // edit session directory for test and reports
            if (!prevTitle.equals(testsession.getTitle())) {
              new FileSystemUtils()
                  .renameSessionDir(
                      testsession.getParentcase().getOwner().getUsername(),
                      testsession.getParentcase().getTitle(),
                      prevTitle,
                      testsession.getTitle());
            }

            //			              	  	// update parameters and adapter ?
            // System.out.println("Sessions' params's session title: " +
            // testsession.getParameters().getOwnersession().getTitle());
            // System.out.println("Sessions' adapter session title: " +
            // testsession.getAdapter().getOwnersession().getTitle());
            // System.out.println("Sessions' adapterXML session title: " +
            // testsession.getAdapterXML().getOwnersession().getTitle());

            id = testsession.getId();

          } else if (clonemode == true) {
            // CLONE
            // System.out.println("\n\nWE ARE IN CLONE MODE!!!!!!!!!\n\n");

            //							TestSession clone = newSessionItem.getBean();
            //								// 1 commit the fieldgroup
            //								binder.commit();

            // 2 add to container
            sessions.addEntity(newSessionItem.getBean()); // jpa container

            // 3 retrieving db generated id
            EntityManager em =
                Persistence.createEntityManagerFactory("mbpet").createEntityManager();
            Query query =
                em.createQuery("SELECT OBJECT(t) FROM TestSession t WHERE t.title = :title");
            //		            query.setParameter("title", newsession.getTitle());
            queriedSession =
                (TestSession) query.setParameter("title", testsession.getTitle()).getSingleResult();
            // System.out.println("the generated id is: " + queriedSession.getId());
            id = queriedSession.getId(); // here is the id we need for tree

            // 4 clone models
            EntityManager em2 =
                Persistence.createEntityManagerFactory("mbpet").createEntityManager();
            Query query2 =
                em2.createQuery(
                    "SELECT OBJECT(m) FROM Model m WHERE m.title = :title AND m.parentsession = :parentsession");
            for (Model m : subject.getModels()) {
              // copy over model values
              Model newmodel =
                  new Model(m.getTitle(), queriedSession, m.getParentsut()); // "(clone) " +
              newmodel.setDotschema(m.getDotschema());

              // add to container
              models.addEntity(newmodel); // jpa container

              // retrieve generated id from db
              query2.setParameter("title", newmodel.getTitle());
              query2.setParameter("parentsession", queriedSession);
              Model queriedModel = (Model) query2.getSingleResult();
              // System.out.println("the generated MODEL id is: " + queriedModel.getId() + " of
              // session ->" + queriedSession.getId());

              // update parent Case to add Session to testCase List<Session> sessions
              parentcase.addModel(queriedModel);
              queriedSession.addModel(queriedModel);

              //						            //write model to disk
              //						            FileSystemUtils fileUtils = new FileSystemUtils();
              //						            fileUtils.writeModelToDisk(
              //						            		parentcase.getOwner().getUsername(),
              //						            		parentcase.getTitle(),
              //						            		queriedSession.getTitle(),
              //						            		queriedSession.getParameters().getModels_folder(),
              //						            		queriedModel);
            }
            sessions.addEntity(queriedSession);

            // 5 clone parameters
            String cloneParams =
                "Fill in parameters for Test Session '" + queriedSession.getTitle() + "'";
            if (!(subject.getParameters().getSettings_file()
                == null)) { // || !(testsession.getParameters().getSettings_file().equals(""))
              cloneParams = subject.getParameters().getSettings_file();
            }
            //					            System.out.println("\n\n the cloned parameters are:\n" +
            //					            		cloneParams + "\n\n");
            new ParametersEditor(queriedSession, cloneParams);

            // 6 clone adapter.py
            String cloneAdapter =
                "Fill in adapter for Test Session '" + queriedSession.getTitle() + "'";
            if (!(subject.getAdapter().getAdapter_file() == null)
                || !(subject
                    .getAdapter()
                    .getAdapter_file()
                    .equals(
                        ""))) { // || !(testsession.getParameters().getSettings_file().equals(""))
              cloneAdapter = subject.getAdapter().getAdapter_file();
            }
            //					            System.out.println("\n\n the cloned adapter is:\n" +
            //					            		cloneAdapter + "\n\n");
            new AdapterEditor(queriedSession, cloneAdapter);

            // 7 clone adapter.xml
            String cloneAdapterXML =
                "Fill in adapterXML for Test Session '" + queriedSession.getTitle() + "'";
            if (!(subject.getAdapterXML().getAdapterXML_file() == null)
                || !(subject
                    .getAdapterXML()
                    .getAdapterXML_file()
                    .equals(
                        ""))) { // || !(testsession.getParameters().getSettings_file().equals(""))
              cloneAdapterXML = subject.getAdapterXML().getAdapterXML_file();
            }
            //					            System.out.println("\n\n the cloned adapterXML is:\n" +
            //					            		cloneAdapterXML + "\n\n");
            new AdapterXMLEditor(queriedSession, cloneAdapterXML);

            // 8 write models to disk
            FileSystemUtils fileUtils = new FileSystemUtils();
            fileUtils.writeModelsToDisk(
                parentcase.getOwner().getUsername(),
                parentcase.getTitle(),
                queriedSession.getTitle(),
                queriedSession.getParameters().getModels_folder(),
                subject.getModels());

            // 9 add to tree in right order
            if (tree.hasChildren(parentcase.getId())) {
              sortAddToTree(id);
            } else {
              tree.addItem(id);
              tree.setParent(id, parentcase.getId());
              tree.setChildrenAllowed(id, false);
              tree.setItemCaption(
                  id, sessions.getItem(id).getEntity().getTitle()); // newsession.getTitle()
              tree.expandItem(parentcase.getId());
              tree.select(id);
            }

            // 10 update parent Case to add Session to testCase List<Session> sessions
            parentcase.addSession(queriedSession);
            //              	  	List<TestSession> listofsessions = parentCase.getSessions();
            //              	  	listofsessions.add(queriedSession);
            //	//sessions.getItem(id).getEntity()
            //              	  	parentCase.setSessions(listofsessions);

            // 9 create session directory for test and reports
            new FileSystemUtils()
                .createSessionTestDir(
                    queriedSession.getParentcase().getOwner().getUsername(),
                    queriedSession.getParentcase().getTitle(),
                    queriedSession.getTitle());

            //				            	System.out.println("WHAT IS NEW LIST OF SESSIONS: " +
            // parentCase.getSessions()); // testing purposes
            //				            	for (TestSession s : parentCase.getSessions()) {
            //					            	System.out.println(s.getId() + " - " + s.getTitle()); // testing
            // purposes
            //				            	}
          }

          //			            	System.out.println("WHAT IS NEW LIST OF SESSIONS: " +
          // parentCase.getSessions()); // testing purposes
          //			            	for (TestSession s : parentCase.getSessions()) {
          //				            	System.out.println(s.getId() + " - " + s.getTitle()); // testing
          // purposes
          //			            	}

          if (clonemode == true && navToCasePage == true) {
            confirmNotification(queriedSession.getTitle(), "was created");
            close();

          } else if (clonemode == true && navToCasePage == false) {
            confirmNotification(queriedSession.getTitle(), "was CLONED");
            getUI()
                .getNavigator()
                .navigateTo(
                    MainView.NAME
                        + "/"
                        + parentcase.getTitle()
                        + "/"
                        + queriedSession.getTitle()
                        + "id="
                        + queriedSession
                            .getId()); // sessions.getItem(id).getEntity()
            close();

          } else if (navToCasePage == true && editmode == false) {
            // 4 UPDATE table title
            table.select(newSessionItem.getBean().getId()); // (testsession.getId());
            confirmNotification(testsession.getTitle(), "was created");
            close();

            //		            		getUI().getNavigator()
            //		            			.navigateTo(MainView.NAME + "/" +
            //		            				parentCase.getTitle());		//sessions.getItem(id).getEntity()

          } else if (navToCasePage == true && editmode == true) {
            getUI()
                .getNavigator()
                .navigateTo(
                    MainView.NAME
                        + "/"
                        + parentcase.getTitle()
                        + "-sut="
                        + parentcase.getId()); // sessions.getItem(id).getEntity()		            	
            confirmNotification(testsession.getTitle(), "was edited");
            close();

          } else if (editmode == true && navToCasePage == false) {
            getUI()
                .getNavigator()
                .navigateTo(
                    MainView.NAME
                        + "/"
                        + parentcase.getTitle()
                        + "/"
                        + newSessionItem.getBean().getTitle()
                        + "id="
                        + newSessionItem
                            .getBean()
                            .getId()); // testsession.getTitle() sessions.getItem(id).getEntity()
          } else {
            getUI()
                .getNavigator()
                .navigateTo(
                    MainView.NAME
                        + "/"
                        + parentcase.getTitle()
                        + "/"
                        + queriedSession.getTitle()
                        + "id="
                        + queriedSession
                            .getId()); // testsession.getTitle() sessions.getItem(id).getEntity()
          }

          // title already existed
        } else {
          // System.out.println("title was NOT fine.");
          //							testsession = sessions.getItem(id).getEntity();
          //							System.out.println("db session is: " + testsession.getId() + " " +
          // testsession.getTitle());

          if (editmode == false && clonemode == false) {
            binder.discard();
            Notification.show(
                "The title '"
                    + wrongTitle
                    + "' already exists for this SUT. Please rename this session.",
                Type.ERROR_MESSAGE); // testsession.getTitle()
            UI.getCurrent().addWindow(new TestSessionEditor(tree, table, parentcase, true));
          } else if (editmode == true) {
            binder.discard();
            Notification.show(
                "The title '"
                    + wrongTitle
                    + "' already exists for this SUT. Please rename this session.",
                Type.ERROR_MESSAGE);
            if (navToCasePage == true) {
              UI.getCurrent()
                  .addWindow(
                      new TestSessionEditor(
                          tree,
                          id,
                          parentcase,
                          table)); // sessions.getItem(testsession.getId()).getEntity().getId()
            } else {
              UI.getCurrent().addWindow(new TestSessionEditor(tree, id, parentcase));
            }

          } else if (clonemode == true) {
            binder.discard();
            Notification.show(
                "The title '"
                    + wrongTitle
                    + "' already exists for this SUT. Please rename this session.",
                Type.ERROR_MESSAGE);
            UI.getCurrent()
                .addWindow(
                    new TestSessionEditor(
                        tree,
                        subject.getId(), // testsession sessions.getItem(
                        parentcase,
                        table,
                        true));
          }
        }

      } catch (CommitException e) {
        binder.discard();
        Notification.show("'Title' cannot be Empty. Please try again.", Type.WARNING_MESSAGE);
        UI.getCurrent().addWindow(new TestSessionEditor(tree, parentcase, true));
      } catch (NonUniqueResultException e) {
        e.printStackTrace();
        binder.discard();
        Notification.show(
            "The title '"
                + testsession.getTitle()
                + "' already exists for this SUT. Please rename this session.",
            Type.ERROR_MESSAGE);
        UI.getCurrent().addWindow(new TestSessionEditor(tree, parentcase, true));
      }
      //					catch (NonUniqueResultException e) {
      //						binder.discard();
      //						Notification.show("'Title' must be a unique name.\n'" +
      //											queriedSession.getTitle() +
      //											"' already exists.\n\nPlease try again.", Type.WARNING_MESSAGE);
      //						UI.getCurrent().addWindow(new TestSessionEditor(tree, parentCase));
      //					}

    } else if (event.getButton() == cancelButton) {
      binder.discard();
    }
    //	        binder.clear();
    //	        form.disableValidationMessages();
    //	        setTreeItemsExpanded();

    close(); // Close the sub-window
  }