List of usage examples for com.vaadin.ui CheckBox setValue
@Override public void setValue(Boolean value)
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 a v a 2 s .com*/ 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 w w .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.LogSettings.java
License:Mozilla Public License
LogSettings() { logErrors = new OptionGroup("? ? :", Arrays.asList(Status.FAILURE.name())); logErrors.setItemCaption(Status.FAILURE.name(), ""); logErrors.setImmediate(true);/* ww w . ja v a 2 s . com*/ 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.vist.stat.forms.register.SubSciption.java
public SubSciption(final Window window) { this.window = window; VerticalLayout layout = new VerticalLayout(); setCaption("? ?"); layout.setMargin(true);/*from w ww .j a v a2s . com*/ List<CView> list = SetSubsDb.getUserViews(Common.getUser()); //VistUI.getSubs().getList(); for (CView cv : list) { CheckBox box = new CheckBox(cv.getName()); box.setValue(Boolean.TRUE); layout.addComponent(box); boxes.add(box); } HorizontalLayout hl = new BasicHorizontalLayout(); BasicButton btnSave = new BasicButton("", "? ? "); btnSave.addClickListener(new SaveClickListener()); hl.addComponent(btnSave); BasicButton btnCancel = new BasicButton("", " "); hl.addComponent(btnCancel); btnCancel.addClickListener(new CancelClickListener()); layout.addComponent(hl); setContent(layout); }