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
示例#2
0
  @PostConstruct
  public void PostConstruct() throws GeneralSecurityException {
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    layout.addComponent(chooseLanguage);

    layout.addComponent(new Label(messageSource.getMessage("error_view.reload")));

    layout.addComponent(
        new Button(
            messageSource.getMessage("error_view.turn_off"),
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent event) {
                Notification.show("one");
              }
            }));

    layout.addComponent(
        new Button(
            messageSource.getMessage("main.go_back"),
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent event) {
                Page.getCurrent().setUriFragment("!" + MainView.NAME);
              }
            }));

    setContent(layout);
  }
示例#3
0
  private com.vaadin.ui.Component buildLoginForm() {
    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("login-panel");

    loginPanel.addComponent(buildLabels());
    loginPanel.addComponent(buildFields());
    loginPanel.addComponent(new CheckBox("Remember me", true));
    return loginPanel;
  }
  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;
  }
  public SettingsLayout(String userName, MainPage mainPage) {
    this.mainPage = mainPage;
    this.userName = userName;

    WebApplicationContext context = (WebApplicationContext) mainPage.getContext();
    WebBrowser webBrowser = context.getBrowser();
    height = webBrowser.getScreenHeight() - 310;

    setMargin(true);
    setSpacing(true);
    vl.setMargin(true);
    vl.setSpacing(true);
    panelEmail.setWidth("100%");
    addComponent(hl);

    hl.setFirstComponent(panelEmail);
    hl.setSecondComponent(panelPassword);

    oldEmail.setValue(GeneralController.getEmailFromUserName(userName));
    oldEmail.setWidth("250");
    oldEmail.setReadOnly(false);

    newEmail.setWidth("250");
    newEmail.addValidator(new EmailValidator("Email должен содержать знак '@' и полный домен."));

    saveButton = new Button("Сохранить изменения");
    saveButton.setVisible(true);
    saveButton.setIcon(new ThemeResource("icons/32/save.png"));

    resetUserPasswordButton.setVisible(true);
    resetUserPasswordButton.setIcon(new ThemeResource("icons/32/group_key.png"));
    resetUserPasswordButton.addListener(this);

    oldEmailInscription.setReadOnly(true);
    panelEmail.addComponent(oldEmailInscription);
    panelEmail.addComponent(oldEmail);
    panelEmail.addComponent(newEmail);
    panelEmail.addComponent(saveButton);
    panelPassword.addComponent(label);
    panelPassword.addComponent(resetUserPasswordButton);

    panelEmail.setHeight(height);
    panelPassword.setHeight(height);

    saveButton.addListener(this);
  }
示例#6
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);
 }
 public MainScreen() {
   Label loginLabel =
       new Label("Welcome " + VaadinSession.getCurrent().getAttribute(String.class));
   HorizontalLayout menuBar = new HorizontalLayout(loginLabel);
   MessageTable table = new MessageTable();
   TextArea messageArea = new TextArea();
   messageArea.setWidth(100, PERCENTAGE);
   Button sendButton = new Button("Send");
   sendButton.addClickListener(new SendMessageClickListener(table, messageArea));
   HorizontalLayout lowerBar = new HorizontalLayout(messageArea, sendButton);
   lowerBar.setWidth(100, PERCENTAGE);
   lowerBar.setSpacing(true);
   VerticalLayout mainLayout = new VerticalLayout(menuBar, table, lowerBar);
   mainLayout.setSpacing(true);
   mainLayout.setMargin(true);
   mainLayout.setSizeFull();
   setCompositionRoot(mainLayout);
 }
示例#8
0
  @PostConstruct
  public void PostConstruct() {
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    HorizontalLayout usernameLayout = new HorizontalLayout();
    usernameLayout.setSpacing(true);
    usernameLayout.addComponent(new Label("Username:"******"Roles:"));
    userRolesLayout.addComponent(rolesLabel);

    layout.addComponent(usernameLayout);
    layout.addComponent(userRolesLayout);

    Link userView =
        new Link(
            "ROLE_USER View (disabled, if user doesn't have access)",
            new ExternalResource("#!" + RoleUserView.NAME));
    Link roleView =
        new Link(
            "ROLE_ADMIN View (disabled, if user doesn't have access)",
            new ExternalResource("#!" + RoleAdminView.NAME));

    userView.setEnabled(SpringSecurityHelper.hasRole("ROLE_USER"));
    roleView.setEnabled(SpringSecurityHelper.hasRole("ROLE_ADMIN"));

    layout.addComponent(userView);
    layout.addComponent(roleView);
    layout.addComponent(
        new Link(
            "ROLE_ADMIN View (throw exception, if user doesn't have access)",
            new ExternalResource("#!" + RoleAdminView.NAME)));

    layout.addComponent(new Link("Logout", new ExternalResource("/j_spring_security_logout")));

    setContent(layout);
  }
示例#9
0
  @SuppressWarnings("serial")
  public NotAllowedPopover() {
    setWidth("75%");

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setHeight("150px");

    Label lbl;
    layout.addComponent(
        lbl =
            new Label(
                "This mmowgli game does not allow guest access.  Thank you for your interest."));

    layout.setExpandRatio(lbl, 1.0f);
    Button closeButt;
    layout.addComponent(closeButt = new Button("Close"));

    NavigationView nv = new NavigationView(layout);
    nv.setCaption("Access Not Allowed");
    setContent(nv);
    this.center();

    closeButt.addClickListener(
        new ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            HSess.init();
            GameLinks links = GameLinks.getTL();
            HSess.close();

            UI.getCurrent().getPage().setLocation(links.getThanksForInterestLink());
            getSession().close();
          }
        });
  }
    @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;
    }
  private Component buildProfileTab() {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption("Profile");
    root.setIcon(FontAwesome.USER);
    root.setWidth(100.0f, Unit.PERCENTAGE);
    root.setSpacing(true);
    root.setMargin(true);
    root.addStyleName("profile-form");

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

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

    root.addComponent(pic);

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

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

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

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

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

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

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

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

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

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

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

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

    return root;
  }
  @Override
  public void execute() {
    List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good);
    Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("650px");
    subWindow.setWidth("700px");
    subWindow.setClosable(true);
    view.getUi().addWindow(subWindow);

    final Button pdfButton = new Button(bundle.getString("pdf.export"));
    pdfButton.setIcon(new ThemeResource("img/pdf.png"));
    pdfButton.setWidth("150");
    StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good));
    pdfStream.setMIMEType("application/pdf");
    FileDownloader pdfDownloader = new FileDownloader(pdfStream);
    pdfDownloader.extend(pdfButton);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(pdfButton);

    for (ChangeRecord record : historyList) {
      for (ChangeRecord.PropertyChange p : record.getChangeList()) {
        p.setName(bundle.getString(p.getName()));
      }
      Panel panel = new Panel();
      BeanItemContainer<ChangeRecord.PropertyChange> container =
          new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList());
      Table table = new Table();
      table.setContainerDataSource(container);
      table.setVisibleColumns("name", "oldValue", "newValue");
      table.setColumnHeaders(
          bundle.getString("history.property"),
          bundle.getString("history.old"),
          bundle.getString("history.new"));
      table.setColumnExpandRatio("name", 0.33f);
      table.setColumnExpandRatio("oldValue", 0.33f);
      table.setColumnExpandRatio("newValue", 0.33f);
      table.setPageLength(0);
      table.setWidth("100%");

      VerticalLayout panelLayout = new VerticalLayout();
      panelLayout.addComponent(
          new Label(
              "<b>"
                  + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate())
                  + ": "
                  + record.getUser().getName()
                  + " "
                  + record.getUser().getSurname()
                  + "</b><br/>",
              ContentMode.HTML));
      panelLayout.addComponent(table);
      panel.setContent(panelLayout);
      layout.addComponent(panel);
    }

    subWindow.setContent(layout);
  }