List of usage examples for com.vaadin.ui GridLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java
public RegisterWindow() { setModal(true);/* ww w . java 2 s . c o m*/ 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:edu.kit.dama.ui.admin.LoginInformationBar.java
License:Apache License
private void buildMainLayout() { loggedInAsLabel = new Label("Login Username"); loggedInAsLabel.addStyleName("myboldcaption"); loggedInUserLabel = new Label(); activeGroupLabel = new Label("Active Group"); activeGroupLabel.addStyleName("myboldcaption"); groupSelection = new ComboBox(); groupSelection.addValueChangeListener(this); activeRoleLabel = new Label("Current Role"); activeRoleLabel.addStyleName("myboldcaption"); roleLabel = new Label(); Label spacer1 = new Label(""); home = buildMenuItem("home", new ThemeResource("img/70x48/logo_default.png")); profile = buildMenuItem("profile", new ThemeResource("img/70x48/preferences.png")); simon = buildMenuItem("simon", new ThemeResource("img/70x48/simon.png")); settings = buildMenuItem("settings", new ThemeResource("img/70x48/gears_preferences.png")); exit = buildMenuItem("exit", new ThemeResource("img/70x48/exit.png")); final AbsoluteLayout helps = new AbsoluteLayout(); helps.setHeight("48px"); helps.setWidth("100%"); addHelpItem("home", "Return to the main page.", helps); addHelpItem("profile", "Open your profile, e.g. to change your password.", helps); addHelpItem("simon", "Open the <b>SI</b>mple<b>MON</b>itoring Tool, e.g. to check the availability of single services.", helps);/* ww w .ja v a 2 s. com*/ addHelpItem("settings", "Open the system settings. (Only available for Group Managers and Administrators)", helps); addHelpItem("exit", "Logout.", helps); HorizontalLayout navigation = new HorizontalLayout(home, profile, simon, settings, exit, helps, spacer1); navigation.setExpandRatio(helps, .9f); navigation.setExpandRatio(spacer1, .1f); navigation.setSizeFull(); navigation.addStyleName("mynavigationmargin"); navigation.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> { if (home.equals(event.getClickedComponent())) { parent.updateView(VIEW.INFORMATION); } else if (profile.equals(event.getClickedComponent())) { parent.updateView(VIEW.PROFILE); } else if (simon.equals(event.getClickedComponent())) { parent.updateView(VIEW.SIMON); } else if (settings.equals(event.getClickedComponent())) { parent.updateView(VIEW.SETTINGS); } else if (exit.equals(event.getClickedComponent())) { parent.logout(); } }); GridLayout loginInformationLayout = new UIUtils7.GridLayoutBuilder(3, 2) .addComponent(loggedInAsLabel, Alignment.MIDDLE_CENTER, 0, 0, 1, 1) .addComponent(activeGroupLabel, Alignment.MIDDLE_CENTER, 1, 0, 1, 1) .addComponent(activeRoleLabel, Alignment.MIDDLE_CENTER, 2, 0, 1, 1) .addComponent(loggedInUserLabel, Alignment.MIDDLE_CENTER, 0, 1, 1, 1) .addComponent(groupSelection, Alignment.MIDDLE_CENTER, 1, 1, 1, 1) .addComponent(roleLabel, Alignment.MIDDLE_CENTER, 2, 1, 1, 1).getLayout(); loginInformationLayout.setSpacing(true); mainLayout = new UIUtils7.GridLayoutBuilder(5, 2) .addComponent(navigation, Alignment.MIDDLE_LEFT, 0, 0, 3, 2) .addComponent(loginInformationLayout, Alignment.MIDDLE_RIGHT, 3, 0, 2, 2).getLayout(); mainLayout.setColumnExpandRatio(0, 1.0f); mainLayout.setColumnExpandRatio(1, .01f); mainLayout.setColumnExpandRatio(2, .01f); mainLayout.setColumnExpandRatio(3, .01f); mainLayout.setColumnExpandRatio(4, .01f); mainLayout.setSpacing(true); mainLayout.setMargin(new MarginInfo(false, true, false, true)); mainLayout.setSizeFull(); }
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Build the main layout.//ww w . j a v a 2 s .com */ private void buildMainLayout() { infoCell = createCell("img/128x128/information2.png", Alignment.TOP_RIGHT, 0, "<p>Show/edit your profile and personel settings.</p>", "help-right"); profileCell = createCell("img/128x128/preferences.png", Alignment.TOP_LEFT, 1, "<p>Get information on how you use this KIT Data Manager instance.</p>", "help-left"); administrationCell = createCell("img/128x128/gears_preferences.png", Alignment.BOTTOM_RIGHT, 2, "<p>Logout.</p>", "help-right"); logoutCell = createCell("img/128x128/exit.png", Alignment.BOTTOM_LEFT, 3, "<p>Show KIT Data Manager settings.<br/>This view is only available for administrators and group manager</p>.", "help-left"); GridLayout actionCellLayout = new UIUtils7.GridLayoutBuilder(2, 2) .addComponent(infoCell, Alignment.BOTTOM_RIGHT, 0, 0, 1, 1) .addComponent(profileCell, Alignment.BOTTOM_LEFT, 1, 0, 1, 1) .addComponent(administrationCell, Alignment.TOP_RIGHT, 0, 1, 1, 1) .addComponent(logoutCell, Alignment.TOP_LEFT, 1, 1, 1, 1).getLayout(); actionCellLayout.setSpacing(true); actionCellLayout.setMargin(true); actionCellLayout.setSizeFull(); actionCellLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (event.getClickedComponent() instanceof Image) { // Check if childComponent is disabled if (!event.getChildComponent().isEnabled()) { return; } Image img = (Image) event.getClickedComponent(); if ("image0".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.INFORMATION); } else if ("image1".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.PROFILE); } else if ("image2".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.SETTINGS); } else if ("image3".equals(img.getId())) { parent.logout(); } } } }); mainLayout = new VerticalLayout(actionCellLayout); mainLayout.setSizeFull(); }
From source file:edu.kit.dama.ui.admin.schedule.trigger.AtTriggerConfigurationPanel.java
License:Apache License
@Override public AbstractLayout getLayout() { GridLayout layout = new UIUtils7.GridLayoutBuilder(2, 5).addComponent(getGroupField(), 0, 0) .addComponent(getNameField(), 1, 0).addComponent(getPrioritySlider(), 0, 1, 2, 1) .addComponent(getAtDateField(), 0, 2, 2, 1).addComponent(getDescriptionField(), 0, 3, 2, 2) .getLayout();//w w w . ja v a 2 s . c o m layout.setMargin(false); layout.setSpacing(true); layout.setSizeFull(); return layout; }
From source file:edu.kit.dama.ui.admin.schedule.trigger.ExpressionTriggerConfigurationPanel.java
License:Apache License
@Override public AbstractLayout getLayout() { GridLayout layout = new UIUtils7.GridLayoutBuilder(2, 6).addComponent(getGroupField(), 0, 0) .addComponent(getNameField(), 1, 0).addComponent(getPrioritySlider(), 0, 1, 2, 1) .addComponent(getStartDateField(), 0, 2, 1, 1).addComponent(getEndDateField(), 1, 2, 1, 1) .addComponent(getExpressionLayout(), 0, 3, 2, 1).addComponent(getDescriptionField(), 0, 4, 2, 2) .getLayout();//from w w w .ja v a 2 s. c o m layout.setMargin(false); layout.setSpacing(true); layout.setSizeFull(); return layout; }
From source file:edu.kit.dama.ui.admin.schedule.trigger.IntervalTriggerConfigurationPanel.java
License:Apache License
@Override public AbstractLayout getLayout() { GridLayout layout = new UIUtils7.GridLayoutBuilder(2, 6).addComponent(getGroupField(), 0, 0) .addComponent(getNameField(), 1, 0).addComponent(getPrioritySlider(), 0, 1, 2, 1) .addComponent(getStartDateField(), 0, 2, 1, 1).addComponent(getEndDateField(), 1, 2, 1, 1) .addComponent(getPeriodField(), 0, 3, 1, 1).addComponent(getTimesField(), 1, 3, 1, 1) .addComponent(getDescriptionField(), 0, 4, 2, 2).getLayout(); layout.setMargin(false);// w w w . java2 s .c o m layout.setSpacing(true); layout.setSizeFull(); return layout; }
From source file:edu.kit.dama.ui.admin.schedule.trigger.NowTriggerConfigurationPanel.java
License:Apache License
@Override public AbstractLayout getLayout() { GridLayout layout = new UIUtils7.GridLayoutBuilder(2, 5).addComponent(getGroupField(), 0, 0) .addComponent(getNameField(), 1, 0).addComponent(getPrioritySlider(), 0, 1, 2, 1) .addComponent(new Label("No configuration needed."), Alignment.MIDDLE_CENTER, 0, 2, 2, 1) .addComponent(getDescriptionField(), 0, 3, 2, 2).getLayout(); layout.setMargin(false);/*from w w w .j a v a 2 s .c o m*/ layout.setSpacing(true); layout.setSizeFull(); return layout; }
From source file:edu.kit.dama.ui.admin.ServiceAccessTokenDialog.java
License:Apache License
private void updateAuthenticatorAttributeLayout(AbstractAuthenticator authenticator) { UIUtils7.GridLayoutBuilder builder;/* w w w. j a va 2 s .co m*/ String[] attributes = authenticator.getCredentialAttributeNames(); switch (attributes.length) { case 0: { tokenField = null; secretField = null; nosecretField = null; builder = new UIUtils7.GridLayoutBuilder(1, 1); break; } case 1: { tokenField = new TextField(attributes[0]); tokenField.addStyleName("myboldcaption"); secretField = null; nosecretField = null; builder = new UIUtils7.GridLayoutBuilder(1, 1); break; } default: { tokenField = new TextField(attributes[0]); tokenField.addStyleName("myboldcaption"); secretField = new PasswordField(attributes[1]); secretField.addStyleName("myboldcaption"); nosecretField = new TextField(attributes[1]); nosecretField.addStyleName("myboldcaption"); builder = new UIUtils7.GridLayoutBuilder(2, 3); } } if (tokenField != null) { builder.fillRow(tokenField, 0, 0, 1); } else { builder.fillRow(new Label("No configuration needed."), 0, 0, 1); } if (secretField != null) { builder.addComponent(secretField, 0, 1); builder.addComponent(generateButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1); builder.fillRow(showSecret, 0, 2, 1); } GridLayout newLayout = builder.getLayout(); newLayout.setSpacing(true); newLayout.setWidth("400px"); mainLayout.replaceComponent(authenticatorConfigurationLayout, newLayout); authenticatorConfigurationLayout = newLayout; }
From source file:edu.kit.dama.ui.components.ConfirmationWindow7.java
License:Apache License
/** * Builds a customized subwindow <b>ConfirmationWindow</b> that allows the * user to confirm his previously requested action. * * @param pTitle The title of the window. * @param pMessage The message shown in the window. * @param pOptionType The type of the window (OK or YES_NO) which defines the * visible buttons.//from w ww . jav a2 s . c o m * @param pMessageType The message type (INFORMATION, WARNING, ERROR) which * determines the icon. If pMessageType is null, no icon will be shown. * @param pListener The listener which receives the result if a button was * pressed or the window was closed. * */ ConfirmationWindow7(String pTitle, String pMessage, OPTION_TYPE pOptionType, MESSAGE_TYPE pMessageType, IConfirmationWindowListener7 pListener) { this.listener = pListener; //basic setup //set caption depending on type String caption = pTitle; if (caption == null) { if (pMessageType != null) { switch (pMessageType) { case QUESTION: caption = DEFAULT_TITLE; break; case INFORMATION: caption = "Information"; break; case WARNING: caption = "Warning"; break; case ERROR: caption = "Error"; break; } } else { //no type provided...use default title caption = DEFAULT_TITLE; } } setCaption(caption); setModal(true); center(); // Build line of buttons depending on pOptionType HorizontalLayout buttonLine = new HorizontalLayout(); buttonLine.setSpacing(true); buttonLine.setWidth("100%"); //add spacer Label spacer = new Label(); buttonLine.addComponent(spacer); //add buttons if (OPTION_TYPE.YES_NO_OPTION.equals(pOptionType)) { buttonLine.addComponent(buildYesButton("Yes")); buttonLine.addComponent(buildNoButton()); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); buttonLine.setComponentAlignment(noButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the YES button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to the NO button noButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); } else { buttonLine.addComponent(buildYesButton("OK")); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the OK button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to close the dialog setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null); } buttonLine.setExpandRatio(spacer, 1.0f); //determine the icon depending on pMessageType ThemeResource icon = null; if (pMessageType != null) { switch (pMessageType) { case QUESTION: icon = new ThemeResource("img/24x24/question.png"); break; case INFORMATION: icon = new ThemeResource("img/24x24/information.png"); break; case WARNING: icon = new ThemeResource("img/24x24/warning.png"); break; case ERROR: icon = new ThemeResource("img/24x24/forbidden.png"); break; } } Component iconComponent = new Label(); if (icon != null) { //icon was set, overwrite icon component iconComponent = new Image(null, icon); } //build the message label Label message = new Label(pMessage, ContentMode.HTML); message.setSizeUndefined(); //build the main layout GridLayout mainLayout = new UIUtils7.GridLayoutBuilder(2, 2) .addComponent(iconComponent, Alignment.TOP_LEFT, 0, 0, 1, 1).addComponent(message, 1, 0, 1, 1) .addComponent(buttonLine, 0, 1, 2, 1).getLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setColumnExpandRatio(0, .05f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, 1f); mainLayout.setRowExpandRatio(1, .05f); setContent(mainLayout); //add the close listener addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { fireCloseEvents(RESULT.CANCEL); } }); }
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
License:Apache License
/** * Create the tab for a single category. * * @param pProbes The probes of this category. * * @return The category tab component./*ww w .j av a 2 s. c om*/ */ private Component createCategoryTab(List<AbstractProbe> pProbes) { UIUtils7.GridLayoutBuilder layoutBuilder = new UIUtils7.GridLayoutBuilder(2, pProbes.size()); int row = 0; for (AbstractProbe probe : pProbes) { Embedded status = new Embedded(null, getResourceForStatus(probe.getCurrentStatus())); Label name = new Label(probe.getName()); layoutBuilder.addComponent(status, Alignment.MIDDLE_LEFT, 0, row, 1, 1).addComponent(name, Alignment.MIDDLE_LEFT, 1, row, 1, 1); row++; } GridLayout tabLayout = layoutBuilder.getLayout(); tabLayout.setColumnExpandRatio(0, .01f); tabLayout.setColumnExpandRatio(1, 1.0f); tabLayout.setImmediate(true); tabLayout.setSpacing(true); tabLayout.setMargin(true); tabLayout.setWidth("100%"); return tabLayout; }