List of usage examples for com.vaadin.ui Layout addComponent
public void addComponent(Component c);
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);//from w ww .ja v a2s . c o 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.apservice.ApServiceForm.java
License:Mozilla Public License
private Form createForm() { final Form form = new Form(); form.setCaption(" ?"); form.setWidth("100%"); TextArea field = new TextArea("?"); field.setRequired(true);/*from w ww. j a v a 2 s .c o m*/ field.setWidth("100%"); field.setMaxLength(1500); form.addField(NAME, field); MaskedTextField code = new MaskedTextField(" ?", "# ### ### ### ### ### ###"); code.setColumns(19); code.addValidator(new FilteredLongValidator("[_ ]", " " + ApInfo.formatCode(Long.MAX_VALUE))); form.addField(CODE, code); ListSelect declarantTypes = new ListSelect(" ?"); declarantTypes.setWidth("100%"); declarantTypes.setHeight("50px"); declarantTypes.setMultiSelect(true); LazyQueryContainer container = new LazyQueryContainer(new DeclarantTypeQueryDefinition(), new DeclarantTypeQueryFactory()); declarantTypes.setContainerDataSource(container); declarantTypes.setItemCaptionPropertyId("value"); declarantTypes.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); Flash.bind(DeclarantTypeChanged.class, container, "refresh"); field.setRequired(true); field.setWidth("100%"); field.setMaxLength(1500); form.addField(DeclarantServiceImpl.DECLARANT_TYPES, declarantTypes); Layout footer = form.getFooter(); Button updateButton = createCreateButton(); footer.addComponent(updateButton); ((HorizontalLayout) footer).setSpacing(true); return form; }
From source file:ru.codeinside.gses.apservice.ApServiceForm.java
License:Mozilla Public License
private Form editForm() { final Form form = new Form(); form.setCaption(" ?"); form.setWidth("100%"); TextField idField = new TextField(" ?"); idField.setRequired(false);//from w w w. j a v a2s . c om idField.setEnabled(true); idField.setVisible(true); idField.setReadOnly(true); form.addField(ID, idField); TextArea field = new TextArea("?"); field.setRequired(true); field.setWidth("100%"); field.setMaxLength(1500); form.addField(NAME, field); MaskedTextField code = new MaskedTextField(" ?", "# ### ### ### ### ### ###"); code.setColumns(19); code.addValidator(new FilteredLongValidator("[_ ]", " " + ApInfo.formatCode(Long.MAX_VALUE))); form.addField(CODE, code); ListSelect declarantTypes = new ListSelect(" ?"); declarantTypes.setWidth("100%"); declarantTypes.setHeight("50px"); declarantTypes.setMultiSelect(true); LazyQueryContainer container = new LazyQueryContainer(new DeclarantTypeQueryDefinition(), new DeclarantTypeQueryFactory()); declarantTypes.setContainerDataSource(container); declarantTypes.setItemCaptionPropertyId("value"); declarantTypes.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); Flash.bind(DeclarantTypeChanged.class, container, "refresh"); field.setRequired(true); field.setWidth("100%"); field.setMaxLength(1500); form.addField(DeclarantService.DECLARANT_TYPES, declarantTypes); Layout footer = form.getFooter(); Button updateButton = createUpdateButton(); Button cancelButton = createCancelButton(form); footer.addComponent(updateButton); footer.addComponent(cancelButton); ((HorizontalLayout) footer).setSpacing(true); return form; }
From source file:ru.codeinside.gses.manager.ProcedureForm.java
License:Mozilla Public License
private Form buildCreateUpdateForm() { final Form form = new Form(); TextField createTextField = createTextField("?", false, true); createTextField.setEnabled(false);//from www. j a va 2 s . c om createTextField.setWidth("100%"); form.addField(ID, createTextField); TextArea areaName = new TextArea("?"); areaName.setRequired(true); areaName.setWidth("100%"); areaName.setMaxLength(1500); form.addField(NAME, areaName); TextArea descriptionArea = new TextArea("?"); descriptionArea.setWidth("100%"); descriptionArea.setMaxLength(1500); form.addField(DESCRIPTION, descriptionArea); servicesComboBox = createServicesComboBox("?"); servicesComboBox.setNullSelectionAllowed(false); form.addField(SERVICE_ID, servicesComboBox); MaskedTextField code = new MaskedTextField(" ?", "# ### ### ### ### ### ###"); code.setColumns(19); code.addValidator(new FilteredLongValidator("[_ ]", " " + ApInfo.formatCode(Long.MAX_VALUE))); form.addField(CODE, code); Layout footer = form.getFooter(); ((HorizontalLayout) footer).setSpacing(true); footer.addComponent(createUpdateButton()); footer.addComponent(createCancelButton()); return form; }
From source file:ui.helper.ImageDropBox.java
License:Apache License
public ImageDropBox(Integer userId, final Layout root) { super(root);/*from w w w .j ava2 s . co m*/ setDropHandler(this); this.userId = userId; rootLayout = root; progress = new ProgressBar(); progress.setIndeterminate(true); progress.setVisible(false); root.addComponent(progress); }