List of usage examples for com.vaadin.ui Label Label
public Label(String text)
From source file:com.esspl.datagen.ui.TableDataView.java
License:Open Source License
protected void refreshDataView(JdbcTable table, Connection connection) { log.debug("TableDataView - refreshDataView() called"); Statement stmt = null;//from w w w. j a v a 2 s . com ResultSet rs = null; Component component; try { stmt = connection.createStatement(); rs = stmt.executeQuery("select * from " + createTableName(table, connection)); component = new ResultSetTable(rs); component.setSizeFull(); ResultSetMetaData meta = rs.getMetaData(); for (int i = 1; i <= meta.getColumnCount(); i++) { columns.add(meta.getColumnName(i)); } } catch (SQLException ex) { log.warn("failed to retrieve table data", ex); component = new Label(ex.getMessage()); } finally { JdbcUtils.close(rs); JdbcUtils.close(stmt); } tableContainer.removeAllComponents(); tableContainer.addComponent(component); }
From source file:com.esspl.datagen.ui.TableStructureView.java
License:Open Source License
public TableStructureView(JdbcTable table, Connection connection) { setCaption("Structure"); try {/*from w ww .j a v a2 s . c om*/ ResultSet attributes = connection.getMetaData().getColumns(table.getCatalog(), table.getSchema(), table.getName(), null); SelectableResultSetTable resultSetTable = new SelectableResultSetTable(attributes, Arrays.asList("CHECK", "COLUMN_NAME", "TYPE_NAME", "COLUMN_SIZE", "DECIMAL_DIGITS", "IS_NULLABLE", "IS_AUTOINCREMENT", "COLUMN_DEF", "REMARKS")); resultSetTable.setSizeFull(); setCompositionRoot(resultSetTable); JdbcUtils.close(attributes); } catch (Exception ex) { log.error("Exception Occoured at TableStructureView."); setCompositionRoot(new Label(ex.getMessage())); } }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void onChangeDataType(ValueChangeEvent event, Select select) { log.debug("DataGenEventHandler - onChangeDataType() method start"); int rowId = (Integer) select.getData(); DataGenApplication tdg = (DataGenApplication) select.getApplication(); Item item = tdg.listing.getItem(rowId); Select formatSel = (Select) item.getItemProperty("Format").getValue(); formatSel.removeAllItems();//from ww w.j a v a2 s.c o m formatSel.setEnabled(true); Label exampleSel = (Label) item.getItemProperty("Examples").getValue(); exampleSel.setValue("NA"); HorizontalLayout addBar = (HorizontalLayout) item.getItemProperty("Additional Data").getValue(); addBar.removeAllComponents(); addBar.setMargin(false); addBar.addComponent(new Label("NA")); if (event.getProperty().getValue() == null) { formatSel.setValue(null); formatSel.setEnabled(false); return; } if (event.getProperty().getValue().equals("Name")) { for (String f : DataGenConstant.NAME_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("First_Name Last_Name"); } else if (event.getProperty().getValue().equals("Date")) { for (String f : DataGenConstant.DATE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("dd/MM/yyyy"); } else if (event.getProperty().getValue().equals("Phone/Fax")) { for (String f : DataGenConstant.PHONE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("India"); } else if (event.getProperty().getValue().equals("Postal/Zip")) { for (String f : DataGenConstant.ZIP_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("India"); } else if (event.getProperty().getValue().equals("State/Provience/County")) { for (String f : DataGenConstant.STATE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("Full"); } else if (event.getProperty().getValue().equals("Random Text")) { exampleSel.setValue(df.getRandomText(6)); addTextFields(addBar, "Min Length", "Max Length"); } else if (event.getProperty().getValue().equals("Fixed Text")) { exampleSel.setValue(df.getRandomWord()); addChkTextField(addBar, "Text", "Is Number"); } else if (event.getProperty().getValue().equals("Number Range")) { exampleSel.setValue(df.getNumberBetween(10, 1000)); addTextFields(addBar, "Start Number", "End Number"); } else if (event.getProperty().getValue().equals("Alphanumeric")) { exampleSel.setValue("SD0358"); addTextFields(addBar, "Starting Text", "Total Length"); } else if (event.getProperty().getValue().equals("Title")) {//Examples start exampleSel.setValue(df.getPrefix()); } else if (event.getProperty().getValue().equals("Email")) { exampleSel.setValue(df.getEmailAddress()); } else if (event.getProperty().getValue().equals("Street Address")) { exampleSel.setValue(df.getStreetName()); } else if (event.getProperty().getValue().equals("City")) { exampleSel.setValue(df.getCity()); } else if (event.getProperty().getValue().equals("Country")) { exampleSel.setValue(df.getCountry()); } else if (event.getProperty().getValue().equals("Incremental Number")) { exampleSel.setValue("1, 2, 3, 4, 5.."); addSingleTextField(addBar, "Starting From"); } else if (event.getProperty().getValue().equals("Marital Status")) { exampleSel.setValue(df.getStatus()); } else if (event.getProperty().getValue().equals("Department Name")) { exampleSel.setValue(df.getBusinessType()); } else if (event.getProperty().getValue().equals("Company Name")) { exampleSel.setValue(df.getCompanyName()); } else if (event.getProperty().getValue().equals("Boolean Flag")) { exampleSel.setValue(df.getBooleanFlag()); } else if (event.getProperty().getValue().equals("Passport Number")) { exampleSel.setValue(df.getPassportNumber()); } //If there are no formats to show, then disable it if (formatSel.getItemIds().size() == 0) { formatSel.setEnabled(false); } log.debug("DataGenEventHandler - onChangeDataType() method end"); }
From source file:com.etest.connection.ErrorDBNotification.java
public static void showLoggedErrorOnWindow(String str) { Window sub = new Window("Logged ERROR"); sub.setWidth("500px"); sub.setHeight("300px"); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub);// www . ja v a 2s .co m } sub.setModal(true); Panel panel = new Panel(); panel.setSizeFull(); panel.setContent(new Label(str)); sub.setContent(panel); }
From source file:com.etest.utilities.CommonUtilities.java
public static int convertStringToInt(String str) { int val = 0; try {//from w w w . ja v a 2s . c o m if (str != null || !str.isEmpty()) { val = Integer.parseInt(str); } } catch (Exception e) { Label label = new Label("cant convert input to String \n" + e.toString()); ShowErrorNotification.error(label.getValue()); e.getMessage(); } return val; }
From source file:com.etest.utilities.CommonUtilities.java
public static boolean isNumeric(String str) { try {//w w w .j a v a2 s .co m Integer.parseInt(str); return true; } catch (Exception e) { Label label = new Label("Enter a Numeric Format \n" + e.toString()); ShowErrorNotification.error(label.getValue()); return false; } }
From source file:com.etest.utilities.CommonUtilities.java
public static boolean isValueInteger(Object object) { try {//from w w w . ja v a 2 s.c om Integer.parseInt(object.toString()); return true; } catch (Exception e) { Label label = new Label("Enter an Integer Value \n" + e.toString()); ShowErrorNotification.error(label.getValue()); return false; } }
From source file:com.etest.valo.ComboBoxes.java
License:Apache License
public ComboBoxes() { setMargin(true);//from w ww. jav a2 s. com Label h1 = new Label("Combo Boxes"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); ComboBox combo = new ComboBox("Normal"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png")); row.addComponent(combo); CssLayout group = new CssLayout(); group.setCaption("Grouped with a Button"); group.addStyleName("v-component-group"); row.addComponent(group); combo = new ComboBox(); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setNullSelectionAllowed(false); combo.select(combo.getItemIds().iterator().next()); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.setWidth("240px"); group.addComponent(combo); Button today = new Button("Do It"); group.addComponent(today); combo = new ComboBox("Explicit size"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setWidth("260px"); combo.setHeight("60px"); row.addComponent(combo); combo = new ComboBox("No text input allowed"); combo.setInputPrompt("You can click here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setTextInputAllowed(false); combo.setNullSelectionAllowed(false); combo.select("Option One"); row.addComponent(combo); combo = new ComboBox("Error"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); row.addComponent(combo); combo = new ComboBox("Error, borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setNullSelectionAllowed(false); combo.select("Option One"); combo.setComponentError(new UserError("Fix it, now!")); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Disabled"); combo.setInputPrompt("You can't type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.setEnabled(false); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color1"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color2"); row.addComponent(combo); combo = new ComboBox("Custom color"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("color3"); row.addComponent(combo); combo = new ComboBox("Small"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("small"); row.addComponent(combo); combo = new ComboBox("Large"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("large"); row.addComponent(combo); combo = new ComboBox("Borderless"); combo.setInputPrompt("You can type here"); combo.addItem("Option One"); combo.addItem("Option Two"); combo.addItem("Option Three"); combo.addStyleName("borderless"); row.addComponent(combo); combo = new ComboBox("Tiny"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("tiny"); row.addComponent(combo); combo = new ComboBox("Huge"); combo.setInputPrompt("You can type here"); combo.setContainerDataSource(MainUI.generateContainer(200, false)); combo.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); combo.setItemIconPropertyId(MainUI.ICON_PROPERTY); combo.addStyleName("huge"); row.addComponent(combo); }
From source file:com.etest.valo.CommonParts.java
License:Apache License
Panel loadingIndicators() { Panel p = new Panel("Loading Indicator"); final VerticalLayout content = new VerticalLayout(); p.setContent(content);//from w w w. j a va 2 s. co m content.setSpacing(true); content.setMargin(true); content.addComponent(new Label("You can test the loading indicator by pressing the buttons.")); CssLayout group = new CssLayout(); group.setCaption("Show the loading indicator for"); group.addStyleName("v-component-group"); content.addComponent(group); Button loading = new Button("0.8"); loading.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(800); } catch (InterruptedException e) { } } }); group.addComponent(loading); Button delay = new Button("3"); delay.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(3000); } catch (InterruptedException e) { } } }); group.addComponent(delay); Button wait = new Button("15"); wait.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(15000); } catch (InterruptedException e) { } } }); wait.addStyleName("last"); group.addComponent(wait); Label label = new Label(" seconds", ContentMode.HTML); label.setSizeUndefined(); group.addComponent(label); Label spinnerDesc = new Label( "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added."); spinnerDesc.addStyleName("small"); spinnerDesc.setCaption("Spinner"); content.addComponent(spinnerDesc); if (!MainUI.isTestMode()) { final Label spinner = new Label(); spinner.addStyleName("spinner"); Button showSpinnerButton = new Button("Show spinner", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { content.replaceComponent(event.getComponent(), spinner); } }); content.addComponent(showSpinnerButton); } return p; }
From source file:com.etest.valo.Forms.java
License:Apache License
public Forms() { setSpacing(true);/*from ww w. j a va 2 s . c om*/ setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); TextField name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Monthly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }