Ejemplo n.º 1
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);
  }
 @SuppressWarnings({"rawtypes", "unchecked"})
 private AbstractField createEnumField(Class<?> type, Object propertyId) {
   ComboBox enumSelect = new ComboBox();
   /* Add possible 'view all' item */
   if (owner.getFilterDecorator() != null
       && owner.getFilterDecorator().getAllItemsVisibleString() != null) {
     Object nullItem = enumSelect.addItem();
     enumSelect.setNullSelectionItemId(nullItem);
     enumSelect.setItemCaption(nullItem, owner.getFilterDecorator().getAllItemsVisibleString());
   }
   /* Add items from enumeration */
   for (Object o : EnumSet.allOf((Class<Enum>) type)) {
     enumSelect.addItem(o);
     if (owner.getFilterDecorator() != null) {
       String caption = owner.getFilterDecorator().getEnumFilterDisplayName(propertyId, o);
       enumSelect.setItemCaption(o, caption == null ? o.toString() : caption);
       Resource icon = owner.getFilterDecorator().getEnumFilterIcon(propertyId, o);
       if (icon != null) {
         enumSelect.setItemIcon(o, icon);
       }
     } else {
       enumSelect.setItemCaption(o, o.toString());
     }
   }
   enums.put(enumSelect, propertyId);
   return enumSelect;
 }
 private AbstractField createBooleanField(Object propertyId) {
   ComboBox booleanSelect = new ComboBox();
   booleanSelect.addItem(true);
   booleanSelect.addItem(false);
   if (owner.getFilterDecorator() != null) {
     /* Add possible 'view all' item */
     if (owner.getFilterDecorator().getAllItemsVisibleString() != null) {
       Object nullItem = booleanSelect.addItem();
       booleanSelect.setNullSelectionItemId(nullItem);
       booleanSelect.setItemCaption(
           nullItem, owner.getFilterDecorator().getAllItemsVisibleString());
     }
     String caption = owner.getFilterDecorator().getBooleanFilterDisplayName(propertyId, true);
     booleanSelect.setItemCaption(true, caption == null ? "true" : caption);
     Resource icon = owner.getFilterDecorator().getBooleanFilterIcon(propertyId, true);
     if (icon != null) {
       booleanSelect.setItemIcon(true, icon);
     }
     caption = owner.getFilterDecorator().getBooleanFilterDisplayName(propertyId, false);
     booleanSelect.setItemCaption(false, caption == null ? "false" : caption);
     icon = owner.getFilterDecorator().getBooleanFilterIcon(propertyId, false);
     if (icon != null) {
       booleanSelect.setItemIcon(false, icon);
     }
   } else {
     booleanSelect.setItemCaption(true, "true");
     booleanSelect.setItemCaption(false, "false");
   }
   booleans.put(booleanSelect, propertyId);
   return booleanSelect;
 }
Ejemplo n.º 4
0
 private void fillcbAcivo(String id_auxiliar, String grupoContable) {
   cb_Activos.removeAllItems();
   cb_Activos.setNullSelectionAllowed(false);
   cb_Activos.setInputPrompt("Seleccione el Activo");
   for (ActivosModel activo : activo_impl.activos_by_auxiliar(id_auxiliar, grupoContable)) {
     cb_Activos.addItem(activo.getACT_Codigo_Activo());
     cb_Activos.setItemCaption(activo.getACT_Codigo_Activo(), activo.getACT_Nombre_Activo());
   }
   String a = "ALL";
   cb_Activos.addItem(a);
   cb_Activos.setItemCaption(a, "Todos los Activos");
 }
  private ComboBox getComboBox(String caption, boolean addNullItem) {
    ComboBox cb = new ComboBox(caption);
    cb.setImmediate(true);
    if (addNullItem) {
      cb.addItem("Null item");
      cb.setNullSelectionItemId("Null item");
    }
    cb.addItem("Value 1");
    cb.addItem("Value 2");
    cb.addItem("Value 3");

    return cb;
  }
Ejemplo n.º 6
0
  public void refreshTable() {
    try {
      table.removeAllItems();
      Collection<LightProcessDefinition> processes =
          ProcessbaseApplication.getCurrent()
              .getBpmModule()
              .getLightProcessDefinitions(ProcessState.ENABLED);

      for (LightProcessDefinition pd : processes) {
        if (pd.getCategoryNames().contains(category.getName())) {
          addTableRow(pd);
        } else {
          Item woItem = processesComboBox.addItem(pd);
          String caption = pd.getLabel() != null ? pd.getLabel() : pd.getName();
          processesComboBox.setItemCaption(pd, caption + " (version " + pd.getVersion() + ")");
        }
      }
      table.setSortContainerPropertyId("name");
      table.setSortAscending(true);
      table.sort();
    } catch (Exception ex) {
      ex.printStackTrace();
      showError(ex.getMessage());
    }
  }
Ejemplo n.º 7
0
  public void buttonClick(ClickEvent event) {
    try {
      if (event.getButton().equals(saveBtn)) {
        save();
        close();
      } else if (event.getButton().equals(addBtn)) {
        LightProcessDefinition lpd = (LightProcessDefinition) processesComboBox.getValue();
        addTableRow(lpd);
        processesComboBox.removeItem(lpd);
      } else if (event.getButton().equals(deleteBtn)) {
        delete();
        close();
      } else if (event.getButton() instanceof TableLinkButton) {
        LightProcessDefinition lpd =
            (LightProcessDefinition) ((TableLinkButton) event.getButton()).getTableValue();
        table.removeItem(lpd);
        processesComboBox.addItem(lpd);
        processesComboBox.setItemCaption(
            lpd, lpd.getLabel() + " (version " + lpd.getVersion() + ")");
      } else {
        close();
      }

    } catch (Exception ex) {
      ex.printStackTrace();
      showError(ex.getMessage());
    }
  }
Ejemplo n.º 8
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;
  }
 @Override
 public void setSelectGoodsData(Map<String, String> data) {
   for (Map.Entry<String, String> entry : data.entrySet()) {
     inputGoodsSelect.addItem(entry.getKey());
     inputGoodsSelect.setItemCaption(entry.getKey(), entry.getValue());
   }
 }
Ejemplo n.º 10
0
  private void createComponents() {
    components.add(new TextField("Default TextBox"));
    components.add(new TextArea("Default TextArea."));
    // components.add(new RichTextArea("Default RichtTextArea"));
    components.add(new PasswordField("Default Password"));
    components.add(new DateField("Default DateField"));

    // PopupDateField popupDateField = new
    // PopupDateField("Default DateField");
    // popupDateField.setTextFieldEnabled(false);
    // components.add(popupDateField);

    components.add(new CheckBox("Default CheckBox"));

    ComboBox comboBox = new ComboBox("Default ComboBox");
    comboBox.addItem("Item1");
    components.add(comboBox);

    OptionGroup radioGroup = new OptionGroup("Single Items");
    radioGroup.addItem("Single Item 1");
    radioGroup.addItem("Single Item 2");
    radioGroup.setMultiSelect(false);
    components.add(radioGroup);

    OptionGroup checkGroup = new OptionGroup("Multi Items");
    checkGroup.addItem("Multi Item 1");
    checkGroup.addItem("Multi Item 2");
    checkGroup.setMultiSelect(true);
    components.add(checkGroup);

    // Tree tree = new Tree();
    // tree.setCaption("tree");
    // tree.addItem("single item");
    // components.add(tree);
  }
 private void preencheCB() {
   ArrayList<Pessoa> arr = new ArrayList();
   arr = pessoaDAO.pesquisar();
   while (!arr.isEmpty()) {
     Pessoa p = arr.remove(0);
     users.addItem(p);
   }
 }
Ejemplo n.º 12
0
 /** Llenado del Combo Box */
 private void fillcbGrupo() {
   cb_Grupo.setNullSelectionAllowed(false);
   cb_Grupo.setInputPrompt("Seleccione un Grupo Contable");
   for (GruposContablesModel grupo : grupo_impl.getalls()) {
     cb_Grupo.addItem(grupo.getGRC_Grupo_Contable());
     cb_Grupo.setItemCaption(grupo.getGRC_Grupo_Contable(), grupo.getGRC_Nombre_Grupo_Contable());
   }
 }
  @Override
  public void setComboBoxData(ComboDataList list) {
    Map<String, String> roleList = list.getRoleList();

    for (Map.Entry<String, String> entry : roleList.entrySet()) {
      selectRole.addItem(entry.getKey());
      selectRole.setItemCaption(entry.getKey(), entry.getValue());
    }
  }
Ejemplo n.º 14
0
  private void initLayout() {

    layout.setMargin(true);
    setContent(layout);

    form.setCaption("Employee Details ");
    PropertysetItem item = new PropertysetItem();
    item.addItemProperty("Name", new ObjectProperty<String>(""));
    item.addItemProperty("Address", new ObjectProperty<String>(""));

    ComboBox combobox = new ComboBox("Sex");
    combobox.setInvalidAllowed(true);
    combobox.setNullSelectionAllowed(false);
    combobox.addItem("Male");
    combobox.addItem("Female");
    item.addItemProperty("Age", new ObjectProperty<String>(""));
    item.addItemProperty("Email", new ObjectProperty<String>(""));
    item.addItemProperty("Mobile No", new ObjectProperty<String>(""));

    Form form = new Form();
    final Form reader = new Form();
    form.setCaption("Fill Your Details");
    form.setItemDataSource(item);
    reader.setItemDataSource(item);
    reader.setCaption("Your registation details");
    reader.setReadOnly(true);

    button.addClickListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {

            Label message = new Label("You are Registered");
            layout.addComponent(message);
            layout.addComponent(reader);
          }
        });
    layout.addComponent(form);

    final RichTextArea area = new RichTextArea();
    area.setValue("Add more details here");
    layout.addComponent(area);

    layout.addComponent(button);
  }
Ejemplo n.º 15
0
 private void fillcbAuxiliar(String id_grupo) {
   cb_Auxiliar.removeAllItems();
   cb_Auxiliar.setNullSelectionAllowed(false);
   cb_Auxiliar.setInputPrompt("Seleccione el Auxiliar Contable");
   for (AuxiliaresContablesModel auxiliar : auxiliar_impl.getreporte(id_grupo)) {
     cb_Auxiliar.addItem(auxiliar.getAUC_Auxiliar_Contable());
     cb_Auxiliar.setItemCaption(
         auxiliar.getAUC_Auxiliar_Contable(), auxiliar.getAUC_Nombre_Auxiliar_Contable());
   }
 }
Ejemplo n.º 16
0
  private ComboBox buildEventTypeComboBox() {

    ComboBox cb = new ComboBox();
    cb.addItem("THREAT");
    cb.addItem("PATCH");
    cb.addItem("SCAN");
    cb.addItem("CLIENT");
    cb.setValue("THREAT");
    cb.setNullSelectionAllowed(false);

    cb.addValueChangeListener(
        new Property.ValueChangeListener() {

          private static final long serialVersionUID = 3133483459264825026L;

          @Override
          public void valueChange(ValueChangeEvent event) {
            String item = (String) event.getProperty().getValue();

            // System.out.println("Selected Item "+item);

            if (item.equals("THREAT")) {
              fieldCombo.removeAllItems();
              fieldCombo.addItems(threatFields);
              fieldCombo.setValue(threatFields[0]);
            } else if (item.equals("PATCH")) {
              fieldCombo.removeAllItems();
              fieldCombo.addItems(patchFields);
              fieldCombo.setValue(patchFields[0]);
            } else if (item.equals("SCAN")) {
              fieldCombo.removeAllItems();
              fieldCombo.addItems(scanFields);
              fieldCombo.setValue(scanFields[0]);
            } else if (item.equals("CLIENT")) {
              fieldCombo.removeAllItems();
              fieldCombo.addItems(clientFields);
              fieldCombo.setValue(clientFields[0]);
            }
          }
        });

    return cb;
  }
Ejemplo n.º 17
0
 private ComboBox createType(Object itemId) {
   ComboBox select = new ComboBox();
   for (AttribType type : AttribType.values()) {
     select.addItem(type.name());
   }
   select.setValue(AttribType.gauge);
   select.setNullSelectionAllowed(false);
   select.setData(itemId);
   select.setBuffered(false);
   select.setImmediate(true);
   select.addValueChangeListener(validateOnValueChangeListener);
   return select;
 }
Ejemplo n.º 18
0
  @Override
  public void init() {
    LegacyWindow main = new LegacyWindow();
    setMainWindow(main);

    ComboBox combobox = new ComboBox("My ComboBox");

    // Enable null selection
    combobox.setNullSelectionAllowed(true);
    // Add the item that marks 'null' value
    String nullitem = "-- none --";
    combobox.addItem(nullitem);
    // Designate it was the 'null' value marker
    combobox.setNullSelectionItemId(nullitem);

    // Add some other items
    for (int i = 0; i < 10; i++) {
      combobox.addItem("Item " + i);
    }

    main.addComponent(combobox);
  }
Ejemplo n.º 19
0
 /* (non-Javadoc)
  * @see com.vaadin.ui.FormFieldFactory#createField(com.vaadin.data.Item, java.lang.Object, com.vaadin.ui.Component)
  */
 public Field createField(Item item, Object propertyId, Component uiContext) {
   if ("name".equals(propertyId)) {
     final TextField f = new TextField("Group Name");
     f.setRequired(true);
     f.setWidth("100%");
     return f;
   }
   if ("ifType".equals(propertyId)) {
     final ComboBox f = new ComboBox("ifType Filter");
     f.addItem("ignore");
     f.addItem("all");
     f.setNullSelectionAllowed(false);
     f.setRequired(true);
     f.setImmediate(true);
     f.setNewItemsAllowed(true);
     f.setNewItemHandler(
         new NewItemHandler() {
           public void addNewItem(String newItemCaption) {
             if (!f.containsId(newItemCaption)) {
               f.addItem(newItemCaption);
               f.setValue(newItemCaption);
             }
           }
         });
     return f;
   }
   if ("mibObjCollection".equals(propertyId)) {
     final MibObjField f = new MibObjField(resourceTypes);
     f.setCaption("MIB Objects");
     f.setRequired(true);
     f.setImmediate(true);
     f.setWidth("100%");
     return f;
   }
   return null;
 }
Ejemplo n.º 20
0
    void displayVersions(String path) {
      List<PageVersion> pageVersions = pageService.getPageVersions(path);
      if (pageVersions.size() > 0) {
        final ComboBox pageSelection = new ComboBox();
        content.addComponent(pageSelection);
        pageSelection.setNullSelectionAllowed(false);
        pageSelection.setStyleName("version-selection-box");
        pageSelection.setTextInputAllowed(false);

        pageSelection.addValueChangeListener(
            new ValueChangeListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                selectedVersion = (PageVersion) pageSelection.getValue();
                if (selectedVersion != null) {
                  Page page =
                      pageService.getPageByVersion(beanItem.getPath(), selectedVersion.getName());
                  page.setPath(beanItem.getPath());
                  previewForm.setBean(page);
                  previewLayout.setTitle(page.getSubject());
                  ((PagePreviewFormLayout) previewLayout).displayPageInfo(page);
                }
              }
            });

        pageSelection.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
        pageSelection.setNullSelectionAllowed(false);

        for (int i = 0; i < pageVersions.size(); i++) {
          PageVersion version = pageVersions.get(i);
          pageSelection.addItem(version);
          pageSelection.setItemCaption(version, getVersionDisplay(version, i));
        }

        if (pageVersions.size() > 0) {
          pageSelection.setValue(pageVersions.get(pageVersions.size() - 1));
        }
      }
    }
Ejemplo n.º 21
0
  private void popMyFavorite(String instruction) {
    List<Item> selection = grid.getSelection();

    if (selection.size() != 1) {
      Messagebox.hint(messageResource.getMessage("100004"));
      return;
    }

    String name = selection.get(0).getItemProperty("name").getValue().toString();

    windowMyFavorite.setCaption(name + "-" + termResource.getTerm("To My Favorite"));
    // reset combobox
    List<String> categories =
        candFavoriteService.findUniqueCategoryByManager(this.currentUser.getUuid());
    ComboBox cbCreateIn = (ComboBox) vfMyFavorite.getForm().getField("createIn");
    cbCreateIn.removeAllItems();
    for (String cbItem : categories) {
      cbCreateIn.addItem(cbItem);
    }

    vfMyFavorite.getForm().clear();
    windowMyFavorite.open();
  }
  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);
  }
  private void configureComponents() {
    configureContainer();
    configureRulesContainer();

    fieldSearch.setNullSelectionAllowed(false);
    fieldSearch.addItem("cc_no");
    fieldSearch.addItem("user_id");
    fieldSearch.addItem("first");
    fieldSearch.addItem("last");
    fieldSearch.addItem("city");
    fieldSearch.addItem("state");
    fieldSearch.setValue("first");

    userGrid.setContainerDataSource(container);
    userGrid.setColumnOrder(
        "creditCardNo", "userId", "firstname", "lastname", "cityName", "stateName", "gender");
    userGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    userGrid.addSelectionListener(
        new SelectionListener() {

          @Override
          public void select(SelectionEvent event) {
            Item item = userGrid.getContainerDataSource().getItem(userGrid.getSelectedRow());

            if (item != null) {
              userId = item.getItemProperty("userId").getValue().toString();
              populateUserRules();
            }
          }
        });
    userRulesGrid.setContainerDataSource(rulesContainer);
    userRulesGrid.setColumnOrder(
        "userId", "ruleName", "merchant", "amount", "noOfTransactions", "noOfDays");
    userRulesGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    userRulesGrid.addSelectionListener(
        new SelectionListener() {

          @Override
          public void select(SelectionEvent event) {}
        });
    filterCCNo.addTextChangeListener(
        new TextChangeListener() {

          @Override
          public void textChange(TextChangeEvent event) {
            String filterValue = event.getText();

            users = service.searchUser(fieldSearch.getValue().toString(), filterValue);
            populateUsers();
          }
        });

    addUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item = userGrid.getContainerDataSource().getItem(userGrid.getSelectedRow());

            if (item != null) {

              userId = item.getItemProperty("userId").getValue().toString();
              UserRuleWindow sub = new UserRuleWindow(userId);
              // Add it to the root component
              getUI().addWindow(sub);
              populateUserRules();
            }
          }
        });
    editUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item =
                userRulesGrid.getContainerDataSource().getItem(userRulesGrid.getSelectedRow());

            if (item != null) {

              UserRule userRule =
                  service.getUserRule(
                      item.getItemProperty("userId").getValue().toString(),
                      item.getItemProperty("ruleId").getValue().toString());

              UserRuleWindow sub = new UserRuleWindow(userRule);

              getUI().addWindow(sub);
              populateUserRules();
            }
          }
        });
    deleteUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item =
                userRulesGrid.getContainerDataSource().getItem(userRulesGrid.getSelectedRow());

            if (item != null) {
              userId = item.getItemProperty("userId").getValue().toString();
              service.deleteUserRule(userId, item.getItemProperty("ruleId").getValue().toString());
              populateUserRules();
            }
          }
        });

    populateUsers();
  }
  /**
   * 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));
  }
  private Component buildProfileTab() {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption("Profile");
    root.setIcon(FontAwesome.USER);
    root.setWidth(100.0f, Unit.PERCENTAGE);
    root.setSpacing(true);
    root.setMargin(true);
    root.addStyleName("profile-form");

    VerticalLayout pic = new VerticalLayout();
    pic.setSizeUndefined();
    pic.setSpacing(true);
    Image profilePic = new Image(null, new ThemeResource("img/profile-pic-300px.jpg"));
    profilePic.setWidth(100.0f, Unit.PIXELS);
    pic.addComponent(profilePic);

    Button upload =
        new Button(
            "Change…",
            event -> {
              Notification.show("Not implemented in this demo");
            });
    upload.addStyleName(ValoTheme.BUTTON_TINY);
    pic.addComponent(upload);

    root.addComponent(pic);

    FormLayout details = new FormLayout();
    details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    root.addComponent(details);
    root.setExpandRatio(details, 1);

    firstNameField = new TextField("First Name");
    details.addComponent(firstNameField);
    lastNameField = new TextField("Last Name");
    details.addComponent(lastNameField);

    titleField = new ComboBox("Title");
    titleField.setInputPrompt("Please specify");
    titleField.addItem("Mr.");
    titleField.addItem("Mrs.");
    titleField.addItem("Ms.");
    titleField.setNewItemsAllowed(true);
    details.addComponent(titleField);

    sexField = new OptionGroup("Sex");
    sexField.addItem(Boolean.FALSE);
    sexField.setItemCaption(Boolean.FALSE, "Female");
    sexField.addItem(Boolean.TRUE);
    sexField.setItemCaption(Boolean.TRUE, "Male");
    sexField.addStyleName("horizontal");
    details.addComponent(sexField);

    Label section = new Label("Contact Info");
    section.addStyleName(ValoTheme.LABEL_H4);
    section.addStyleName(ValoTheme.LABEL_COLORED);
    details.addComponent(section);

    emailField = new TextField("Email");
    emailField.setWidth("100%");
    emailField.setRequired(true);
    emailField.setNullRepresentation("");
    details.addComponent(emailField);

    locationField = new TextField("Location");
    locationField.setWidth("100%");
    locationField.setNullRepresentation("");
    locationField.setComponentError(new UserError("This address doesn't exist"));
    details.addComponent(locationField);

    phoneField = new TextField("Phone");
    phoneField.setWidth("100%");
    phoneField.setNullRepresentation("");
    details.addComponent(phoneField);

    newsletterField = new OptionalSelect<>();
    newsletterField.addOption(0, "Daily");
    newsletterField.addOption(1, "Weekly");
    newsletterField.addOption(2, "Monthly");
    details.addComponent(newsletterField);

    section = new Label("Additional Info");
    section.addStyleName(ValoTheme.LABEL_H4);
    section.addStyleName(ValoTheme.LABEL_COLORED);
    details.addComponent(section);

    websiteField = new TextField("Website");
    websiteField.setInputPrompt("http://");
    websiteField.setWidth("100%");
    websiteField.setNullRepresentation("");
    details.addComponent(websiteField);

    bioField = new TextArea("Bio");
    bioField.setWidth("100%");
    bioField.setRows(4);
    bioField.setNullRepresentation("");
    details.addComponent(bioField);

    return root;
  }
Ejemplo n.º 26
0
 private void llenarLista(LinkedList<String> elementos, ComboBox cmb) {
   cmb.removeAllItems();
   for (String elemento : elementos) cmb.addItem(elemento);
 }
 @SuppressWarnings("unchecked")
 private void addItem(ComboBox s, String string) {
   Object id = s.addItem();
   s.getItem(id).getItemProperty(CAPTION).setValue(string);
 }
Ejemplo n.º 28
0
  private Panel designLoginPanel() {

    final Panel loginPanel = new Panel("Login");
    HashMap<String, String> users = null;

    loginPanel.setWidth("100%");
    loginPanel.setHeight("100%");
    // Create absolute layout specifying its properties
    final AbsoluteLayout loginLayout = new AbsoluteLayout();
    loginLayout.setSizeFull();
    // Create components Objects and specify their properties
    int startLeft = 200, startTop = 300;
    try {
      users = getLoginInfo("jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Button btnLogin = new Button("Login");
    final ComboBox cmbUser = new ComboBox("Select your USER ID");
    final ComboBox cmbTask = new ComboBox("Select your TASK");
    cmbUser.setNullSelectionAllowed(false);
    cmbTask.setNullSelectionAllowed(false);
    // Add data
    Iterator it = users.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry pairs = (Map.Entry) it.next();
      cmbUser.addItem(pairs.getKey());
      cmbUser.setItemCaption(pairs.getKey(), pairs.getValue().toString());
      it.remove(); // avoids a ConcurrentModificationException
    }

    cmbUser.setValue(cmbUser.getItemIds().iterator().next());

    // Listeners

    btnLogin.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            userId =
                String.valueOf(
                    cmbUser
                        .getValue()); // which is his Id in tabel as this combo box shows names as
            // captions and Ids as values
            userName = cmbUser.getItemCaption(userId);
            task = String.valueOf(cmbTask.getValue());
            if (task != "" && userId != "") {
              VerticalSplitPanel vsplit = new VerticalSplitPanel();
              displayedPanel = designMainPanel();
              vsplit.setSecondComponent(displayedPanel);
              vsplit.setFirstComponent(allLinksDetails());
              UI.getCurrent().setContent(vsplit);
            }
          }
        });
    cmbUser.addFocusListener(
        new FocusListener() {

          @Override
          public void focus(FocusEvent event) {
            // TODO Auto-generated method stub
            cmbUser.setValue(cmbUser.getItemIds().iterator().next());
          }
        });
    cmbUser.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(final ValueChangeEvent event) {
            final String valueString = String.valueOf(event.getProperty().getValue());

            try {
              List<String> tasks =
                  getTasksInfo(
                      "jdbc:mysql://localhost:3306/", "linkeval", "root", "mofo", valueString);

              cmbTask.removeAllItems();
              if (tasks != null) {
                for (String task : tasks) {
                  cmbTask.addItem(task);
                }
                cmbTask.setValue(cmbTask.getItemIds().iterator().next());
              }
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              Notification.show(e.getMessage());
            }
          }
        });

    loginLayout.addComponent(cmbUser, "left: 800px; top: 200px;");
    loginLayout.addComponent(cmbTask, "left: 800px; top: 300px;");
    loginLayout.addComponent(btnLogin, "left: 900px; top: 400px;");

    loginPanel.setContent(loginLayout);

    return loginPanel;
  }
  @Override
  public void init() {
    buttonCancel = new Button("Batalkan");
    buttonCancel.addClickListener(this);

    buttonShow = new Button("Tampilkan Laporan");
    buttonShow.addClickListener(this);

    buttonPrint = new Button("Cetak");
    buttonPrint.addClickListener(this);
    buttonPrint.setIcon(new ThemeResource("icons/image/icon-print.png"));

    opener = new BrowserWindowOpener(ReportPrint.class);
    opener.setFeatures("height=200,width=400,resizable");
    // A button to open the printer-friendly page.
    opener.extend(buttonPrint);

    DateTime now = DateTime.now();
    Date beginYear =
        now.withDayOfYear(now.dayOfYear().getMinimumValue())
            .withHourOfDay(now.hourOfDay().getMinimumValue())
            .toDate();
    Date endYear =
        now.withDayOfYear(now.dayOfYear().getMaximumValue())
            .withHourOfDay(now.hourOfDay().getMaximumValue())
            .toDate();

    selectStartDate = new DateField("Dari Tanggal");
    selectStartDate.setImmediate(true);
    selectStartDate.setWidth(function.FORM_WIDTH);
    selectStartDate.setValue(beginYear);

    selectEndDate = new DateField("Hingga Tanggal");
    selectEndDate.setImmediate(true);
    selectEndDate.setWidth(function.FORM_WIDTH);
    selectEndDate.setValue(endYear);
    selectAcceptance = new OptionGroup("Persetujuan");
    Item itemType1 = selectAcceptance.addItem("diterima");
    Item itemType2 = selectAcceptance.addItem("belumditerima");
    selectAcceptance.setImmediate(true);
    selectAcceptance.setValue("diterima");

    selectAcceptance.setItemCaption("diterima", "Barang Kadaluarsa Disetujui");

    selectAcceptance.setItemCaption("belumditerima", "Barang Kadaluarsa Belum Disetujui");
    selectContent = new ComboBox("Pilih Tampilan");
    selectContent.setImmediate(true);
    selectContent.addItem(ReportContent.CHART);
    selectContent.addItem(ReportContent.TABLE);
    selectContent.addItem(ReportContent.TABLE_CHART);
    selectContent.setItemCaption(ReportContent.CHART, "Tampilkan Chart");
    selectContent.setItemCaption(ReportContent.TABLE, "Tampilkan Tabel");
    selectContent.setItemCaption(ReportContent.TABLE_CHART, "Tampilkan Tabel dan Chart");
    selectContent.setItemCaption(4, "Minggu Ke-4");
    selectContent.setValue(ReportContent.TABLE);

    selectAcceptance.addValueChangeListener(this);
    selectStartDate.addValueChangeListener(this);
    selectEndDate.addValueChangeListener(this);
    selectContent.addValueChangeListener(this);
    updateWindowOpener();

    construct();
  }