private void initComponents() {
    setSpacing(true);
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setWidth("100%");
    cardNuberField = new TextField();
    cardNuberField.setWidth("100%");
    cardNuberField.setInputPrompt("Ноомер социальной карты, либо e-mail");
    layout.addComponent(cardNuberField);
    layout.setComponentAlignment(cardNuberField, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(cardNuberField, 1.0f);
    addComponent(layout);

    layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setWidth("100%");
    checkwordField = new TextField();
    checkwordField.setWidth("100%");
    checkwordField.setInputPrompt("Проверочное слово");
    layout.addComponent(checkwordField);
    layout.setComponentAlignment(checkwordField, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(checkwordField, 1.0f);
    addComponent(layout);

    Button btnSearch = new Button("Найти");
    btnSearch.addClickListener(getSearchClickListener());
    addComponent(btnSearch);
  }
Exemple #2
0
  public UserSelect() {
    loginInfo = new Label("");
    loginInfo.addStyleName("error-font");
    loginInfo.addStyleName("margin15");
    loginInfo.addStyleName("margin-top40");
    loginInfo.setVisible(false);
    selected = null;
    loginField = new PasswordField("");
    loginField.setWidth("200px");
    loginField.addStyleName("margin15");
    loginField.addStyleName("margin-bot40");
    loginBut = new Button("login");
    loginBut.addStyleName("margin15");
    loginBut.addClickListener(
        e -> {
          if (loginField.getValue().equals(selected.getPassword())) {
            hidePass();
            Globals.user = selected;
            Globals.root.changeScreen(Globals.user);
          } else {
            loginInfo.setVisible(true);
            loginInfo.setValue("Wrong password");
            loginField.setValue("");
          }
        });

    loginBox = new HorizontalLayout();
    loginBox.addStyleName("popup-box");
    loginBox.addComponents(loginField, loginBut, loginInfo);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT);
    loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT);
    loginBox.setVisible(false);
    userIcon = new ThemeResource("icons/user.png");
    users = Globals.control.usersData();
    vbox = new VerticalLayout();
    // vbox.setSizeUndefined();
    vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    Panel p = new Panel();
    p.setSizeFull();

    p.setContent(vbox);
    // vbox.addStyleName("border-l-r");
    this.addComponent(p, "left: 25%; right: 25%; top: 15px");
    this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%");

    this.addLayoutClickListener(
        e -> {
          if (!loginBox.isVisible()) return;
          System.out.println(e.getClickedComponent());
          if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass();
        });
  }
Exemple #3
0
 private Layout createTextFieldMail(String title, Component component) {
   HorizontalLayout layout = new HorizontalLayout();
   Label lbTitle = new Label(title);
   lbTitle.setWidth("60px");
   lbTitle.setStyleName("lbmail");
   layout.addComponent(lbTitle);
   layout.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
   layout.addComponent(component);
   layout.setComponentAlignment(component, Alignment.MIDDLE_LEFT);
   layout.setWidth("100%");
   layout.setExpandRatio(component, 1.0f);
   return layout;
 }
Exemple #4
0
  private com.vaadin.ui.Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(final Button.ClickEvent event) {
            DashboardEventBus.post(
                new UserLoginRequestedEvent(username.getValue(), password.getValue()));
          }
        });
    return fields;
  }
  private Component buildFooter() {
    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Unit.PERCENTAGE);

    Button ok = new Button("OK");
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.addClickListener(
        event -> {
          try {
            fieldGroup.commit();
            // Updated user should also be persisted to database. But
            // not in this demo.

            Notification success = new Notification("Profile updated successfully");
            success.setDelayMsec(2000);
            success.setStyleName("bar success small");
            success.setPosition(Position.BOTTOM_CENTER);
            success.show(Page.getCurrent());

            //                    DashboardEventBus.post(new ProfileUpdatedEvent());
            close();
          } catch (CommitException e) {
            Notification.show("Error while updating profile", Type.ERROR_MESSAGE);
          }
        });
    ok.focus();
    footer.addComponent(ok);
    footer.setComponentAlignment(ok, Alignment.TOP_RIGHT);
    return footer;
  }
  public TableEditorWindow(final Table table, final Object value, Object... dates) {

    for (Object o : dates) dates2.add(o);
    VerticalLayout content = new VerticalLayout();
    Object[] columns = table.getVisibleColumns();
    String[] headers = table.getColumnHeaders();
    int n = columns.length;

    for (int i = 0; i < n; ++i) {
      HorizontalLayout lay = new HorizontalLayout();
      Label l = new Label(headers[i]);
      lay.addComponent(l);
      Component field = dates2.contains(columns[i]) ? new DateField() : new TextField();

      lay.addComponent(field);
      map.put(columns[i], field);
      content.addComponent(lay);
      lay.setComponentAlignment(l, Alignment.MIDDLE_LEFT);
      lay.setComponentAlignment(field, Alignment.MIDDLE_RIGHT);
    }

    if (value != null) {
      Item item = table.getItem(value);
      for (Object o : columns) {
        Object val = item.getItemProperty(o).getValue();
        if (dates2.contains(o)) {
          ((DateField) map.get(o)).setValue((Date) val);
        } else {
          ((TextField) map.get(o)).setValue(val.toString());
        }
      }
    }

    save = new Button("Записать");
    content.addComponent(save);
    save.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent clickEvent) {
            if (actionPerformed()) close();
          }
        });

    setContent(content);
  }
  public SubsEditViewImpl() {
    ButtonRenderer deleteButton = createDeleteButton();
    Slider percentSlider = createPercentSlider();
    MultiFileUpload uploader = createUploader();

    // need to update the grid a first time for initialization.
    updateGrid(null);
    grid.getColumn("delete").setRenderer(deleteButton);
    fileDownloader = new FileDownloader(generateResource());
    fileDownloader.extend(downloadButton);

    // create the main layout
    VerticalLayout content = new VerticalLayout();

    // layout which contains the uploader and the percentage - in other words : all the
    // configuration information
    HorizontalLayout configHorizontalLayout = new HorizontalLayout();
    configHorizontalLayout.addComponent(uploader);

    // Configure the layout which contains the percentage slider
    AbsoluteLayout sliderLayout = new AbsoluteLayout();
    sliderLayout.setWidth("100px");
    sliderLayout.setHeight("35px");
    sliderLayout.addComponent(percentSlider);

    // Configure the layout which contains the percentage slider layout and the labels linked to the
    // percentage
    HorizontalLayout percentageLayout = new HorizontalLayout();
    percentageLayout.addComponent(percentSliderTitle);
    percentageLayout.addComponent(sliderLayout);
    percentageLayout.addComponent(percentLabel);
    percentageLayout.setComponentAlignment(percentSliderTitle, Alignment.MIDDLE_LEFT);
    percentageLayout.setComponentAlignment(percentLabel, Alignment.MIDDLE_LEFT);

    // add the percentage Layout to the layout which contains the uploader
    configHorizontalLayout.addComponent(percentageLayout);
    configHorizontalLayout.setComponentAlignment(percentageLayout, Alignment.BOTTOM_LEFT);

    // add every layouts to the principal one
    content.addComponent(configHorizontalLayout);
    content.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    content.addComponents(grid);
    content.addComponent(downloadButton);
    setCompositionRoot(content);
  }
 private Layout createButtonControls() {
   final HorizontalLayout controlPanel = new HorizontalLayout();
   final Layout controlButtons =
       (new EditFormControlsGenerator<>(editUserForm)).createButtonControls();
   controlButtons.setSizeUndefined();
   controlPanel.addComponent(controlButtons);
   controlPanel.setComponentAlignment(controlButtons, Alignment.MIDDLE_CENTER);
   return controlPanel;
 }
  private void init() {
    VerticalLayout root = new VerticalLayout();

    header = new HorizontalLayout();

    tituloLbl.setStyleName("titlePanel");
    header.addComponent(tituloLbl);
    headerLayout = new HorizontalLayout();
    header.addComponent(headerLayout);

    header.setComponentAlignment(headerLayout, Alignment.MIDDLE_RIGHT);

    header.setStyleName("headerPanel");
    header.setWidth("100%");
    header.setHeight("50px");

    body = new VerticalLayout();
    body.setStyleName("bodyPanel");
    body.setWidth("100%");

    footer = new HorizontalLayout();
    footer.setStyleName("footerPanel");
    footerLayout = new HorizontalLayout();
    footer.addComponent(footerLayout);
    footer.setComponentAlignment(footerLayout, Alignment.MIDDLE_CENTER);

    footer.setWidth("100%");
    footer.setHeight("60px");

    root.addComponent(header);
    root.addComponent(body);
    root.addComponent(footer);

    root.setWidth("100%");

    setCompositionRoot(root);
  }
  // Private methods -----------------------------------------------------------
  private void createComponent(String labelWidth, String labelCompSpace) {
    HorizontalLayout hl = (HorizontalLayout) viewContents;

    // Label
    Label label = new Label(componentLabel);
    label.setWidth(labelWidth);
    label.addStyleName("small");
    label.addStyleName("catTextAlignRight");
    hl.addComponent(label);
    hl.setComponentAlignment(label, Alignment.MIDDLE_LEFT);

    // Space
    hl.addComponent(UILayoutUtil.createSpace(labelCompSpace, null, true));

    // Component
    hl.addComponent(component);
    hl.setExpandRatio(component, 1.0f);
    hl.setComponentAlignment(component, Alignment.MIDDLE_CENTER);

    // Tail space
    hl.addComponent(UILayoutUtil.createSpace("2px", null, true));

    hl.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);
  }
  private Component createConnectionSelectorLayout() {
    final ProfileInfoPanelHolder infoPanelHolder = new ProfileInfoPanelHolder();
    profileSelector = createProfileSelector(infoPanelHolder);
    HorizontalLayout content = new HorizontalLayout(profileSelector, infoPanelHolder);
    content.setSizeFull();
    content.setExpandRatio(infoPanelHolder, 1);

    Component buttons = createConnectionButtons(infoPanelHolder);
    Component profileManagerToolbar = createProfileManagerToolbar(profileSelector);

    HorizontalLayout footer = new HorizontalLayout(profileManagerToolbar, buttons);
    footer.setWidth("100%");
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    VerticalLayout layout = new VerticalLayout(content, footer);
    layout.setSizeFull();
    layout.setExpandRatio(content, 1);

    return layout;
  }
    private Layout createBottomPanel() {
      final HorizontalLayout controlPanel = new HorizontalLayout();
      controlPanel.setMargin(true);
      controlPanel.setStyleName("more-info");
      controlPanel.setHeight("40px");
      controlPanel.setWidth("100%");
      Button moreInfoBtn =
          new Button(
              "More information...",
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                  editUserForm.displayAdvancedForm(user);
                }
              });
      moreInfoBtn.addStyleName(UIConstants.THEME_LINK);
      controlPanel.addComponent(moreInfoBtn);
      controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT);
      return controlPanel;
    }
Exemple #13
0
  @Override
  public void init() {
    Window mainWindow = new Window("Test Application");
    Form form = new Form();
    form.setCaption("Form Caption");
    form.setDescription(
        "This is a description of the Form that is "
            + "displayed in the upper part of the form. You normally "
            + "enter some descriptive text about the form and its "
            + "use here.");
    // Add a field and bind it to an named item property.
    form.addField("nom", new TextField("Nom"));
    form.addField("prenom", new TextField("Prenom"));
    form.addField("age", new TextField("Age"));
    // Set the footer layout.
    form.setFooter(new VerticalLayout());

    form.getFooter()
        .addComponent(
            new Label(
                "This is the footer area of the Form. "
                    + "You can use any layout here. "
                    + "This is nice for buttons."));

    // Have a button bar in the footer.
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setHeight("25px");
    form.getFooter().addComponent(okbar);
    Button okbutton = new Button("OK", form, "commit");
    okbutton.addListener(new OkListener(form));
    okbar.addComponent(okbutton);
    okbar.setComponentAlignment(okbutton, Alignment.TOP_RIGHT);
    Button resetbutton = new Button("Reset", form, "discard");
    resetbutton.addListener(new ResetListener(form));
    okbar.addComponent(resetbutton);
    mainWindow.addComponent(form);
    setMainWindow(mainWindow);
  }
Exemple #14
0
  @SuppressWarnings({"deprecation", "serial"})
  private void updateComponents(final User user) {
    if (container != null) {
      container.removeAllComponents();
    }
    container = new Panel();
    root = new Panel();
    root.setStyle(Reindeer.PANEL_LIGHT);
    container.setHeight("100%");
    container.setStyle(Reindeer.PANEL_LIGHT);
    setCompositionRoot(container);

    // Create the Form
    newExpForm = new Form();
    newExpForm.setCaption("New Experiment");
    newExpForm.setWriteThrough(false); // we want explicit 'apply'
    newExpForm.setInvalidCommitted(false); // no invalid values in data model
    // Determines which properties are shown, and in which order:
    expNameField = new TextField("Experiment Name:");
    expNameField.setStyle(Reindeer.TEXTFIELD_SMALL);
    expNameField.setRequired(true);
    expNameField.setRequiredError("EXPERIMENT NAME CAN NOT BE EMPTY!");
    expNameField.setWidth("350px");
    expNameField.setMaxLength(70);

    speciesField = new TextField("Species:");
    speciesField.setStyle(Reindeer.TEXTFIELD_SMALL);
    speciesField.setRequired(true);
    speciesField.setRequiredError("EXPERIMENT SPECIES CAN NOT BE EMPTY!");
    speciesField.setWidth("350px");
    speciesField.setMaxLength(70);

    sampleTypeField = new TextField("Sample Type:");
    sampleTypeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    sampleTypeField.setRequired(true);
    sampleTypeField.setRequiredError("EXPERIMENT SAMPLE TYPE CAN NOT BE EMPTY!");
    sampleTypeField.setWidth("350px");
    sampleTypeField.setMaxLength(70);

    sampleProcessingField = new TextField("Sample Processing:");
    sampleProcessingField.setStyle(Reindeer.TEXTFIELD_SMALL);
    sampleProcessingField.setRequired(true);
    sampleProcessingField.setRequiredError("EXPERIMENT SAMPLE PROCESSING CAN NOT BE EMPTY!");
    sampleProcessingField.setWidth("350px");
    sampleProcessingField.setMaxLength(70);

    instrumentTypeField = new TextField("Instrument Type:");
    instrumentTypeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    instrumentTypeField.setRequired(true);
    instrumentTypeField.setRequiredError("EXPERIMENT INSTURMENT TYPE CAN NOT BE EMPTY!");
    instrumentTypeField.setWidth("350px");
    instrumentTypeField.setMaxLength(70);

    fragModeField = new TextField("Frag Mode:");
    fragModeField.setStyle(Reindeer.TEXTFIELD_SMALL);
    fragModeField.setRequired(true);
    fragModeField.setRequiredError("EXPERIMENT FRAG MODE CAN NOT BE EMPTY!");
    fragModeField.setWidth("350px");
    fragModeField.setMaxLength(70);

    UploadedByNameField = new TextField("Uploaded By:");
    UploadedByNameField.setStyle(Reindeer.TEXTFIELD_SMALL);
    UploadedByNameField.setRequired(true);
    UploadedByNameField.setRequiredError("EXPERIMENT UPLOADED BY CAN NOT BE EMPTY!");
    UploadedByNameField.setValue(user.getUsername());
    UploadedByNameField.setEnabled(false);
    UploadedByNameField.setWidth("350px");
    UploadedByNameField.setMaxLength(70);

    emailField = new TextField("Email:");
    emailField.setStyle(Reindeer.TEXTFIELD_SMALL);
    emailField.setRequired(true);
    emailField.setValue(user.getEmail());
    emailField.setEnabled(false);
    emailField.setRequiredError("EXPERIMENT EMAIL CAN NOT BE EMPTY!");
    emailField.setWidth("350px");
    emailField.setMaxLength(70);

    descriptionField = new TextArea("Description:");
    descriptionField.setStyle(Reindeer.TEXTFIELD_SMALL);
    descriptionField.setRequired(true);
    descriptionField.setRequiredError("EXPERIMENT Description CAN NOT BE EMPTY!");
    descriptionField.setWidth("350px");
    descriptionField.setMaxLength(950);

    publicationLinkField = new TextField("Publication Link:");
    publicationLinkField.setStyle(Reindeer.TEXTFIELD_SMALL);
    publicationLinkField.setWidth("350px");
    publicationLinkField.setMaxLength(300);

    newExpForm.addField(Integer.valueOf(1), expNameField);
    newExpForm.addField(Integer.valueOf(2), descriptionField);

    newExpForm.addField(Integer.valueOf(3), speciesField);
    newExpForm.addField(Integer.valueOf(4), sampleTypeField);
    newExpForm.addField(Integer.valueOf(5), sampleProcessingField);
    newExpForm.addField(Integer.valueOf(6), instrumentTypeField);
    newExpForm.addField(Integer.valueOf(7), fragModeField);
    newExpForm.addField(Integer.valueOf(8), UploadedByNameField);
    newExpForm.addField(Integer.valueOf(9), emailField);
    newExpForm.addField(Integer.valueOf(10), publicationLinkField);

    // Add form to layout
    container.addComponent(newExpForm);

    Panel p = new Panel();
    Label l =
        new Label(
            "<h4 style='color:blue'>Or Update Existing Experiments !</h4><h4 style='color:blue'>For New Experiment Please Leave Experiment ID Blank!</h4><h4 style='color:blue'><strong style='color:red'>* </strong> For New Experiment Please Remember to Upload Protein file first!</h4>");
    l.setContentMode(Label.CONTENT_XHTML);
    p.addComponent(l);
    container.addComponent(p);

    // Create the Form
    Form existExpForm = new Form();
    existExpForm.setCaption("Exist Experiments");
    expList = eh.getExperiments(null);
    List<String> strExpList = new ArrayList<String>();
    for (ExperimentBean exp : expList.values()) {
      if (user.getEmail().equalsIgnoreCase("*****@*****.**")
          || exp.getEmail().equalsIgnoreCase(user.getEmail())) {
        String str = exp.getExpId() + "	" + exp.getName() + "	( " + exp.getUploadedByName() + " )";
        strExpList.add(str);
      }
    }
    select = new Select("Experiment ID", strExpList);
    select.setImmediate(true);
    select.addListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            Object o = select.getValue();
            if (o != null) {
              String str = select.getValue().toString();
              String[] strArr = str.split("\t");
              int id = (Integer.valueOf(strArr[0]));
              ExperimentBean expDet = expList.get(id);
              if (expDetails != null) {
                expDetails.removeAllComponents();

                if (expDet.getProteinsNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>1) Protein File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>1) Protein File is Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
                if (expDet.getFractionsNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>2) Fraction File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>2) Fraction File Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
                //                        if (expDet.getFractionRange() == 0) {
                //                            Label l = new Label("<h4 style='color:red'>3) Fraction
                // Range File is Missing</h4>");
                //                            l.setContentMode(Label.CONTENT_XHTML);
                //                            expDetails.addComponent(l);
                //                        } else {
                //                            Label l = new Label("<h4 style='color:blue'>3)
                // Fraction Range File Uploaded</h4>");
                //                            l.setContentMode(Label.CONTENT_XHTML);
                //                            expDetails.addComponent(l);
                //                        }
                if (expDet.getPeptidesNumber() == 0) {
                  Label l = new Label("<h4 style='color:red'>3) Peptides File is Missing</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                } else {
                  Label l = new Label("<h4 style='color:blue'>3) Peptides File Uploaded</h4>");
                  l.setContentMode(Label.CONTENT_XHTML);
                  expDetails.addComponent(l);
                }
              }
            } else {
              expDetails.removeAllComponents();
              Label labelDetails =
                  new Label(
                      "<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>");
              labelDetails.setContentMode(Label.CONTENT_XHTML);
              expDetails.addComponent(labelDetails);
            }
          }
        });
    select.setWidth("60%");
    existExpForm.addField(Integer.valueOf(1), select);

    // Add form to layout
    VerticalLayout vlo = new VerticalLayout();

    if (hslo != null) {
      vlo.removeComponent(hslo);
    }
    hslo = new HorizontalLayout();
    hslo.setSizeFull();
    hslo.addComponent(existExpForm);
    vlo.addComponent(hslo);
    if (removeExperimentLayout != null) {
      hslo.removeComponent(removeExperimentLayout);
    }
    removeExperimentLayout = this.getRemoveForm(user.getEmail());
    hslo.addComponent(removeExperimentLayout);
    hslo.setComponentAlignment(removeExperimentForm, Alignment.MIDDLE_CENTER);
    vlo.addComponent(hslo);
    container.addComponent(vlo);

    // Create the Upload component.

    upload = new Upload(null, this);
    upload.setStyleName("small");
    upload.setVisible(true);
    upload.setHeight("30px");
    upload.setButtonCaption("ADD / EDIT EXPERIMENT !");

    // *****************************************************
    upload.addListener(
        new Upload.StartedListener() {
          @SuppressWarnings("static-access")
          @Override
          public void uploadStarted(StartedEvent event) {
            try {

              Thread.currentThread().sleep(1000);
              Thread t =
                  new Thread(
                      new Runnable() {
                        @Override
                        public void run() {
                          pi.setVisible(true);
                        }
                      });
              t.start();
              t.join();
            } catch (InterruptedException e) {
            }

            mainTabs.setReadOnly(true);
            subTabs.setReadOnly(true);
          }
        });

    upload.addListener(
        new Upload.FinishedListener() {
          @Override
          public void uploadFinished(FinishedEvent event) {
            pi.setVisible(false);
            mainTabs.setReadOnly(false);
            subTabs.setReadOnly(false);
            file = new File(event.getFilename());
          }
        });

    // ***********************************

    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.FailedListener) this);
    if (helpNote != null) {
      vlo.removeComponent(helpNote);
    }
    Label label =
        new Label(
            "<h4 style='color:red;'>Please upload proteins file first</h4><h4 style='color:red;'>Please upload proteins files in (.txt) format.</h4><h4 style='color:red;'>Upload fraction range file after upload protein fraction file.</h4><h4 style='color:red;'>Upload fraction range file in (.xlsx) format.</h4>");
    label.setContentMode(Label.CONTENT_XHTML);
    helpNote = help.getHelpNote(label);
    helpNote.setMargin(false, true, true, true);

    vlo.addComponent(upload);
    vlo.addComponent(pi);
    vlo.addComponent(helpNote);
    vlo.setComponentAlignment(helpNote, Alignment.MIDDLE_RIGHT);

    expDetails = new Panel("Experiment Details");
    Label labelDetails =
        new Label("<h4 style='color:red;'>Please Select Experiment To Show the Details.</h4>");
    labelDetails.setContentMode(Label.CONTENT_XHTML);
    expDetails.addComponent(labelDetails);

    vlo.addComponent(expDetails);
    root.addComponent(vlo);
    container.addComponent(root);
  }
Exemple #15
0
  private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
      for (String mail : lstMail) {
        if (StringUtils.isNotBlank(mail)) {
          if (mail.indexOf("<") > -1) {
            String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
            if (strMail != null && !strMail.equalsIgnoreCase("null")) {}

          } else {

          }
        }
      }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setWidth("100%");

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    controlsLayout.addComponent(uploadExt);
    controlsLayout.setExpandRatio(uploadExt, 1.0f);

    controlsLayout.setSpacing(true);

    Button cancelBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {
                MailFormWindow.this.close();
              }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn =
        new Button(
            "Send",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {

                if (tokenFieldMailTo.getListRecipient().size() <= 0
                    || subject.getValue().equals("")) {
                  NotificationUtil.showErrorNotification(
                      "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
                  return;
                }
                if (AppContext.getUser().getEmail() != null
                    && AppContext.getUser().getEmail().length() > 0) {
                  ExtMailService systemMailService =
                      ApplicationContextUtil.getSpringBean(ExtMailService.class);

                  List<File> listFile = attachments.files();
                  List<EmailAttachementSource> emailAttachmentSource = null;
                  if (listFile != null && listFile.size() > 0) {
                    emailAttachmentSource = new ArrayList<>();
                    for (File file : listFile) {
                      emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                  }

                  systemMailService.sendHTMLMail(
                      AppContext.getUser().getEmail(),
                      AppContext.getUser().getDisplayName(),
                      tokenFieldMailTo.getListRecipient(),
                      tokenFieldMailCc.getListRecipient(),
                      tokenFieldMailBcc.getListRecipient(),
                      subject.getValue().toString(),
                      noteArea.getValue().toString(),
                      emailAttachmentSource);
                  MailFormWindow.this.close();
                } else {
                  NotificationUtil.showErrorNotification(
                      "Your email is empty value, please fulfil it before sending email!");
                }
              }
            });
    sendBtn.setIcon(FontAwesome.SEND);
    sendBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
  }
  /** @param el */
  public BookImage(Books el, String user) {
    super();
    this.Book = el;

    this.setStyleName("cells");
    this.setHeight("250px");
    this.setWidth("200px");

    rating.setAnimated(true);
    rating.setCaption(null);
    rating.setMaxValue(5);
    rating.setStyleName("rating");
    rating.setReadOnly(true);

    rating_my.setAnimated(true);
    rating_my.setCaption(null);
    rating_my.setMaxValue(5);
    rating_my.setStyleName("rating_my");

    IRaitingService iRaitingService = new IRaitingService();
    try {
      double rate = iRaitingService.getRaiting(el.getId());
      rating.setReadOnly(false);
      rating.setValue(rate);
      rating.setReadOnly(true);
      double myrate = iRaitingService.getRaiting(user, el.getId());
      rating_my.setValue(myrate);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    rating_my.addValueChangeListener(
        e -> {
          try {
            Rating rat =
                iRaitingService.getUser(
                    getUI().getSession().getAttribute("user").toString(), el.getId());

            rat.setRaiting(rating_my.getValue());

            iRaitingService.update(rat);

            double rate = iRaitingService.getRaiting(el.getId());
            rating.setReadOnly(false);
            rating.setValue(rate);
            rating.setReadOnly(true);

            new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION)
                .show(Page.getCurrent());
          } catch (SQLException e1) {
            e1.printStackTrace();
          }
        });

    rating_layout.addComponent(rating);
    rating_layout.addComponent(rating_my);
    rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT);
    rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT);
    rating_layout.setStyleName("ratinglayout");

    imageEmbedded.setSource(new FileResource(new File(Book.getImage())));

    title.setValue(Book.getTitle());
    author.setValue(Book.getAuthor());

    if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false);

    buttonDownload.setWidth("80%");
    imageEmbedded.setWidth("100%");
    imageEmbedded.setHeight("100%");

    title.setWidth(null);
    author.setWidth(null);

    VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded);

    bodyLayout.setExpandRatio(title, 12);
    bodyLayout.setExpandRatio(author, 8);
    bodyLayout.setExpandRatio(imageEmbedded, 80);
    bodyLayout.setSizeFull();
    bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
    bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER);
    bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER);

    buttonDownload.setStyleName("super-button");
    title.setStyleName("name-label");
    author.setStyleName("author-label");

    this.addComponent(rating_layout);
    this.addComponent(bodyLayout);
    this.addComponent(buttonDownload);

    this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER);
    this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER);
    this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER);
    this.setExpandRatio(rating_layout, 5);
    this.setExpandRatio(bodyLayout, 85);
    this.setExpandRatio(buttonDownload, 10);

    StreamResource sr = getStream();
    FileDownloader fileDownloader = new FileDownloader(sr);
    fileDownloader.extend(buttonDownload);

    bodyLayout.addLayoutClickListener(
        e -> {
          BookWin win = new BookWin(this.Book);
          UI.getCurrent().addWindow(win);
        });
  }
Exemple #17
0
  private void buildFeedControl() {
    mainLayout.addTab(feedControl, "Feed Management");
    feedControl.setSizeFull();

    HorizontalLayout h1 = new HorizontalLayout();
    final TextField feedPath = new TextField("Feeds Folder:");
    h1.addComponent(feedPath);
    final Button updateFeedPath = new Button("Update");
    h1.addComponent(updateFeedPath);
    h1.setComponentAlignment(updateFeedPath, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h1);

    updateFeedPath.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.reset();
            feedsPath = feedPath.getValue().toString();
            feed.setFeedsPath(feedsPath);
            buildFeedSelect();
          }
        });

    HorizontalLayout h2 = new HorizontalLayout();
    final Select pairSelect = buildPairSelect();
    h2.addComponent(pairSelect);
    h2.addComponent(feedSelect);
    final Button addPairFeed = new Button("Add");
    h2.addComponent(addPairFeed);
    h2.setComponentAlignment(addPairFeed, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h2);

    addPairFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.addPairFeed((Pair) pairSelect.getValue(), feedSelect.getValue().toString());
          }
        });

    HorizontalLayout h3 = new HorizontalLayout();
    final TextField maxPopulation = new TextField("Maximum Population:");
    maxPopulation.setValue("200");
    h3.addComponent(maxPopulation);
    final Button updateMaxPop = new Button("Update");
    h3.addComponent(updateMaxPop);
    h3.setComponentAlignment(updateMaxPop, Alignment.BOTTOM_RIGHT);
    feedControl.addComponent(h3);

    updateMaxPop.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            correlatorPool.setMaxPopulation(Integer.parseInt(maxPopulation.getValue().toString()));
          }
        });

    final Button startSim = new Button("Start Learning");

    feedControl.addComponent(startSim);

    startSim.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            try {
              emulator.startEmulation();
              // emulator.run();
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    final Button endSim = new Button("End Learning");

    feedControl.addComponent(endSim);

    endSim.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            try {
              emulator.die();
              // emulator.stop();
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    final Button pauseFeed = new Button("Pause Feed");

    feedControl.addComponent(pauseFeed);

    pauseFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.pause();
          }
        });

    final Button resumeFeed = new Button("Resume Feed");

    feedControl.addComponent(resumeFeed);

    resumeFeed.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.resume();
          }
        });

    final Button testInit = new Button("Use Test Init");

    feedControl.addComponent(testInit);

    testInit.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            feed.reset();
            feedsPath = "C:\\Users\\Oblene\\Desktop\\Sandbox\\Data";
            // feedsPath = "/app/testing/hans/WebApps/Data";
            feed.setFeedsPath(feedsPath);
            buildFeedSelect();

            feed.addPairFeed(Pair.EURUSD, "EURUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.GBPUSD, "GBPUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.USDCHF, "USDCHF_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            // feed.addPairFeed(Pair.USDJPY, "USDJPY_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.AUDUSD, "AUDUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addPairFeed(Pair.NZDUSD, "NZDUSD_5 Mins_Bid_2008.01.01_2012.12.31.csv");
            feed.addCalendarFeed("Calendar_2008.csv");

            CorrelatorFromCodeFactory.createCorrelator(
                (String) helper.getBean("classPath"),
                "MovingAverageCorrelator",
                "import com.bluesmoke.farm.correlator.CorrelatorPool;\n"
                    + "import com.bluesmoke.farm.correlator.GenericCorrelator;\n"
                    + "import com.bluesmoke.farm.correlator.builder.CorrelatorBuilderManager;\n"
                    + "import com.bluesmoke.farm.model.tickdata.Tick;\n"
                    + "import com.bluesmoke.farm.service.feed.FeedService;\n"
                    + "import com.bluesmoke.farm.enumeration.PairResolution;\n"
                    + "import com.bluesmoke.farm.enumeration.Pair;\n"
                    + "\n"
                    + "import java.util.HashMap;\n"
                    + "import java.util.TreeMap;\n"
                    + "import java.util.Random;\n"
                    + "\n"
                    + "public class MovingAverageCorrelator extends GenericCorrelator{\n"
                    + "\n"
                    + "    private int refresh = 0;\n"
                    + "    private double ma;\n"
                    + "    private double sum = 0;\n"
                    + "    private Pair statePair;"
                    + "    private double statePairResolution;"
                    + "\n"
                    + "    public MovingAverageCorrelator(String id, CorrelatorBuilderManager correlatorBuilderManager, CorrelatorPool pool, FeedService feed, GenericCorrelator aggressiveParent, GenericCorrelator passiveParent, HashMap<String, Object> config)\n"
                    + "    {\n"
                    + "        super(\"MovingAverage_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, aggressiveParent, passiveParent, config);\n"
                    + "        Random rand = new Random();\n"
                    + "        this.config.put(\"price_type\", rand.nextInt(4));\n"
                    + "        TreeMap<Double, Pair> randMap = new TreeMap<Double, Pair>();\n"
                    + "        for(Pair pair : Pair.values())\n"
                    + "        {\n"
                    + "            randMap.put(Math.random(), pair);\n"
                    + "        }\n"
                    + "\n"
                    + "        statePair = randMap.firstEntry().getValue();"
                    + "        this.config.put(\"statePair\", statePair);\n"
                    + "        statePairResolution = PairResolution.getResolution(statePair);\n"
                    + "        this.config.put(\"statePairResolution\", statePairResolution);"
                    + "    }\n"
                    + "\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public void createMutant() {\n"
                    + "        new MovingAverageCorrelator(\"MovingAverage_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, null, null, config);\n"
                    + "    }\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public String createState() {\n"
                    + "\n"
                    + "        if(refresh == 0)\n"
                    + "        {\n"
                    + "            refresh = 1000;\n"
                    + "            sum = 0;\n"
                    + "            boolean passedFirst = false;\n"
                    + "            for(Tick tick : ticks)\n"
                    + "            {\n"
                    + "                   double price = 0;\n"
                    + "                   switch ((Integer)config.get(\"price_type\"))\n"
                    + "                   {\n"
                    + "                       case 0:\n"
                    + "                           price = tick.getPairData(statePair.name()).getOpen();\n"
                    + "                           break;\n"
                    + "                       case 1:\n"
                    + "                           price = tick.getPairData(statePair.name()).getClose();\n"
                    + "                           break;\n"
                    + "                       case 2:\n"
                    + "                           price = tick.getPairData(statePair.name()).getHigh();\n"
                    + "                           break;\n"
                    + "                       case 3:\n"
                    + "                           price = tick.getPairData(statePair.name()).getLow();\n"
                    + "                           break;\n"
                    + "                   }"
                    + "                if(passedFirst)\n"
                    + "                {\n"
                    + "                    sum += price;\n"
                    + "                }\n"
                    + "                else {\n"
                    + "                    passedFirst = true;\n"
                    + "                }\n"
                    + "            }\n"
                    + "            ma = sum/(ticks.size() - 1);\n"
                    + "        }\n"
                    + "        else {\n"
                    + "           double priceRemove = 0;"
                    + "           double priceAdd = 0;"
                    + "           switch ((Integer)config.get(\"price_type\"))\n"
                    + "                   {\n"
                    + "                       case 0:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getOpen();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getOpen();\n"
                    + "                           break;\n"
                    + "                       case 1:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getClose();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getClose();\n"
                    + "                           break;\n"
                    + "                       case 2:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getHigh();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getHigh();\n"
                    + "                           break;\n"
                    + "                       case 3:\n"
                    + "                           priceRemove = ticks.get(0).getPairData(statePair.name()).getLow();\n"
                    + "                           priceAdd = currentTick.getPairData(statePair.name()).getLow();\n"
                    + "                           break;\n"
                    + "                   }"
                    + "            sum -= priceRemove;\n"
                    + "            sum += priceAdd;\n"
                    + "            ma = sum/(ticks.size() - 1);\n"
                    + "        }\n"
                    + "        currentUnderlyingComponents.put(\"MA\", ma);\n"
                    + "        refresh--;\n"
                    + "        return \"\" + (int)(ma/(100 * statePairResolution));\n"
                    + "    }\n"
                    + "}\n",
                correlatorBuilderManager,
                feed,
                correlatorPool,
                null,
                null,
                null);

            CorrelatorFromCodeFactory.createCorrelator(
                (String) helper.getBean("classPath"),
                "PriceCorrelator",
                "import com.bluesmoke.farm.correlator.CorrelatorPool;\n"
                    + "import com.bluesmoke.farm.correlator.GenericCorrelator;\n"
                    + "import com.bluesmoke.farm.correlator.builder.CorrelatorBuilderManager;\n"
                    + "import com.bluesmoke.farm.model.tickdata.Tick;\n"
                    + "import com.bluesmoke.farm.service.feed.FeedService;\n"
                    + "import com.bluesmoke.farm.enumeration.PairResolution;\n"
                    + "import com.bluesmoke.farm.enumeration.Pair;\n"
                    + "\n"
                    + "import java.util.HashMap;\n"
                    + "import java.util.TreeMap;\n"
                    + "import java.util.Random;\n"
                    + "\n"
                    + "public class PriceCorrelator extends GenericCorrelator{\n"
                    + "\n"
                    + "    private Pair statePair;"
                    + "    private double statePairResolution;"
                    + "    public PriceCorrelator(String id, CorrelatorBuilderManager correlatorBuilderManager, CorrelatorPool pool, FeedService feed, GenericCorrelator aggressiveParent, GenericCorrelator passiveParent, HashMap<String, Object> config)\n"
                    + "    {\n"
                    + "        super(\"Price_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, aggressiveParent, passiveParent, config);\n"
                    + "        Random rand = new Random();\n"
                    + "        this.config.put(\"price_type\", rand.nextInt(4));\n"
                    + "        "
                    + "        TreeMap<Double, Pair> randMap = new TreeMap<Double, Pair>();\n"
                    + "        for(Pair pair : Pair.values())\n"
                    + "        {\n"
                    + "            randMap.put(Math.random(), pair);\n"
                    + "        }\n"
                    + "\n"
                    + "        statePair = randMap.firstEntry().getValue();"
                    + "        this.config.put(\"statePair\", statePair);\n"
                    + "        statePairResolution = PairResolution.getResolution(statePair);\n"
                    + "        this.config.put(\"statePairResolution\", statePairResolution);"
                    + "    }\n"
                    + "\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public void createMutant() {\n"
                    + "        new PriceCorrelator(\"Price_\" + pool.getNextID(), correlatorBuilderManager, pool, feed, null, null, config);\n"
                    + "    }\n"
                    + "\n"
                    + "    @Override\n"
                    + "    public String createState() {\n"
                    + "\n"
                    + "        double price = 0;\n"
                    + "        switch ((Integer)config.get(\"price_type\"))\n"
                    + "        {\n"
                    + "            case 0:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getOpen();\n"
                    + "                break;\n"
                    + "            case 1:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getClose();\n"
                    + "                break;\n"
                    + "            case 2:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getHigh();\n"
                    + "                break;\n"
                    + "            case 3:\n"
                    + "                price = currentTick.getPairData(statePair.name()).getLow();\n"
                    + "                break;\n"
                    + "        }\n"
                    + "        currentUnderlyingComponents.put(\"price\", price);\n"
                    + "        return \"\" + (int)(price/(10 * statePairResolution));\n"
                    + "    }\n"
                    + "}\n",
                correlatorBuilderManager,
                feed,
                correlatorPool,
                null,
                null,
                null);
          }
        });

    final Button checkPool = new Button("Check Pool");

    feedControl.addComponent(checkPool);

    checkPool.addListener(
        new Button.ClickListener() {
          public void buttonClick(Button.ClickEvent event) {
            System.out.println(correlatorPool.getHandlesInfo());
          }
        });
  }