Пример #1
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);
  }
Пример #2
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));
        }
      }
    }
  public CadastrarPassageiro(int i, String tipoPassageiro) {
    limit = i;
    bn = Util.getBundle();
    this.passageiroDAO = new PassageiroDAO();
    passagem = new Passagem();
    passagemDAO = new PassagemDAO();
    painel = new Janela();

    // joga no frame pq o passageiro precisa saber seu cod.

    sTipoPassageiro = tipoPassageiro;
    layout = new GridBagLayout();
    painel.setLayout(layout);
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(5, 10, 0, 0);

    lbCodPas = new Rotulo(bn.getString("menuCadastrarPassageiro.bilhete"));

    lbNome = new Rotulo(bn.getString("menuCadastrarPassageiro.lbNome"));
    lbSobrenome = new Rotulo(bn.getString("menuCadastrarPassageiro.lbSobrenome"));
    lbDataNascimento = new Rotulo(bn.getString("menuCadastrarPassageiro.lbDataNascimento"));
    lbEmail = new Rotulo(bn.getString("menuCadastrarPassageiro.lbEmail"));
    lbTelefone = new Rotulo(bn.getString("menuCadastrarPassageiro.lbTelefone"));
    lbCpf = new Rotulo(bn.getString("menuCadastrarPassageiro.lbCpf"));
    lbFormaTratamento = new Rotulo(bn.getString("menuCadastrarPassageiro.lbFormaTratamento"));
    lbTipo = new Rotulo(bn.getString("menuCadastrarPassageiro.lbTipo"));

    btProximo = new Botao(bn.getString("menuComprarPassagem.btProximo"));
    btProximo.setPreferredSize(new Dimension(90, 40));
    btProximo.addActionListener(this);
    btCancelar = new Botao(bn.getString("menuComprarPassagem.btCancelar"));
    btCancelar.setPreferredSize(new Dimension(90, 40));
    btCancelar.addActionListener(this);
    btVoltar = new Botao(bn.getString("menuComprarPassagem.btVoltar"));
    btVoltar.setPreferredSize(new Dimension(90, 40));
    btVoltar.addActionListener(this);

    cTipoPassageiro = new ComboBox("Adulto");
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.adulto"));
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.crianca"));
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.bebe"));

    cFormaTratamento = new ComboBox("Sr");
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.sra"));
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.sr"));
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.srta"));

    txNome = new CaixaDeTexto();
    txSobrenome = new CaixaDeTexto();
    txDataNascimento = new JFormattedTextField(Mascara("##/##/####"));
    txEmail = new CaixaDeTexto();
    txTelefone = new CaixaDeTexto();
    txCpf = new CaixaDeTexto();
    txTipo = new CaixaDeTexto();
    passagem = passagemDAO.getCodPassagem(limit);
    txCodPas = new CaixaDeTexto();
    txCodPas.setEditable(false);
    txCodPas.setText("" + passagem.getCodPas());
    txTipo.setEditable(false);
    txTipo.setText(sTipoPassageiro);
    // lbNome
    gbc.gridy = 0; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbNome, gbc);
    painel.add(lbNome);

    // txNome
    gbc.gridy = 0; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txNome, gbc);
    painel.add(txNome);

    // lbsobrenome
    gbc.gridy = 1; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbSobrenome, gbc);
    painel.add(lbSobrenome);

    // txSobrenome
    gbc.gridy = 1; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txSobrenome, gbc);
    painel.add(txSobrenome);

    // lbDatanasci
    gbc.gridy = 2; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbDataNascimento, gbc);
    painel.add(lbDataNascimento);

    // txDataNasci
    gbc.gridy = 2; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txDataNascimento, gbc);
    painel.add(txDataNascimento);

    // lbTelefone
    gbc.gridy = 3; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbTelefone, gbc);
    painel.add(lbTelefone);

    // txTelefone
    gbc.gridy = 3; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txTelefone, gbc);
    painel.add(txTelefone);

    // lbCpf
    gbc.gridy = 4; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbCpf, gbc);
    painel.add(lbCpf);

    // txCpf
    gbc.gridy = 4; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txCpf, gbc);
    painel.add(txCpf);

    // lbEmail
    gbc.gridy = 5; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbEmail, gbc);
    painel.add(lbEmail);

    // txEmail
    gbc.gridy = 5; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txEmail, gbc);
    painel.add(txEmail);

    // lbTipo
    gbc.gridy = 6; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbTipo, gbc);
    painel.add(lbTipo);

    // txCpf
    gbc.gridy = 6; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txTipo, gbc);
    painel.add(txTipo);

    // lbFormaTratamento
    gbc.gridy = 7; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbFormaTratamento, gbc);
    painel.add(lbFormaTratamento);

    // cFormaTratamento
    gbc.gridy = 7; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(cFormaTratamento, gbc);
    painel.add(cFormaTratamento);

    gbc.gridy = 8; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbCodPas, gbc);
    painel.add(lbCodPas);
    gbc.gridy = 8; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txCodPas, gbc);
    painel.add(txCodPas);

    // botoes
    gbc.gridy = 9;
    gbc.gridx = 2;

    JPanel botoes = new JPanel(new FlowLayout());
    botoes.setBackground(minhaCor);
    botoes.add(btVoltar);
    botoes.add(btProximo);
    botoes.add(btCancelar);
    layout.setConstraints(botoes, gbc);
    painel.add(botoes);

    painel.setLocationRelativeTo(null);
    painel.setTitle(bn.getString("menuCadastrarPassageiro.titulo"));
    painel.setVisible(true);
    int op = painel.getDefaultCloseOperation(); // HIDE_ON_CLOSE
    painel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // painel.setResizable(false);
  }
  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;
  }