コード例 #1
0
ファイル: LoginView.java プロジェクト: codefacts/vaadincrm
  private com.vaadin.ui.Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

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

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

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

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

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

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

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

            //                    DashboardEventBus.post(new ProfileUpdatedEvent());
            close();
          } catch (CommitException e) {
            Notification.show("Error while updating profile", Type.ERROR_MESSAGE);
          }
        });
    ok.focus();
    footer.addComponent(ok);
    footer.setComponentAlignment(ok, Alignment.TOP_RIGHT);
    return footer;
  }
コード例 #3
0
 private Layout createButtonControls() {
   final HorizontalLayout controlPanel = new HorizontalLayout();
   final Layout controlButtons =
       (new EditFormControlsGenerator<>(editUserForm)).createButtonControls();
   controlButtons.setSizeUndefined();
   controlPanel.addComponent(controlButtons);
   controlPanel.setComponentAlignment(controlButtons, Alignment.MIDDLE_CENTER);
   return controlPanel;
 }
コード例 #4
0
  private void buildLayout() {
    setSizeUndefined();
    setMargin(true);

    HorizontalLayout actions = new HorizontalLayout(save, cancel);
    actions.setSpacing(true);

    addComponents(actions, firstName, lastName, phone, email, birthDate);
  }
コード例 #5
0
  private void buildLayout() {
    setSizeUndefined();
    setMargin(true);

    HorizontalLayout actions = new HorizontalLayout(save, cancel);
    actions.setSpacing(true);

    addComponents(actions, name, nominal, description, variantField, priceField, sourceLink);
  }
コード例 #6
0
  public HorizontalLayout createToolbar() {

    MyApplication.debug(3, "createToolbar");
    HorizontalLayout lo = new HorizontalLayout();
    lo.addComponent(newContact);
    lo.addComponent(search);
    lo.addComponent(share);
    lo.addComponent(help);

    return lo;
  }
コード例 #7
0
 private HorizontalLayout createPanelLayout(
     final String msg, final AbstractTextField textField, final String textValue) {
   HorizontalLayout msgLayout = new HorizontalLayout();
   msgLayout.setSpacing(true);
   Label msgLabel = new Label(msg);
   msgLabel.setWidth("65px");
   textField.setWidth("150px");
   msgLayout.addComponent(msgLabel);
   msgLayout.addComponent(textField);
   textField.setValue(textValue);
   return msgLayout;
 }
コード例 #8
0
ファイル: MyScatterChart.java プロジェクト: Peppe/chart-tests
  private HorizontalLayout createButtonBar() {
    final HorizontalLayout buttonBar = new HorizontalLayout();
    Button drawBadge =
        new Button(
            "Draw badge",
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent clickEvent) {
                extension.addBadge();
              }
            });

    final Button enableZoomTracking = new Button("Enable zoom tracking");
    enableZoomTracking.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent clickEvent) {
            extension.enableZoomTracking();
            buttonBar.replaceComponent(enableZoomTracking, goBackInZooming);
          }
        });

    goBackInZooming =
        new Button(
            "Go back in zoom state",
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent clickEvent) {
                if (list.size() > 1) {
                  ZoomCoordinates zoom = list.get(list.size() - 2);
                  zoomTo(zoom);
                  list.remove(list.size() - 1);
                } else {
                  list.clear();
                  XAxis xAxis = chart.getConfiguration().getxAxis();
                  YAxis yAxis = chart.getConfiguration().getyAxis();
                  xAxis.setExtremes(148, 182);
                  yAxis.setExtremes(0, 125);
                  goBackInZooming.setEnabled(false);
                }
                writeOutZoomInfo();
              }
            });
    goBackInZooming.setEnabled(false);
    buttonBar.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buttonBar.addComponents(drawBadge, enableZoomTracking, zoominfo);
    buttonBar.setSpacing(true);
    return buttonBar;
  }
コード例 #9
0
ファイル: UserSelect.java プロジェクト: snells/smarthome
 private Button genBut(String name) {
   Button b = new Button(name);
   b.addStyleName("user-select");
   b.setIcon(userIcon);
   b.addClickListener(
       e -> {
         if (loginBox.isVisible()) {
           hidePass();
           return;
         }
         loginField.setValue("");
         String t = e.getButton().getCaption();
         if (Globals.control.hasPassword(t)) {
           selected = Globals.control.getUser(t);
           showPassField();
         } else {
           User s = Globals.control.getUser(t);
           if (s == null) {
             return;
           }
           Globals.user = s;
           Globals.root.changeScreen(Globals.user);
         }
       });
   return b;
 }
コード例 #10
0
ファイル: SelectWindow.java プロジェクト: mdescher/mytunesrss
 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);
 }
コード例 #11
0
  public TableEditorWindow(final Table table, final Object value, Object... dates) {

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

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

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

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

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

    setContent(content);
  }
コード例 #12
0
 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);
 }
コード例 #13
0
  public SubsEditViewImpl() {
    ButtonRenderer deleteButton = createDeleteButton();
    Slider percentSlider = createPercentSlider();
    MultiFileUpload uploader = createUploader();

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

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

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

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

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

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

    // add every layouts to the principal one
    content.addComponent(configHorizontalLayout);
    content.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    content.addComponents(grid);
    content.addComponent(downloadButton);
    setCompositionRoot(content);
  }
コード例 #14
0
ファイル: TestApplication.java プロジェクト: lgervela/Demo
  @Override
  public void init() {
    Window mainWindow = new Window("Test Application");
    Form form = new Form();
    form.setCaption("Form Caption");
    form.setDescription(
        "This is a description of the Form that is "
            + "displayed in the upper part of the form. You normally "
            + "enter some descriptive text about the form and its "
            + "use here.");
    // Add a field and bind it to an named item property.
    form.addField("nom", new TextField("Nom"));
    form.addField("prenom", new TextField("Prenom"));
    form.addField("age", new TextField("Age"));
    // Set the footer layout.
    form.setFooter(new VerticalLayout());

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

    // Have a button bar in the footer.
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setHeight("25px");
    form.getFooter().addComponent(okbar);
    Button okbutton = new Button("OK", form, "commit");
    okbutton.addListener(new OkListener(form));
    okbar.addComponent(okbutton);
    okbar.setComponentAlignment(okbutton, Alignment.TOP_RIGHT);
    Button resetbutton = new Button("Reset", form, "discard");
    resetbutton.addListener(new ResetListener(form));
    okbar.addComponent(resetbutton);
    mainWindow.addComponent(form);
    setMainWindow(mainWindow);
  }
コード例 #15
0
  private Component createConnectionButtons(final ProfileInfoPanelHolder infoPanelHolder) {
    Button connectButton =
        new Button(
            "Connect",
            new Button.ClickListener() {
              @Override
              public void buttonClick(Button.ClickEvent event) {
                ConnectionProfileLoginPanelFactory panel = infoPanelHolder.getPanelFactory();
                ConnectionProfile profile = panel.createConnectionProfile();
                try {
                  databaseSessionManager.createSession(profile);
                } catch (Exception ex) {
                  Notification.show(
                      "Failed to connect\n", ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                }
              }
            });
    connectButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    HorizontalLayout buttons = new HorizontalLayout(connectButton);
    buttons.setSpacing(true);
    return buttons;
  }
コード例 #16
0
ファイル: MailFormWindow.java プロジェクト: gsccs/mycollab
 private Layout createTextFieldMail(String title, Component component) {
   HorizontalLayout layout = new HorizontalLayout();
   Label lbTitle = new Label(title);
   lbTitle.setWidth("60px");
   lbTitle.setStyleName("lbmail");
   layout.addComponent(lbTitle);
   layout.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
   layout.addComponent(component);
   layout.setComponentAlignment(component, Alignment.MIDDLE_LEFT);
   layout.setWidth("100%");
   layout.setExpandRatio(component, 1.0f);
   return layout;
 }
コード例 #17
0
  protected void replaceToCombo(String key, Container container, String defaultValue) {
    final TextField field = (TextField) map.get(key);
    HorizontalLayout layout = (HorizontalLayout) field.getParent();
    field.setVisible(false);
    final ComboBox comboBox = new ComboBox("", container);
    comboBox.setImmediate(true);
    comboBox.setNullSelectionAllowed(false);

    comboBox.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            field.setValue((String) comboBox.getValue());
          }
        });

    if (container.containsId(field.getValue())) {
      comboBox.select(field.getValue());
    } else {
      field.setValue(defaultValue);
      comboBox.select(defaultValue);
    }
    layout.addComponent(comboBox, 1);
  }
コード例 #18
0
ファイル: UserSelect.java プロジェクト: snells/smarthome
  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();
        });
  }
コード例 #19
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);
  }
コード例 #20
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);
  }
コード例 #21
0
  // Private methods -----------------------------------------------------------
  private void createComponent(String labelWidth, String labelCompSpace) {
    HorizontalLayout hl = (HorizontalLayout) viewContents;

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

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

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

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

    hl.setComponentAlignment(label, Alignment.MIDDLE_RIGHT);
  }
コード例 #22
0
    void displayVersions(String path) {
      List<PageVersion> pageVersions = pageService.getPageVersions(path);
      if (pageVersions.size() > 0) {
        final ComboBox pageSelection = new ComboBox();
        content.addComponent(pageSelection);
        pageSelection.setNullSelectionAllowed(false);
        pageSelection.setStyleName("version-selection-box");
        pageSelection.setTextInputAllowed(false);

        pageSelection.addValueChangeListener(
            new ValueChangeListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                selectedVersion = (PageVersion) pageSelection.getValue();
                if (selectedVersion != null) {
                  Page page =
                      pageService.getPageByVersion(beanItem.getPath(), selectedVersion.getName());
                  page.setPath(beanItem.getPath());
                  previewForm.setBean(page);
                  previewLayout.setTitle(page.getSubject());
                  ((PagePreviewFormLayout) previewLayout).displayPageInfo(page);
                }
              }
            });

        pageSelection.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
        pageSelection.setNullSelectionAllowed(false);

        for (int i = 0; i < pageVersions.size(); i++) {
          PageVersion version = pageVersions.get(i);
          pageSelection.addItem(version);
          pageSelection.setItemCaption(version, getVersionDisplay(version, i));
        }

        if (pageVersions.size() > 0) {
          pageSelection.setValue(pageVersions.get(pageVersions.size() - 1));
        }
      }
    }
コード例 #23
0
ファイル: AddressForm.java プロジェクト: smkumatela/infoshare
  private HorizontalLayout getButtons() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeUndefined();
    layout.setSpacing(true);

    save.addStyleName(Reindeer.BUTTON_DEFAULT);
    save.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    layout.addComponent(save);
    layout.addComponent(edit);
    layout.addComponent(update);
    layout.addComponent(cancel);
    layout.addComponent(exit);

    return layout;
  }
コード例 #24
0
  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;
  }
コード例 #25
0
    private Layout createBottomPanel() {
      final HorizontalLayout controlPanel = new HorizontalLayout();
      controlPanel.setMargin(true);
      controlPanel.setStyleName("more-info");
      controlPanel.setHeight("40px");
      controlPanel.setWidth("100%");
      Button moreInfoBtn =
          new Button(
              "More information...",
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                  editUserForm.displayAdvancedForm(user);
                }
              });
      moreInfoBtn.addStyleName(UIConstants.THEME_LINK);
      controlPanel.addComponent(moreInfoBtn);
      controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT);
      return controlPanel;
    }
コード例 #26
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
コード例 #27
0
  @Override
  protected void init(VaadinRequest request) {
    setSizeFull();

    VerticalLayout layout = new VerticalLayout();

    List<Aircraft> message = aircraftService.list();
    Label label = new Label(message.toString());
    final TextField field = new TextField();
    Button button = new Button();

    button.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent clickEvent) {
            aircraftService.create(field.getValue());
          }
        });
    HorizontalLayout fieldPanel = new HorizontalLayout();
    fieldPanel.addComponent(field);
    fieldPanel.addComponent(button);
    fieldPanel.addComponent(label);

    Table table = new Table();
    table.setRowHeaderMode(Table.RowHeaderMode.ID);
    table.setSizeFull();

    final BeanItemContainer<Booking> container = new BeanItemContainer<Booking>(Booking.class);
    container.addAll(bookingService.list());
    container.addNestedContainerProperty("flight.flightNumber");
    container.removeContainerProperty("flight");
    table.setContainerDataSource(container);

    HorizontalLayout toolbar = new HorizontalLayout();
    Button addButton = new Button("Add");
    addButton.addClickListener(
        new Button.ClickListener() {

          @Override
          public void buttonClick(Button.ClickEvent clickEvent) {
            FormLayout formLayout = new FormLayout();

            // Form for editing the bean
            final BeanFieldGroup<Booking> binder = new BeanFieldGroup<Booking>(Booking.class);
            binder.setBuffered(true);
            final Booking bean = new Booking();
            bean.setFlight(new Flight());
            binder.setItemDataSource(bean);
            formLayout.addComponent(binder.buildAndBind("Ticket", "ticket"));
            formLayout.addComponent(binder.buildAndBind("Flight Nr.", "flight.flightNumber"));

            Button save = new Button("Save");
            save.addClickListener(
                new Button.ClickListener() {
                  @Override
                  public void buttonClick(Button.ClickEvent event) {
                    try {
                      binder.commit();
                      container.addBean(bean);
                    } catch (FieldGroup.CommitException e) {
                      throw new RuntimeException(e.getMessage());
                    }
                  }
                });
            formLayout.addComponent(save);

            UI.getCurrent().addWindow(new Window("Edit Booking", formLayout));
          }
        });
    toolbar.addComponent(addButton);

    layout.addComponent(fieldPanel);
    layout.addComponent(toolbar);
    layout.addComponent(table);

    UI.getCurrent()
        .setErrorHandler(
            new ErrorHandler() {
              @Override
              public void error(com.vaadin.server.ErrorEvent event) {
                Notification.show(
                    event.getThrowable().getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
              }
            });
    setContent(layout);
  }
コード例 #28
0
ファイル: UserSelect.java プロジェクト: snells/smarthome
 private void hidePass() {
   loginBox.setVisible(false);
   loginInfo.setVisible(false);
   loginField.setValue("");
   vbox.removeStyleName("fuzzy");
 }
コード例 #29
0
ファイル: UserSelect.java プロジェクト: snells/smarthome
 private void showPassField() {
   vbox.addStyleName("fuzzy");
   loginBox.setVisible(true);
 }
コード例 #30
0
ファイル: UploadUnit.java プロジェクト: yehiafarag/csf-pr
  @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);
  }