List of usage examples for com.vaadin.ui Panel setSizeFull
@Override public void setSizeFull()
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private RefreshableTab createSettings() { final Form systemForm; {//from w w w.j av a2s .com final ComboBox serviceLocation; { String[][] defs = { { "? ", "http://195.245.214.33:7777/esv" }, { "? ", "http://oraas.rt.ru:7777/gateway/services/SID0003318" } }; serviceLocation = new ComboBox("?? ?? "); serviceLocation.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_EXPLICIT); for (String[] def : defs) { addOption(serviceLocation, def[1], def[0], false); } serviceLocation.setImmediate(true); serviceLocation.setInputPrompt("http://"); serviceLocation.setNewItemsAllowed(true); serviceLocation.setNewItemHandler(new AbstractSelect.NewItemHandler() { @Override public void addNewItem(String newItemCaption) { addOption(serviceLocation, newItemCaption, newItemCaption, true); } }); String href = AdminServiceProvider.get() .getSystemProperty(CertificateVerifier.VERIFY_SERVICE_LOCATION); addOption(serviceLocation, href, href, true); } final CheckBox allowValidate; { allowValidate = new CheckBox(" ? "); allowValidate.setRequired(true); allowValidate.setImmediate(true); allowValidate.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { serviceLocation.setRequired(Boolean.TRUE.equals(event.getProperty().getValue())); } }); allowValidate.setValue(AdminServiceProvider .getBoolProperty(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY)); } systemForm = new Form(); systemForm.addField("location", serviceLocation); systemForm.addField("allowVerify", allowValidate); systemForm.setImmediate(true); systemForm.setWriteThrough(false); systemForm.setInvalidCommitted(false); Button commit = new Button("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { systemForm.commit(); set(CertificateVerifier.VERIFY_SERVICE_LOCATION, serviceLocation.getValue()); set(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY, allowValidate.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } catch (Validator.InvalidValueException ignore) { } } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(commit); systemForm.getFooter().addComponent(buttons); } Panel b1 = new Panel(); b1.setSizeFull(); Label b1label = new Label(" ?"); b1label.addStyleName(Reindeer.LABEL_H2); b1.addComponent(b1label); b1.addComponent(systemForm); VerticalLayout certificates = new VerticalLayout(); certificates.setSizeFull(); certificates.setSpacing(true); HorizontalLayout topHl = new HorizontalLayout(); topHl.setSizeFull(); topHl.setSpacing(true); Panel certificatesPanel = new Panel("", certificates); certificatesPanel.setSizeFull(); certificatesPanel.addStyleName(Reindeer.PANEL_LIGHT); boolean linkCertificate = AdminServiceProvider.getBoolProperty(CertificateVerifier.LINK_CERTIFICATE); final CheckBox switchLink = new CheckBox("? "); switchLink.setValue(linkCertificate); switchLink.setImmediate(true); switchLink.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { set(CertificateVerifier.LINK_CERTIFICATE, switchLink.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); Panel b2 = new Panel(); b2.setSizeFull(); Label b2label = new Label("? ?"); b2label.addStyleName(Reindeer.LABEL_H2); b2.addComponent(b2label); b2.addComponent(switchLink); certificates.addComponent(b1); certificates.addComponent(b2); certificates.setExpandRatio(b1, 0.7f); certificates.setExpandRatio(b2, 0.3f); CheckBox productionMode = new CheckBox("? ", AdminServiceProvider.getBoolProperty(API.PRODUCTION_MODE)); productionMode.setImmediate(true); productionMode.setDescription( " ? ? ?? ?? testMsg"); productionMode.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { boolean value = Boolean.TRUE.equals(event.getProperty().getValue()); set(API.PRODUCTION_MODE, value); } }); Panel smevPanel = new Panel(" "); smevPanel.setSizeFull(); smevPanel.addComponent(productionMode); HorizontalLayout bottomHl = new HorizontalLayout(); bottomHl.setSizeFull(); bottomHl.setSpacing(true); LogSettings logSettings = new LogSettings(); Panel emailDatesPanel = createEmailDatesPanel(); Panel mailTaskConfigPanel = createMilTaskConfigPanel(); topHl.addComponent(certificatesPanel); topHl.addComponent(emailDatesPanel); topHl.addComponent(mailTaskConfigPanel); topHl.setExpandRatio(certificatesPanel, 0.4f); topHl.setExpandRatio(emailDatesPanel, 0.6f); topHl.setExpandRatio(mailTaskConfigPanel, 0.5f); Panel esiaPanel = buildEsiaPanel(); Panel printTemplatesPanel = buildPrintTemplatesPanel(); bottomHl.addComponent(smevPanel); bottomHl.addComponent(esiaPanel); bottomHl.addComponent(printTemplatesPanel); bottomHl.setExpandRatio(smevPanel, 0.2f); bottomHl.setExpandRatio(esiaPanel, 0.4f); bottomHl.setExpandRatio(printTemplatesPanel, 0.4f); final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeFull(); layout.addComponent(topHl); layout.addComponent(logSettings); layout.addComponent(bottomHl); layout.setExpandRatio(topHl, 0.40f); layout.setExpandRatio(logSettings, 0.40f); layout.setExpandRatio(bottomHl, 0.20f); layout.setMargin(true); layout.setSpacing(true); return new RefreshableTab(layout, logSettings); }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel buildEsiaPanel() { boolean isEsiaAuth = "true".equals(get(API.ALLOW_ESIA_LOGIN)); final TextField esiaServiceLocation = new TextField("?? ?? "); esiaServiceLocation.setValue(get(API.ESIA_SERVICE_ADDRESS)); esiaServiceLocation.setEnabled(isEsiaAuth); esiaServiceLocation.setRequired(isEsiaAuth); esiaServiceLocation.setWidth(370, Sizeable.UNITS_PIXELS); final CheckBox allowEsiaLogin = new CheckBox(" ?"); allowEsiaLogin.setValue(isEsiaAuth); allowEsiaLogin.setImmediate(true);/*from w ww .j a v a2 s .co m*/ allowEsiaLogin.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { Boolean newValue = (Boolean) valueChangeEvent.getProperty().getValue(); esiaServiceLocation.setEnabled(newValue); esiaServiceLocation.setRequired(newValue); } }); final Form form = new Form(); form.addField(API.ALLOW_ESIA_LOGIN, allowEsiaLogin); form.addField(API.ESIA_SERVICE_ADDRESS, esiaServiceLocation); form.setImmediate(true); form.setWriteThrough(false); form.setInvalidCommitted(false); Button commit = new Button("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { form.commit(); set(API.ALLOW_ESIA_LOGIN, allowEsiaLogin.getValue()); set(API.ESIA_SERVICE_ADDRESS, esiaServiceLocation.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } catch (Validator.InvalidValueException ignore) { } } }); Panel panel = new Panel("?? ?"); panel.setSizeFull(); panel.addComponent(form); panel.addComponent(commit); return panel; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel buildPrintTemplatesPanel() { boolean isUseService = "true".equals(get(API.PRINT_TEMPLATES_USE_OUTER_SERVICE)); final TextField serviceLocation = new TextField("?? ??"); serviceLocation.setValue(get(API.PRINT_TEMPLATES_SERVICELOCATION)); serviceLocation.setEnabled(isUseService); serviceLocation.setRequired(isUseService); serviceLocation.setWidth(370, Sizeable.UNITS_PIXELS); final CheckBox useOuterService = new CheckBox("? ??"); useOuterService.setValue(isUseService); useOuterService.setImmediate(true);/*from www. ja v a 2 s . c o m*/ useOuterService.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { Boolean newValue = (Boolean) valueChangeEvent.getProperty().getValue(); serviceLocation.setEnabled(newValue); serviceLocation.setRequired(newValue); } }); final Form form = new Form(); form.addField(API.PRINT_TEMPLATES_USE_OUTER_SERVICE, useOuterService); form.addField(API.PRINT_TEMPLATES_SERVICELOCATION, serviceLocation); form.setImmediate(true); form.setWriteThrough(false); form.setInvalidCommitted(false); Button commit = new Button("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { form.commit(); set(API.PRINT_TEMPLATES_USE_OUTER_SERVICE, useOuterService.getValue()); set(API.PRINT_TEMPLATES_SERVICELOCATION, serviceLocation.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } catch (Validator.InvalidValueException ignore) { } } }); Panel panel = new Panel(" "); panel.setSizeFull(); panel.addComponent(form); panel.addComponent(commit); return panel; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createEmailDatesPanel() { VerticalLayout emailDates = new VerticalLayout(); emailDates.setSpacing(true);// w ww . j av a 2s . c om emailDates.setMargin(true); emailDates.setSizeFull(); Panel panel2 = new Panel(" ? ??", emailDates); panel2.setSizeFull(); final TextField emailToField = new TextField("e-mail ?:"); emailToField.setValue(get(API.EMAIL_TO)); emailToField.setRequired(true); emailToField.setReadOnly(true); emailToField.addValidator(new EmailValidator(" e-mail ?")); final TextField receiverNameField = new TextField("? ?:"); receiverNameField.setValue(get(API.RECEIVER_NAME)); receiverNameField.setRequired(true); receiverNameField.setReadOnly(true); final TextField emailFromField = new TextField("e-mail ?:"); emailFromField.setValue(get(API.EMAIL_FROM)); emailFromField.setRequired(true); emailFromField.setReadOnly(true); emailFromField.addValidator(new EmailValidator(" e-mail ?")); final TextField senderLoginField = new TextField(" ?:"); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderLoginField.setRequired(true); senderLoginField.setReadOnly(true); final TextField senderNameField = new TextField("? ?:"); senderNameField.setValue(get(API.SENDER_NAME)); senderNameField.setRequired(true); senderNameField.setReadOnly(true); final PasswordField passwordField = new PasswordField(":"); passwordField.setValue(API.PASSWORD); passwordField.setRequired(true); passwordField.setReadOnly(true); final TextField hostField = new TextField("SMTP ?:"); String host = get(API.HOST); hostField.setValue(host == null ? "" : host); hostField.setRequired(true); hostField.setReadOnly(true); final TextField portField = new TextField(":"); String port = get(API.PORT); portField.setValue(port == null ? "" : port); portField.setRequired(true); portField.setReadOnly(true); portField.addValidator(new IntegerValidator(" ")); final CheckBox tls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.TLS)); tls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); final Button check = new Button(""); check.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String emailTo = get(API.EMAIL_TO); String receiverName = get(API.RECEIVER_NAME); String hostName = get(API.HOST); String port = get(API.PORT); String senderLogin = get(API.SENDER_LOGIN); String password = get(API.PASSWORD); String emailFrom = get(API.EMAIL_FROM); String senderName = get(API.SENDER_NAME); if (emailTo.isEmpty() || receiverName.isEmpty() || hostName.isEmpty() || port.isEmpty() || senderLogin.isEmpty() || password.isEmpty() || emailFrom.isEmpty() || senderName.isEmpty()) { check.getWindow().showNotification("? ? "); return; } Email email = new SimpleEmail(); try { email.setSubject("? ?"); email.setMsg("? ?"); email.addTo(emailTo, receiverName); email.setHostName(hostName); email.setSmtpPort(Integer.parseInt(port)); email.setTLS(AdminServiceProvider.getBoolProperty(API.TLS)); email.setAuthentication(senderLogin, password); email.setFrom(emailFrom, senderName); email.setCharset("utf-8"); email.send(); } catch (EmailException e) { check.getWindow().showNotification(e.getMessage()); e.printStackTrace(); return; } check.getWindow().showNotification("? ? "); } }); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setReadOnly(false); receiverNameField.setReadOnly(false); emailFromField.setReadOnly(false); senderLoginField.setReadOnly(false); senderNameField.setReadOnly(false); passwordField.setReadOnly(false); hostField.setReadOnly(false); portField.setReadOnly(false); tls.setReadOnly(false); change.setVisible(false); check.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) emailToField.getValue()) || StringUtils.isEmpty((String) receiverNameField.getValue()) || StringUtils.isEmpty((String) emailFromField.getValue()) || StringUtils.isEmpty((String) senderNameField.getValue()) || StringUtils.isEmpty((String) senderLoginField.getValue()) || StringUtils.isEmpty((String) passwordField.getValue()) || StringUtils.isEmpty((String) hostField.getValue()) || portField.getValue() == null) { emailToField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { emailToField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { emailFromField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { portField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.EMAIL_TO, emailToField.getValue()); set(API.RECEIVER_NAME, receiverNameField.getValue()); set(API.EMAIL_FROM, emailFromField.getValue()); set(API.SENDER_LOGIN, senderLoginField.getValue()); set(API.SENDER_NAME, senderNameField.getValue()); set(API.PASSWORD, passwordField.getValue()); set(API.HOST, hostField.getValue()); set(API.PORT, portField.getValue()); set(API.TLS, tls.getValue()); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); emailToField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setValue(get(API.EMAIL_TO)); receiverNameField.setValue(get(API.RECEIVER_NAME)); emailFromField.setValue(get(API.EMAIL_FROM)); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderNameField.setValue(get(API.SENDER_NAME)); passwordField.setValue(get(API.PASSWORD)); hostField.setValue(get(API.HOST)); portField.setValue(get(API.PORT)); tls.setValue(AdminServiceProvider.getBoolProperty(API.TLS)); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); } }); FormLayout fields1 = new FormLayout(); fields1.setSizeFull(); fields1.addComponent(senderLoginField); fields1.addComponent(passwordField); fields1.addComponent(hostField); fields1.addComponent(portField); fields1.addComponent(tls); FormLayout fields2 = new FormLayout(); fields2.setSizeFull(); fields2.addComponent(emailToField); fields2.addComponent(receiverNameField); fields2.addComponent(emailFromField); fields2.addComponent(senderNameField); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setSizeFull(); fields.addComponent(fields1); fields.addComponent(fields2); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); buttons.addComponent(check); Label label = new Label("?? "); label.addStyleName(Reindeer.LABEL_H2); emailDates.addComponent(label); emailDates.addComponent(fields); emailDates.addComponent(buttons); emailDates.setExpandRatio(fields, 1f); return panel2; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createMilTaskConfigPanel() { VerticalLayout mailConfig = new VerticalLayout(); mailConfig.setSpacing(true);//from w ww. jav a 2s. c o m mailConfig.setMargin(true); mailConfig.setSizeFull(); Panel emailTaskPanel = new Panel("?? SMTP ? Email Task", mailConfig); emailTaskPanel.setSizeFull(); final TextField mtDefaultFrom = new TextField("email :"); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtDefaultFrom.setRequired(true); mtDefaultFrom.setReadOnly(true); mtDefaultFrom.addValidator(new EmailValidator(" e-mail ?")); final TextField mtSenderLoginField = new TextField(" ?:"); mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtSenderLoginField.setRequired(true); mtSenderLoginField.setReadOnly(true); final PasswordField mtPasswordField = new PasswordField(":"); mtPasswordField.setValue(API.MT_PASSWORD); mtPasswordField.setRequired(true); mtPasswordField.setReadOnly(true); final TextField mtHostField = new TextField("SMTP ?:"); String host = get(API.MT_HOST); mtHostField.setValue(host == null ? "" : host); mtHostField.setRequired(true); mtHostField.setReadOnly(true); final TextField mtPortField = new TextField(":"); String port = get(API.MT_PORT); mtPortField.setValue(port == null ? "" : port); mtPortField.setRequired(true); mtPortField.setReadOnly(true); mtPortField.addValidator(new IntegerValidator(" ")); final CheckBox mtTls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtTls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setReadOnly(false); mtDefaultFrom.setReadOnly(false); mtPasswordField.setReadOnly(false); mtHostField.setReadOnly(false); mtPortField.setReadOnly(false); mtTls.setReadOnly(false); change.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) mtSenderLoginField.getValue()) || StringUtils.isEmpty((String) mtDefaultFrom.getValue()) || StringUtils.isEmpty((String) mtPasswordField.getValue()) || StringUtils.isEmpty((String) mtHostField.getValue()) || mtPortField.getValue() == null) { mtSenderLoginField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { mtDefaultFrom.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { mtPortField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.MT_SENDER_LOGIN, mtSenderLoginField.getValue()); set(API.MT_DEFAULT_FROM, mtDefaultFrom.getValue()); set(API.MT_PASSWORD, mtPasswordField.getValue()); set(API.MT_HOST, mtHostField.getValue()); set(API.MT_PORT, mtPortField.getValue()); set(API.MT_TLS, mtTls.getValue()); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); mtSenderLoginField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtPasswordField.setValue(get(API.MT_PASSWORD)); mtHostField.setValue(get(API.MT_HOST)); mtPortField.setValue(get(API.MT_PORT)); mtTls.setValue(AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); } }); FormLayout leftFields = new FormLayout(); leftFields.setSizeFull(); leftFields.addComponent(mtSenderLoginField); leftFields.addComponent(mtDefaultFrom); leftFields.addComponent(mtPasswordField); leftFields.addComponent(mtHostField); leftFields.addComponent(mtPortField); FormLayout rightFields = new FormLayout(); rightFields.setSizeFull(); rightFields.addComponent(mtTls); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSpacing(true); fieldsLayout.setSizeFull(); fieldsLayout.addComponent(leftFields); fieldsLayout.addComponent(rightFields); fieldsLayout.setExpandRatio(leftFields, 0.6f); fieldsLayout.setExpandRatio(rightFields, 0.4f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); Label label = new Label("?? Email Task"); label.addStyleName(Reindeer.LABEL_H2); mailConfig.addComponent(label); mailConfig.addComponent(fieldsLayout); mailConfig.addComponent(buttons); mailConfig.setExpandRatio(fieldsLayout, 1f); return emailTaskPanel; }
From source file:ru.codeinside.adm.ui.CrudNews.java
License:Mozilla Public License
private Panel createForm() { systemForm = new Form(); title.setRequired(true);//ww w . j av a 2 s . co m text.setRequired(true); systemForm.setValidationVisibleOnCommit(false); systemForm.addField("id", id); systemForm.addField("title", title); systemForm.addField("text", text); systemForm.addField("dateCreated", dateCreated); systemForm.setWriteThrough(false); systemForm.setInvalidCommitted(false); Panel upperPanel = new Panel(); upperPanel.setSizeFull(); upperPanel.addComponent(systemForm); return upperPanel; }
From source file:ru.codeinside.adm.ui.CrudNews.java
License:Mozilla Public License
private Panel createTable() { tableNews = new FilterTable("? ?"); tableNews.setFilterBarVisible(true); tableNews.setSizeFull();//from ww w.jav a 2s . c o m tableNews.setImmediate(true); tableNews.setSelectable(true); tableNews.setPageLength(5); tableNews.setFilterDecorator(new FilterDecorator_()); final JPAContainer<News> container = new JPAContainer<News>(News.class); container.setEntityProvider( new CachingLocalEntityProvider<News>(News.class, ActivitiEntityManager.INSTANCE)); tableNews.setContainerDataSource(container); tableNews.setVisibleColumns(new Object[] { "id", "title", "text", "dateCreated" }); tableNews.setColumnHeaders( new String[] { "id", "", "", " ??" }); tableNews.setColumnExpandRatio("id", 4); tableNews.setColumnExpandRatio("title", 20); tableNews.setColumnExpandRatio("text", 60); tableNews.setColumnExpandRatio("dateCreated", 14); tableNews.setFilterGenerator(new FilterGenerator_()); tableNews.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { systemForm.setValidationVisible(false); ((JPAContainer) tableNews.getContainerDataSource()).refresh(); if (event.getProperty().getValue() != null) { create.setVisible(false); update.setVisible(true); remove.setVisible(true); reset.setVisible(true); } else { systemForm.getField("id").setReadOnly(false); systemForm.getField("id").setValue(""); systemForm.getField("id").setReadOnly(true); systemForm.getField("title").setValue(""); systemForm.getField("text").setValue(""); systemForm.getField("dateCreated").setReadOnly(false); systemForm.getField("dateCreated").setValue(""); systemForm.getField("dateCreated").setReadOnly(true); create.setVisible(true); update.setVisible(false); remove.setVisible(false); reset.setVisible(false); } } }); tableNews.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Item item = event.getItem(); id.setReadOnly(false); id.setValue(item.getItemProperty("id").getValue()); id.setReadOnly(true); title.setValue(item.getItemProperty("title").getValue()); text.setValue(item.getItemProperty("text").getValue()); dateCreated.setReadOnly(false); dateCreated.setValue(item.getItemProperty("dateCreated").getValue()); dateCreated.setReadOnly(true); } }); Panel lowerPanel = new Panel(); lowerPanel.setSizeFull(); lowerPanel.addComponent(tableNews); return lowerPanel; }
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(); 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); }//from w w w.java 2 s . c o m 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.adm.ui.LogSettings.java
License:Mozilla Public License
LogSettings() { logErrors = new OptionGroup("? ? :", Arrays.asList(Status.FAILURE.name())); logErrors.setItemCaption(Status.FAILURE.name(), ""); logErrors.setImmediate(true);//w ww . ja v a2 s .co m logErrors.setMultiSelect(true); logStatus = new OptionGroup("? ? '':", statusKeys()); logStatus.setItemCaption(Status.REQUEST.name(), "?"); logStatus.setItemCaption(Status.RESULT.name(), ""); logStatus.setItemCaption(Status.PING.name(), "?"); logStatus.setMultiSelect(true); logStatus.setImmediate(true); ipSet = new TextArea("? IP ?:"); ipSet.setWordwrap(true); ipSet.setNullRepresentation(""); ipSet.setWidth(100f, UNITS_PERCENTAGE); ipSet.setRows(10); tf = new TextField(" , :"); tf.setRequired(true); tf.addValidator(new Validator() { public void validate(Object value) throws InvalidValueException { if (!isValid(value)) { throw new InvalidValueException( " ? "); } } public boolean isValid(Object value) { return value instanceof String && ((String) value).matches("[1-9][0-9]*"); } }); b1 = new Block("") { @Override void onLayout(Layout layout) { layout.addComponent(logErrors); layout.addComponent(logStatus); } @Override void onChange() { logErrors.setReadOnly(false); logStatus.setReadOnly(false); } @Override void onRefresh() { boolean _logErrors = AdminServiceProvider.getBoolProperty(API.LOG_ERRORS); if (_logErrors) { logErrors.setReadOnly(false); logErrors.setValue(Arrays.asList(Status.FAILURE.name())); } else { logErrors.setValue(Collections.emptySet()); } logErrors.setReadOnly(true); String _logStatus = AdminServiceProvider.get().getSystemProperty(API.LOG_STATUS); if (_logStatus != null) { Set<String> set = new HashSet<String>(); for (String key : statusKeys()) { if (_logStatus.contains(key)) { set.add(key); } } logStatus.setReadOnly(false); logStatus.setValue(set); } else { logStatus.setValue(Collections.emptySet()); } logStatus.setReadOnly(true); } @Override void onApply() { Collection logErrorsValue = (Collection) logErrors.getValue(); boolean errorsEnabled = logErrorsValue.contains(Status.FAILURE.name()); AdminServiceProvider.get().saveSystemProperty(API.LOG_ERRORS, Boolean.toString(errorsEnabled)); LogCustomizer.setShouldWriteServerLogErrors(errorsEnabled); Collection logStatusValue = (Collection) logStatus.getValue(); Set<Status> statuses = new TreeSet<Status>(); if (logStatusValue.contains(Status.REQUEST.name())) { statuses.add(Status.REQUEST); statuses.add(Status.ACCEPT); statuses.add(Status.CANCEL); } if (logStatusValue.contains(Status.RESULT.name())) { statuses.add(Status.RESULT); statuses.add(Status.REJECT); statuses.add(Status.STATE); statuses.add(Status.NOTIFY); } if (logStatusValue.contains(Status.PING.name())) { statuses.add(Status.PING); statuses.add(Status.PROCESS); statuses.add(Status.PACKET); } StringBuilder statusBuilder = new StringBuilder(); for (Status status : statuses) { if (statusBuilder.length() > 0) { statusBuilder.append(", "); } statusBuilder.append(status); } String status = statusBuilder.toString(); AdminServiceProvider.get().saveSystemProperty(API.LOG_STATUS, status); LogCustomizer.setServerLogStatus(status); boolean enabled = !status.isEmpty(); LogCustomizer.setShouldWriteServerLog(enabled); AdminServiceProvider.get().saveSystemProperty(API.ENABLE_CLIENT_LOG, Boolean.toString(enabled)); } }; b2 = new Block("? ") { @Override void onLayout(Layout layout) { layout.addComponent(ipSet); } @Override void onRefresh() { String ips = AdminServiceProvider.get().getSystemProperty(API.SKIP_LOG_IPS); ipSet.setReadOnly(false); ipSet.setValue(ips); ipSet.setReadOnly(true); } @Override void onChange() { ipSet.setReadOnly(false); } @Override void onApply() { String value = (String) ipSet.getValue(); TreeSet<String> items = new TreeSet<String>(); if (value != null) { for (String item : value.split("[,;\\s]+")) { items.add(item); } StringBuilder sb = new StringBuilder(); for (String item : items) { if (sb.length() > 0) { sb.append(", "); } sb.append(item); } value = sb.toString(); } AdminServiceProvider.get().saveSystemProperty(API.SKIP_LOG_IPS, value); LogCustomizer.setIgnoreSet(items); } }; b3 = new Block("? ") { @Override void onButtons(Layout layout) { layout.addComponent(new Button("? ", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LogScheduler.cleanLog(); getWindow().showNotification("?? ", Window.Notification.TYPE_HUMANIZED_MESSAGE); } })); } @Override void onLayout(Layout layout) { layout.addComponent(tf); } @Override void onRefresh() { String logDepth = AdminServiceProvider.get().getSystemProperty(API.LOG_DEPTH); tf.setReadOnly(false); if (logDepth != null && logDepth.matches("[1-9][0-9]*")) { tf.setValue(logDepth); } else { tf.setValue(String.valueOf(API.DEFAULT_LOG_DEPTH)); } tf.setReadOnly(true); } @Override void onChange() { tf.setReadOnly(false); } @Override void onApply() { tf.validate(); AdminServiceProvider.get().saveSystemProperty(API.LOG_DEPTH, tf.getValue().toString()); } }; final CheckBox logSpSign = new CheckBox(" ? "); logSpSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_SP_SIGN))); logSpSign.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { AdminServiceProvider.get().saveSystemProperty(API.LOG_SP_SIGN, String.valueOf(valueChangeEvent.getProperty().getValue())); notifySuccess(); } }); logSpSign.setImmediate(true); final CheckBox logOvSign = new CheckBox(" ? "); logOvSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_OV_SIGN))); logOvSign.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { AdminServiceProvider.get().saveSystemProperty(API.LOG_OV_SIGN, String.valueOf(valueChangeEvent.getProperty().getValue())); notifySuccess(); } }); logOvSign.setImmediate(true); Label userSignsLabel = new Label("? ?"); userSignsLabel.addStyleName(Reindeer.LABEL_H2); VerticalLayout userSignsVl = new VerticalLayout(); userSignsVl.setMargin(true); userSignsVl.setSpacing(true); userSignsVl.addComponent(userSignsLabel); userSignsVl.addComponent(logSpSign); userSignsVl.addComponent(logOvSign); Panel userSingsWrapper = new Panel(); userSingsWrapper.setScrollable(true); userSingsWrapper.setContent(userSignsVl); userSingsWrapper.setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.addComponent(b1); vl.addComponent(userSingsWrapper); vl.setExpandRatio(b1, 0.7f); vl.setExpandRatio(userSingsWrapper, 0.3f); vl.setSizeFull(); HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.addComponent(vl); layout.addComponent(b2); layout.addComponent(b3); layout.setSizeFull(); layout.setExpandRatio(vl, 0.333f); layout.setExpandRatio(b2, 0.333f); layout.setExpandRatio(b3, 0.333f); Panel wrapper = new Panel(" ", layout); wrapper.addStyleName(Reindeer.PANEL_LIGHT); wrapper.setSizeFull(); setCompositionRoot(wrapper); setSizeFull(); }
From source file:ru.codeinside.gses.webui.components.ProcessDefinitionShowUi.java
License:Mozilla Public License
private Component buildMainLayout() { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();/* w ww . j a va 2 s . com*/ 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; }