List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout
public HorizontalLayout()
From source file:com.etest.view.tq.charts.ItemAnalysisGraphicalViewAll.java
public ItemAnalysisGraphicalViewAll(int curriculumId) { this.curriculumId = curriculumId; setModal(true);/*from w w w .j a va2 s . c om*/ setHeight("100%"); VerticalLayout v = new VerticalLayout(); v.setMargin(true); v.setSpacing(true); Label title = new Label(); title.setCaption("Item Analysis of " + cs.getCurriculumById(getCurriculumId()).getSubject()); title.setWidthUndefined(); v.addComponent(title); v.setComponentAlignment(title, Alignment.TOP_CENTER); HorizontalLayout h = new HorizontalLayout(); h.setSpacing(true); h.addComponent(getDiscriminationIndexChart()); h.addComponent(getDifficultIndexChart()); h.setWidthUndefined(); h.setHeightUndefined(); v.addComponent(h); v.setWidthUndefined(); setContent(v); getContent().setWidthUndefined(); // getContent().setHeightUndefined(); center(); }
From source file:com.etest.view.tq.itemanalysis.FileUploadWindow.java
void readContentFromExcelFile(File excelFile) { try {//from w w w .ja v a2 s .co m POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFile)); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(wb.getActiveSheetIndex()); HSSFRow row; HSSFCell cell; boolean stop = false; boolean nonBlankRowFound; int s; HSSFRow lastRow = null; while (stop == false) { nonBlankRowFound = false; lastRow = sheet.getRow(sheet.getLastRowNum()); for (s = lastRow.getFirstCellNum(); s <= lastRow.getLastCellNum(); s++) { cell = lastRow.getCell(s); if (cell != null && lastRow.getCell(s).getCellType() != HSSFCell.CELL_TYPE_BLANK) { nonBlankRowFound = true; } } if (nonBlankRowFound == true) { stop = true; } else { sheet.removeRow(lastRow); } } int rows; // No of rows rows = sheet.getPhysicalNumberOfRows(); int cols = 0; // No of columns int tmp = 0; // This trick ensures that we get the data properly even if it doesn't start from first few rows for (int i = 0; i < 10 || i < rows; i++) { row = sheet.getRow(i); if (row != null) { tmp = sheet.getRow(i).getPhysicalNumberOfCells(); if (tmp > cols) cols = tmp; } } List<ItemAnalysis> itemAnalysisList = new ArrayList<>(); List<Character> answer; ItemAnalysis itemAnalysis = null; for (int c = 0; c < cols; c++) { itemAnalysis = new ItemAnalysis(); answer = new ArrayList<>(); for (int r = 0; r < rows; r++) { row = sheet.getRow(r); if (row == null || row.toString().isEmpty()) { ShowErrorNotification.error("Remove all blank/empty rows after the last Item!"); return; } else { // if(row != null){ cell = row.getCell(c); if (cell == null || cell.toString().isEmpty()) { ShowErrorNotification.error("Remove all blank/empty columns after the last student!"); return; } else { // if(cell != null){ if (c != 0) { if (r == 0) { itemAnalysis.setStudentNumber(cell.toString().trim()); } else { answer.add(cell.toString().trim().charAt(0)); } } else { if (r != 0) { totalItems++; } } } } } if (c != 0) { itemAnalysis.setAnswer(answer); itemAnalysisList.add(itemAnalysis); } } if (tq.getCellItemIdByTQCoverageId(getTqCoverageId()).size() != totalItems) { ShowErrorNotification.error("Total Items do not MATCH!"); totalItems = 0; return; } studentNoAndTotalScore = new HashMap<>(); studentNoAndAnswer = new HashMap<>(); totalItems = 1; new Thread() { @Override public void run() { totalData = itemAnalysisList.size(); for (ItemAnalysis i : itemAnalysisList) { try { Thread.sleep(50); studentNoAndTotalScore.put(i.getStudentNumber(), ItemAnalysisInterpretation .getTotalScoresOfAllStudent(tqCoverageId, i.getAnswer())); studentNoAndAnswer.put(i.getStudentNumber(), i.getAnswer()); getUI().access(new Runnable() { @Override public void run() { if (totalItems < itemAnalysisList.size()) { analyze.setValue("Analyzing data.. " + CommonUtilities.roundOffToTwoDecimal((current / totalData) * 100) + "%"); current++; } else { analyze.setValue("Data analyzed... 100%"); getLowerAndUpperGroupStudent(studentNoAndTotalScore); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.addComponent(viewTableProportion()); h.addComponent(viewStudentsTotalScore()); h.addComponent(approveItemAnalysis()); v.addComponent(h); v.addComponent(itemAnalysisGridPanel()); } } }); totalItems++; } catch (InterruptedException ex) { Logger.getLogger(FileUploadWindow.class.getName()).log(Level.SEVERE, null, ex); } } } }.start(); UI.getCurrent().setPollInterval(500); } catch (IOException ex) { Logger.getLogger(TQItemAnalysisUI.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.etest.view.tq.reports.OnlineQueriesUI.java
public OnlineQueriesUI() { setWidth("100%"); setMargin(true);/*w w w . j a va2s . co m*/ setSpacing(true); Label lineSeparator1 = new Label(); lineSeparator1.setContentMode(ContentMode.HTML); lineSeparator1.setStyleName("line-separator"); Label lineSeparator2 = new Label(); lineSeparator2.setContentMode(ContentMode.HTML); lineSeparator2.setStyleName("line-separator"); disableAllComponents(false); GridLayout topGrid = new GridLayout(3, 2); topGrid.setWidth("800px"); topGrid.setSpacing(true); VerticalLayout top = new VerticalLayout(); top.setWidth("166px"); graphicalInventory.addItem("Graphical Inventory"); graphicalInventory.setWidth("300px"); top.addComponent(graphicalInventory); graphicalInventory.addValueChangeListener(firstLevelOptionListener); graphicalInventory.setImmediate(true); graphicalInventoryGroup.addItem("All Subjects"); Label subjectProportionedCaption = new Label(); subjectProportionedCaption.setWidth("500px"); subjectProportionedCaption .setCaption("A Subject's No. of Items Proportioned " + "According to the Revised Bloom's Taxonomy"); subjectProportionedCaption.setContentMode(ContentMode.HTML); subjectProportionedCaption.setHeightUndefined(); graphicalInventoryGroup.addItem(subjectProportionedCaption.getCaption()); graphicalInventoryGroup.setWidth("400px"); graphicalInventoryGroup.addValueChangeListener(secondLevelTopOptionListener); graphicalInventoryGroup.setImmediate(true); topGrid.addComponent(top, 0, 0); topGrid.addComponent(graphicalInventoryGroup, 1, 0, 2, 0); addComponent(topGrid); searchSubject1.setInputPrompt("Search Subject"); searchSubject1.setWidth("225px"); searchSubject1.addValueChangeListener(dropDownChangeListener); searchSubject1.setEnabled(false); topGrid.addComponent(searchSubject1, 1, 1); addComponent(lineSeparator1); GridLayout bottomGrid = new GridLayout(3, 3); bottomGrid.setWidth("800px"); bottomGrid.setSpacing(true); VerticalLayout bottom = new VerticalLayout(); bottom.setWidth("235px"); itemAnalysis.addItem("Item Analysis"); itemAnalysis.setWidth("310px"); bottom.addComponent(itemAnalysis); itemAnalysis.addValueChangeListener(firstLevelOptionListener); itemAnalysis.setImmediate(true); graphicalView.addItem("Graphical View"); graphicalView.setWidth("210px"); graphicalView.addValueChangeListener(secondLevelBottomOptionListener); graphicalView.setImmediate(true); tabularView.addItem("Tabular View"); tabularView.addValueChangeListener(secondLevelBottomOptionListener); tabularView.setImmediate(true); graphicalViewGroup.addItem("Summary: All Tests of a Subject"); graphicalViewGroup.addItem("Difficulty Index of a Subject's Test"); graphicalViewGroup.addItem("Discrimination Index of a Subject's Test"); graphicalViewGroup.setWidth("300px"); graphicalViewGroup.addValueChangeListener(thirdLevelBottomOptionListener); graphicalViewGroup.setImmediate(true); tabularViewGroup.addItem("Summary: All Tests of a Subject"); tabularViewGroup.addItem("Critical values of a test"); tabularViewGroup.addValueChangeListener(thirdLevelBottomOptionListener); tabularViewGroup.setImmediate(true); searchSubject2.setInputPrompt("Search Subject"); searchSubject2.setWidth("225px"); searchSubject2.addValueChangeListener(dropDownChangeListener); searchSubject2.setEnabled(false); searchTest.setWidth("225px"); searchTest.setInputPrompt("Search Test"); searchTest.setEnabled(false); searchTest.addStyleName(ValoTheme.COMBOBOX_SMALL); bottomGrid.addComponent(bottom, 0, 0); bottomGrid.addComponent(graphicalView, 1, 0); bottomGrid.addComponent(tabularView, 1, 1); bottomGrid.addComponent(graphicalViewGroup, 2, 0); bottomGrid.addComponent(tabularViewGroup, 2, 1); bottomGrid.addComponent(searchSubject2, 1, 2); bottomGrid.addComponent(searchTest, 2, 2); addComponent(bottomGrid); addComponent(lineSeparator2); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setMargin(true); Button calculateAndViewBtn = new Button("Calculate & View"); calculateAndViewBtn.setWidth("300px"); calculateAndViewBtn.addClickListener(buttonClickListener); h.addComponent(calculateAndViewBtn); h.setComponentAlignment(calculateAndViewBtn, Alignment.MIDDLE_LEFT); addComponent(calculateAndViewBtn); }
From source file:com.etest.view.tq.TQCoverageWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);/*from www .ja v a2s . co m*/ int itemNo = 1; Label caseTopic; Label stem; Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId()); for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) { Integer tqCaseId = tqCases.getKey(); caseTopic = new Label(); caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic()); caseTopic.setContentMode(ContentMode.HTML); form.addComponent(caseTopic); Map<Integer, Integer> value = tqCases.getValue(); for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) { Integer itemId = itemIds.getKey(); Integer itemKeyId = itemIds.getValue(); List<String> keyList = k.getAllItemKey(itemId); if (keyList.isEmpty()) { ShowErrorNotification .error("No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem()); return null; } stem = new Label(); // stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0))); stem.setValue(itemNo + ". " + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId))); stem.setContentMode(ContentMode.HTML); form.addComponent(stem); GridLayout glayout = new GridLayout(2, 2); glayout.setWidth("100%"); glayout.setSpacing(true); glayout.addComponent(new Label("A) " + cis.getCellItemById(itemId).getOptionA(), ContentMode.HTML), 0, 0); glayout.addComponent(new Label("C) " + cis.getCellItemById(itemId).getOptionC(), ContentMode.HTML), 0, 1); glayout.addComponent(new Label("B) " + cis.getCellItemById(itemId).getOptionB(), ContentMode.HTML), 1, 0); glayout.addComponent(new Label("D) " + cis.getCellItemById(itemId).getOptionD(), ContentMode.HTML), 1, 1); form.addComponent(glayout); itemNo++; } } HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); Button delete = new Button("DELETE"); delete.setWidth("200px"); delete.setIcon(FontAwesome.TRASH_O); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener(buttonClickListener); h.addComponent(delete); Button approve = new Button("APPROVE"); approve.setWidth("200px"); approve.setIcon(FontAwesome.THUMBS_UP); approve.addStyleName(ValoTheme.BUTTON_PRIMARY); approve.addStyleName(ValoTheme.BUTTON_SMALL); approve.addClickListener(buttonClickListener); h.addComponent(approve); if (tq.isTQCoverageApproved(getTQCoverageId())) { approve.setVisible(false); } else { approve.setVisible(true); } form.addComponent(h); return form; }
From source file:com.example.AbstractMongoDemo.java
License:Apache License
protected AbstractMongoDemo initLayout() { try {/*from w ww.ja va2 s .com*/ mongoContainer = buildMongoContainer(); table = new Table("Persons", mongoContainer); table.setSizeFull(); } catch (Exception e) { throw new Error(e); } this.setMargin(true); this.addComponent(addButtons(new HorizontalLayout())); logger.info(mongoContainer.getContainerPropertyIds().toString()); table.setSelectable(true); this.addComponent(table); //table.setVisibleColumns("firstName", "lastName"); initButtons(); return this; }
From source file:com.example.bbs.vaadin.view.Labels.java
License:Apache License
public Labels() { setMargin(true);/*from www. j av a 2 s .c om*/ addStyleName("content-labels"); Label h1 = new Label("Labels"); h1.addStyleName(ValoTheme.LABEL_H1); addComponent(h1); HorizontalLayout split = new HorizontalLayout(); split.setWidth("100%"); addComponent(split); VerticalLayout left = new VerticalLayout(); left.setMargin(new MarginInfo(false, true, false, false)); split.addComponent(left); Label huge = new Label("Huge type for display text."); huge.addStyleName(ValoTheme.LABEL_HUGE); left.addComponent(huge); Label large = new Label( "Large type for introductory text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); large.addStyleName(ValoTheme.LABEL_LARGE); left.addComponent(large); Label h2 = new Label("Subtitle"); h2.addStyleName(ValoTheme.LABEL_H2); left.addComponent(h2); Label normal = new Label( "Normal type for plain text, with a <a href=\"https://vaadin.com\">regular link</a>. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu.", ContentMode.HTML); left.addComponent(normal); Label h3 = new Label("Small Title"); h3.addStyleName(ValoTheme.LABEL_H3); left.addComponent(h3); Label small = new Label( "Small type for additional text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); small.addStyleName(ValoTheme.LABEL_SMALL); left.addComponent(small); Label tiny = new Label("Tiny type for minor text."); tiny.addStyleName(ValoTheme.LABEL_TINY); left.addComponent(tiny); Label h4 = new Label("Section Title"); h4.addStyleName(ValoTheme.LABEL_H4); left.addComponent(h4); normal = new Label( "Normal type for plain text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); left.addComponent(normal); Panel p = new Panel("Additional Label Styles"); split.addComponent(p); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setMargin(true); p.setContent(right); Label label = new Label( "Bold type for prominent text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); label.addStyleName(ValoTheme.LABEL_BOLD); right.addComponent(label); label = new Label( "Light type for subtle text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); label.addStyleName(ValoTheme.LABEL_LIGHT); right.addComponent(label); label = new Label( "Colored type for highlighted text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); label.addStyleName(ValoTheme.LABEL_COLORED); right.addComponent(label); label = new Label("A label for success"); label.addStyleName(ValoTheme.LABEL_SUCCESS); right.addComponent(label); label = new Label("A label for failure"); label.addStyleName(ValoTheme.LABEL_FAILURE); right.addComponent(label); }
From source file:com.example.EditingWindow.java
License:Apache License
protected HorizontalLayout makeFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true);/* w w w. j ava 2s . co m*/ footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); btnOK.addStyleName(ValoTheme.BUTTON_PRIMARY); btnOK.setClickShortcut(ShortcutAction.KeyCode.ENTER); btnCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); footer.addComponents(footerText, btnOK, btnCancel); footer.setExpandRatio(footerText, 1); return footer; }
From source file:com.example.tomeevaadin.ui.BookUI.java
private HorizontalLayout addInputFields() { HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(new Label("Enter a book")); TextField field = new TextField(stringModel); Button button = new Button("press this to save"); button.addClickListener(new Button.ClickListener() { @Override//from w ww . j av a2 s. c o m public void buttonClick(Button.ClickEvent event) { if (bookService == null) { System.out.println("uho, ejb is null"); } Notification.show("button is pressed " + stringModel.getValue()); Book book = new Book(); book.setBookTitle(stringModel.getValue()); bookService.addBook(book); updateBeanContainer(); } }); hl.addComponent(field); hl.addComponent(button); return hl; }
From source file:com.example.vaadindemo.AddItemPanel.java
public HorizontalLayout draw(BeanItemContainer<ShoppingList> container) { final HorizontalLayout x = new HorizontalLayout(); x.setId("addItemPanel"); Button persistNewItemButton = new Button("Dodaj"); final Item item = new Item(); BeanItem<Item> personBean = new BeanItem<Item>(item); final FormLayout formLayout = new FormLayout(); final FieldGroup form = new FieldGroup(); //new name: form form.setItemDataSource(personBean);/*from ww w . ja va 2s . com*/ form.setBuffered(true); Field imieField = form.buildAndBind("Name", "firstName"); imieField.setRequired(true); imieField.addValidator(new StringLengthValidator("bad length", 2, 5, false)); formLayout.addComponent(imieField); //Container final BeanItemContainer<Item> beanContainer = new BeanItemContainer<Item>(Item.class); //beanContainer.addBean(new Item(); //beanContainer.addBean(new Item("Bolek")); //beanContainer.addBean(new Person("Lolek", 1933)); // Put some example data in it container.addItem(new ShoppingList("Mercury", null, null)); //container.addItem(new Planet(2, "Venus")); //container.addItem(new Planet(3, "Earth")); //container.addItem(new Planet(4, "Mars")); // Create a selection component bound to the container final ComboBox select = new ComboBox("Planets", container); // Set the caption mode to read the caption directly // from the 'name' property of the bean select.setItemCaptionMode(ItemCaptionMode.PROPERTY); select.setItemCaptionPropertyId("name"); select.setImmediate(true); final Label ldd = new Label(); x.addComponent(select); x.addComponent(formLayout); x.addComponent(persistNewItemButton); x.addComponent(ldd); persistNewItemButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Label l = new Label("jsdcbsc"); x.addComponent(l); //ldd.setValue(select.getItem(item.firstName).toString()); } }); select.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { ldd.setValue(select.getItemCaption(event.getProperty().getValue())); } }); return x; }
From source file:com.example.vaadindemo.MenuPanel.java
public HorizontalLayout draw() { HorizontalLayout menu = new HorizontalLayout(); addItemButton = new Button("Dodaj do listy"); addListButton = new Button("Dodaj list"); Label appTitle = new Label("Organizator zakupw"); appTitle.setId("appTitle"); menu.addComponent(appTitle);/*w ww . j a va2 s . c o m*/ menu.addComponent(addItemButton); menu.addComponent(addListButton); return menu; }