예제 #1
0
  public DepartmentSelector() {
    setImmediate(false);
    // conu = SpringApplicationContext.getContainerUtils();
    container = conu.createJPABatchableContainer(Department.class);
    geoContainer = conu.createJPABatchableContainer(Department.class);
    geoContainer.setAutoCommit(false);
    container.setAutoCommit(false);
    setCaption("Department");
    // Only list "roots" which are in our example geographical super
    // departments
    geoContainer.addContainerFilter(new IsNull("parent"));
    geographicalDepartment.setContainerDataSource(geoContainer);
    geographicalDepartment.setItemCaptionPropertyId("name");
    geographicalDepartment.setImmediate(true);

    container.setApplyFiltersImmediately(false);
    filterDepartments(null);
    department.setContainerDataSource(container);
    department.setItemCaptionPropertyId("name");

    geographicalDepartment.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            /*
             * Modify filtering of the department combobox
             */
            EntityItem<Department> item = geoContainer.getItem(geographicalDepartment.getValue());
            Department entity = item.getEntity();
            filterDepartments(entity);
          }
        });
    department.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            /*
             * Modify the actual value of the custom field.
             */
            if (department.getValue() == null) {
              setValue(null, false);
            } else {
              Department entity = container.getItem(department.getValue()).getEntity();
              setValue(entity, false);
            }
          }
        });
  }
예제 #2
0
  ComboBox userList() {
    users.setCaption("Users: ");
    users.setWidth("200px");
    users.setNullSelectionAllowed(false);
    users.addContainerProperty("y", String.class, "");
    users.setItemCaptionPropertyId("y");

    Item i;
    for (User u : service.getUserList()) {
      i = users.addItem(u.getId());
      i.getItemProperty("y").setValue(u.getUsername());
    }

    users.addListener(
        new ValueChangeListener() {

          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            allowedBackwardInputAttendance.setValue(
                service.isUserAllowedToEnterPreviousAttendance(
                    util.convertStringToInteger(event.getProperty().getValue().toString())));
          }
        });

    users.setImmediate(true);

    return users;
  }
예제 #3
0
  protected final void setupRowPerPageCombo(
      final PMContext ctx, final PaginatedList list, HorizontalLayout l, final PMMainWindow window)
      throws UnsupportedOperationException {
    rowPerPage = new ComboBox();
    rowPerPage.addItem("5");
    rowPerPage.addItem("10");
    rowPerPage.addItem("20");
    rowPerPage.addItem("50");
    if (list.getRowsPerPage() == null) {
      rowPerPage.select("10");
    } else {
      rowPerPage.select(list.getRowsPerPage().toString());
    }
    rowPerPage.setNullSelectionAllowed(false);
    rowPerPage.setNewItemsAllowed(false);
    rowPerPage.setWidth("50px");
    rowPerPage.setFilteringMode(Filtering.FILTERINGMODE_OFF);
    rowPerPage.setImmediate(true);
    rowPerPage.addListener(
        new ValueChangeListener() {

          public void valueChange(Property.ValueChangeEvent event) {
            list.setRowsPerPage(Integer.parseInt((String) event.getProperty().getValue()));
            PMContext c = cloneContext(ctx);
            c.put("rows_per_page", list.getRowsPerPage());
            final ListCommand cmd = new ListCommand(c);
            window.setMainScreen(cmd.execute());
          }
        });
    l.addComponent(rowPerPage);
  }
예제 #4
0
  /**
   * The constructor should first build the main layout, set the composition root and then do any
   * custom initialization.
   *
   * <p>The constructor will not be automatically regenerated by the visual editor.
   */
  public ParameterPathQuestion() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // Parameter Name
    parameterName.setNullRepresentation("");
    parameterName.setRequiredError("Parameter must be filled");

    // TODO: vyrobit skryvani
    // TODO: brat v uvahu fragmenty!!!
    // TODO: link na vnorene fieldy
    BeanItemContainer<ParameterType> parameterTypeContainer =
        new BeanItemContainer<ParameterType>(
            ParameterType.class, Arrays.asList(ParameterType.values()));
    parameterType.setContainerDataSource(parameterTypeContainer);
    parameterType.setImmediate(true);
    parameterType.setNullSelectionAllowed(false);
    parameterType.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void valueChange(ValueChangeEvent event) {
            if (parameterType.getValue() instanceof ParameterType) {
              ParameterType value = (ParameterType) parameterType.getValue();

              if (ParameterType.FIXED.equals(value)) {
                semanticComposite.setVisible(false);
              } else {
                semanticComposite.setVisible(true);
              }
            }
          }
        });
  }
  public JanelaGerenciarUsuarios() {
    this.center();
    this.setWidth("40%");
    this.setHeight("80%");
    this.setModal(true);

    users = new ComboBox("Usuários");
    preencheCB();
    users.setImmediate(true);
    users.addListener(new EventoMostraDados());
    users.setNullSelectionAllowed(false);

    leiaute = new FormLayout();
    leiaute.setSpacing(true);

    titulo = new Label("Gerenciar Usuários");
    nome = new TextField("Nome");
    email = new TextField("E-Mail");
    telefone = new TextField("Telefone");
    cargo = new TextField("Cargo");
    login = new TextField("Login");
    senha1 = new PasswordField("Senha");
    senha2 = new PasswordField("Confirme a senha");
    admin = new CheckBox("Administrador? ");
    bloquear = new CheckBox("Bloqueado? ");
    // bloquear.setEnabled(false);

    addUser = new Button("Adicionar Usuário");
    addUser.addListener(new EventoNovoUsuario());

    editar = new Button("Editar Usuário");
    editar.addListener(new EventoEditarUsuario());

    excluir = new Button("Excluir Usuário");
    excluir.addListener(new EventoExclusao());

    desligaCampos();

    leiaute.addComponent(titulo);
    leiaute.addComponent(users);
    leiaute.addComponent(nome);
    leiaute.addComponent(email);
    leiaute.addComponent(telefone);
    leiaute.addComponent(cargo);
    leiaute.addComponent(login);
    leiaute.addComponent(senha1);
    leiaute.addComponent(senha2);
    leiaute.addComponent(admin);
    leiaute.addComponent(bloquear);
    leiaute.addComponent(addUser);
    leiaute.addComponent(editar);
    leiaute.addComponent(excluir);

    this.addComponent(leiaute);
  }
예제 #6
0
  @Override
  protected void setup() {

    List<String> list = new ArrayList<String>();
    for (int i = 0; i < 100; i++) {
      list.add("Item " + i);
    }

    ComboBox cb = new ComboBox("Combobox", list);
    cb.setImmediate(true);
    cb.setInputPrompt("Enter text");
    cb.setDescription("Some Combobox");
    addComponent(cb);

    final ObjectProperty<String> log = new ObjectProperty<String>("");

    cb.addListener(
        new FieldEvents.FocusListener() {
          public void focus(FocusEvent event) {
            log.setValue(log.getValue().toString() + "<br>" + counter + ": Focus event!");
            counter++;
          }
        });

    cb.addListener(
        new FieldEvents.BlurListener() {
          public void blur(BlurEvent event) {
            log.setValue(log.getValue().toString() + "<br>" + counter + ": Blur event!");
            counter++;
          }
        });

    TextField field = new TextField("Some textfield");
    field.setImmediate(true);
    addComponent(field);

    Label output = new Label(log);
    output.setCaption("Events:");

    output.setContentMode(Label.CONTENT_XHTML);
    addComponent(output);
  }
예제 #7
0
    public void attach() {
      this.addStyleName("custom-report-step-caption");
      Label caption = new Label("Select Reference Table");
      caption.setStyleName("caption");
      this.addComponent(caption);
      box.setWidth(fieldWidth);
      box.setImmediate(true);
      box.addStyleName("custom-report-step-box");
      BeanItemContainer<ReportModel> container =
          new BeanItemContainer<ReportModel>(ReportModel.class);
      container.addAll(getReportModels());
      box.setContainerDataSource(container);
      box.setItemCaptionPropertyId("tableLabel");
      box.addListener(this);
      this.addComponent(box);
      columnLayout.setSpacing(true);
      columnLayout.setVisible(false);

      //			List<ReportTable> relateReportTables=null;
      //			if(getEditableReportTable()!=null){
      //				for(Iterator<ReportModel> it=container.getItemIds().iterator();it.hasNext();){
      //					rm=(ReportModel) it.next();
      //					if(rm.getTableName().equals(getEditableReportTable().getTableName())){
      //						box.setValue(rm);
      //						mainReportTable=rm.getReportTables().iterator().next();
      //						relateReportTables=buildEditableRelatedTableInfo();
      //						break;
      //					}
      //				}
      //				box.setValue(getEditableReportTable().getTableName());
      //				rm.getReportTables().addAll(relateReportTables);
      //			}

      if (relateReportTables != null && isEditableFlg) {
        columnLayout.setVisible(true);
        columnLayout.setImmediate(true);
        //				columnLayout.addComponent(gridLayout);

        //				box.setValue(getEditableReportTable().getTableName());
        //				rm.getReportTables().addAll(relateReportTables);

        for (ReportTable relateRT : relateReportTables) {
          for (Iterator<ReportModel> it = container.getItemIds().iterator(); it.hasNext(); ) {
            ReportModel tempRm = it.next();
            if (tempRm.getTableName().equals(relateRT.getTableName())) {
              box.setValue(tempRm);
              break;
            }
          }
          List<ReportColumn> columnFields = relateRT.getReportColumns();

          for (final ReportColumn columnField : columnFields) {
            if (columnField.getColumnLabel() != null) {
              ReportColumnCard reportColumnCard =
                  new ReportColumnCard(columnField) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void layoutClick(LayoutClickEvent event) {
                      ReportColumn reportColumn = columnField;
                      reportColumn.setColumnUseMode(
                          ReportConfiguration.ReportColumnType.OutputColumn.toString());
                      rm.getSubTableSelectedColumns().add(reportColumn);
                    }
                  };

              for (ReportColumn rc : relateRT.getReportColumns()) {
                if (rc.getColumnUseMode() != null
                    && rc.getColumnUseMode()
                        .equals(ReportConfiguration.ReportColumnType.OutputColumn.toString())) {
                  if (rc.getColumnName().equals(columnField.getColumnName())) {
                    reportColumnCard.getCheckBox().setValue(true);
                  }
                }
              }

              gridLayout.addComponent(reportColumnCard);
            }
          }
        }
      }

      this.addComponent(columnLayout);
      reportColumnLabel.setStyleName("custom-report-step-column-caption");
      reportColumnLabel.setVisible(false);
      reportColumnStepDesc.setStyleName("custom-report-step-column-desc");
      reportColumnStepDesc.setVisible(false);
      this.addComponent(reportColumnLabel);
      this.addComponent(reportColumnStepDesc);
      gridLayout.setSizeFull();
      gridLayout.setImmediate(true);
      gridLayout.addStyleName("custom-report-step-column-gridlayout");
      this.addComponent(gridLayout);
    }
  /**
   * Instantiates a new include collection window.
   *
   * @param dataCollectionConfigDao the data collection configuration DAO
   * @param container the source list of elements
   * @param wrapper the current selected value
   */
  public IncludeCollectionWindow(
      final DataCollectionConfigDao dataCollectionConfigDao,
      final BeanItemContainer<IncludeCollectionWrapper> container,
      final IncludeCollectionWrapper wrapper) {

    setCaption("Include SystemDef/DataCollectionGroup");
    setModal(true);
    setWidth("400px");
    setHeight("180px");
    setResizable(false);
    setClosable(false);
    addStyleName(Runo.WINDOW_DIALOG);

    form.setImmediate(true);
    form.setWidth("100%");
    form.setWriteThrough(false);
    form.getLayout().setMargin(true);

    final ComboBox valueField = new ComboBox("Value");
    valueField.setEnabled(false);
    valueField.setRequired(true);
    valueField.setImmediate(true);
    valueField.setNewItemsAllowed(false);
    valueField.setNullSelectionAllowed(false);

    final ComboBox typeField = new ComboBox("Type");
    typeField.setRequired(true);
    typeField.setImmediate(true);
    typeField.setNewItemsAllowed(false);
    typeField.setNullSelectionAllowed(false);
    typeField.addItem(IncludeCollectionWrapper.DC_GROUP);
    typeField.addItem(IncludeCollectionWrapper.SYSTEM_DEF);
    typeField.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            String selected = (String) typeField.getValue();
            if (selected == null) {
              return;
            }
            // Get available fields.
            // FIXME If a new dcGroup is added, DataCollectionConfigDao is not able to reach it.
            List<String> values =
                selected.equals(IncludeCollectionWrapper.SYSTEM_DEF)
                    ? dataCollectionConfigDao.getAvailableSystemDefs()
                    : dataCollectionConfigDao.getAvailableDataCollectionGroups();
            // Remove already selected
            for (IncludeCollectionWrapper obj : container.getItemIds()) {
              if (obj.getType().equals(selected)) {
                values.remove(obj.getValue());
              }
            }
            // Updating combo-box
            valueField.removeAllItems();
            for (String v : values) {
              valueField.addItem(v);
            }
            if (wrapper.getValue() != null) {
              valueField.addItem(wrapper.getValue());
            }
            valueField.setEnabled(valueField.getItemIds().size() > 1);
          }
        });

    form.setFormFieldFactory(
        new FormFieldFactory() {
          @Override
          public Field createField(Item item, Object propertyId, Component uiContext) {
            if (propertyId.equals("type")) return typeField;
            if (propertyId.equals("value")) return valueField;
            return null;
          }
        });

    okButton = new Button("Update");
    okButton.addListener(this);

    cancelButton = new Button("Cancel");
    cancelButton.addListener(this);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addComponent(okButton);
    toolbar.addComponent(cancelButton);

    addComponent(form);
    addComponent(toolbar);

    ((VerticalLayout) getContent()).setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT);

    form.setItemDataSource(new BeanItem<IncludeCollectionWrapper>(wrapper));
  }
예제 #9
0
  @Override
  public void postConstruct() {

    flagNuevoUsuario = true;
    btnCrearUsuario.setIcon(Constante.ICONOS.SAVE);
    btnEliminarUsuario.setIcon(Constante.ICONOS.DELETE);
    btnAgregarPolicia.setIcon(Constante.ICONOS.CREATE);

    lstRoles = rolService.buscar(null);
    BeanItemContainer<Rol> bicRoles = new BeanItemContainer<Rol>(Rol.class, lstRoles);
    cmbRol.setInputPrompt("Rol");
    cmbRol.setContainerDataSource(bicRoles);
    cmbRol.setItemCaptionPropertyId("nombre");
    cmbRol.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
    cmbRol.setImmediate(true);
    cmbRol.addListener((ValueChangeListener) this);

    lstPolicias = policiaService.buscar(null);
    BeanItemContainer<Policia> bicPolicias =
        new BeanItemContainer<Policia>(Policia.class, lstPolicias);
    cmbPolicia.setInputPrompt("Policia");
    cmbPolicia.setContainerDataSource(bicPolicias);
    cmbPolicia.setItemCaptionPropertyId("nombreCompleto");
    cmbPolicia.setImmediate(true);
    cmbPolicia.addListener(
        new ValueChangeListener() {

          private static final long serialVersionUID = 4418094011985520491L;

          @Override
          public void valueChange(ValueChangeEvent event) {
            pintarPersona(event);
          }

          private void pintarPersona(ValueChangeEvent event) {

            if (cmbPolicia.getValue() != null) {
              Policia policia = (Policia) cmbPolicia.getValue();
              txtApellidoPaterno.setValue(policia.getPersona().getApePaterno());
              txtApellidoMaterno.setValue(policia.getPersona().getApeMaterno());
              txtNombres.setValue(policia.getPersona().getNombres());
              txtCargo.setValue(
                  policia.getCargo() != null ? policia.getCargo().getNombre() : StringUtils.EMPTY);
            }
          }
        });

    cmbPolicia.addListener((ValueChangeListener) this);

    cmbOficina.setItemCaptionPropertyId("nombre");
    cmbOficina.setInputPrompt("Oficina");

    lstDependencias = dependenciasService.buscar(null);
    BeanItemContainer<Dependencia> bicDependencias =
        new BeanItemContainer<Dependencia>(Dependencia.class, lstDependencias);
    cmbOficina.setContainerDataSource(bicDependencias);
    cmbOficina.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
    cmbOficina.setImmediate(true);
    cmbOficina.addListener((ValueChangeListener) this);

    tblUsuarios.setSelectable(true);
    tblUsuarios.setImmediate(true);
    tblUsuarios.setNullSelectionAllowed(true);
    tblUsuarios.setNullSelectionItemId(null);

    habilitarBoton(false);
    btnCrearUsuario.addListener((ClickListener) this);
    btnEliminarUsuario.addListener((ClickListener) this);
    btnAgregarPolicia.addListener((ClickListener) this);

    tblUsuarios.addListener(
        new ValueChangeListener() {
          private static final long serialVersionUID = -6124596484581515359L;

          @Override
          public void valueChange(ValueChangeEvent event) {
            boolean esModoNuevo = tblUsuarios.getValue() == null;
            habilitarBoton(!esModoNuevo);
            limpiar();
            if (esModoNuevo) {
              tblUsuarios.setValue(null);
              habilitarEdicion(esModoNuevo);
            } else {
              Item item = tblUsuarios.getItem(tblUsuarios.getValue());
              clave = item.getItemProperty("clave").getValue().toString();
              txtUsuario.setValue(item.getItemProperty("usuario").getValue());
              txtNombres.setValue(item.getItemProperty("nombres").getValue());
              txtApellidoPaterno.setValue(item.getItemProperty("apePat").getValue());
              txtApellidoMaterno.setValue(item.getItemProperty("apeMat").getValue());
              cmbPolicia.select(item.getItemProperty("policia").getValue());
              cmbOficina.select(item.getItemProperty("dependencia").getValue());
              cmbRol.select(item.getItemProperty("rol").getValue());
              txtCargo.setValue(
                  item.getItemProperty("cargo").getValue() != null
                      ? item.getItemProperty("cargo").getValue()
                      : StringUtils.EMPTY);
              txtCargoDescripcion.setValue(
                  item.getItemProperty("descCargo").getValue() != null
                      ? item.getItemProperty("descCargo").getValue()
                      : StringUtils.EMPTY);
              habilitarEdicion(esModoNuevo);
            }
          }
        });

    txtFiltroUsuario.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });
    txtFiltroNombres.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });
    txtFiltroApePaterno.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });
    txtFiltroApeMaterno.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });
    txtFiltroCargo.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });
    txtFiltroOficina.addShortcutListener(
        new ShortcutListener("", KeyCode.ENTER, null) {
          private static final long serialVersionUID = 4068232062569621771L;

          @Override
          public void handleAction(Object sender, Object target) {
            shortCutEnter(sender, target);
          }
        });

    txtUsuario.setImmediate(true);
    txtNombres.setImmediate(true);
    txtApellidoPaterno.setImmediate(true);
    txtApellidoMaterno.setImmediate(true);
    txtCargo.setImmediate(true);
    txtFiltroOficina.setImmediate(true);

    txtUsuario.addListener((TextChangeListener) this);
    txtNombres.addListener((TextChangeListener) this);
    txtApellidoPaterno.addListener((TextChangeListener) this);
    txtApellidoMaterno.addListener((TextChangeListener) this);
    txtCargo.addListener((TextChangeListener) this);
    txtFiltroOficina.addListener((TextChangeListener) this);

    lstUsuarios = usuarioService.buscar(null);
    cargarUsuarios(lstUsuarios, true);
  }
예제 #10
0
  /**
   * The constructor should first build the main layout, set the composition root and then do any
   * custom initialization.
   *
   * <p>The constructor will not be automatically regenerated by the visual editor.
   *
   * @throws Exception
   * @throws IllegalArgumentException
   */
  public JobViewForm() throws IllegalArgumentException, Exception {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // TODO add user code here
    initComponents();

    cronExpressionField.setVisible(false);
    future_timeField.setEnabled(false);
    startTimeField.setResolution(DateField.RESOLUTION_SEC);
    endTimeField.setResolution(DateField.RESOLUTION_SEC);

    // configure Type data
    areaField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
    areaField.setItemCaptionPropertyId("name");

    jobTriggerTypeField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
    jobTriggerTypeField.setItemCaptionPropertyId("description");

    jobIntervalTypeField.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
    jobIntervalTypeField.setItemCaptionPropertyId("description");

    // get form services from OSGi Service Registry
    getServices();

    // load data sources
    loadData();

    futureField.setImmediate(true);
    futureField.addListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() == null) return;

            if ((Boolean) event.getProperty().getValue()) future_timeField.setEnabled(true);
            else {
              future_timeField.setValue(null);
              future_timeField.setEnabled(false);
            }
          }
        });

    jobTriggerTypeField.setImmediate(true);
    jobTriggerTypeField.setNullSelectionAllowed(false);
    jobTriggerTypeField.addListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() == null) return;

            if (((JobTriggerType) event.getProperty().getValue())
                .getCode()
                .equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) {
              jobIntervalField.setVisible(true);
              jobIntervalTypeField.setVisible(true);
              repeatCountField.setVisible(true);
              cronExpressionField.setVisible(false);
            } else {
              jobIntervalField.setVisible(false);
              jobIntervalTypeField.setVisible(false);
              repeatCountField.setVisible(false);
              cronExpressionField.setVisible(true);
            }
          }
        });
  }