private void BuildBranding() {
    branding.setSizeUndefined();
    branding.addStyleName("branding");
    branding.addStyleName("menu");

    Button b = new NativeButton();
    b.addStyleName("icon-dashboard");
    b.setSizeFull();
    b.addClickListener(
        new ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            clearMenuSelection(menu);
            event.getButton().addStyleName("selected");
            if (!navegador.getState().equals("/dashboard")) navegador.navigateTo("/dashboard");
          }
        });

    viewNameToMenuButton.put("/dashboard", b);
    viewNameToMenuButton.get("/dashboard").setHtmlContentAllowed(true);
    viewNameToMenuButton.get("/dashboard").setCaption("<span class=\"badge\">2</span>");

    Label logo = new Label("Zombre <span>Underwear</span>", ContentMode.HTML);
    logo.setSizeFull();
    branding.addComponent(b);
    //    	branding.addComponent(logo);
  }
  @Override
  public void attach() {
    //		System.out.println("refer url is: "+referrer);
    //		System.out.println("Start to read the window name: ");
    //		List<String> wNames = new ArrayList<String>();
    //		for(Window w:getWindows()){
    //			wNames.add(w.getName());
    //			System.out.println("window name is: "+w.getName());
    //		}
    //		getApplication().getMainWindow().removeAllComponents();
    VerticalLayout userAuthLayout = new VerticalLayout();
    userAuthLayout.addStyleName("sourceAppLayout");
    Label comfireLable = new Label("Please Check the User Information");
    comfireLable.addStyleName("comfireLable");
    userAuthLayout.addComponent(comfireLable);
    //		userAuthLayout.setComponentAlignment(comfireLable, Alignment.MIDDLE_RIGHT);

    HorizontalLayout g1 = new HorizontalLayout();
    g1.addStyleName("sourceAPPAuthInfoLayout");
    userAuthLayout.addComponent(g1);
    userAuthLayout.setComponentAlignment(g1, Alignment.MIDDLE_LEFT);

    // network infor
    Label networkInfo = new Label("Authencation Network");
    networkInfo.addStyleName("inforCard");
    g1.addComponent(networkInfo);
    g1.setComponentAlignment(networkInfo, Alignment.TOP_LEFT);
    Label autheFromSiteName = new Label("eBay");
    autheFromSiteName.addStyleName("inforValue");
    g1.addComponent(autheFromSiteName);
    g1.setComponentAlignment(autheFromSiteName, Alignment.TOP_RIGHT);

    HorizontalLayout g2 = new HorizontalLayout();
    g2.addStyleName("sourceAPPAuthInfoLayout");
    userAuthLayout.addComponent(g2);
    userAuthLayout.setComponentAlignment(g2, Alignment.MIDDLE_LEFT);
    // userName infor
    Label userNameInfo = new Label("User Info");
    userNameInfo.addStyleName("inforCard");
    userNameInfo.addStyleName("userNameInfo");
    g2.addComponent(userNameInfo);
    g2.setComponentAlignment(userNameInfo, Alignment.TOP_LEFT);
    Label authUserName = new Label(referrer.split("username="******"inforValue");
    g2.addComponent(authUserName);
    g2.setComponentAlignment(authUserName, Alignment.TOP_RIGHT);

    //		// token expireDate infor
    //		Label tokenInfo=new Label("Developer");
    //		g.addComponent(tokenInfo);
    //		g.setComponentAlignment(tokenInfo,Alignment.MIDDLE_CENTER);
    //		Label tokenExpireDate=new Label(referrer.split("username=")[1]);
    //		g.addComponent(authUserName);
    //		g.setComponentAlignment(authUserName,Alignment.MIDDLE_CENTER);

    userAuthLayout.addComponent(getWebFoot());
    this.setContent(userAuthLayout);
  }
示例#3
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;
  }
  public CrmPreviewFormControlsGenerator(final AdvancedPreviewBeanForm<T> editForm) {
    this.previewForm = editForm;

    editButtons = new HorizontalLayout();
    editButtons.setSpacing(true);
    editButtons.addStyleName("edit-btn");
  }
示例#5
0
  private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    username = new TextField("Usuario");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    username.focus();

    clave = new PasswordField("Contraseña");
    clave.setIcon(FontAwesome.LOCK);
    clave.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Entrar");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(KeyCode.ENTER);

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

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

          @Override
          public void buttonClick(final ClickEvent event) {

            doLogin();
          }
        });
    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;
  }
示例#7
0
  /**
   * 页面底部版权 Bar
   *
   * @return
   */
  public HorizontalLayout getPageFooter() {
    // 底部公司介绍 水平布局
    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth(100, Unit.PERCENTAGE);
    footer.setMargin(true);
    footer.addStyleName(Reindeer.LAYOUT_BLACK);
    // -----------------------底部公司介绍-------------------------------
    Label lbcopyright = new Label("Copyright 2014");
    lbcopyright.setSizeUndefined();
    // lbcopyright.addStyleName(Reindeer.LABEL_H2);
    Label lbcompany = new Label("上海释伟科技有限公司");
    // lbcompany.addStyleName(Reindeer.LABEL_H2);
    Label lbdesc = new Label("留夫鸭电子商务O2O解决方案");
    // lbdesc.addStyleName(Reindeer.LABEL_H2);

    Label lbspace = new Label(); // 占位空间
    lbspace.setWidth(520, Unit.PIXELS);

    footer.setSpacing(true); // 设置间隙
    footer.addComponent(lbcopyright);
    footer.setComponentAlignment(lbcopyright, Alignment.MIDDLE_LEFT);

    // footer.addComponent(lbspace);
    footer.addComponent(lbdesc);
    footer.setComponentAlignment(lbdesc, Alignment.MIDDLE_LEFT);

    footer.addComponent(lbspace);
    footer.addComponent(lbcompany);
    footer.setComponentAlignment(lbcompany, Alignment.MIDDLE_LEFT);

    return footer;
  }
  private void BuildMenu() {
    menu.removeAllComponents();
    menu.addStyleName("menu");
    menu.setSizeUndefined();
    menu.setMargin(true);

    for (final String view : routes.keySet()) {
      Button b =
          new NativeButton(
              view.substring(0, 1).toUpperCase() + view.substring(1).replace('-', ' '));
      b.addStyleName("icon-" + view);
      b.setSizeFull();
      b.addClickListener(
          new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
              clearMenuSelection(menu);
              event.getButton().addStyleName("selected");
              if (!navegador.getState().equals("/" + view)) navegador.navigateTo("/" + view);
            }
          });

      menu.addComponent(b);
      viewNameToMenuButton.put("/" + view, b);
    }
  }
示例#9
0
 private Component buildNavBar() {
   Panel navPanel = new Panel();
   HorizontalLayout nav = new HorizontalLayout();
   nav.addStyleName("ait-content-nav");
   nav.addComponent(new Label(AitView.getNavText(menu), ContentMode.HTML));
   navPanel.setContent(nav);
   return navPanel;
 }
示例#10
0
  private Component AutoGeneratedLayoutDesign() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    // set parent Test Case manually without a field
    if (editmode == false && (clonemode == false)) {
      testsession.setParentcase(parentcase);
    }

    binder = new FieldGroup();
    //		BeanItem<Person> item = new BeanItem<Person>(person);		// takes item as argument
    //		item.addNestedProperty("address.street");	// Address info is not person but address to which
    // person is linked
    binder.setItemDataSource(newSessionItem); // link to data model to binder	
    //		binder.bindMemberFields(form);	// link to layout

    // GENERATE FIELDS
    //	for (Object propertyId : item.getItemPropertyIds()) {
    //		if(!"address".equals(propertyId)) {
    //			Field field = binder.buildAndBind(propertyId);
    //			layout.addComponent(field);
    //		}
    //	}

    // using bind() to determine what type of field is created yourself...
    title = new TextField();
    binder.bind(title, "title");
    title.setWidth(22, Unit.EM);
    title.setCaption("Title");
    title.focus();
    title.setImmediate(true);
    title.addValidator(new BeanValidator(TestSession.class, "title"));
    //		title.setValidationVisible(false);
    title.setNullRepresentation("");
    layout.addComponent(title);

    binder.setBuffered(true);

    // button layout
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addStyleName("buttons-margin-top");
    layout.addComponent(buttons);

    createButton = new Button("Create", this);
    if (editmode) createButton.setCaption("Save");
    createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    createButton.setClickShortcut(KeyCode.ENTER);

    cancelButton = new Button("Cancel", this);

    buttons.addComponents(createButton, cancelButton);
    buttons.setComponentAlignment(createButton, Alignment.MIDDLE_LEFT);
    buttons.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    return layout;
  }
示例#11
0
 private HorizontalLayout getCaptionLayout() {
   final HorizontalLayout captionLayout = new HorizontalLayout();
   captionLayout.setSizeFull();
   captionLayout.setHeight("36px");
   captionLayout.addComponents(windowCaption, minimizeButton, resizeButton, closeButton);
   captionLayout.setExpandRatio(windowCaption, 1.0F);
   captionLayout.addStyleName("v-window-header");
   return captionLayout;
 }
示例#12
0
  private Component buildHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.addStyleName("viewheader");

    titleLabel = new Label("Dashboard");
    titleLabel.setId(TITLE_ID);
    titleLabel.setSizeUndefined();
    titleLabel.addStyleName(ValoTheme.LABEL_H1);
    titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    header.addComponent(titleLabel);

    notificationsButton = buildNotificationsButton();
    Component edit = buildEditButton();
    HorizontalLayout tools = new HorizontalLayout(notificationsButton, edit);
    tools.addStyleName("toolbar");
    header.addComponent(tools);

    return header;
  }
示例#13
0
  private void BuildMenuBar() {
    menuBar.addComponent(branding);
    menuBar.addComponent(menu);
    menuBar.addComponent(settings);
    menuBar.addStyleName("sidebar");

    //		menuBar.setComponentAlignment(menu, Alignment.MIDDLE_CENTER);
    menuBar.setExpandRatio(menu, 1);
    menuBar.setWidth("100%");
  }
示例#14
0
 public void build() {
   //		super.attach();
   layout.setWidth("980px");
   //		layout.setSpacing(true);
   layout.addStyleName("mocha-index");
   layout.addComponent(buildInformationColumn());
   layout.addComponent(buildContentColumn());
   layout.addComponent(proxy);
   addComponent(layout);
   setComponentAlignment(layout, Alignment.TOP_CENTER);
 }
示例#15
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();
        });
  }
示例#16
0
  private HorizontalLayout createActionButtonsLayout() {

    buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSizeFull();
    buttonsLayout.setSpacing(true);
    buttonsLayout.setSpacing(true);
    buttonsLayout.addStyleName("actionButtonsMargin");

    createSaveButton();
    createCancelButton();

    addHelpLink();

    return buttonsLayout;
  }
示例#17
0
  public Login() {
    // TODO Auto-generated constructor stub
    VaadinSession.getCurrent().setAttribute("municipaldata", null);
    VaadinSession.getCurrent().setAttribute("barangaydata", null);
    VaadinSession.getCurrent().setAttribute("id", null);
    setSizeFull();
    dialog = new Window("Login");
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.center();

    //		new CreateAccount();

    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(new MarginInfo(false, true, true, true));
    dialog.setContent(content);

    Label title = new Label("Login");
    title.addStyleName(ValoTheme.LABEL_H2);
    title.addStyleName(ValoTheme.LABEL_COLORED);

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

    username.setIcon(FontAwesome.USER);
    username.focus();
    form.addComponent(username);

    password.setIcon(FontAwesome.LOCK);
    form.addComponent(password);

    Button submit = new Button("Login");
    submit.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_RIGHT);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);
    submit.setIcon(FontAwesome.ARROW_RIGHT);
    submit.setWidth("100%");
    submit.addListener(ClickEvent.class, this, "gotoMain");
    content.addComponent(submit);
  }
  public ServerDescBasic() {
    setHeight("100%");
    addStyleName(Reindeer.PANEL_LIGHT);

    VerticalLayout panel = (VerticalLayout) getContent();
    panel.setWidth("100%");
    panel.setHeight("100%");
    panel.setMargin(true);
    panel.setSpacing(false);
    panel.addStyleName("server-desc-basic");

    HorizontalLayout hlPanels = new HorizontalLayout();
    hlPanels.setWidth("100%");
    hlPanels.setHeight("100%");
    hlPanels.setMargin(true);
    hlPanels.setSpacing(true);
    hlPanels.addStyleName("server-desc-basic");
    //        setContent(hlPanels);

    left.setWidth("100%");
    right.setHeight("100%");
    right.setWidth("100%");

    // 表同士の間隔をあける
    Label padding = new Label(" ");
    padding.setWidth("7px");
    padding.setHeight("99%");
    padding.addStyleName("desc-padding");

    Label padding2 = new Label("");
    padding2.setWidth("1px");

    hlPanels.addComponent(left);
    hlPanels.addComponent(padding);
    hlPanels.addComponent(padding2);
    hlPanels.addComponent(right);
    hlPanels.setExpandRatio(left, 40);
    hlPanels.setExpandRatio(right, 60);

    panel.addComponent(hlPanels);
    panel.setExpandRatio(hlPanels, 1.0f);
  }
  private void initForm() {
    layout = new VerticalLayout();
    addComponent(layout);

    layout.addComponent(fileName);

    pi.setVisible(false);
    pi.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(pi);

    textualProgress.setVisible(false);

    cancelLayout = new HorizontalLayout();
    cancelLayout.addStyleName(CANCEL_BUTTON_LAYOUT_STYLE_CLASS);
    cancelLayout.setWidth(100, Unit.PERCENTAGE);
    cancelLayout.addComponent(textualProgress);
    cancelButton = new Button();
    cancelLayout.addComponent(cancelButton);
    cancelLayout.setComponentAlignment(cancelButton, Alignment.TOP_RIGHT);
    layout.addComponent(cancelLayout);
  }
  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;
  }
示例#21
0
  @Override
  protected void setup(VaadinRequest request) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName("layout-update");
    layout.setWidth("100%");
    setContent(layout);
    Responsive.makeResponsive(layout);

    Label label =
        new Label(
            "This label changes its size between the breakpoints, allowing more space for the adjacent component.");
    label.addStyleName("change-width");
    layout.addComponent(label);

    Panel panel = new Panel("Panel");
    Label label2 = new Label("This Panel should be maximized in both breakpoints.");
    label2.setWidth("100%");
    panel.setContent(label2);
    panel.setSizeFull();
    layout.addComponent(panel);
    layout.setExpandRatio(panel, 1);
  }
示例#22
0
  private void openNotificationsPopup(final ClickEvent event) {
    VerticalLayout notificationsLayout = new VerticalLayout();

    Label title = new Label("Notifications");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    notificationsLayout.addComponent(title);

    Collection<DashboardNotification> notifications =
        DashboardUI.getDataProvider().getNotifications();
    DashboardEventBus.post(new NotificationsCountUpdatedEvent());

    for (DashboardNotification notification : notifications) {
      VerticalLayout notificationLayout = new VerticalLayout();
      notificationLayout.setMargin(false);
      notificationLayout.setSpacing(false);
      notificationLayout.addStyleName("notification-item");

      Label titleLabel =
          new Label(
              notification.getFirstName()
                  + " "
                  + notification.getLastName()
                  + " "
                  + notification.getAction());
      titleLabel.addStyleName("notification-title");

      Label timeLabel = new Label(notification.getPrettyTime());
      timeLabel.addStyleName("notification-time");

      Label contentLabel = new Label(notification.getContent());
      contentLabel.addStyleName("notification-content");

      notificationLayout.addComponents(titleLabel, timeLabel, contentLabel);
      notificationsLayout.addComponent(notificationLayout);
    }

    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.setSpacing(false);
    Button showAll =
        new Button(
            "View All Notifications",
            new ClickListener() {
              @Override
              public void buttonClick(final ClickEvent event) {
                Notification.show("Not implemented in this demo");
              }
            });
    showAll.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    showAll.addStyleName(ValoTheme.BUTTON_SMALL);
    footer.addComponent(showAll);
    footer.setComponentAlignment(showAll, Alignment.TOP_CENTER);
    notificationsLayout.addComponent(footer);

    if (notificationsWindow == null) {
      notificationsWindow = new Window();
      notificationsWindow.setWidth(300.0f, Unit.PIXELS);
      notificationsWindow.addStyleName("notifications");
      notificationsWindow.setClosable(false);
      notificationsWindow.setResizable(false);
      notificationsWindow.setDraggable(false);
      notificationsWindow.setCloseShortcut(KeyCode.ESCAPE, null);
      notificationsWindow.setContent(notificationsLayout);
    }

    if (!notificationsWindow.isAttached()) {
      notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40);
      getUI().addWindow(notificationsWindow);
      notificationsWindow.focus();
    } else {
      notificationsWindow.close();
    }
  }
示例#23
0
  public CheckBoxes() {
    setMargin(true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    options = new OptionGroup("Horizontal items, explicit width");
    options.setMultiSelect(true);
    options.setWidth("500px");
    options.addStyleName("horizontal");
    options.addItem("Option One");
    two = options.addItem("Option Two, with a longer caption");
    options.addItem("Option Three");
    options.select("Option One");
    options.setItemIcon("Option One", testIcon.get());
    options.setItemIcon(two, testIcon.get());
    options.setItemIcon("Option Three", testIcon.get());
    row.addComponent(options);
  }
    @Override
    public Component generateRow(final SimpleMessage message, final int rowIndex) {
      final HorizontalLayout messageLayout = new HorizontalLayout();
      messageLayout.setStyleName("message");
      messageLayout.setSpacing(true);
      if (message.getIsstick() != null && message.getIsstick()) {
        messageLayout.addStyleName("important-message");
      }
      messageLayout.setWidth("100%");
      VerticalLayout userBlock = new VerticalLayout();
      userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER);
      userBlock.setWidth("80px");
      userBlock.setSpacing(true);
      userBlock.addComponent(
          UserAvatarControlFactory.createUserAvatarButtonLink(
              message.getPostedUserAvatarId(), message.getFullPostedUserName()));
      Label userName = new Label(message.getFullPostedUserName());
      userName.setStyleName("user-name");
      userBlock.addComponent(userName);
      messageLayout.addComponent(userBlock);

      final CssLayout rowLayout = new CssLayout();
      rowLayout.setStyleName("message-container");
      rowLayout.setWidth("100%");
      final Button title =
          new Button(
              message.getTitle(),
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  EventBus.getInstance()
                      .fireEvent(
                          new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId()));
                }
              });

      title.setWidth("550px");
      title.setStyleName("link");
      title.addStyleName(UIConstants.WORD_WRAP);

      final HorizontalLayout messageHeader = new HorizontalLayout();
      messageHeader.setStyleName("message-header");
      messageHeader.setMargin(new MarginInfo(true, true, false, true));
      final VerticalLayout leftHeader = new VerticalLayout();

      title.addStyleName("message-title");
      leftHeader.addComponent(title);

      final HorizontalLayout rightHeader = new HorizontalLayout();
      rightHeader.setSpacing(true);

      final Label timePostLbl =
          new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate()));
      timePostLbl.setSizeUndefined();
      timePostLbl.setStyleName("time-post");

      final HorizontalLayout notification = new HorizontalLayout();
      notification.setStyleName("notification");
      notification.setSizeUndefined();
      notification.setSpacing(true);
      if (message.getCommentsCount() > 0) {
        final HorizontalLayout commentNotification = new HorizontalLayout();
        final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount()));
        commentCountLbl.setStyleName("comment-count");
        commentCountLbl.setSizeUndefined();
        commentNotification.addComponent(commentCountLbl);
        final Image commentIcon =
            new Image(null, MyCollabResource.newResource("icons/16/project/message.png"));
        commentNotification.addComponent(commentIcon);

        notification.addComponent(commentNotification);
      }
      ResourceService attachmentService =
          ApplicationContextUtil.getSpringBean(ResourceService.class);
      List<Content> attachments =
          attachmentService.getContents(
              AttachmentUtils.getProjectEntityAttachmentPath(
                  AppContext.getAccountId(),
                  message.getProjectid(),
                  AttachmentType.PROJECT_MESSAGE,
                  message.getId()));
      if (attachments != null && !attachments.isEmpty()) {
        final HorizontalLayout attachmentNotification = new HorizontalLayout();
        final Label attachmentCountLbl = new Label(Integer.toString(attachments.size()));
        attachmentCountLbl.setStyleName("attachment-count");
        attachmentCountLbl.setSizeUndefined();
        attachmentNotification.addComponent(attachmentCountLbl);
        final Image attachmentIcon =
            new Image(null, MyCollabResource.newResource("icons/16/attachment.png"));
        attachmentNotification.addComponent(attachmentIcon);

        notification.addComponent(attachmentNotification);
      }

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

                @Override
                public void buttonClick(ClickEvent event) {
                  ConfirmDialogExt.show(
                      UI.getCurrent(),
                      LocalizationHelper.getMessage(
                          GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()),
                      LocalizationHelper.getMessage(
                          GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE),
                      LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL),
                      LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL),
                      new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(final ConfirmDialog dialog) {
                          if (dialog.isConfirmed()) {
                            final MessageService messageService =
                                ApplicationContextUtil.getSpringBean(MessageService.class);
                            messageService.removeWithSession(
                                message.getId(),
                                AppContext.getUsername(),
                                AppContext.getAccountId());
                            MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria);
                          }
                        }
                      });
                }
              });
      deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png"));
      deleteBtn.addStyleName("link");
      deleteBtn.setEnabled(
          CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES));

      rightHeader.addComponent(timePostLbl);
      rightHeader.addComponent(deleteBtn);
      rightHeader.setExpandRatio(timePostLbl, 1.0f);

      messageHeader.addComponent(leftHeader);
      messageHeader.setExpandRatio(leftHeader, 1.0f);
      messageHeader.addComponent(rightHeader);
      messageHeader.setWidth("100%");

      rowLayout.addComponent(messageHeader);

      final Label messageContent =
          new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML);
      messageContent.setStyleName("message-body");
      rowLayout.addComponent(messageContent);

      if (notification.getComponentCount() > 0) {
        VerticalLayout messageFooter = new VerticalLayout();
        messageFooter.setWidth("100%");
        messageFooter.setStyleName("message-footer");
        messageFooter.addComponent(notification);
        messageFooter.setMargin(true);
        messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
      }

      messageLayout.addComponent(rowLayout);
      messageLayout.setExpandRatio(rowLayout, 1.0f);

      return messageLayout;
    }
示例#25
0
  private void initUI() {
    addStyleName(Reindeer.WINDOW_LIGHT);
    setModal(true);
    setHeight("90%");
    setWidth("60%");
    center();

    HorizontalLayout bottom = new HorizontalLayout();
    bottom.setStyleName(ExplorerLayout.THEME);
    bottom.setSizeFull();
    // bottom.setMargin(true);
    bottom.setSpacing(true);
    bottom.addStyleName(Runo.LAYOUT_DARKER);
    this.setContent(bottom);

    scheduleEventFieldGroup = new FieldGroup();
    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
      scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }

    line = new GridLayout(4, 20);
    line.addStyleName("v-gridlayout");
    line.setWidth("100%");
    line.setSpacing(true);
    line.setMargin(true);

    final Label lbTitle = CommonFieldHandler.createLable("计划名称:");
    line.addComponent(lbTitle);
    line.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
    final TextField txtTitle = new TextField();
    txtTitle.setWidth("80%");
    scheduleEventFieldGroup.bind(txtTitle, "name");
    line.addComponent(txtTitle, 1, 0, 3, 0);
    line.setComponentAlignment(txtTitle, Alignment.MIDDLE_LEFT);

    Label label2 = CommonFieldHandler.createLable("开始时间:");
    line.addComponent(label2, 0, 1, 0, 1);
    line.setComponentAlignment(label2, Alignment.MIDDLE_RIGHT);
    // 创建一个时间后台变化的listener
    BlurListener startTimeListener = createTimeReCountListener();
    DateField startDateField = CommonFieldHandler.createDateField("", false);
    scheduleEventFieldGroup.bind(startDateField, "startDate");
    startDateField.addBlurListener(startTimeListener);
    line.addComponent(startDateField, 1, 1, 1, 1);
    line.setComponentAlignment(startDateField, Alignment.MIDDLE_LEFT);

    Label label3 = CommonFieldHandler.createLable("估算时间:");
    line.addComponent(label3, 2, 1, 2, 1);
    line.setComponentAlignment(label3, Alignment.MIDDLE_RIGHT);
    HorizontalLayout hlay = new HorizontalLayout();
    final TextField estimateField = new TextField();
    estimateField.setValue("1");
    estimateField.setWidth("60px");
    estimateField.setNullSettingAllowed(false);
    BlurListener timeReCountListener = createTimeReCountListener();
    estimateField.addBlurListener(timeReCountListener);
    scheduleEventFieldGroup.bind(estimateField, "estimate");
    hlay.addComponent(estimateField);
    Map<Object, String> data = new HashMap();
    data.put(0, "天");
    data.put(1, "时");
    data.put(2, "分");
    // WW_TODO 估算时间单位
    ComboBox unit_cb = createComboBox(data, "55px");
    scheduleEventFieldGroup.bind(unit_cb, "estimateUnit");
    hlay.addComponent(unit_cb);
    line.addComponent(hlay, 3, 1, 3, 1);
    line.setComponentAlignment(hlay, Alignment.MIDDLE_LEFT);

    Label label4 = CommonFieldHandler.createLable("到期时间:");
    line.addComponent(label4, 0, 2, 0, 2);
    line.setComponentAlignment(label4, Alignment.MIDDLE_RIGHT);
    completionDateField = CommonFieldHandler.createDateField("", false);
    line.addComponent(completionDateField, 1, 2, 1, 2);
    line.setComponentAlignment(completionDateField, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(completionDateField, "completionDate");
    //		line.setExpandRatio(completionDateField, 1.0f);

    Label label6 = CommonFieldHandler.createLable("消耗时间:");
    line.addComponent(label6, 2, 2, 2, 2);
    line.setComponentAlignment(label6, Alignment.MIDDLE_RIGHT);
    TextField gs1 = new TextField();
    gs1.setValue("20%");
    gs1.setInputPrompt("50%");
    scheduleEventFieldGroup.bind(gs1, "useup");
    line.addComponent(gs1, 3, 2, 3, 2);
    line.setComponentAlignment(gs1, Alignment.MIDDLE_LEFT);

    Label label5 = CommonFieldHandler.createLable("优先级:");
    //		label.setWidth("80px");
    line.addComponent(label5, 0, 3, 0, 3);
    line.setComponentAlignment(label5, Alignment.MIDDLE_RIGHT);
    Map<Object, String> dtp = new HashMap();
    dtp.put(0, "底");
    dtp.put(1, "中");
    dtp.put(2, "高");
    ComboBox selectPriority = createComboBox(dtp, "100px");
    //		NativeSelect select = new NativeSelect();
    //		select.addItem("无");
    //		select.addItem("0(最低)");
    //		String itemId = "1(中)";
    //		select.addItem(itemId);
    //		select.addItem("2(高)");
    selectPriority.setNullSelectionAllowed(false);
    selectPriority.select(2);
    scheduleEventFieldGroup.bind(selectPriority, "priority");
    line.addComponent(selectPriority, 1, 3, 1, 3);
    line.setComponentAlignment(selectPriority, Alignment.MIDDLE_LEFT);

    Label label1 = CommonFieldHandler.createLable("完成百分比:");
    line.addComponent(label1, 2, 3, 2, 3);
    line.setComponentAlignment(label1, Alignment.MIDDLE_RIGHT);
    TextField tf = new TextField();
    tf.setInputPrompt("50%");
    line.addComponent(tf, 3, 3, 3, 3);
    line.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);

    Label label7 = CommonFieldHandler.createLable("关联日程:");
    line.addComponent(label7, 0, 4, 0, 4);
    line.setComponentAlignment(label7, Alignment.MIDDLE_RIGHT);
    CheckBox relatedCalendar_cb = new CheckBox();
    relatedCalendar_cb.setValue(false);
    line.addComponent(relatedCalendar_cb, 1, 4, 1, 4);
    line.setComponentAlignment(relatedCalendar_cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(relatedCalendar_cb, "relatedCalendar");

    Label lbStatus = CommonFieldHandler.createLable("计划状态:");
    lbStatus.setWidth("20px");
    line.addComponent(lbStatus, 2, 4, 2, 4);
    line.setComponentAlignment(lbStatus, Alignment.MIDDLE_RIGHT);
    Map<Object, String> sta = new HashMap();
    sta.put(0, "新建");
    sta.put(1, "完成");
    sta.put(2, "关闭");
    sta.put(3, "取消");
    ComboBox sectStatus = createComboBox(sta, "100px");
    sectStatus.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectStatus, "status");
    line.addComponent(sectStatus, 3, 4, 3, 4);
    line.setComponentAlignment(sectStatus, Alignment.MIDDLE_LEFT);

    Label label8 = CommonFieldHandler.createLable("关联外部任务:");
    label8.setWidth("20px");
    line.addComponent(label8, 0, 5, 0, 5);
    line.setComponentAlignment(label8, Alignment.MIDDLE_RIGHT);
    CheckBox cb = new CheckBox();
    cb.setValue(true);
    line.addComponent(cb, 1, 5, 1, 5);
    line.setComponentAlignment(cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(cb, "relatedTask");

    Label label9 = CommonFieldHandler.createLable("外部任务类型:");
    label9.setWidth("20px");
    line.addComponent(label9, 2, 5, 2, 5);
    line.setComponentAlignment(label9, Alignment.MIDDLE_RIGHT);
    Map<Object, String> oat = new HashMap();
    oat.put(0, "外包任务");
    oat.put(1, "外包任务-类型2");
    ComboBox select2 = createComboBox(oat, "150px");
    //		NativeSelect select2 = new NativeSelect();
    //		select2.addItem("外包任务");
    //		select2.addItem("外包任务-类型2");
    select2.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(select2, "type");
    line.addComponent(select2, 3, 5, 3, 5);
    line.setComponentAlignment(select2, Alignment.MIDDLE_LEFT);
    // select2.select("Timed");

    Label lbOwnGrp = CommonFieldHandler.createLable("计划分配团队:");
    lbOwnGrp.setWidth("20px");
    line.addComponent(lbOwnGrp, 0, 6, 0, 6);
    line.setComponentAlignment(lbOwnGrp, Alignment.MIDDLE_RIGHT);

    //		NativeSelect sectOwnGrp = new NativeSelect();
    Map<Object, String> groupsMap =
        teamService.queryTeamOfUser(LoginHandler.getLoggedInUser().getId());
    groupsMap.put("", "请选择");
    ComboBox sectOwnGrp = createComboBox(groupsMap, "150px");
    //		for (String p : groupsMap.keySet()) {
    //			String title = groupsMap.get(p);
    //			sectOwnGrp.addItem(p);
    //			sectOwnGrp.setItemCaption(p, title);
    //		}
    sectOwnGrp.setNullSelectionAllowed(false);
    ValueChangeListener valueChangeListener = createValueChangeListener();
    sectOwnGrp.addValueChangeListener(valueChangeListener);
    sectOwnGrp.setImmediate(true);
    scheduleEventFieldGroup.bind(sectOwnGrp, "assignedTeam");
    line.addComponent(sectOwnGrp, 1, 6, 1, 6);
    line.setComponentAlignment(sectOwnGrp, Alignment.MIDDLE_LEFT);

    final Label lbOwner = CommonFieldHandler.createLable("计划分配用户:");
    lbOwner.setWidth("20px");
    line.addComponent(lbOwner, 2, 6, 2, 6);
    line.setComponentAlignment(lbOwner, Alignment.MIDDLE_RIGHT);
    //		sectOwner = new NativeSelect();
    //		sectOwner.addItem("请选择");
    sectOwner.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectOwner, "assignedUser");
    line.addComponent(sectOwner, 3, 6, 3, 6);
    line.setComponentAlignment(sectOwner, Alignment.MIDDLE_LEFT);

    final Label lbDesc = CommonFieldHandler.createLable("计划描述:");
    lbDesc.setWidth("15px");
    line.addComponent(lbDesc, 0, 7, 0, 7);
    line.setComponentAlignment(lbDesc, Alignment.MIDDLE_RIGHT);
    final TextArea taDesc = CommonFieldHandler.createTextArea("");
    taDesc.setWidth("85%");
    taDesc.setHeight("290px");
    scheduleEventFieldGroup.bind(taDesc, "description");
    line.addComponent(taDesc, 1, 7, 3, 13);
    line.setComponentAlignment(taDesc, Alignment.MIDDLE_LEFT);

    //		CKEditorConfig config = new CKEditorConfig();

    final Button updateSave = new Button("保存");
    updateSave.addClickListener(
        new ClickListener() {
          @SuppressWarnings("unchecked")
          public void buttonClick(ClickEvent event) {
            // WW_TODO 修改保存到数据库
            Todo fieldGroupTodo = saveFieldGroupToDB();
            fireEvent(
                new SubmitEvent(
                    updateSave,
                    SubmitEvent.SUBMITTED,
                    scheduleEventFieldGroup.getItemDataSource()));

            // close popup window
            close();
            /*
             * Todo fieldGroupTodo = saveFieldGroupToDB(); //reflash current
             * Item copyBeanValueToContainer(hContainer,(BeanItem<Todo>)(
             * scheduleEventFieldGroup.getItemDataSource())); //刷新日历
             * main.refreshCalendarView(); Notification.show("保存成功",
             * Notification.Type.HUMANIZED_MESSAGE); //如果有外部流程,启动外部流程 if
             * (fieldGroupTodo.getRelatedTask()) { ViewToolManager
             * .showPopupWindow(new ActivityStartPopupWindow( "1111")); }
             */
            if (fieldGroupTodo.getRelatedTask()) {
              ViewToolManager.showPopupWindow(new ActivityStartPopupWindow("1111"));
            }
          }
        });
    line.addComponent(updateSave, 3, 14, 3, 14);
    line.setComponentAlignment(updateSave, Alignment.MIDDLE_RIGHT);
    //		line.setExpandRatio(updateSave, 1.0f);

    bottom.addComponent(line);
  }
  public void init(String title, Class<T> typeOfRows, String objectCode) {
    setModal(true);
    setClosable(true);
    setResizable(false);
    setDraggable(false);
    setHeight("90%");
    setWidth("100%");
    setCaption("<b>" + title + "</b>");
    setCaptionAsHtml(true);

    this.objectCode = objectCode;

    dfFrom = new DateField();
    dfFrom.setCaption("Từ Ngày");
    dfFrom.addStyleName("date-field-caption");
    dfTo = new DateField();
    dfTo.setCaption("Đến Ngày");
    dfTo.addStyleName("date-field-caption");
    btnOk = new Button("Xem Báo Cáo");
    btnOk.addStyleName(ValoTheme.BUTTON_SMALL);
    btnOk.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    btnOk.addStyleName("margin-top-2px");

    gridSummaryReportDetail = new MGrid<ReportDetailSummary>(ReportDetailSummary.class);
    gridSummaryReportDetail.setWidth("50%");
    gridSummaryReportDetail.setHeight("77px");
    gridSummaryReportDetail.setEditorEnabled(false);
    gridSummaryReportDetail.setSelectionMode(SelectionMode.NONE);
    gridSummaryReportDetail.withProperties(
        "openingStock", "issueInPeriod", "receiptInPeriod", "closingStock");

    gridContent = new MGrid<>(typeOfRows);

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

    // Add first line
    HorizontalLayout hrzDateFields = new HorizontalLayout();
    wrapper.addComponent(hrzDateFields);
    wrapper.setComponentAlignment(hrzDateFields, Alignment.TOP_CENTER);
    hrzDateFields.addComponent(dfFrom);
    hrzDateFields.addComponent(dfTo);
    hrzDateFields.addComponent(btnOk);
    hrzDateFields.addStyleName("margin-left-right-20px df-report-detail-style");

    // Add second line
    wrapper.addComponent(gridSummaryReportDetail);
    wrapper.setComponentAlignment(gridSummaryReportDetail, Alignment.TOP_CENTER);

    wrapper.addComponent(gridContent);
    gridContent.setWidth("100%");
    gridContent.setHeight("10%");
    gridContent.setEditorEnabled(false);
    gridContent.setSelectionMode(SelectionMode.NONE);

    gridContentProperties = new ArrayList<String>();

    withTableProperties(getProperties());
    withHeaderNames(getHeaderNames());
    setContent(wrapper);

    btnOk.addClickListener(
        new ClickListener() {
          private static final long serialVersionUID = -2918006939436642296L;

          @Override
          public void buttonClick(ClickEvent event) {
            if (!objectCode.isEmpty()) {
              generateSummaryReportDetails(dfFrom.getValue(), dfTo.getValue());
              generateReportDetails(dfFrom.getValue(), dfTo.getValue());
            }
          }
        });
  }
示例#27
0
  private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    toolbar.setSpacing(false);

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max =
        tools.addItem(
            "",
            FontAwesome.EXPAND,
            new Command() {

              @Override
              public void menuSelected(final MenuItem selectedItem) {
                if (!slot.getStyleName().contains("max")) {
                  selectedItem.setIcon(FontAwesome.COMPRESS);
                  toggleMaximized(slot, true);
                } else {
                  slot.removeStyleName("max");
                  selectedItem.setIcon(FontAwesome.EXPAND);
                  toggleMaximized(slot, false);
                }
              }
            });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.COG, null);
    root.addItem(
        "Configure",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });
    root.addSeparator();
    root.addItem(
        "Close",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
  }
示例#28
0
  public RegisterView() {
    super();

    Page.getCurrent().setUriFragment("", false);

    setSizeFull();
    addStyleName("login-layout");

    registerPanel = new CssLayout();
    registerPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");
    labels.setMargin(true);
    labels.addStyleName("labels");
    registerPanel.addComponent(labels);

    Resource res = new ThemeResource("img/dms.png");

    Image image = new Image(null, res);
    image.setHeight("200px");
    labels.addComponent(image);
    labels.setComponentAlignment(image, Alignment.TOP_CENTER);

    VerticalLayout fields = new VerticalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    username = new TextField("Nom d#utilisateur");
    username.focus();
    fields.addComponent(username);
    fields.setComponentAlignment(username, Alignment.MIDDLE_CENTER);

    password = new PasswordField("Mot de passe");
    fields.addComponent(password);
    fields.setComponentAlignment(password, Alignment.MIDDLE_CENTER);

    passwordVerification = new PasswordField("Répéter mot de passe");
    fields.addComponent(passwordVerification);
    fields.setComponentAlignment(passwordVerification, Alignment.MIDDLE_CENTER);

    email = new TextField("Courriel (optionale):");
    fields.addComponent(email);
    fields.setComponentAlignment(email, Alignment.MIDDLE_CENTER);

    HorizontalLayout nav = new HorizontalLayout();
    nav.setSpacing(true);

    final Button back = new Button("Retour");
    back.setId("back");
    back.addClickListener(
        new ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent event) {
            ((DmsUI) UI.getCurrent()).displayLogin();
          }
        });
    nav.addComponent(back);

    final Button signin = new Button("Enregistrer");
    signin.setId("signin");
    signin.addStyleName("default");
    signin.setClickShortcut(KeyCode.ENTER, null);
    nav.addComponent(signin);

    fields.addComponent(nav);
    fields.setComponentAlignment(nav, Alignment.BOTTOM_CENTER);

    signin.addClickListener(new RegisterListener(this));

    registerPanel.addComponent(fields);

    addComponent(registerPanel);
    setComponentAlignment(registerPanel, Alignment.MIDDLE_CENTER);
  }
示例#29
0
  public ExceptionDialog(Throwable ex, String caption) {
    this.cause = ex;
    Preconditions.checkNotNull(ex);

    layout = new VerticalLayout();
    setContent(layout);
    layout.setWidth("100%");
    layout.setHeight("-1");

    if (caption == null) {
      setCaption("Unexpected error");
    } else {
      setCaption(caption);
    }

    Label lblInfo =
        new Label("An unexpected error occured.<br />The error message was:", ContentMode.HTML);
    lblInfo.setHeight("-1px");
    lblInfo.setWidth("100%");
    layout.addComponent(lblInfo);
    lblInfo.addStyleName("exception-message-caption");

    String message = ex.getMessage();
    if (message == null || message.isEmpty()) {
      message = "<no message>";
    }
    Label lblMessage = new Label(message);
    lblMessage.addStyleName("exception-message-content");
    lblMessage.setHeight("-1px");
    lblMessage.setWidth("100%");
    layout.addComponent(lblMessage);

    actionsLayout = new HorizontalLayout();
    actionsLayout.addStyleName("exception-dlg-details");
    actionsLayout.setWidth("100%");
    actionsLayout.setHeight("-1px");
    layout.addComponent(actionsLayout);

    btDetails = new Button("Show Details", this);
    btDetails.setStyleName(BaseTheme.BUTTON_LINK);
    actionsLayout.addComponent(btDetails);

    btReportBug = new Button("Report Problem", this);
    btReportBug.setStyleName(BaseTheme.BUTTON_LINK);
    btReportBug.setVisible(false);
    btReportBug.setIcon(FontAwesome.ENVELOPE_O);
    UI ui = UI.getCurrent();
    if (ui instanceof SearchUI) {
      btReportBug.setVisible(((SearchUI) ui).canReportBugs());
    }
    actionsLayout.addComponent(btReportBug);
    actionsLayout.setComponentAlignment(btDetails, Alignment.TOP_LEFT);
    actionsLayout.setComponentAlignment(btReportBug, Alignment.TOP_RIGHT);

    lblStacktrace = new Label(Helper.convertExceptionToMessage(ex), ContentMode.PREFORMATTED);
    detailsPanel = new Panel(lblStacktrace);
    detailsPanel.setWidth("100%");
    detailsPanel.setHeight("300px");
    detailsPanel.setVisible(false);
    lblStacktrace.setSizeUndefined();
    lblStacktrace.setVisible(true);
    layout.addComponent(detailsPanel);

    btClose = new Button("OK", this);
    layout.addComponent(btClose);

    layout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER);
    layout.setExpandRatio(detailsPanel, 0.0f);
    layout.setExpandRatio(actionsLayout, 1.0f);
  }
  public void init(final Window main) {
    VerticalLayout mainLayout = new VerticalLayout();
    main.setContent(mainLayout);
    mainLayout.setSizeFull();

    HorizontalLayout titlebar = new HorizontalLayout();
    titlebar.addStyleName("titlebar");
    titlebar.setWidth("100%");
    Label title = new Label("Book of Vaadin Examples");
    title.addStyleName("title");
    titlebar.addComponent(title);
    titlebar.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    Embedded logo = new Embedded(null, new ThemeResource("img/vaadin-logo.png"));
    titlebar.addComponent(logo);
    titlebar.setComponentAlignment(logo, Alignment.MIDDLE_RIGHT);
    main.addComponent(titlebar);

    HorizontalLayout hor = new HorizontalLayout();
    hor.setSizeFull();
    main.addComponent(hor);
    mainLayout.setExpandRatio(hor, 1.0f);

    final Panel menupanel = new Panel("Examples");
    menupanel.addStyleName("menupanel");
    menupanel.setWidth(null);
    menupanel.setHeight("100%");
    menupanel.getContent().setWidth(null);
    // menupanel.getContent().setHeight("100%");
    hor.addComponent(menupanel);

    final Tree menu = new Tree();
    menu.setWidth(null);
    // menu.setHeight("100%");
    menu.setImmediate(true);
    menupanel.addComponent(menu);

    final Panel viewpanel = new Panel("Selected Example");
    viewpanel.addStyleName("viewpanel");
    viewpanel.setSizeFull();
    VerticalLayout viewlayout = new VerticalLayout();
    viewlayout.addStyleName("viewlayout");
    viewlayout.setSpacing(true);
    viewlayout.setMargin(true);
    viewpanel.setContent(viewlayout);

    hor.addComponent(viewpanel);
    hor.setExpandRatio(viewpanel, 1.0f);

    WebApplicationContext ctx = (WebApplicationContext) getContext();
    BookExampleLibrary library = BookExampleLibrary.getInstance(ctx.getBaseDirectory());

    AbstractExampleItem[] examples = library.getAllExamples();

    // Collect redirects here
    final HashMap<String, String> redirects = new HashMap<String, String>();

    // Collect examples here
    final HashMap<String, CaptionedExampleItem> exampleitems =
        new HashMap<String, CaptionedExampleItem>();

    // Build the menu and collect redirections
    for (int i = 0; i < examples.length; i++)
      if (examples[i] instanceof BookExample || examples[i] instanceof ExampleCtgr) {
        CaptionedExampleItem example = (CaptionedExampleItem) examples[i];
        exampleitems.put(example.getExampleId(), example);

        String itemid = example.getExampleId();
        menu.addItem(itemid);
        menu.setItemCaption(itemid, example.getShortName());

        if (examples[i].getParentId() != null) menu.setParent(itemid, examples[i].getParentId());
      } else if (examples[i] instanceof RedirctItem) {
        RedirctItem redirect = (RedirctItem) examples[i];
        redirects.put(redirect.getExampleId(), redirect.redirectid);
      }

    // Expand the menu
    for (int i = 0; i < examples.length; i++) {
      if (examples[i].getParentId() == null)
        menu.expandItemsRecursively(examples[i].getExampleId());

      if (examples[i].isCollapsed()) menu.collapseItem(examples[i].getExampleId());

      if (menu.getChildren(examples[i].getExampleId()) == null)
        menu.setChildrenAllowed(examples[i].getExampleId(), false);
    }

    // Set selected example as given in the URI fragment
    final UriFragmentUtility urifu = new UriFragmentUtility();
    urifu.addListener(
        new FragmentChangedListener() {
          private static final long serialVersionUID = -6588416218607827834L;

          public void fragmentChanged(FragmentChangedEvent source) {
            String fragment = source.getUriFragmentUtility().getFragment();
            if (fragment != null) {
              // Handle redirection
              while (redirects.containsKey(fragment)) fragment = redirects.get(fragment);

              menu.setValue(fragment);

              // Open the tree nodes leading to the example
              for (Object parent = menu.getParent(fragment);
                  parent != null;
                  parent = menu.getParent(parent)) menu.expandItem(parent);
            }
          }
        });
    mainLayout.addComponent(urifu);

    // Handle menu selection
    menu.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 8236533959795019956L;

          public void valueChange(ValueChangeEvent event) {
            viewpanel.removeAllComponents();

            String selection = (String) event.getProperty().getValue();

            // Find the example
            CaptionedExampleItem exampleItem = exampleitems.get(selection);
            if (selection != null && exampleItem == null)
              main.showNotification("Invalid item " + selection);
            else if (exampleItem != null) {
              if (exampleItem.getClass().isAssignableFrom(ExampleCtgr.class)) {
                if (menu.hasChildren(exampleItem.getExampleId())) {
                  menu.select((String) menu.getChildren(exampleItem.getExampleId()).toArray()[0]);
                }
              } else { // A leaf
                BookExample example = (BookExample) exampleItem;

                // Load unless already loaded
                WebApplicationContext ctx = (WebApplicationContext) getContext();
                example.loadExample(ctx.getBaseDirectory());

                if (example.getDescription() != null) {
                  Label descLabel = new Label(example.getDescription(), Label.CONTENT_XHTML);
                  descLabel.addStyleName("example-description");
                  viewpanel.addComponent(descLabel);
                }

                // The actual example component
                viewpanel.addComponent(example.createInstance());

                // Java sources on the left, CSS on the right
                HorizontalLayout horizontalOrder = new HorizontalLayout();
                horizontalOrder.addStyleName("sourcecontainer");
                horizontalOrder.setSpacing(true);
                horizontalOrder.setMargin(true);

                Panel bookRefs = null;
                Panel forumLinks = null;
                Panel kbRefs = null;

                List<SourceFragment> fragments = example.getSourceFragments();
                if (fragments != null) {
                  // Java Sources are laid out vertically
                  VerticalLayout verticalListings = new VerticalLayout();
                  verticalListings.setSizeUndefined();
                  verticalListings.setSpacing(true);
                  horizontalOrder.addComponent(verticalListings);

                  // Find the widest source fragment
                  int widestIndex = 0;
                  int widestWidth = 0;
                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++)
                    if (fragments.get(fragmentNum).getSrcWidth() > widestWidth) {
                      widestIndex = fragmentNum;
                      widestWidth = fragments.get(fragmentNum).getSrcWidth();
                    }
                  System.out.println("Widest listing: " + widestIndex + " which is " + widestWidth);

                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) {
                    SourceFragment fragment = fragments.get(fragmentNum);

                    // Have caption only in the beginning of the listings
                    String listingCaption = fragmentNum == 0 ? "Source Code" : "";

                    String srcurl =
                        "http://dev.vaadin.com/browser/doc/book-examples/trunk/src"
                            + fragment.getSrcName();
                    SourceListing listing = new SourceListing(listingCaption, srcurl, fragment);
                    verticalListings.addComponent(listing);

                    // Use the width of the widest listing for all listings
                    if (fragmentNum == widestIndex) listing.setWidth(Sizeable.SIZE_UNDEFINED, 0);
                    else listing.setWidth("100%");

                    if (!fragment.getBookRefs().isEmpty()) {
                      bookRefs = new Panel("Book References");
                      bookRefs.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getBookRefs().iterator();
                          iter.hasNext(); ) {
                        String ref = iter.next();
                        int hashPos = ref.indexOf('#');
                        String refFragment = "";
                        if (hashPos != -1) {
                          refFragment = "#" + ref.replace('#', '.');
                          ref = ref.substring(0, hashPos);
                        }
                        String bookUrl =
                            "http://vaadin.com/book/-/page/" + ref + ".html" + refFragment;
                        Link link = new Link(bookUrl, new ExternalResource(bookUrl));
                        link.setTargetName("_new");
                        bookRefs.addComponent(link);
                      }
                    }

                    if (!fragment.getForumLinks().isEmpty()) {
                      forumLinks = new Panel("Forum Messages");
                      forumLinks.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getForumLinks().iterator();
                          iter.hasNext(); ) {
                        String url = iter.next();
                        Link link = new Link(url, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }

                    if (!fragment.getKbRefs().isEmpty()) {
                      kbRefs = new Panel("Pro Account Knowledge Base Articles");
                      kbRefs.setSizeUndefined();
                      for (Iterator<SourceFragment.Ref> iter = fragment.getKbRefs().iterator();
                          iter.hasNext(); ) {
                        SourceFragment.Ref ref = iter.next();
                        String url = "http://vaadin.com/knowledge-base#" + ref.ref;
                        Link link = new Link(ref.caption, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }
                  }
                }

                // Show associated CSS
                if (example.getCssFragments() != null && example.getCssFragments().size() > 0) {
                  SourceFragment csscode = example.getCssFragments().get(0);
                  String srcurl =
                      "http://dev.vaadin.com/browser/doc/book-examples/trunk/WebContent/VAADIN/themes/book-examples/styles.css";
                  horizontalOrder.addComponent(new SourceListing("CSS Code", srcurl, csscode));
                }

                if (horizontalOrder.getComponentIterator().hasNext())
                  viewpanel.addComponent(horizontalOrder);
                if (bookRefs != null) viewpanel.addComponent(bookRefs);
                if (forumLinks != null) viewpanel.addComponent(forumLinks);
                if (kbRefs != null) viewpanel.addComponent(kbRefs);

                urifu.setFragment(example.getExampleId());
              }
            }
          }
        });

    Tree.ItemStyleGenerator itemStyleGenerator =
        new Tree.ItemStyleGenerator() {
          private static final long serialVersionUID = -3231268865512947125L;

          public String getStyle(Object itemId) {
            // Chapter title items do not contain a period
            if (!((String) itemId).contains(".")) return "chaptertitle";
            return null;
          }
        };
    menu.setItemStyleGenerator(itemStyleGenerator);
  }