private void initLayout() {
        FormLayout loginForm = new FormLayout();
        loginForm.setSizeUndefined();

        loginForm.addComponent(userName = new TextField("Username"));
        loginForm.addComponent(passwordField = new PasswordField("Password"));
        loginForm.addComponent(login = new Button("Login"));
        login.addStyleName(ValoTheme.BUTTON_PRIMARY);
        login.setDisableOnClick(true);
        login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        login.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                login();
            }
        });

        VerticalLayout loginLayout = new VerticalLayout();
        loginLayout.setSizeUndefined();

        loginLayout.addComponent(loginFailedLabel = new Label());
        loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
        loginFailedLabel.setSizeUndefined();
        loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
        loginFailedLabel.setVisible(false);

        loginLayout.addComponent(loginForm);
        loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

        VerticalLayout rootLayout = new VerticalLayout(loginLayout);
        rootLayout.setSizeFull();
        rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
        setCompositionRoot(rootLayout);
        setSizeFull();
    }
Ejemplo n.º 2
0
  public void addTab(
      Component component, String id, int level, String caption, String link, Resource resource) {
    if (!hasTab(id)) {
      final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link);

      button.addClickListener(
          new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
              if (!event.isCtrlKey() && !event.isMetaKey()) {
                if (selectedButton != button) {
                  clearTabSelection(true);
                  selectedButton = button;
                  selectedButton.addStyleName(TAB_SELECTED_STYLENAME);
                  selectedComp = compMap.get(button.getTabId());
                }
                fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this));
              } else {
                Page.getCurrent().open(button.link, "_blank", false);
              }
            }
          });

      if (resource == null) {
        setDefaulButtonIcon(button, false);
      } else {
        button.setIcon(resource);
      }
      button.setStyleName(TAB_STYLENAME);
      button.setWidth("90%");

      if (button.getLevel() > 0) {
        int insertIndex = 0;
        for (int i = 0; i < navigatorContainer.getComponentCount(); i++) {
          ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i);
          if (buttonTmp.getLevel() > level) {
            break;
          } else {
            insertIndex++;
          }
        }
        navigatorContainer.addComponent(button, insertIndex);
        navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
      } else {
        navigatorContainer.addComponent(button);
        navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
      }

      TabImpl tabImpl = new TabImpl(id, caption, component);
      compMap.put(id, tabImpl);
    }
  }
Ejemplo n.º 3
0
  void confirmDelete() {

    // Create the window...
    subwindow = new Window("Xoa ??");
    // ...and make it modal
    subwindow.setModal(true);

    // Configure the windws layout; by default a VerticalLayout
    VerticalLayout layout = (VerticalLayout) subwindow.getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    // Add some content; a label and a close-button
    Label message = new Label("Ban co chac chan muon xoa ?");
    subwindow.addComponent(message);

    Button close =
        new Button(
            "Co",
            new Button.ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {

                (subwindow.getParent()).removeWindow(subwindow);
              }
            });
    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.TOP_RIGHT);
  } // end of confirmDelete
Ejemplo n.º 4
0
 public SelectWindow(
     float width,
     int units,
     Collection<T> items,
     T selectedItem,
     Resource icon,
     String caption,
     String message,
     String okButtonText,
     String cancelButtonText) {
   super();
   if (caption != null) {
     setCaption(caption);
   }
   if (icon != null) {
     setIcon(icon);
   }
   setWidth(width, units);
   setModal(true);
   setClosable(false);
   setResizable(false);
   setDraggable(false);
   VerticalLayout verticalLayout = new VerticalLayout();
   verticalLayout.setMargin(true);
   verticalLayout.setSpacing(true);
   setContent(verticalLayout);
   Label label = new Label(message);
   addComponent(label);
   mySelect = new Select(null, items);
   mySelect.setNullSelectionAllowed(false);
   mySelect.setValue(selectedItem != null ? selectedItem : items.iterator().next());
   mySelect.setWidth(100, Sizeable.UNITS_PERCENTAGE);
   addComponent(mySelect);
   Panel panel = new Panel();
   addComponent(panel);
   verticalLayout.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
   panel.addStyleName("light");
   HorizontalLayout horizontalLayout = new HorizontalLayout();
   panel.setContent(horizontalLayout);
   horizontalLayout.setSpacing(true);
   verticalLayout.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
   myCancelButton = new Button(cancelButtonText, this);
   panel.addComponent(myCancelButton);
   myOkButton = new Button(okButtonText, this);
   panel.addComponent(myOkButton);
 }
Ejemplo n.º 5
0
 public Button addButtonOnNavigatorContainer(String id, String caption, Resource icon) {
   final ButtonTabImpl button = new ButtonTabImpl(id, 0, caption, "");
   navigatorContainer.addComponent(button);
   navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
   button.setStyleName(TAB_STYLENAME);
   button.setWidth("90%");
   button.setIcon(icon);
   return button;
 }
Ejemplo n.º 6
0
 @Override
 public void show() {
   this.setVisible(true);
   users = Globals.control.usersData();
   vbox.removeAllComponents();
   for (UserData d : users) {
     Button b = genBut(d.name);
     vbox.addComponent(b);
     vbox.setComponentAlignment(b, Alignment.TOP_CENTER);
   }
 }
  private Component buildPreferencesTab() {
    VerticalLayout root = new VerticalLayout();
    root.setCaption("Preferences");
    root.setIcon(FontAwesome.COGS);
    root.setSpacing(true);
    root.setMargin(true);
    root.setSizeFull();

    Label message = new Label("Not implemented in this demo");
    message.setSizeUndefined();
    message.addStyleName(ValoTheme.LABEL_LIGHT);
    root.addComponent(message);
    root.setComponentAlignment(message, Alignment.MIDDLE_CENTER);

    return root;
  }
  @Override
  protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(
        new SplitButton.SplitButtonClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void splitButtonClick(SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
          }
        });
    controlsBtn.setSizeUndefined();
    Button selectBtn =
        new Button(
            "Select from existing opportunities",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                ContactOpportunitySelectionWindow opportunitiesWindow =
                    new ContactOpportunitySelectionWindow(ContactOpportunityListComp.this);
                OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
                criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
                UI.getCurrent().addWindow(opportunitiesWindow);
                opportunitiesWindow.setSearchCriteria(criteria);
                controlsBtn.setPopupVisible(false);
              }
            });
    selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
    OptionPopupContent buttonControlsLayout = new OptionPopupContent();
    buttonControlsLayout.addOption(selectBtn);
    controlsBtn.setContent(buttonControlsLayout);

    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
  }
Ejemplo n.º 9
0
  public WindowTimtheobomon() {

    setCaption("Tìm theo bộ môn "); // Constants.USER_CAPTION) ;

    HorizontalLayout mainLayout = new HorizontalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS);
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);

    mainLayout.addComponent(new leftSide());
    rContent = new VerticalLayout();
    rContent.setWidth("100%");

    mainLayout.addComponent(rContent);
    mainLayout.setExpandRatio(rContent, 1.0f);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setStyleName("bl-mainContent");
    v.addComponent(mainLayout);
    v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);

    addComponent(new topLogin());
    addComponent(new topPanel());
    addComponent(new mainMenu());
    addComponent(v);
    addComponent(new bottom());

    // --------------------bl
    Label title = new Label("<center><h1>Tìm theo bộ môn<h1></center>", Label.CONTENT_XHTML);

    final BeanItemContainer<ResearchingBean> beans =
        new BeanItemContainer<ResearchingBean>(ResearchingBean.class);

    Table table = new Table("Tìm kiếm", beans);

    table.setWidth("100%");
    table.setPageLength(10);

    rContent.addComponent(title);
    rContent.addComponent(table);
  }
Ejemplo n.º 10
0
  public WindowManagerTeacher() {

    setCaption("quan ly bo mon "); // Constants.USER_CAPTION) ;

    mainLayout = new HorizontalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS);
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);

    mainLayout.addComponent(new leftSide());

    rContentList = new VerticalLayout();
    rContentList.setWidth("100%");
    mainLayout.addComponent(rContentList);
    mainLayout.setExpandRatio(rContentList, 1.0f);

    rContentModify = new rightContentAddNewTeacher(1);
    rContentModify.setWidth("100%");

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setStyleName("bl-mainContent");
    v.addComponent(mainLayout);
    v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);

    addComponent(new topLogin());
    addComponent(new topPanel());
    addComponent(new mainMenu());
    addComponent(v);
    addComponent(new bottom());

    // --------------------bl
    Label title = new Label("<center><h1>Danh sách giang vien<h1></center>", Label.CONTENT_XHTML);

    table = new Table();
    table.setWidth("100%");
    table.setPageLength(20);

    rContentList.addComponent(title);
    rContentList.addComponent(table);

    Connection conn = null;
    Statement stmt = null;

    try {
      JDBCConnectionPool pool =
          new SimpleJDBCConnectionPool(
              JDBC_DRIVER,
              DB_URL + QlgiangvienApplication.DB_DBNAME,
              QlgiangvienApplication.DB_USER,
              QlgiangvienApplication.DB_PASS);

      String mysql = "SELECT * from GiangVien";

      TableQuery query = new TableQuery("GiangVien", pool);
      query.setVersionColumn("OPTLOCK");

      SQLContainer container = new SQLContainer(query);
      container.setAutoCommit(true);
      //          container.re
      table.setContainerDataSource(container);

      //           FreeformQuery query = new FreeformQuery(mysql, pool, "MaGV") ;

      //           container = new SQLContainer(query);

      //           table.setContainerDataSource(container) ;

      table.addGeneratedColumn(
          "Chinh Sua",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {
              final Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Chinh Sua",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          //              				rContentList.setVisible(false);
                          //              				rContentModify.setVisible(true);
                          System.out.println(item.toString());
                          rContentModify.setUpdateData(
                              item.getItemProperty("MaGV").getValue().toString());
                          mainLayout.removeComponent(rContentList);
                          mainLayout.addComponent(rContentModify);
                          mainLayout.setExpandRatio(rContentModify, 1.0f);
                        }
                      });

              return btnModify;
            }
          });
      confirmDelete();
      table.addGeneratedColumn(
          "Xoa",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {

              //            	   Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Xoa",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          if (subwindow.getParent() == null) {

                            getWindow().addWindow(subwindow);
                          }
                        }
                      });

              return btnModify;
            }
          });

    } catch (Exception e) {
      System.out.println("in right COntent: " + e.toString());
    }
  } // end of container
Ejemplo n.º 11
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);
  }
Ejemplo n.º 12
0
  @SuppressWarnings("serial")
  @Override
  public void editPhoto(final byte[] imageData) {
    this.removeAllComponents();
    LOG.debug("Receive avatar upload with size: " + imageData.length);
    try {
      originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
      throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox =
        new MHorizontalLayout()
            .withSpacing(true)
            .withMargin(new MarginInfo(false, true, true, false))
            .withWidth("100%");

    Resource defaultPhoto =
        UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.with(previewImage).withAlign(previewImage, Alignment.TOP_LEFT);

    VerticalLayout previewBoxRight = new VerticalLayout();
    previewBoxRight.setMargin(new MarginInfo(false, true, false, true));
    Label lbPreview =
        new Label(
            "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p>"
                + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
                + "When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxRight.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                EventBusFactory.getInstance()
                    .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null));
              }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    Button acceptBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                if (scaleImageData != null && scaleImageData.length > 0) {
                  try {
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                    UserAvatarService userAvatarService =
                        ApplicationContextUtil.getSpringBean(UserAvatarService.class);
                    userAvatarService.uploadAvatar(
                        image, AppContext.getUsername(), AppContext.getUserAvatarId());
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                  } catch (IOException e) {
                    throw new MyCollabException("Error when saving user avatar", e);
                  }
                }
              }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    previewBoxRight.addComponent(controlBtns);
    previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);

    previewBox.addComponent(previewBoxRight);
    previewBox.setExpandRatio(previewBoxRight, 1.0f);

    this.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.addStyleName(UIConstants.PHOTO_CROPBOX);
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource =
        new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(
        new Property.ValueChangeListener() {

          @Override
          public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.getProperty().getValue();
            int x1 = newSelection.getXTopLeft();
            int y1 = newSelection.getYTopLeft();
            int x2 = newSelection.getXBottomRight();
            int y2 = newSelection.getYBottomRight();
            if (x2 > x1 && y2 > y1) {
              BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
              ByteArrayOutputStream outStream = new ByteArrayOutputStream();
              try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
              } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
              }
            }
          }
        });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");

    currentPhotoBox.addComponent(cropField);

    cropBox.addComponent(currentPhotoBox);

    this.addComponent(previewBox);
    this.addComponent(cropBox);
    this.setExpandRatio(cropBox, 1.0f);
  }
Ejemplo n.º 13
0
      @Override
      public ComponentContainer getLayout() {
        final VerticalLayout layout = new VerticalLayout();
        this.informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 6);

        layout.addComponent(this.informationLayout.getLayout());

        final MHorizontalLayout controlsBtn =
            new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false));
        layout.addComponent(controlsBtn);

        final Button approveBtn =
            new Button(
                "Approve & Close",
                new Button.ClickListener() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public void buttonClick(Button.ClickEvent event) {

                    if (EditForm.this.validateForm()) {
                      // Save bug status and assignee
                      bug.setStatus(BugStatus.Verified.name());

                      BugService bugService =
                          ApplicationContextUtil.getSpringBean(BugService.class);
                      bugService.updateSelectiveWithSession(bug, AppContext.getUsername());

                      // Save comment
                      String commentValue = commentArea.getValue();
                      if (StringUtils.isNotBlank(commentValue)) {
                        CommentWithBLOBs comment = new CommentWithBLOBs();
                        comment.setComment(
                            Jsoup.clean(commentArea.getValue(), Whitelist.relaxed()));
                        comment.setCreatedtime(new GregorianCalendar().getTime());
                        comment.setCreateduser(AppContext.getUsername());
                        comment.setSaccountid(AppContext.getAccountId());
                        comment.setType(ProjectTypeConstants.BUG);
                        comment.setTypeid("" + bug.getId());
                        comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                        CommentService commentService =
                            ApplicationContextUtil.getSpringBean(CommentService.class);
                        commentService.saveWithSession(comment, AppContext.getUsername());
                      }

                      ApproveInputWindow.this.close();
                      callbackForm.refreshBugItem();
                    }
                  }
                });
        approveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        approveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        controlsBtn.with(approveBtn).withAlign(approveBtn, Alignment.MIDDLE_LEFT);

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

                  @Override
                  public void buttonClick(Button.ClickEvent event) {
                    ApproveInputWindow.this.close();
                  }
                });
        cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
        controlsBtn.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_LEFT);

        layout.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
        return layout;
      }
Ejemplo n.º 14
0
    @Override
    public Component generateBlock(final SimpleOpportunity opportunity, int blockIndex) {
      CssLayout beanBlock = new CssLayout();
      beanBlock.addStyleName("bean-block");
      beanBlock.setWidth("350px");

      VerticalLayout blockContent = new VerticalLayout();
      MHorizontalLayout blockTop = new MHorizontalLayout().withWidth("100%");
      CssLayout iconWrap = new CssLayout();
      iconWrap.setStyleName("icon-wrap");
      FontIconLabel opportunityIcon =
          new FontIconLabel(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
      iconWrap.addComponent(opportunityIcon);
      blockTop.addComponent(iconWrap);

      VerticalLayout opportunityInfo = new VerticalLayout();
      opportunityInfo.setSpacing(true);

      MButton btnDelete = new MButton(FontAwesome.TRASH_O);
      btnDelete.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
              ConfirmDialogExt.show(
                  UI.getCurrent(),
                  AppContext.getMessage(
                      GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                  AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                  AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                  AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                  new ConfirmDialog.Listener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClose(ConfirmDialog dialog) {
                      if (dialog.isConfirmed()) {
                        ContactService contactService =
                            ApplicationContextUtil.getSpringBean(ContactService.class);
                        ContactOpportunity associateOpportunity = new ContactOpportunity();
                        associateOpportunity.setContactid(contact.getId());
                        associateOpportunity.setOpportunityid(opportunity.getId());
                        contactService.removeContactOpportunityRelationship(
                            associateOpportunity, AppContext.getAccountId());
                        ContactOpportunityListComp.this.refresh();
                      }
                    }
                  });
            }
          });

      btnDelete.addStyleName(UIConstants.BUTTON_ICON_ONLY);

      blockContent.addComponent(btnDelete);
      blockContent.setComponentAlignment(btnDelete, Alignment.TOP_RIGHT);

      Label opportunityName =
          new Label(
              String.format(
                  "Name: <a href='%s%s'>%s</a>",
                  SiteConfiguration.getSiteUrl(AppContext.getUser().getSubdomain()),
                  CrmLinkGenerator.generateCrmItemLink(
                      CrmTypeConstants.OPPORTUNITY, opportunity.getId()),
                  opportunity.getOpportunityname()),
              ContentMode.HTML);

      opportunityInfo.addComponent(opportunityName);

      Label opportunityAmount =
          new Label("Amount: " + (opportunity.getAmount() != null ? opportunity.getAmount() : ""));
      if (opportunity.getCurrency() != null && opportunity.getAmount() != null) {
        opportunityAmount.setValue(
            opportunityAmount.getValue() + opportunity.getCurrency().getSymbol());
      }
      opportunityInfo.addComponent(opportunityAmount);

      Label opportunitySaleStage =
          new Label(
              "Sale Stage: "
                  + (opportunity.getSalesstage() != null ? opportunity.getSalesstage() : ""));
      opportunityInfo.addComponent(opportunitySaleStage);

      ELabel opportunityExpectedCloseDate =
          new ELabel(
                  "Expected Closed Date: "
                      + AppContext.formatPrettyTime(opportunity.getExpectedcloseddate()))
              .withDescription(AppContext.formatDate(opportunity.getExpectedcloseddate()));
      opportunityInfo.addComponent(opportunityExpectedCloseDate);

      blockTop.with(opportunityInfo).expand(opportunityInfo);
      blockContent.addComponent(blockTop);

      blockContent.setWidth("100%");

      beanBlock.addComponent(blockContent);
      return beanBlock;
    }
Ejemplo n.º 15
0
  /** @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);
        });
  }