예제 #1
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);
  }
  @Override
  protected void init(VaadinRequest request) {
    final PortletPreferences portletPrefs =
        ((PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST))
            .getPreferences();

    VerticalLayout editLayout = new VerticalLayout();
    editLayout.setMargin(true);
    editLayout.setSpacing(true);

    OptionGroup langSelect = new OptionGroup("Choose application language");
    langSelect.setMultiSelect(false);
    langSelect.addItem(LanguageConst.getLocaleStrFromLocale(LanguageConst.LOCALE_FI));
    langSelect.addItem(LanguageConst.getLocaleStrFromLocale(LanguageConst.LOCALE_EN));
    editLayout.addComponent(langSelect);

    String localeStr = portletPrefs.getValue(TupaConst.PORTLET_PREFERENCE_KEY_LANGUAGE, null);
    if (localeStr != null) {
      langSelect.setValue(localeStr);
    }

    Button storeBtn = VaadinTools.createButton("Save", FontAwesome.SAVE, null, null);
    storeBtn.addClickListener(
        e -> {
          if (langSelect.getValue() == null) {
            VaadinTools.showWarning("Please select language", null);
          } else {
            try {
              portletPrefs.setValue(
                  TupaConst.PORTLET_PREFERENCE_KEY_LANGUAGE, langSelect.getValue().toString());
              portletPrefs.store();
              VaadinTools.showNotification("Language selection saved!", null);
            } catch (Exception e1) {
              VaadinTools.showError(
                  "Something went wrong when saving the language preference", null);
              e1.printStackTrace();
            }
          }
        });
    editLayout.addComponent(storeBtn);
    setContent(editLayout);
  }
예제 #3
0
  public PeptidesTableLayout(
      final int validPep,
      final int totalPep,
      final String desc,
      final Map<Integer, PeptideBean> pepProtList,
      final String accession,
      final String expName) {
    // for  peptides information (table) view
    MarginInfo m = new MarginInfo(false, false, true, false);
    this.setMargin(m);
    this.setSpacing(false);
    this.setWidth("100%");

    final HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setHeight("45px");
    headerLayout.setSpacing(true);
    show = new ShowLabel(true);
    headerLayout.addComponent(show);
    headerLayout.setComponentAlignment(show, Alignment.BOTTOM_LEFT);
    stat = true;

    final Label pepLabel =
        new Label(
            "<h4 style='font-family:verdana;color:black;'>Peptides ("
                + validPep
                + ") "
                + desc
                + "</h4>");
    // new Label("<h4 style='font-family:verdana;color:black;'>Peptides (" + validPep + "/" +
    // totalPep + ") " + desc + "</h4>");
    pepLabel.setContentMode(Label.CONTENT_XHTML);
    pepLabel.setHeight("45px");
    headerLayout.addComponent(pepLabel);
    headerLayout.setComponentAlignment(pepLabel, Alignment.TOP_RIGHT);

    this.addComponent(headerLayout);
    mainLayout = new VerticalLayout();
    mainLayout.setWidth("100%");
    this.addComponent(mainLayout);
    mainLayout.addComponent(pepTableLayout);
    mainLayout.setComponentAlignment(pepTableLayout, Alignment.MIDDLE_CENTER);

    Map<Integer, PeptideBean> vPepProtList = getValidatedList(pepProtList);

    vt = new PeptideTable(vPepProtList, null, false);
    pepTableLayout.addComponent(vt);
    if (trs != null) {
      PepSize = trs.getCurrentSize();
    }
    vt.setHeight(PepSize);

    HorizontalLayout lowerLayout = new HorizontalLayout();
    lowerLayout.setWidth("100%");
    lowerLayout.setHeight("25px");
    lowerLayout.setSpacing(false);
    //  Panel toolbar = new Panel(lowerLayout);
    // toolbar.setStyleName(Reindeer.PANEL_LIGHT);
    // toolbar.setHeight("35px");
    mainLayout.addComponent(lowerLayout);
    mainLayout.setComponentAlignment(lowerLayout, Alignment.TOP_CENTER);

    HorizontalLayout lowerLeftLayout = new HorizontalLayout();
    lowerLayout.addComponent(lowerLeftLayout);
    lowerLeftLayout.setSpacing(true);
    lowerLeftLayout.setMargin(new MarginInfo(false, false, false, false));
    lowerLayout.setComponentAlignment(lowerLeftLayout, Alignment.MIDDLE_LEFT);
    // lowerLayout.setExpandRatio(lowerLeftLayout, 0.4f);

    HorizontalLayout lowerRightLayout = new HorizontalLayout();
    // lowerRightLayout.setSpacing(true);
    lowerRightLayout.setWidth("450px");
    lowerLayout.addComponent(lowerRightLayout);
    lowerLayout.setComponentAlignment(lowerRightLayout, Alignment.BOTTOM_RIGHT);
    // lowerLayout.setExpandRatio(lowerRightLayout, 0.5f);

    final OptionGroup selectionType = new OptionGroup();
    selectionType.setMultiSelect(true);
    selectionType.addItem("\t\tShow Validated Peptides Only");
    selectionType.select("\t\tShow Validated Peptides Only");
    selectionType.setHeight("15px");
    lowerLeftLayout.addComponent(selectionType);
    lowerLeftLayout.setComponentAlignment(selectionType, Alignment.BOTTOM_LEFT);

    final TableResizeSet trs1 = new TableResizeSet(vt, PepSize); // resize tables
    lowerLeftLayout.addComponent(trs1);
    lowerLeftLayout.setComponentAlignment(trs1, Alignment.BOTTOM_LEFT);

    exportPepLayout.setWidth("300px");
    lowerRightLayout.addComponent(exportPepLayout);
    lowerRightLayout.setComponentAlignment(exportPepLayout, Alignment.BOTTOM_RIGHT);

    mainLayout.setSpacing(true);

    headerLayout.addListener(
        new com.vaadin.event.LayoutEvents.LayoutClickListener() {
          @Override
          public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            if (stat) {
              stat = false;
              show.updateIcon(false);
              mainLayout.setVisible(false);
            } else {
              stat = true;
              show.updateIcon(true);
              mainLayout.setVisible(true);
            }
          }
        });
    selectionType.setImmediate(true);
    selectionType.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            if (selectionType.isSelected("\t\tShow Validated Peptides Only")) {

              headerLayout.removeAllComponents();
              headerLayout.addComponent(show);
              headerLayout.setComponentAlignment(show, Alignment.BOTTOM_LEFT);

              // Label pepLabel = new Label("<h4 style='font-family:verdana;color:black;'>Peptides
              // (" + validPep + ") " + desc + "</h4>");
              pepLabel.setContentMode(Label.CONTENT_XHTML);
              pepLabel.setHeight("45px");
              headerLayout.addComponent(pepLabel);
              headerLayout.setComponentAlignment(pepLabel, Alignment.TOP_RIGHT);

              // Map<Integer, PeptideBean> vPepProtList = getValidatedList(pepProtList);

              pepTableLayout.removeAllComponents();
              // vt = new PeptideTable(vPepProtList, null);
              pepTableLayout.addComponent(vt);
              trs1.setTable(vt);
              vt.setHeight(pepTable.getHeight() + "");

            } else {
              headerLayout.removeAllComponents();
              headerLayout.addComponent(show);
              headerLayout.setComponentAlignment(show, Alignment.BOTTOM_LEFT);
              Label pepLabel =
                  new Label(
                      "<h4 style='font-family:verdana;color:black;'>Peptides ("
                          + validPep
                          + "/"
                          + totalPep
                          + ") "
                          + desc
                          + "</h4>");
              pepLabel.setContentMode(Label.CONTENT_XHTML);
              headerLayout.addComponent(pepLabel);
              headerLayout.setComponentAlignment(pepLabel, Alignment.TOP_RIGHT);

              pepTableLayout.removeAllComponents();
              pepTable = new PeptideTable(pepProtList, null, false);
              pepTableLayout.addComponent(pepTable);
              trs1.setTable(pepTable);
              pepTable.setHeight(vt.getHeight() + "");
            }
          }
        });
  }
예제 #4
0
  public CheckBoxes() {
    setMargin(true);

    Label h1 = new Label("Check Boxes");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    CheckBox check = new CheckBox("Checked", true);
    row.addComponent(check);

    check = new CheckBox("Checked, explicit width, so that the caption should wrap", true);
    row.addComponent(check);
    check.setWidth("150px");

    check = new CheckBox("Not checked");
    row.addComponent(check);

    check = new CheckBox(null, true);
    check.setDescription("No caption");
    row.addComponent(check);

    check = new CheckBox("Custom color", true);
    check.addStyleName("color1");
    row.addComponent(check);

    TestIcon testIcon = new TestIcon(30);
    check = new CheckBox("Custom color", true);
    check.addStyleName("color2");
    check.setIcon(testIcon.get());
    row.addComponent(check);

    check = new CheckBox("With Icon", true);
    check.setIcon(testIcon.get());
    row.addComponent(check);

    check = new CheckBox();
    check.setIcon(testIcon.get(true));
    row.addComponent(check);

    check = new CheckBox("Small", true);
    check.addStyleName("small");
    row.addComponent(check);

    check = new CheckBox("Large", true);
    check.addStyleName("large");
    row.addComponent(check);

    h1 = new Label("Option Groups");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    OptionGroup options = new OptionGroup("Choose one, explicit width");
    options.setWidth("200px");
    options.addItem("Option One");
    Item two =
        options.addItem(
            "Option Two, with a longer caption that should wrap when the components width is explicitly set.");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon(two, testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Choose many, explicit width");
    options.setMultiSelect(true);
    options.setWidth("200px");
    options.addItem("Option One");
    two =
        options.addItem(
            "Option Two, with a longer caption that should wrap when the components width is explicitly set.");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon(two, testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Choose one, small");
    options.addStyleName("small");
    options.setMultiSelect(false);
    options.addItem("Option One");
    options.addItem("Option Two");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon("Option Two", testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Choose many, small");
    options.addStyleName("small");
    options.setMultiSelect(true);
    options.addItem("Option One");
    options.addItem("Option Two");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon("Option Two", testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Choose one, large");
    options.addStyleName("large");
    options.setMultiSelect(false);
    options.addItem("Option One");
    options.addItem("Option Two");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon("Option Two", testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Choose many, large");
    options.addStyleName("large");
    options.setMultiSelect(true);
    options.addItem("Option One");
    options.addItem("Option Two");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon("Option Two", testIcon.get());
    options.setItemIcon("Option Three", testIcon.get(true));
    row.addComponent(options);

    options = new OptionGroup("Horizontal items");
    options.addStyleName("horizontal");
    options.addItem("Option One");
    two = options.addItem("Option Two, with a longer caption");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon(two, testIcon.get());
    options.setItemIcon("Option Three", testIcon.get());
    row.addComponent(options);

    options = new OptionGroup("Horizontal items, explicit width");
    options.setMultiSelect(true);
    options.setWidth("500px");
    options.addStyleName("horizontal");
    options.addItem("Option One");
    two = options.addItem("Option Two, with a longer caption");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon(two, testIcon.get());
    options.setItemIcon("Option Three", testIcon.get());
    row.addComponent(options);
  }
  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;
  }
  @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();
  }