List of usage examples for com.vaadin.ui HorizontalLayout setCaption
@Override public void setCaption(String caption)
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private Component getHorizontalLayout() { HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true);/*from www . ja v a 2s .com*/ controls.setStyleName("inline"); final VerticalLayout main = new VerticalLayout(); final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(true); hl.setCaption("Layout Caption"); hl.setIcon(new ThemeResource("../runo/icons/16/document.png")); hl.addComponent(createImageFixedHeight()); hl.addComponent(createImageFixedHeight()); hl.addComponent(createImageFixedHeight()); controls.addComponent( new StyleController(hl, BennuTheme.LAYOUT_BIG, BennuTheme.LAYOUT_INSET, BennuTheme.LAYOUT_SECTION)); controls.addComponent(new SpacingController(hl)); controls.addComponent(new MarginController(hl)); main.addComponent(controls); main.addComponent(hl); return main; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.execution.ExecutionWizardStep.java
License:Apache License
@Override public Component getContent() { Panel form = new Panel(TRANSLATOR.translate("step.detail")); if (getExecutionStep().getExecutionStart() == null) { //Set the start date. getExecutionStep().setExecutionStart(new Date()); }//from w w w . j a v a 2 s . co m FormLayout layout = new FormLayout(); form.setContent(layout); form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); BeanFieldGroup binder = new BeanFieldGroup(getExecutionStep().getStep().getClass()); binder.setItemDataSource(getExecutionStep().getStep()); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setConverter(new ByteToStringConverter()); binder.bind(text, "text"); text.setSizeFull(); layout.addComponent(text); Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class); notes.setSizeFull(); layout.addComponent(notes); if (getExecutionStep().getExecutionStart() != null) { start = new DateField(TRANSLATOR.translate("start.date")); start.setResolution(Resolution.SECOND); start.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); start.setValue(getExecutionStep().getExecutionStart()); start.setReadOnly(true); layout.addComponent(start); } if (getExecutionStep().getExecutionEnd() != null) { end = new DateField(TRANSLATOR.translate("end.date")); end.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); end.setResolution(Resolution.SECOND); end.setValue(getExecutionStep().getExecutionEnd()); end.setReadOnly(true); layout.addComponent(end); } binder.setReadOnly(true); //Space to record result if (getExecutionStep().getResultId() != null) { result.setValue(getExecutionStep().getResultId().getResultName()); } layout.addComponent(result); if (reviewer) {//Space to record review if (getExecutionStep().getReviewResultId() != null) { review.setValue(getExecutionStep().getReviewResultId().getReviewName()); } layout.addComponent(review); } //Add Reviewer name if (getExecutionStep().getReviewer() != null) { TextField reviewerField = new TextField(TRANSLATOR.translate("general.reviewer")); reviewerField.setValue(getExecutionStep().getReviewer().getFirstName() + " " + getExecutionStep().getReviewer().getLastName()); reviewerField.setReadOnly(true); layout.addComponent(reviewerField); } if (getExecutionStep().getReviewDate() != null) { reviewDate = new DateField(TRANSLATOR.translate("review.date")); reviewDate.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); reviewDate.setResolution(Resolution.SECOND); reviewDate.setValue(getExecutionStep().getReviewDate()); reviewDate.setReadOnly(true); layout.addComponent(reviewDate); } if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { TextArea expectedResult = new TextArea(TRANSLATOR.translate("expected.result")); expectedResult.setConverter(new ByteToStringConverter()); binder.bind(expectedResult, "expectedResult"); expectedResult.setSizeFull(); layout.addComponent(expectedResult); } //Add the fields fields.clear(); getExecutionStep().getStep().getDataEntryList().forEach(de -> { switch (de.getDataEntryType().getId()) { case 1://String TextField tf = new TextField(TRANSLATOR.translate(de.getEntryName())); tf.setRequired(true); tf.setData(de.getEntryName()); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { //Add expected result DataEntryProperty stringCase = DataEntryServer.getProperty(de, "property.match.case"); DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null && !r.getPropertyValue().equals("null")) { String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); tf.setRequiredError(error); tf.setRequired(DataEntryServer.getProperty(de, "property.required").getPropertyValue() .equals("true")); tf.addValidator((Object val) -> { //We have an expected result and a match case requirement if (stringCase != null && stringCase.getPropertyValue().equals("true") ? !((String) val).equals(r.getPropertyValue()) : !((String) val).equalsIgnoreCase(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(tf); //Set value if already recorded updateValue(tf); layout.addComponent(tf); break; case 2://Numeric NumberField field = new NumberField(TRANSLATOR.translate(de.getEntryName())); field.setSigned(true); field.setUseGrouping(true); field.setGroupingSeparator(','); field.setDecimalSeparator('.'); field.setConverter(new StringToDoubleConverter()); field.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); field.setData(de.getEntryName()); Double min = null, max = null; for (DataEntryProperty prop : de.getDataEntryPropertyList()) { String value = prop.getPropertyValue(); if (prop.getPropertyName().equals("property.max")) { try { max = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } else if (prop.getPropertyName().equals("property.min")) { try { min = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } } //Add expected result if (VMSettingServer.getSetting("show.expected.result").getBoolVal() && (min != null || max != null)) { String error = TRANSLATOR.translate("error.out.of.range") + " " + (min == null ? " " : (TRANSLATOR.translate("property.min") + ": " + min)) + " " + (max == null ? "" : (TRANSLATOR.translate("property.max") + ": " + max)); field.setRequiredError(error); field.addValidator(new DoubleRangeValidator(error, min, max)); } fields.add(field); //Set value if already recorded updateValue(field); layout.addComponent(field); break; case 3://Boolean CheckBox cb = new CheckBox(TRANSLATOR.translate(de.getEntryName())); cb.setData(de.getEntryName()); cb.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null) { //Add expected result String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); cb.addValidator((Object val) -> { if (!val.toString().equals(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(cb); //Set value if already recorded updateValue(cb); layout.addComponent(cb); break; case 4://Attachment Label l = new Label(TRANSLATOR.translate(de.getEntryName())); layout.addComponent(l); break; default: LOG.log(Level.SEVERE, "Unexpected field type: {0}", de.getDataEntryType().getId()); } }); //Add the Attachments HorizontalLayout attachments = new HorizontalLayout(); attachments.setCaption(TRANSLATOR.translate("general.attachment")); HorizontalLayout comments = new HorizontalLayout(); comments.setCaption(TRANSLATOR.translate("general.comments")); HorizontalLayout issues = new HorizontalLayout(); issues.setCaption(TRANSLATOR.translate("general.issue")); int commentCounter = 0; int issueCounter = 0; for (ExecutionStepHasIssue ei : getExecutionStep().getExecutionStepHasIssueList()) { issueCounter++; Button a = new Button("Issue #" + issueCounter); a.setIcon(VaadinIcons.BUG); a.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer(ei.getIssue())); }); a.setEnabled(!step.getLocked()); issues.addComponent(a); } for (ExecutionStepHasAttachment attachment : getExecutionStep().getExecutionStepHasAttachmentList()) { switch (attachment.getAttachment().getAttachmentType().getType()) { case "comment": { //Comments go in a different section commentCounter++; Button a = new Button("Comment #" + commentCounter); a.setIcon(VaadinIcons.CLIPBOARD_TEXT); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayComment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); a.setEnabled(!step.getLocked()); comments.addComponent(a); break; } default: { Button a = new Button(attachment.getAttachment().getFileName()); a.setEnabled(!step.getLocked()); a.setIcon(VaadinIcons.PAPERCLIP); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayAttachment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); attachments.addComponent(a); break; } } } if (attachments.getComponentCount() > 0) { layout.addComponent(attachments); } if (comments.getComponentCount() > 0) { layout.addComponent(comments); } if (issues.getComponentCount() > 0) { layout.addComponent(issues); } //Add the menu HorizontalLayout hl = new HorizontalLayout(); attach = new Button(TRANSLATOR.translate("add.attachment")); attach.setIcon(VaadinIcons.PAPERCLIP); attach.addClickListener((Button.ClickEvent event) -> { //Show dialog to upload file. Window dialog = new VMWindow(TRANSLATOR.translate("attach.file")); VerticalLayout vl = new VerticalLayout(); MultiFileUpload multiFileUpload = new MultiFileUpload() { @Override protected void handleFile(File file, String fileName, String mimeType, long length) { try { LOG.log(Level.FINE, "Received file {1} at: {0}", new Object[] { file.getAbsolutePath(), fileName }); //Process the file //Create the attachment AttachmentServer a = new AttachmentServer(); a.addFile(file, fileName); //Overwrite the default file name set in addFile. It'll be a temporary file name a.setFileName(fileName); a.write2DB(); //Now add it to this Execution Step if (getExecutionStep().getExecutionStepHasAttachmentList() == null) { getExecutionStep().setExecutionStepHasAttachmentList(new ArrayList<>()); } getExecutionStep().addAttachment(a); getExecutionStep().write2DB(); w.updateCurrentStep(); } catch (Exception ex) { LOG.log(Level.SEVERE, "Error creating attachment!", ex); } } }; multiFileUpload.setCaption(TRANSLATOR.translate("select.files.attach")); vl.addComponent(multiFileUpload); dialog.setContent(vl); dialog.setHeight(25, Sizeable.Unit.PERCENTAGE); dialog.setWidth(25, Sizeable.Unit.PERCENTAGE); ValidationManagerUI.getInstance().addWindow(dialog); }); hl.addComponent(attach); bug = new Button(TRANSLATOR.translate("create.issue")); bug.setIcon(VaadinIcons.BUG); bug.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer()); }); hl.addComponent(bug); comment = new Button(TRANSLATOR.translate("add.comment")); comment.setIcon(VaadinIcons.CLIPBOARD_TEXT); comment.addClickListener((Button.ClickEvent event) -> { AttachmentServer as = new AttachmentServer(); //Get comment type AttachmentType type = AttachmentTypeServer.getTypeForExtension("comment"); as.setAttachmentType(type); displayComment(as); }); hl.addComponent(comment); step.update(); attach.setEnabled(!step.getLocked()); bug.setEnabled(!step.getLocked()); comment.setEnabled(!step.getLocked()); result.setEnabled(!step.getLocked()); layout.addComponent(hl); return layout; }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java
License:Open Source License
public void setupPanel() { //clear everything // content.removeAllComponents(); //add components only if components have not already been added if (content.getComponentCount() == 0) { //Main chart HorizontalLayout chartContainer = new HorizontalLayout(); chartContainer.setWidth(95, Unit.PERCENTAGE); chartContainer.setMargin(true);/*from ww w . j a v a2s. c om*/ // chartContainer.setHeight(30,Unit.PERCENTAGE); mainChart = buildMainChart(); chartContainer.addComponent(mainChart); chartContainer.setComponentAlignment(mainChart, Alignment.MIDDLE_CENTER); chartContainer.setCaption(mainChart.getCaption()); // chartContainer.setCaption("Price"); // chartContainer.addStyleName("center-caption"); content.addComponent(chartContainer); content.setExpandRatio(chartContainer, 1.3f); content.setComponentAlignment(chartContainer, Alignment.MIDDLE_CENTER); //Quantity chart HorizontalLayout quantityChartContainer = new HorizontalLayout(); quantityChartContainer.setWidth(95, Unit.PERCENTAGE); // quantityChartContainer.setMargin(true); quantityChartContainer.setMargin(new MarginInfo(true, true, false, true)); // quantityChartContainer.setHeight(30,Unit.PERCENTAGE); quantityChart = buildQuantityChart(); quantityChartContainer.addComponent(quantityChart); quantityChartContainer.setComponentAlignment(quantityChart, Alignment.MIDDLE_CENTER); // quantityChartContainer.setCaption("Quantity"); // quantityChartContainer.addStyleName("center-caption"); content.addComponent(quantityChartContainer); content.setExpandRatio(quantityChartContainer, 1.0f); content.setComponentAlignment(quantityChartContainer, Alignment.MIDDLE_CENTER); //bottom row conatainer HorizontalLayout bottowRow = new HorizontalLayout(); bottowRow.setWidth(100, Unit.PERCENTAGE); content.addComponent(bottowRow); content.setExpandRatio(bottowRow, 1.0f); //Stock price table GridLayout stockPriceTableContainer = new GridLayout(1, 2); //add a caption to the table // Label tableCaption=new Label("Stock Price Table"); // stockPriceTableContainer.addComponent(tableCaption, 0, 0); // stockPriceTableContainer.setComponentAlignment(tableCaption,Alignment.MIDDLE_RIGHT); stockPriceTable = setupStockPriceTable(); stockPriceTableContainer.addComponent(stockPriceTable, 0, 1); stockPriceTableContainer.setMargin(new MarginInfo(false, true, true, true)); stockPriceTableContainer.setCaption("Stock Price Table"); stockPriceTableContainer.addStyleName("center-caption"); stockPriceTableContainer.setComponentAlignment(stockPriceTable, Alignment.MIDDLE_CENTER); bottowRow.addComponent(stockPriceTableContainer); // bottowRow.setExpandRatio(stockPriceTableContainer,1.0f); //buy-sell window GridLayout buySellWindowContainer = new GridLayout(1, 2); // //add a caption to the table // Label buySellWindowCaption=new Label("Buy/Sell Stocks"); // buySellWindowContainer.addComponent(buySellWindowCaption,0,0); // buySellWindowContainer.setComponentAlignment(buySellWindowCaption,Alignment.MIDDLE_CENTER); Component buySellWindow = setupBuySellForm(); buySellWindowContainer.addComponent(buySellWindow, 0, 1); buySellWindowContainer.setMargin(new MarginInfo(false, false, true, false)); buySellWindowContainer.setCaption("Buy/Sell Stocks"); buySellWindowContainer.addStyleName("center-caption"); buySellWindowContainer.setComponentAlignment(buySellWindow, Alignment.MIDDLE_CENTER); bottowRow.addComponent(buySellWindowContainer); // bottowRow.setExpandRatio(buySellWindowContainer,1.0f); //portfolio data // VerticalLayout myPortfolioLayout=new VerticalLayout(); // myPortfolioLayout.setMargin(new MarginInfo(false,true,true,true)); // bottowRow.addComponent(myPortfolioLayout); //add a caption to the table // Label portfolioCaption=new Label("My Portfolio"); // myPortfolioLayout.addComponent(portfolioCaption); // myPortfolioLayout.setComponentAlignment(portfolioCaption,Alignment.MIDDLE_CENTER); HorizontalLayout portfolioContainer = new HorizontalLayout(); portfolioContainer.setMargin(new MarginInfo(false, true, true, true)); portfolioContainer.setCaption("My Portfolio"); portfolioContainer.addStyleName("center-caption"); bottowRow.addComponent(portfolioContainer); // bottowRow.setExpandRatio(portfolioContainer,1.0f); //portfolio table portfolioTable = setupPortfolioTable(); portfolioContainer.addComponent(portfolioTable); // portfolioContainer.setExpandRatio(portfolioTable,1.0f); //profit chart // HorizontalLayout profitContainer = new HorizontalLayout(); // bottowRow.addComponent(profitContainer); profitChart = setupProfitChart(); profitChart.setCaption("Profit Chart"); profitChart.addStyleName("center-caption"); bottowRow.addComponent(profitChart); bottowRow.setExpandRatio(profitChart, 1.3f); // Component accountInfo=setUpAccountInfoForm(); // accountInfo.setCaption("Profit Chart"); // accountInfo.addStyleName("center-caption"); // // bottowRow.addComponent(accountInfo); // bottowRow.setExpandRatio(accountInfo,1.3f); this.setContent(content); } }
From source file:org.lucidj.newview.NewView.java
License:Apache License
private Component form_type_panel() { HorizontalLayout group = new HorizontalLayout(); group.setWidth(100, Unit.PERCENTAGE); group.setCaption("Artifact type"); Map<String, Object> component = new HashMap<>(); component.put("iconTitle", "LucidJ Application"); component.put("iconUrl", "apps/system-run"); List<Map<String, Object>> components = new ArrayList<>(); components.add(component);/* w ww .j a v a 2s . c o m*/ ObjectRenderer component_renderer = rendererFactory.newRenderer(components); component_renderer.setWidth(100, Unit.PERCENTAGE); Panel field_panel = new Panel(); field_panel.setWidth(100, Unit.PERCENTAGE); field_panel.setContent(component_renderer); group.addComponent(field_panel); return (group); }
From source file:org.opennms.features.topology.app.internal.ui.info.NodeInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(VertexRef ref, GraphContainer container) { if (ref instanceof AbstractVertex && ((AbstractVertex) ref).getNodeID() != null) { AbstractVertex vertex = ((AbstractVertex) ref); OnmsNode node = nodeDao.get(vertex.getNodeID()); if (node != null) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false); formLayout.addComponent(createLabel("Node ID", "" + node.getId())); final HorizontalLayout nodeButtonLayout = new HorizontalLayout(); Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(vertex.getNodeID()).open()); nodeButton.setStyleName(BaseTheme.BUTTON_LINK); nodeButtonLayout.addComponent(nodeButton); nodeButtonLayout.setCaption("Node Label"); formLayout.addComponent(nodeButtonLayout); if (!Strings.isNullOrEmpty(node.getSysObjectId())) { formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId())); }//from w ww . j ava2s . c o m return formLayout; } } return null; }
From source file:org.opennms.features.topology.app.internal.ui.info.NodeInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(AbstractVertex ref) { Preconditions.checkState(ref.getNodeID() != null, "no Node ID defined."); OnmsNode node = nodeDao.get(ref.getNodeID()); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false);/* ww w . j a v a 2s.c o m*/ formLayout.setMargin(false); formLayout.addComponent(createLabel("Node ID", "" + node.getId())); final HorizontalLayout nodeButtonLayout = new HorizontalLayout(); Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(ref.getNodeID()).open()); nodeButton.setStyleName(BaseTheme.BUTTON_LINK); nodeButtonLayout.addComponent(nodeButton); nodeButtonLayout.setCaption("Node Label"); formLayout.addComponent(nodeButtonLayout); if (!Strings.isNullOrEmpty(node.getSysObjectId())) { formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId())); } return formLayout; }
From source file:ru.codeinside.adm.ui.employee.ExecutorGroupsBlock.java
License:Mozilla Public License
public ExecutorGroupsBlock(UserItem userItem) { HorizontalLayout executorGroups = new HorizontalLayout(); executorGroups.setMargin(true, false, true, false); executorGroups.setSpacing(true);//from ww w . j a v a2s. c om executorGroups.setCaption(" ?:"); FilterTable allExecutorGroups = new FilterTable(); allExecutorGroups.setCaption("?:"); TableEmployee.table(executorGroups, allExecutorGroups); currentExecutorGroups = new FilterTable(); currentExecutorGroups .setCaption(", :"); TableEmployee.table(executorGroups, currentExecutorGroups); for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { if (userItem.getGroups().contains(groupName)) { currentExecutorGroups.addItem(new Object[] { groupName, group.getTitle() }, groupName); } else { allExecutorGroups.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } } TableEmployee.addListener(allExecutorGroups, currentExecutorGroups); TableEmployee.addListener(currentExecutorGroups, allExecutorGroups); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); layout.addComponent(executorGroups); layout.setExpandRatio(executorGroups, 1f); setCompositionRoot(layout); setWidth(100f, UNITS_PERCENTAGE); }
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();//from w w w.jav a2s . 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.adm.ui.TreeTableOrganization.java
License:Mozilla Public License
private Component buttonCreateEmployee(final Long id) { HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true);//from ww w .j av a 2s . c o m buttons.setMargin(false, true, false, false); addComponent(buttons); Button createUser = new Button(" ?", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { showOrganizationLabelsAndButtons(id); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); panel.addComponent(layout); String widthColumn = "100px"; final TextField fieldLogin = TableEmployee.addTextField(layout, widthColumn, ""); final PasswordField fieldPass = TableEmployee.addPasswordField(layout, widthColumn, ""); final PasswordField fieldPassRepeat = TableEmployee.addPasswordField(layout, widthColumn, " "); final MaskedTextField fieldSnils = TableEmployee.addMaskedTextField(layout, widthColumn, "?"); fieldSnils.setMask("###-###-### ##"); fieldPassRepeat.addValidator(new RepeatPasswordValidator(fieldPass)); final TextField fieldFIO = TableEmployee.addTextField(layout, widthColumn, ""); 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); l1.addComponent(roleOptionGroup); layout.addComponent(l1); UserItem emptyItem = new UserItem(); emptyItem.setGroups(ImmutableSet.<String>of()); final CertificateBlock certificateBlock = new CertificateBlock(emptyItem); layout.addComponent(certificateBlock); final ExecutorGroupsBlock executorGroupsBlock = new ExecutorGroupsBlock(emptyItem); 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("?"); TableEmployee.table(supervisorGroupsEmp, allSupervisorGroupsEmp); final FilterTable currentSupervisorGroupsEmp = new FilterTable(); currentSupervisorGroupsEmp.setCaption(""); TableEmployee.table(supervisorGroupsEmp, currentSupervisorGroupsEmp); for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { allSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } TableEmployee.addListener(allSupervisorGroupsEmp, currentSupervisorGroupsEmp); TableEmployee.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("?"); TableEmployee.table(supervisorGroupsOrg, allSupervisorGroupsOrg); final FilterTable currentSupervisorGroupsOrg = new FilterTable(); currentSupervisorGroupsOrg.setCaption(""); TableEmployee.table(supervisorGroupsOrg, currentSupervisorGroupsOrg); for (String groupName : AdminServiceProvider.get().getOrgGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { allSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } TableEmployee.addListener(allSupervisorGroupsOrg, currentSupervisorGroupsOrg); TableEmployee.addListener(currentSupervisorGroupsOrg, allSupervisorGroupsOrg); layout.addComponent(supervisorGroupsOrg); TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); roleOptionGroup.addListener(new Listener() { private static final long serialVersionUID = 1L; public void componentEvent(Event event) { TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); } }); HorizontalLayout l2 = new HorizontalLayout(); Label labelPrint = new Label("? ?"); labelPrint.setWidth(widthColumn); l2.addComponent(labelPrint); l2.setComponentAlignment(labelPrint, Alignment.MIDDLE_LEFT); final CheckBox checkBoxPrint = new CheckBox(); checkBoxPrint.setDescription("? ?"); l2.addComponent(checkBoxPrint); layout.addComponent(l2); HorizontalLayout layoutButton = new HorizontalLayout(); layoutButton.setSpacing(true); Button buttonUserForm = new Button("", new Button.ClickListener() { private static final long serialVersionUID = -7193894183022375021L; public void buttonClick(ClickEvent event) { if (!fieldPassRepeat.isValid()) { return; } String snilsFieldValue = fieldSnils.getValue() == null ? "" : (String) fieldSnils.getValue(); String snilsValue = snilsFieldValue.replaceAll("\\D+", ""); Pattern snilsPattern = Pattern.compile("\\d{11}"); Matcher snilsMatcher = snilsPattern.matcher(snilsValue); if (!snilsFieldValue.isEmpty() && !snilsMatcher.matches()) { getWindow().showNotification("? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } String loginUser = (String) fieldLogin.getValue(); if (!AdminServiceProvider.get().isUniqueSnils(loginUser, snilsValue)) { getWindow().showNotification(" ? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } String password = (String) fieldPass.getValue(); String passwordRepeat = (String) fieldPassRepeat.getValue(); 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()); if (loginUser.equals("") || password.equals("") || passwordRepeat.equals("") || fio.equals("")) { getWindow().showNotification(" ? ?!", Notification.TYPE_WARNING_MESSAGE); } else if (!(password.equals(passwordRepeat))) { getWindow().showNotification(" ?!", Notification.TYPE_WARNING_MESSAGE); } else if (AdminServiceProvider.get().findEmployeeByLogin(loginUser) == null) { if (roles.contains(Role.SuperSupervisor)) { groupSupervisorEmp = new TreeSet<String>( AdminServiceProvider.get().selectGroupNamesBySocial(true)); groupSupervisorOrg = new TreeSet<String>( AdminServiceProvider.get().selectGroupNamesBySocial(false)); } String creator = getApplication().getUser().toString(); AdminServiceProvider.get().createEmployee(loginUser, password, fio, snilsValue, roles, creator, id, groupExecutor, groupSupervisorEmp, groupSupervisorOrg); showOrganization(id); getWindow().showNotification(" " + loginUser + " ?"); if (checkBoxPrint.booleanValue()) { // Create a window that contains what you want to print Window window = new Window(); window.addComponent(new Label("<h1>: " + loginUser + "</h1>\n" + "<h1>: " + password + "</h1>\n", Label.CONTENT_XHTML)); getApplication().addWindow(window); getWindow().open(new ExternalResource(window.getURL()), "_blank", 500, 200, // Width and // height Window.BORDER_NONE); window.executeJavaScript("print();"); window.executeJavaScript("self.close();"); } } else { getWindow().showNotification(" ?!", Notification.TYPE_WARNING_MESSAGE); } } }); layoutButton.addComponent(buttonUserForm); Button buttonCancel = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { showOrganization(id); } }); layoutButton.addComponent(buttonCancel); layout.addComponent(layoutButton); } }); createUser.addListener(this); buttons.addComponent(createUser); return buttons; }
From source file:sph.vaadin.ui.videojs.VideojsSeekToController.java
License:Apache License
/** * Creates and sets up all UI components. *///from w w w. j av a2s. c o m private void doLayout() { HorizontalLayout compositionRoot = new HorizontalLayout(); compositionRoot.setMargin(true); compositionRoot.setSpacing(true); compositionRoot.setDefaultComponentAlignment(Alignment.BOTTOM_CENTER); hoursField = createTextField("00", 2); minutesField = createTextField("00", 2); secondsField = createTextField("00", 2); //hoursField.addValidator(new IntegerRangeValidator("Virheellinen aika tunnit", 0, 2)); minutesField.addValidator(new IntegerRangeValidator("Requires an integer between 0-59", 0, 59)); secondsField.addValidator(new IntegerRangeValidator("Requires an integer between 0-59", 0, 59)); compositionRoot.addComponents(hoursField, new Label(":"), minutesField, new Label(":"), secondsField, seekBtn); compositionRoot.setCaption("Seekto"); this.setCompositionRoot(compositionRoot); }