List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Instantiates a new monitors settings. * * @param settingsDialog the settings dialog * @param systemID the system id//w w w. ja v a 2 s . com * @param systemType the system type */ MonitorsSettings(SettingsDialog settingsDialog, String systemID, String systemType) { this.settingsDialog = settingsDialog; this.systemID = systemID; this.systemType = systemType; addStyleName("monitorsTab"); setSizeFull(); setSpacing(true); setMargin(true); HorizontalLayout selectLayout = new HorizontalLayout(); addComponent(selectLayout); selectLayout.setSizeFull(); selectLayout.setSpacing(true); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); select = new ListSelect("Monitors"); select.setImmediate(true); for (MonitorRecord monitor : monitorsAll.values()) { String id = monitor.getID(); select.addItem(id); select.setItemCaption(id, monitor.getName()); } select.setNullSelectionAllowed(false); selectLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String monitorID = (String) event.getProperty().getValue(); displayMonitorRecord(monitorID); MonitorRecord monitor = monitorsAll.get(monitorID); if (monitor != null) { String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor.setEnabled(true); break; } } } } }); selectLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String monitorID = (String) select.getValue(); MonitorRecord monitor = monitorsAll.get(monitorID); String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor(monitor); break; } } } } }); monitorLayout = new FormLayout(); selectLayout.addComponent(monitorLayout); selectLayout.setExpandRatio(monitorLayout, 1.0f); monitorLayout.setSpacing(false); id.setCaption("ID:"); monitorLayout.addComponent(id); name.setCaption("Name:"); monitorLayout.addComponent(name); description.setCaption("Description:"); monitorLayout.addComponent(description); unit.setCaption("Unit:"); monitorLayout.addComponent(unit); // type.setCaption("Type:"); // monitorLayout.addComponent(type); delta.setCaption("Is Delta:"); monitorLayout.addComponent(delta); average.setCaption("Is Average:"); monitorLayout.addComponent(average); chartType.setCaption("Chart Type:"); monitorLayout.addComponent(chartType); interval.setCaption("Interval:"); monitorLayout.addComponent(interval); sql.setCaption("Statement:"); monitorLayout.addComponent(sql); HorizontalLayout selectButtons = new HorizontalLayout(); selectButtons.setSizeFull(); addComponent(selectButtons); selectButtons.setSpacing(true); Button addMonitor = new Button("Add..."); selectButtons.addComponent(addMonitor); selectButtons.setComponentAlignment(addMonitor, Alignment.MIDDLE_LEFT); addMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { addMonitor(); } }); deleteMonitor = new Button("Delete"); deleteMonitor.setEnabled(false); selectButtons.addComponent(deleteMonitor); selectButtons.setComponentAlignment(deleteMonitor, Alignment.MIDDLE_LEFT); deleteMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { deleteMonitor(monitorsAll.get(monitorID)); } } }); editMonitor = new Button("Edit..."); editMonitor.setEnabled(false); selectButtons.addComponent(editMonitor); selectButtons.setComponentAlignment(editMonitor, Alignment.MIDDLE_CENTER); selectButtons.setExpandRatio(editMonitor, 1.0f); editMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { editMonitor(monitorsAll.get(monitorID)); } } }); }
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Instantiates a new users settings.//from w ww . j a va2 s . co m */ UsersSettings() { addStyleName("usersTab"); setSizeFull(); setSpacing(true); setMargin(true); UserObject currentUser = VaadinSession.getCurrent().getAttribute(UserObject.class); currentUserID = currentUser.getUserID(); HorizontalLayout usersLayout = new HorizontalLayout(); addComponent(usersLayout); usersLayout.setSizeFull(); usersLayout.setSpacing(true); // make sure we're working with current info userInfo = new UserInfo(null); VaadinSession.getCurrent().setAttribute(UserInfo.class, userInfo); select = new ListSelect("Users"); select.setImmediate(true); for (UserObject user : userInfo.getUsersList().values()) { String id = user.getUserID(); select.addItem(id); if (id.equals(currentUserID)) { select.select(id); userName.setValue(user.getName()); selectedUserID = id; } } select.setNullSelectionAllowed(false); select.setWidth("14em"); usersLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { selectedUserID = (String) event.getProperty().getValue(); if (selectedUserID == null || selectedUserID.equals(currentUserID)) { removeUser.setEnabled(false); } else { removeUser.setEnabled(true); } if (selectedUserID == null) { editUser.setEnabled(false); userName.setEnabled(false); userName.setValue(""); } else { editUser.setEnabled(true); userName.setValue(userInfo.findNameByID(selectedUserID)); userName.setEnabled(true); } } }); usersLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String userID = (String) select.getValue(); new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } } }); userLayout = new FormLayout(); usersLayout.addComponent(userLayout); usersLayout.setExpandRatio(userLayout, 1.0f); userLayout.setSpacing(false); userName.setCaption("Full Name:"); userLayout.addComponent(userName); HorizontalLayout userButtonsLayout = new HorizontalLayout(); userButtonsLayout.setSpacing(true); addComponent(userButtonsLayout); Button addUser = new Button("Add..."); addUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, null, thisObject); } }); userButtonsLayout.addComponent(addUser); userButtonsLayout.setComponentAlignment(addUser, Alignment.MIDDLE_LEFT); removeUser = new Button("Delete"); removeUser.setEnabled(false); removeUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { removeUser(event); } }); userButtonsLayout.addComponent(removeUser); userButtonsLayout.setComponentAlignment(removeUser, Alignment.MIDDLE_LEFT); editUser = new Button("Edit..."); editUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } }); userButtonsLayout.addComponent(editUser); userButtonsLayout.setComponentAlignment(editUser, Alignment.MIDDLE_CENTER); }
From source file:com.snowy.NewUserSubWindow.java
public void build() { //setClosable(false); setModal(true);/*from ww w.j av a2 s .com*/ setResizable(false); setResponsive(true); setDraggable(false); FormLayout fl = new FormLayout(); fl.setMargin(true); //fl.setSizeFull(); fl.setSizeUndefined(); fl.setSpacing(true); TextField uname = new TextField("Username"); uname.setRequired(true); //uname.addValidator(null); fl.addComponent(uname); TextField email = new TextField("Email"); email.setRequired(true); email.addValidator(new EmailValidator("A Valid Email is Required")); fl.addComponent(email); PasswordField pf1 = new PasswordField("Password"); pf1.setRequired(true); pf1.addValidator(new StringLengthValidator("Password must be between 8 and 60 characters", 8, 60, false)); fl.addComponent(pf1); PasswordField pf2 = new PasswordField("Confirm Password"); pf2.setRequired(true); pf2.addValidator((Object value) -> { if (!pf2.getValue().equals(pf1.getValue())) { throw new InvalidValueException("Passwords Must Match"); } }); //pf2.setImmediate(true); fl.addComponent(pf2); Button b = new Button("Submit"); b.addClickListener((Button.ClickEvent e) -> { if (uname.isValid() && email.isValid() && pf1.isValid() && pf2.isValid()) { String result = d.createUser(uname.getValue(), pf2.getValue(), email.getValue()); if (result.equals("Creation Sucess")) { fl.removeAllComponents(); fl.addComponent(new Label("User Created Sucessfully")); fl.addComponent(new Button("Close", (ee) -> { this.close(); })); } else { Notification.show(result); } } else { b.setComponentError(new UserError("Issues with required fields")); } //d.close(); }); fl.addComponent(b); setContent(fl); }
From source file:com.squadd.chat.ChatController.java
public ChatController(Panel chatPanel, Panel contactsPanel, ChatView view) { this.chatPanel = chatPanel; this.contactsPanel = contactsPanel; this.content = new FormLayout(); content.setSizeFull();/* w w w . j a v a 2 s .c om*/ configureImages(); }
From source file:com.squadd.chat.ChatController.java
public void clearChat() { content = new FormLayout(); chatPanel.setContent(content); firstMessage = 0; }
From source file:com.squadd.chat.ChatController.java
public FormLayout createPhotoLayout(Embedded image) { FormLayout photoLayout = new FormLayout(); photoLayout.addComponent(image);//from w ww. j a va 2 s . co m photoLayout.setWidth("50px"); photoLayout.setHeight("50px"); UserInfoBean use = man.get(userTo.getId(), UserInfo.class, UserInfoBean.class); MouseEvents.ClickListener showUserButtonListener = new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { if (use != null) { System.out.println(use.getId()); view.setAnotherUser(use); UI.getCurrent().getNavigator().navigateTo(UserPageView.NAME); } } }; //if(use!=null){ //photoLayout.addClickListener(showUserButtonListener);} return photoLayout; }
From source file:com.squadd.chat.UserInfoFace.java
public Panel getUserPanel() { Panel contactPanel = new Panel(); FormLayout contactLine = new FormLayout(); contactPanel.addClickListener(upd);// w w w . j a v a 2 s . com Label nameLabel = new Label(user.getName()); nameLabel.setStyleName("userPanel"); contactLine.addComponent(nameLabel); contactPanel.setContent(contactLine); contactPanel.setId(user.getId().toString()); return contactPanel; //contactsContent.addComponent(look); //contactsPanel.setContent(contactsContent); }
From source file:com.squadd.chat.UserInfoFace.java
public Panel getUserPanel(Integer userId) { Panel contactPanel = new Panel(); FormLayout contactLine = new FormLayout(); user = new UserInfoBean(); user.setId(userId);//from w w w .j a v a2 s .c o m user.setName("id" + userId); contactPanel.addClickListener(upd); Label nameLabel = new Label(user.getName()); nameLabel.setStyleName("userPanel"); contactLine.addComponent(nameLabel); contactPanel.setContent(contactLine); contactPanel.setId(userId.toString()); return contactPanel; //contactsContent.addComponent(look); //contactsPanel.setContent(contactsContent); }
From source file:com.squadd.views.ChatView.java
private void configureComponents() { mainLayout = new HorizontalLayout(); mainUser = man.get(contact.getUserInfo().getId(), UserInfo.class, UserInfoBean.class); contactsLayout = new VerticalLayout(); contactsPanel = new Panel(); chatPanel = new Panel(); footer = new HorizontalLayout(); control = new DialogController(mainUser, null, chatPanel, contactsPanel, footer, this); content = new FormLayout(); contactsContent = new FormLayout(); //this.getUI().getPushConfiguration().setPushMode(PushMode.MANUAL); ClickListener sendListener = new ClickListener() { @Override/*from w w w. j a va2 s.c o m*/ public void buttonClick(final ClickEvent event) { ChatMessage mess = new ChatMessage(control.getUserFromId(), control.getUserToId(), new Date(), chatInput.getValue()); String body = mess.getBody(); if (body != null && !body.isEmpty()) { control.manager.add(mess); MessageBroadcaster.broadcast(mess); chatInput.clear(); chatInput.focus(); } } }; ClickListener clearListener = (ClickEvent event) -> { clearChat(); content = new FormLayout(); }; ClickListener updateListener = new ClickListener() { @Override public void buttonClick(ClickEvent event) { clearChat(); content = new FormLayout(); control.updateChatLog(4); } }; send = new Button("Send", sendListener); clear = new Button("Clear", clearListener); update = new Button("Update", updateListener); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout setDetailsForm(String strUID, String strAction) { cDetailsAndOperations = new HorizontalLayout(); cDetailsAndOperations.setSizeUndefined(); cUPersonalDetails = new FormLayout(); cUPersonalDetails.setMargin(false);//from w ww. j a v a 2 s .co m cUPersonalDetails.setSpacing(false); cUPersonalDetails.setStyleName("frm_details_personal_info"); cUPersonalDetails.setSizeUndefined(); cDetailsAndOperations.addComponent(cUPersonalDetails); arrLAllFormFields = new ArrayList<Object>(); final String btnEditId = "edit"; arrLAllEditableFields = new ArrayList<Object>(); arrLTfEditableVals = new ArrayList<String>(); final Button btnEdit = new Button(); btnEdit.setId(btnEditId); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName(ValoTheme.BUTTON_ICON_ONLY); btnEdit.setStyleName("btn_link"); btnEdit.setVisible(false); final Button btnCancel = new Button(); btnCancel.setId(btnEditId); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName(ValoTheme.BUTTON_ICON_ONLY); btnCancel.setStyleName("btn_link"); btnCancel.setVisible(false); cBtnEditCancel = new HorizontalLayout(); cBtnEditCancel.setSizeUndefined(); cBtnEditCancel.addComponent(btnEdit); setData(strUID, strAction); return cDetailsAndOperations; }