List of usage examples for com.vaadin.ui Panel getContent
@Override
public Component getContent()
From source file:ru.codeinside.adm.ui.employee.TableEmployee.java
License:Mozilla Public License
protected void edit(final CustomTable table) { final Item item = table.getItem(table.getValue()); final String login = (String) item.getItemProperty("login").getValue(); final UserItem userItem = AdminServiceProvider.get().getUserItem(login); final Pattern snilsPattern = Pattern.compile("\\d{11}"); final Pattern splitSnilsPattern = Pattern.compile("(\\d{3})(\\d{3})(\\d{3})(\\d{2})"); final Panel layout = new Panel(); ((Layout.SpacingHandler) layout.getContent()).setSpacing(true); layout.setSizeFull();/* w w w . jav a 2 s . c om*/ layout.addComponent(new Label("? ? " + login)); String widthColumn = "100px"; final PasswordField fieldPass = addPasswordField(layout, widthColumn, ""); final PasswordField fieldPassRepeat = addPasswordField(layout, widthColumn, " ?"); fieldPassRepeat.addValidator(new RepeatPasswordValidator(fieldPass)); final MaskedTextField fieldSnils = addMaskedTextField(layout, widthColumn, "?"); fieldSnils.setMask("###-###-### ##"); final TextField fieldFIO = addTextField(layout, widthColumn, ""); final String snils = userItem.getSnils() == null ? "" : userItem.getSnils(); final Matcher maskMatcher = snilsPattern.matcher(snils); final Matcher splitMatcher = splitSnilsPattern.matcher(snils); if (maskMatcher.matches()) { String maskedSnils = splitMatcher.replaceAll("$1-$2-$3 $4"); fieldSnils.setValue(maskedSnils); } fieldFIO.setValue(userItem.getFio()); HorizontalLayout l1 = new HorizontalLayout(); Label labelRole = new Label(""); labelRole.setWidth(widthColumn); l1.addComponent(labelRole); l1.setComponentAlignment(labelRole, Alignment.MIDDLE_LEFT); final OptionGroup roleOptionGroup = TableEmployee.createRoleOptionGroup(null); roleOptionGroup.setValue(userItem.getRoles()); l1.addComponent(roleOptionGroup); layout.addComponent(l1); final CertificateBlock certificateBlock = new CertificateBlock(userItem); layout.addComponent(certificateBlock); final ExecutorGroupsBlock executorGroupsBlock = new ExecutorGroupsBlock(userItem); layout.addComponent(executorGroupsBlock); final HorizontalLayout supervisorGroupsEmp = new HorizontalLayout(); supervisorGroupsEmp.setMargin(true, true, true, false); supervisorGroupsEmp.setSpacing(true); supervisorGroupsEmp .setCaption("? ? ? ?"); final FilterTable allSupervisorGroupsEmp = new FilterTable(); allSupervisorGroupsEmp.setCaption("?"); table(supervisorGroupsEmp, allSupervisorGroupsEmp); final FilterTable currentSupervisorGroupsEmp = new FilterTable(); currentSupervisorGroupsEmp.setCaption(""); table(supervisorGroupsEmp, currentSupervisorGroupsEmp); for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { if (userItem.getEmployeeGroups().contains(groupName)) { currentSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName); } else { allSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } } addListener(allSupervisorGroupsEmp, currentSupervisorGroupsEmp); addListener(currentSupervisorGroupsEmp, allSupervisorGroupsEmp); layout.addComponent(supervisorGroupsEmp); final HorizontalLayout supervisorGroupsOrg = new HorizontalLayout(); supervisorGroupsOrg.setMargin(true, true, true, false); supervisorGroupsOrg.setSpacing(true); supervisorGroupsOrg .setCaption("? ? ?"); final FilterTable allSupervisorGroupsOrg = new FilterTable(); allSupervisorGroupsOrg.setCaption("?"); table(supervisorGroupsOrg, allSupervisorGroupsOrg); final FilterTable currentSupervisorGroupsOrg = new FilterTable(); currentSupervisorGroupsOrg.setCaption(""); table(supervisorGroupsOrg, currentSupervisorGroupsOrg); for (String groupName : AdminServiceProvider.get().getOrgGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { if (userItem.getOrganizationGroups().contains(groupName)) { currentSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName); } else { allSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } } addListener(allSupervisorGroupsOrg, currentSupervisorGroupsOrg); addListener(currentSupervisorGroupsOrg, allSupervisorGroupsOrg); layout.addComponent(supervisorGroupsOrg); setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); roleOptionGroup.addListener(new Listener() { private static final long serialVersionUID = 1L; public void componentEvent(Event event) { setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); } }); Button cancel = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { removeComponent(layout); addComponent(table); table.setValue(null); if (hr != null) { hr.setVisible(true); } setExpandRatio(table, 1f); } }); Button apply = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String password = (String) fieldPass.getValue(); String passwordRepeat = (String) fieldPassRepeat.getValue(); if (!fieldPassRepeat.isValid() || !(password.equals(passwordRepeat))) { getWindow().showNotification( "? ? ? ?", Window.Notification.TYPE_ERROR_MESSAGE); return; } String snilsFieldValue = fieldSnils.getValue() == null ? "" : (String) fieldSnils.getValue(); String snilsValue = snilsFieldValue.replaceAll("\\D+", ""); Matcher snilsMatcher = snilsPattern.matcher(snilsValue); if (!snilsFieldValue.isEmpty() && !snilsMatcher.matches()) { getWindow().showNotification("? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } if (!AdminServiceProvider.get().isUniqueSnils(login, snilsValue)) { getWindow().showNotification(" ? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } String fio = (String) fieldFIO.getValue(); Set<Role> roles = (Set) roleOptionGroup.getValue(); TreeSet<String> groupExecutor = executorGroupsBlock.getGroups(); TreeSet<String> groupSupervisorEmp = new TreeSet<String>( (Collection<String>) currentSupervisorGroupsEmp.getItemIds()); TreeSet<String> groupSupervisorOrg = new TreeSet<String>( (Collection<String>) currentSupervisorGroupsOrg.getItemIds()); boolean modified = false; if (certificateBlock.isCertificateWasRemoved()) { userItem.setX509(null); modified = true; } if (!password.equals("") && password.equals(passwordRepeat)) { userItem.setPassword1(password); userItem.setPassword2(passwordRepeat); modified = true; } if (!fio.trim().equals("") && !fio.equals(userItem.getFio())) { userItem.setFio(fio); userItem.setX509(null); modified = true; } if (!snilsValue.equals(userItem.getSnils())) { userItem.setSnils(snilsValue); modified = true; } if (!roles.equals(userItem.getRoles())) { userItem.setRoles(roles); modified = true; } if (!groupExecutor.equals(userItem.getGroups())) { userItem.setGroups(groupExecutor); modified = true; } if (!groupSupervisorEmp.equals(userItem.getEmployeeGroups())) { userItem.setEmployeeGroups(groupSupervisorEmp); modified = true; } if (!groupSupervisorOrg.equals(userItem.getOrganizationGroups())) { userItem.setOrganizationGroups(groupSupervisorOrg); modified = true; } if (modified) { // TODO : userInfoPanel // if (getApplication().getUser().equals(login)) { // ((AdminApp) getApplication()).getUserInfoPanel().setRole( // userItem.getRoles().toString()); // } AdminServiceProvider.get().setUserItem(login, userItem); final Container container = table.getContainerDataSource(); if (container instanceof LazyLoadingContainer2) { ((LazyLoadingContainer2) container).fireItemSetChange(); } getWindow().showNotification(" " + login + " "); } else { getWindow().showNotification(" "); } removeComponent(layout); addComponent(table); table.setValue(null); if (hr != null) { hr.setVisible(true); } setExpandRatio(table, 1f); refresh(table); } }); cancel.setClickShortcut(KeyCode.ESCAPE, 0); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(apply); buttons.addComponent(cancel); layout.addComponent(buttons); removeComponent(table); addComponent(layout); setExpandRatio(layout, 1f); }
From source file:ru.codeinside.gses.webui.components.ProcessDefinitionShowUi.java
License:Mozilla Public License
private Component buildMainLayout() { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();//from w w w . j a v a 2 s . co m layout.setSpacing(true); layout.setMargin(true); Label label = new Label(); String name = getProcessDefinitionById(processDefinitionId).getName(); label.setCaption(name); label.setStyleName(Reindeer.LABEL_H2); Button showScheme = new Button(""); showScheme.addListener(new Button.ClickListener() { private static final long serialVersionUID = -5911713385519847639L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { VerticalLayout imageLayout = new VerticalLayout(); Button back = new Button("?"); back.addListener(new Button.ClickListener() { private static final long serialVersionUID = 4154712522487297925L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { changer.back(); } }); imageLayout.addComponent(back); imageLayout.setMargin(true); imageLayout.setSpacing(true); imageLayout.setWidth(1100, Sizeable.UNITS_PIXELS); imageLayout.setHeight(600, Sizeable.UNITS_PIXELS); final Panel panel = new Panel(); panel.getContent().setSizeUndefined(); TaskGraph tg = new TaskGraph(processDefinitionId, null); panel.addComponent(tg); panel.setSizeFull(); panel.setScrollable(true); imageLayout.addComponent(panel); imageLayout.setExpandRatio(back, 0.01f); imageLayout.setExpandRatio(panel, 0.99f); changer.change(imageLayout); } }); layout.addComponent(showScheme); Table table = new Table(); table.setSizeFull(); table.setImmediate(true); table.setSelectable(true); table.setSortDisabled(true); table.setPageLength(0); table.setSelectable(false); table.addContainerProperty("id", String.class, null); table.addContainerProperty("name", String.class, null); table.addContainerProperty("accessPermissions", Component.class, null); table.addContainerProperty("formProperties", Component.class, null); table.addContainerProperty("other", String.class, null); table.setColumnHeaders(new String[] { " ?", "?", /*" ?",*/ " ?", "? ", "? " }); table.setColumnExpandRatio("id", 0.1f); table.setColumnExpandRatio("name", 0.1f); table.setColumnExpandRatio("accessPermissions", 0.1f); table.setColumnExpandRatio("formProperties", 0.4f); table.setColumnExpandRatio("other", 0.2f); fillTable(table); layout.addComponent(label); layout.setExpandRatio(label, 1); layout.addComponent(table); layout.setExpandRatio(table, 40); return layout; }
From source file:ru.codeinside.gses.webui.components.ShowDiagramComponent.java
License:Mozilla Public License
private void buildLayout(final ShowDiagramComponentParameterObject param) { setSizeFull();/* w w w. j a va 2 s . co m*/ setSpacing(true); final Panel panel = new Panel(); panel.getContent().setSizeUndefined(); panel.setCaption(param.caption); TaskGraph tg = new TaskGraph(param.processDefinitionId, param.executionId); if (param.height != null) { tg.setHeight(param.height); } if (param.width != null) { tg.setWidth(param.width); } tg.setStyleName("scheme-image"); final TaskGraph bigGraph = new TaskGraph(param.processDefinitionId, param.executionId); tg.addListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 1L; @Override public void click(MouseEvents.ClickEvent event) { final Window schemeWindow = new Window(param.windowHeader); getWindow().addWindow(schemeWindow); schemeWindow.addComponent(bigGraph); schemeWindow.setWidth("90%"); schemeWindow.setHeight("90%"); schemeWindow.center(); schemeWindow.focus(); schemeWindow.setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, 0); bigGraph.addListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { getWindow().removeWindow(schemeWindow); } }); } }); panel.addComponent(tg); addComponent(panel); }