Exemplo 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);
  }
Exemplo 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;
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
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();
  }