List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
public Component getThirdStage(Source s) { Label header = new Label(Language.get(Word.CRAWLER)); header.addStyleName(ValoTheme.LABEL_H1); Crawler crawler;//from w w w. ja v a 2 s . c o m if (s.getCrawler() != null) { crawler = s.getCrawler(); } else { crawler = new Crawler(s); s.setCrawler(crawler); } GridLayout mainGrid = new GridLayout(2, 2); mainGrid.setSizeFull(); mainGrid.setSpacing(true); FormLayout layoutForms = new FormLayout(); //Exclude or Include RadioButtonGroup<Boolean> radios = new RadioButtonGroup<>(); radios.setItems(true, false); radios.setItemCaptionGenerator(b -> b ? Language.get(Word.INCLUDE_TAGS) : Language.get(Word.EXCLUDE_TAGS)); radios.setItemIconGenerator(b -> b ? VaadinIcons.CHECK : VaadinIcons.CLOSE); radios.setSelectedItem(true); radios.addValueChangeListener(event -> include = event.getValue()); //By Class CssLayout addByClassGroup = new CssLayout(); addByClassGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByClass = new TextField(); textFieldAddByClass.setWidth("465px"); Button buttonAddByClass = new Button(VaadinIcons.PLUS); buttonAddByClass.addClickListener(e -> { crawler.addByClass(textFieldAddByClass.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByClass.clear(); }); addByClassGroup.addComponents(textFieldAddByClass, buttonAddByClass); addByClassGroup.setCaption(Language.get(Word.BYCLASS)); //ByTag CssLayout addByTagGroup = new CssLayout(); addByTagGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByTag = new TextField(); Button buttonAddByTag = new Button(VaadinIcons.PLUS); textFieldAddByTag.setWidth("465px"); buttonAddByTag.addClickListener(e -> { crawler.addByTag(textFieldAddByTag.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByTag.clear(); }); addByTagGroup.addComponents(textFieldAddByTag, buttonAddByTag); addByTagGroup.setCaption(Language.get(Word.BYTAG)); //ByID CssLayout addByIDGroup = new CssLayout(); addByIDGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByID = new TextField(); textFieldAddByID.setWidth("465px"); Button buttonAddByID = new Button(VaadinIcons.PLUS); buttonAddByID.addClickListener(e -> { crawler.addByID(textFieldAddByID.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByID.clear(); }); addByIDGroup.addComponents(textFieldAddByID, buttonAddByID); addByIDGroup.setCaption(Language.get(Word.BYID)); //ByAttribute CssLayout addByAttributeGroup = new CssLayout(); addByAttributeGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByAttributeKey = new TextField(); textFieldAddByAttributeKey.setWidth("233px"); TextField textFieldAddByAttributeValue = new TextField(); textFieldAddByAttributeValue.setWidth("232px"); Button buttonAddByAttribute = new Button(VaadinIcons.PLUS); buttonAddByAttribute.addClickListener(e -> { crawler.addByAttribute(textFieldAddByAttributeKey.getValue(), textFieldAddByAttributeValue.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByAttributeKey.clear(); textFieldAddByAttributeValue.clear(); }); addByAttributeGroup.addComponents(textFieldAddByAttributeKey, textFieldAddByAttributeValue, buttonAddByAttribute); addByAttributeGroup.setCaption(Language.get(Word.BYATTRIBUTEVALUE)); layoutForms.addComponents(radios, addByClassGroup, addByTagGroup, addByIDGroup, addByAttributeGroup); mainGrid.addComponent(layoutForms); Label labelResult = new Label(); Panel panelResult = new Panel(labelResult); labelResult.setWidth("100%"); panelResult.setWidth("100%"); panelResult.setHeight("175px"); mainGrid.addComponent(panelResult, 0, 1, 1, 1); Button buttonTestURL = new Button(); buttonTestURL.setIcon(VaadinIcons.EXTERNAL_LINK); buttonTestURL.setCaption(Language.get(Word.OPEN_LINK)); Button buttonTest = new Button(Language.get(Word.TEST), VaadinIcons.CLIPBOARD_CHECK); buttonTest.addClickListener(ce -> { Article a = CrawlerUtils.executeRandom(crawler); labelResult.setValue(a.getBody()); if (reg != null) { reg.remove(); } reg = buttonTestURL .addClickListener(cev -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); }); refreshList(mainGrid, crawler); Runnable cancel = () -> close(); Runnable next = () -> validateThirdStage(s); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.addComponents(header, mainGrid, getFooter(cancel, next, buttonTest, buttonTestURL)); windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER); windowLayout.setExpandRatio(mainGrid, 5); windowLayout.setWidth("1250px"); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.PasswordRecoveryWindow.java
public PasswordRecoveryWindow() { setModal(true);// w w w. jav a2 s . co m setResizable(false); setDraggable(false); setCaption(Language.get(Word.RESET_PW)); addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); send = new Button(Language.get(Word.SEND_RESET_CODE)); emailOrUsername = new TextField(Language.get(Word.USERNAME_OR_EMAIL)); emailOrUsername.setMaxLength(256); emailOrUsername.focus(); forms.addComponent(emailOrUsername); footer = new GridLayout(3, 1); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); Label placeholder = new Label(); cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { close(); }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); send.setIcon(VaadinIcons.CHECK); send.addStyleName(ValoTheme.BUTTON_PRIMARY); sendListener = send.addClickListener(ce -> changeWindow()); send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); footer.setSizeUndefined(); footer.setWidth("100%"); footer.addComponents(placeholder, cancel, send); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(send, Alignment.MIDDLE_CENTER); windowLayout.addComponents(forms, footer); windowLayout.setWidth("450px"); setContent(windowLayout); //setWidth("450px"); }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildUserTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.PROFILE)); root.setIcon(VaadinIcons.USER);//from ww w . j a va 2 s . c om root.setWidth("100%"); root.setSpacing(true); root.setMargin(true); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); firstNameField = new TextField(Language.get(Word.FIRST_NAME)); firstNameField.setValue(user.getFirstName()); firstNameField.setMaxLength(20); firstNameField.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstNameField.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); saveButton.setEnabled(setError(firstNameField, true)); } else { firstNameField.setComponentError(null); boolean enabled = setError(firstNameField, false); saveButton.setEnabled(enabled); } }); setError(firstNameField, false); lastNameField = new TextField(Language.get(Word.LAST_NAME)); lastNameField.setValue(user.getLastName()); lastNameField.setMaxLength(20); lastNameField.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); saveButton.setEnabled(setError(lastNameField, true)); } else { lastNameField.setComponentError(null); saveButton.setEnabled(setError(lastNameField, false)); } }); setError(lastNameField, false); usernameField = new TextField(Language.get(Word.USERNAME)); usernameField.setValue(user.getUsername()); usernameField.setMaxLength(20); usernameField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getUsername())) { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { usernameField.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); saveButton.setEnabled(setError(usernameField, true)); } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } }); setError(usernameField, false); emailField = new TextField(Language.get(Word.EMAIL)); emailField.setValue(user.getEmail()); emailField.setMaxLength(256); emailField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getEmail())) { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); saveButton.setEnabled(setError(emailField, true)); } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } }); setError(emailField, false); oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD)); oldPasswordField.setValue(""); oldPasswordField.setMaxLength(51); oldPasswordField.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); if (!password1Error.isEmpty()) { oldPasswordField.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(oldPasswordField, true)); } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } }); setError(oldPasswordField, false); ProgressBar strength = new ProgressBar(); password1Field = new PasswordField(Language.get(Word.PASSWORD)); password1Field.setValue(""); password1Field.setMaxLength(51); password1Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1Field.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(password1Field, true)); } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } }); setError(password1Field, false); strength.setWidth("184px"); strength.setHeight("1px"); password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2Field.setValue(""); password2Field.setMaxLength(51); password2Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2Field.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); saveButton.setEnabled(setError(password2Field, true)); } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } }); setError(password2Field, false); details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField, password1Field, strength, password2Field); return root; }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildClippingsTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.CLIPPINGS)); root.setIcon(VaadinIcons.NEWSPAPER); root.setWidth("100%"); root.setSpacing(true);//from w w w. j ava 2s . c o m root.setMargin(true); FormLayout formLayoutClippingDetails = new FormLayout(); formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(formLayoutClippingDetails); CheckBox checkBoxReceiveEmails = new CheckBox(); checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user)); checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue())); HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails); layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION)); layoutCheckBoxReceiveEmails.setMargin(false); layoutCheckBoxReceiveEmails.setSpacing(false); HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout(); layoutAddNewClippingTime.setMargin(false); layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME)); layoutAddNewClippingTime.setWidth("100%"); InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField(); LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin")); dateFieldNewClippingTime.setValue(value); dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale()); dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE); dateFieldNewClippingTime.addStyleName("time-only"); Button buttonAddClippingTime = new Button(); buttonAddClippingTime.setIcon(VaadinIcons.PLUS); buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonAddClippingTime.addClickListener(e -> { LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime(); layoutClippingTimes.addComponent(getTimeRow(user, generalTime)); UserUtils.addClippingSendTime(user, generalTime); }); layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime); layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT); layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER); layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5); layoutClippingTimes = new VerticalLayout(); layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true)); layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES)); layoutClippingTimes.setWidth("100%"); layoutClippingTimes.addStyleName("times"); Set<LocalTime> userTimes = user.getClippingTime(); userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t))); formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime, layoutClippingTimes); return root; }
From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java
public RegisterWindow() { setModal(true);/*from ww w . ja va 2 s. c om*/ setResizable(false); setDraggable(false); setCaption(Language.get(Word.REGISTER)); addCloseShortcut(KeyCode.ENTER, null); Button save = new Button(Language.get(Word.REGISTER)); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); TextField firstName = new TextField(Language.get(Word.FIRST_NAME)); firstName.focus(); firstName.setMaxLength(20); firstName.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); save.setEnabled(setError(firstName, true)); } else { firstName.setComponentError(null); boolean enabled = setError(firstName, false); save.setEnabled(enabled); } }); forms.addComponent(firstName); TextField lastName = new TextField(Language.get(Word.LAST_NAME)); lastName.setMaxLength(20); lastName.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); save.setEnabled(setError(lastName, true)); } else { lastName.setComponentError(null); save.setEnabled(setError(lastName, false)); } }); forms.addComponent(lastName); TextField userName = new TextField(Language.get(Word.USERNAME)); userName.setMaxLength(20); userName.addValueChangeListener(event -> { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); save.setEnabled(setError(userName, true)); } else { userName.setComponentError(null); save.setEnabled(setError(userName, false)); } }); forms.addComponent(userName); TextField email1 = new TextField(Language.get(Word.EMAIL)); email1.setMaxLength(256); email1.addValueChangeListener(event -> { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); save.setEnabled(setError(email1, true)); } else { email1.setComponentError(null); save.setEnabled(setError(email1, false)); } }); forms.addComponent(email1); TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN)); email2.setMaxLength(256); email2.addValueChangeListener(event -> { String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase()) + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase()); if (!email2Error.isEmpty()) { email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email2Error); save.setEnabled(setError(email2, true)); } else { email2.setComponentError(null); save.setEnabled(setError(email2, false)); } }); forms.addComponent(email2); ProgressBar strength = new ProgressBar(); PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD)); password1.setMaxLength(51); password1.addValueChangeListener(event -> { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); save.setEnabled(setError(password1, true)); } else { password1.setComponentError(null); save.setEnabled(setError(password1, false)); } }); forms.addComponent(password1); strength.setWidth("184px"); strength.setHeight("1px"); forms.addComponent(strength); PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2.setMaxLength(51); password2.addValueChangeListener(event -> { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); save.setEnabled(setError(password2, true)); } else { password2.setComponentError(null); save.setEnabled(setError(password2, false)); } }); forms.addComponent(password2); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { close(); }); cancel.setClickShortcut(KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(), email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(), lastName.getValue()); UserUtils.setCurrentUser(user); close(); UI.getCurrent().addWindow(ActivateWindow.get()); } catch (UserCreationException ex) { Log.error("Registration failed", ex); VaadinUtils.errorNotification(Language.get(Word.REG_FAILED)); } }); save.setClickShortcut(KeyCode.ENTER, null); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); setContent(windowLayout); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java
License:Open Source License
/** * Zeige das Projekt-Hinzufuegen-Dialogfenster, bei dem ein Eingabefeld fuer * den Namen des Projekts und ein Hinzfuege-Button vorhanden ist. Funktion * bei geklicktem Button siehe Clicklistener in dieser Klasse. Das * horizontale Layout zur Darstellung besitzt ein Formlayout und den Button, * die nebeneinander dargestellt werden. * //from w w w . j av a2 s .c o m * @author Christian Scherer, Mirko Gpfrich */ @Override public void showAddProjectDialog() { addDialog = new Window("Projekt hinzufgen"); addDialog.setModal(true); addDialog.setWidth(410, UNITS_PIXELS); addDialog.setResizable(false); addDialog.setDraggable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(false); FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setSpacing(true); //TextFeld fr Name dem Formular hinzufgen tfName = new TextField("Name whlen:"); tfName.setRequired(true); tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2, 20, false)); tfName.setRequiredError("Pflichtfeld"); tfName.setSizeFull(); formLayout.addComponent(tfName); //TextArea fr Beschreibung dem Formular hinzufgen taDescription = new TextArea("Beschreibung whlen"); taDescription.setSizeFull(); formLayout.addComponent(taDescription); //Formular dem Layout hinzufgen layout.addComponent(formLayout); //Hinzufge-Button erstllen und dem Layout hinzufgen dialogAddBtn = new Button("Hinzufgen", this); layout.addComponent(dialogAddBtn); //Layout dem Dialog-Fenster hinzufgen addDialog.addComponent(layout); //Dialog dem Hauptfenster hinzufgen getWindow().addWindow(addDialog); logger.debug("Hinzufuege-Dialog erzeugt"); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java
License:Open Source License
/**Methode zur Implementierung des Dialogfensters fr Projekt-nderungen. * /*w ww . ja v a2 s . co m*/ */ @Override public void showEditProjectDialog(Project project) { editDialog = new Window("Projekt bearbeiten"); editDialog.setModal(true); editDialog.setWidth(410, UNITS_PIXELS); editDialog.setResizable(false); editDialog.setDraggable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setSpacing(true); //TextFeld fr Name dem Formular hinzufgen tfName = new TextField("Name ndern:", project.getName()); tfName.setRequired(true); tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2, 20, false)); tfName.setRequiredError("Pflichtfeld"); tfName.setSizeFull(); formLayout.addComponent(tfName); //TextArea fr Beschreibung dem Formular hinzufgen taDescription = new TextArea("Beschreibung ndern:", project.getDescription()); taDescription.setSizeFull(); formLayout.addComponent(taDescription); //Formular dem Layout hinzufgen layout.addComponent(formLayout); //Speichern-Button erstllen und dem Layout hinzufgen //TODO: ist das korrekt? Gute Frage, I have no idea what u r doing dialogEditBtn = new Button("Speichern"); layout.addComponent(dialogEditBtn); dialogEditBtn.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { if (tfName.isValid()) { boolean succed = presenter.editProject(projects.get(indexEditBtn), (String) tfName.getValue(), (String) taDescription.getValue()); if (succed) { getWindow().removeWindow(editDialog); logger.debug("Projekt-bearbeiten Dialog geschlossen"); } } else { getWindow().showNotification("", "Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an", Notification.TYPE_ERROR_MESSAGE); } } }); //Layout dem Dialog-Fenster hinzufgen editDialog.addComponent(layout); //Dialog dem Hauptfenster hinzufgen getWindow().addWindow(editDialog); logger.debug("Bearbeiten-Dialog erzeugt"); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenViewImpl.java
License:Open Source License
/** * Konkrete Erzeugung des Dialogfensters zur Registrierung eines neuen * Users./*from www.j a v a2s .co m*/ * * @author Christian Scherer, Marcel Rosenberger, Annika Weis */ public void showRegisterUserDialog() { regDialog = new Window("Benutzer bei Business Horizon registrieren"); regDialog.setModal(true); regDialog.setWidth(400, UNITS_PIXELS); regDialog.setResizable(false); regDialog.setDraggable(false); regDialog.setCaption("Registrierung eines neuen Benutzers"); fl = new FormLayout(); fl.setSpacing(true); fl.setMargin(true); regDialog.addComponent(fl); //Vorname textfieldFirstName = new TextField(); textfieldFirstName.setCaption("Bitte Vornamen angeben: "); textfieldFirstName.setRequired(true); textfieldFirstName.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldFirstName); //Nachname textfieldLastName = new TextField(); textfieldLastName.setCaption("Bitte Nachnamen angeben: "); textfieldLastName.setRequired(true); textfieldLastName.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldLastName); //Unternehmen textfieldCompany = new TextField(); textfieldCompany.setCaption("Bitte Unternehmen angeben: "); textfieldCompany.setRequired(true); textfieldCompany.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldCompany); //Mailadresse textfieldEmailAdress = new TextField(); textfieldEmailAdress.setCaption("Bitte Mailadresse angeben: "); textfieldEmailAdress.setRequired(true); textfieldEmailAdress.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldEmailAdress); //Passwort passwordFieldPassword = new PasswordField("Bitte Passwort whlen: "); passwordFieldPassword.setRequired(true); passwordFieldPassword.setRequiredError("Pflichtfeld"); fl.addComponent(passwordFieldPassword); //Passwort WDH passwordFieldPasswordRep = new PasswordField("Bitte Passwort wiederholen:"); passwordFieldPasswordRep.setRequired(true); passwordFieldPasswordRep.setRequiredError("Pflichtfeld"); fl.addComponent(passwordFieldPasswordRep); VerticalLayout vl = new VerticalLayout(); dialogRegBtn = new Button("Registrierung abschlieen", this); vl.addComponent(dialogRegBtn); vl.setComponentAlignment(dialogRegBtn, Alignment.MIDDLE_CENTER); regDialog.addComponent(vl); getWindow().addWindow(regDialog); logger.debug("Registrier-Dialog erzeugt"); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.scenario.ScenarioViewImpl.java
License:Open Source License
/** * Die Methode fuegt der View ein Szenario hinzu. Sie baut hierzu saemtliche * notwendigen GUI-Elemente und entsprecheenden Listener hinzu. * //from w ww. ja v a2 s . com * @author Julius Hacker * @param rateReturnEquity Standardwert fuer die Renditeforderung Eigenkapital * @param rateReturnCapitalStock Standardwert fuer die Renditeforderung Fremdkapital * @param businessTax Standardwert fuer die Gewerbesteuer * @param corporateAndSolitaryTax Standardwert fuer die Koerperschaftssteuer mit Solidaritaetszuschlag. */ @Override public void addScenario(String rateReturnEquity, String rateReturnCapitalStock, String corporateAndSolitaryTax, String businessTax, boolean isIncludeInCalculation, final int number) { HashMap<String, AbstractComponent> scenarioComponents = new HashMap<String, AbstractComponent>(); Property.ValueChangeListener changeListener = new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { presenter.updateScenario(number); logger.debug("TextChange ausgeloest"); logger.debug("ChangeListener " + System.identityHashCode(this)); } }; HorizontalLayout hlScenario = new HorizontalLayout(); hlScenario.setSizeFull(); FormLayout formLeft = new FormLayout(); FormLayout formRight = new FormLayout(); hlScenario.addComponent(formLeft); //hlScenario.addComponent(formRight); final Label scenarioName = new Label("<strong>Szenario " + number + "</strong>"); scenarioName.setContentMode(Label.CONTENT_XHTML); scenarioComponents.put("label", scenarioName); formLeft.addComponent(scenarioName); scenarioName.setWidth(Sizeable.SIZE_UNDEFINED, 0); final CheckBox cbBerechnungEinbezug = new CheckBox("In Berechnung einbeziehen"); cbBerechnungEinbezug.setValue(isIncludeInCalculation); cbBerechnungEinbezug.setImmediate(true); cbBerechnungEinbezug.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { presenter.updateScenario(number); logger.debug("ChangeListener " + System.identityHashCode(this)); } }); scenarioComponents.put("isIncludeInCalculation", cbBerechnungEinbezug); formLeft.addComponent(cbBerechnungEinbezug); final TextField tfEigenkapital = new TextField("Renditeforderung Eigenkapital: "); if (!"0.0".equals(rateReturnEquity)) { tfEigenkapital.setValue(rateReturnEquity); } tfEigenkapital.setImmediate(true); tfEigenkapital.addListener(changeListener); scenarioComponents.put("rateReturnEquity", tfEigenkapital); formLeft.addComponent(tfEigenkapital); final TextField tfFremdkapital = new TextField("Renditeforderung Fremdkapital: "); if (!"0.0".equals(rateReturnCapitalStock)) { tfFremdkapital.setValue(rateReturnCapitalStock); } tfFremdkapital.setImmediate(true); tfFremdkapital.addListener(changeListener); scenarioComponents.put("rateReturnCapitalStock", tfFremdkapital); formLeft.addComponent(tfFremdkapital); final TextField tfGewerbesteuer = new TextField("Gewerbesteuer: "); if (!"0.0".equals(businessTax)) { tfGewerbesteuer.setValue(businessTax); } tfGewerbesteuer.setImmediate(true); tfGewerbesteuer.addListener(changeListener); scenarioComponents.put("businessTax", tfGewerbesteuer); formLeft.addComponent(tfGewerbesteuer); final TextField tfKoerperschaftssteuer = new TextField( "K\u00F6rperschaftssteuer mit Solidarit\u00E4tszuschlag: "); if (!"0.0".equals(corporateAndSolitaryTax)) { tfKoerperschaftssteuer.setValue(corporateAndSolitaryTax); } tfKoerperschaftssteuer.setImmediate(true); tfKoerperschaftssteuer.addListener(changeListener); scenarioComponents.put("corporateAndSolitaryTax", tfKoerperschaftssteuer); formLeft.addComponent(tfKoerperschaftssteuer); final Button removeScenario = new Button("Szenario entfernen"); removeScenario.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { presenter.removeScenario(number); } }); formLeft.addComponent(removeScenario); formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0); formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0); scenarioComponents.put("scenario", hlScenario); this.scenarios.add(scenarioComponents); this.vlScenarios.addComponent(hlScenario); }
From source file:edu.nps.moves.mmowgli.modules.cards.ShowCardCacheCountsDialog.java
License:Open Source License
private ShowCardCacheCountsDialog() { setCaption("Show Card Cache Sizes"); setModal(true);/*from w w w .j a va2 s . co m*/ setWidth("350px"); FormLayout fl = new FormLayout(); setContent(fl); fl.setMargin(true); fl.setSpacing(true); MCacheManager mgr = MCacheManager.instance(); Object[][] caches = mgr.getCaches(); Label lab; for (int i = 0; i < caches[0].length; i++) { if (!(caches[0][i] instanceof String)) continue; if (!(caches[1][i] instanceof Map)) continue; fl.addComponent(lab = new Label("" + ((Map<?, ?>) caches[1][i]).size())); lab.setCaption(caches[0][i].toString()); } }