List of usage examples for com.vaadin.ui CheckBox CheckBox
public CheckBox(String caption)
From source file:com.esofthead.mycollab.module.project.view.user.ProjectUnresolvedAssignmentWidget.java
License:Open Source License
public ProjectUnresolvedAssignmentWidget() { super("", new CssLayout()); this.setWidth("100%"); final CheckBox myItemsSelection = new CheckBox(AppContext.getMessage(GenericI18Enum.OPT_MY_ITEMS)); myItemsSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override//w ww . j av a 2s .co m public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isMyItemsOption = myItemsSelection.getValue(); if (isMyItemsOption) { searchCriteria.setAssignUser(StringSearchField.and(AppContext.getUsername())); } else { searchCriteria.setAssignUser(null); } updateSearchResult(); } }); taskList = new DefaultBeanPagedList(AppContextUtil.getSpringBean(ProjectGenericTaskService.class), new GenericTaskRowDisplayHandler(), 10) { @Override protected String stringWhenEmptyList() { return AppContext.getMessage(ProjectI18nEnum.OPT_NO_ASSIGNMENT); } }; addHeaderElement(myItemsSelection); bodyContent.addComponent(taskList); }
From source file:com.esofthead.mycollab.module.project.view.user.TaskStatusComponent.java
License:Open Source License
public TaskStatusComponent() { withSpacing(false).withMargin(false); this.addStyleName("myprojectlist"); MHorizontalLayout header = new MHorizontalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px"); header.addStyleName("panel-header"); titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_OPEN_ASSIGNMENTS_TITLE, 0)); final CheckBox overdueSelection = new CheckBox("Overdue"); overdueSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override/*from ww w. j a v a2s . c o m*/ public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isOverdueOption = overdueSelection.getValue(); if (isOverdueOption) { searchCriteria.setDueDate( new DateSearchField(DateSearchField.AND, DateTimeUtils.getCurrentDateWithoutMS())); } else { searchCriteria.setDueDate(null); } updateSearchResult(); } }); final CheckBox myItemsOnly = new CheckBox("My Items"); myItemsOnly.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean selectMyItemsOnly = myItemsOnly.getValue(); if (selectMyItemsOnly) { searchCriteria.setAssignUser(new StringSearchField(AppContext.getUsername())); } else { searchCriteria.setAssignUser(null); } taskComponents.setSearchCriteria(searchCriteria); } }); header.with(titleLbl, overdueSelection, myItemsOnly).withAlign(titleLbl, Alignment.MIDDLE_LEFT) .withAlign(overdueSelection, Alignment.MIDDLE_RIGHT).withAlign(myItemsOnly, Alignment.MIDDLE_RIGHT) .expand(titleLbl); taskComponents = new TaskStatusPagedList(); this.with(header, taskComponents); }
From source file:com.esofthead.mycollab.module.project.view.user.UserUnresolvedAssignmentWidget.java
License:Open Source License
public UserUnresolvedAssignmentWidget() { super("", new CssLayout()); this.setWidth("100%"); final CheckBox myItemsSelection = new CheckBox(AppContext.getMessage(GenericI18Enum.OPT_MY_ITEMS)); myItemsSelection.addValueChangeListener(new Property.ValueChangeListener() { @Override// www. j ava2s. c o m public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean isMyItemsOption = myItemsSelection.getValue(); if (searchCriteria != null) { if (isMyItemsOption) { searchCriteria.setAssignUser(StringSearchField.and(AppContext.getUsername())); } else { searchCriteria.setAssignUser(null); } updateSearchResult(); } } }); taskList = new DefaultBeanPagedList(AppContextUtil.getSpringBean(ProjectGenericTaskService.class), new GenericTaskRowDisplayHandler(), 10) { @Override protected String stringWhenEmptyList() { return AppContext.getMessage(ProjectI18nEnum.OPT_NO_ASSIGNMENT); } }; this.addHeaderElement(myItemsSelection); this.bodyContent.addComponent(taskList); }
From source file:com.esspl.datagen.DataGenApplication.java
License:Open Source License
private void buildMainLayout() { log.debug("DataGenApplication - buildMainLayout() start"); VerticalLayout rootLayout = new VerticalLayout(); final Window root = new Window("DATA Gen", rootLayout); root.setStyleName("tData"); setMainWindow(root);/*ww w . java2s . c o m*/ rootLayout.setSizeFull(); rootLayout.setMargin(false, true, false, true); // Top area, containing logo and header HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); root.addComponent(top); // Create the placeholders for all the components in the top area HorizontalLayout header = new HorizontalLayout(); // Add the components and align them properly top.addComponent(header); top.setComponentAlignment(header, Alignment.TOP_LEFT); top.setStyleName("top"); top.setHeight("75px"); // Same as the background image height // header controls Embedded logo = new Embedded(); logo.setSource(DataGenConstant.LOGO); logo.setWidth("100%"); logo.setStyleName("logo"); header.addComponent(logo); header.setSpacing(false); //Show which connection profile is connected connectedString = new Label("Connected to - Oracle"); connectedString.setStyleName("connectedString"); connectedString.setWidth("500px"); connectedString.setVisible(false); top.addComponent(connectedString); //Toolbar toolbar = new ToolBar(this); top.addComponent(toolbar); top.setComponentAlignment(toolbar, Alignment.TOP_RIGHT); listing = new Table(); listing.setHeight("240px"); listing.setWidth("100%"); listing.setStyleName("dataTable"); listing.setImmediate(true); // turn on column reordering and collapsing listing.setColumnReorderingAllowed(true); listing.setColumnCollapsingAllowed(true); listing.setSortDisabled(true); // Add the table headers listing.addContainerProperty("Sl No.", Integer.class, null); listing.addContainerProperty("Column Name", TextField.class, null); listing.addContainerProperty("Data Type", Select.class, null); listing.addContainerProperty("Format", Select.class, null); listing.addContainerProperty("Examples", Label.class, null); listing.addContainerProperty("Additional Data", HorizontalLayout.class, null); listing.setColumnAlignments(new String[] { Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER }); //From the starting create 5 rows addRow(5); //Add different style for IE browser WebApplicationContext context = ((WebApplicationContext) getMainWindow().getApplication().getContext()); WebBrowser browser = context.getBrowser(); //Create a TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); if (!browser.isIE()) { tabSheet.setStyleName("tabSheet"); } //Generator Tab content start generator = new VerticalLayout(); generator.setMargin(true, true, false, true); generateTypeHl = new HorizontalLayout(); generateTypeHl.setMargin(false, false, false, true); generateTypeHl.setSpacing(true); List<String> generateTypeList = Arrays.asList(new String[] { "Sql", "Excel", "XML", "CSV" }); generateType = new OptionGroup("Generation Type", generateTypeList); generateType.setNullSelectionAllowed(false); // user can not 'unselect' generateType.select("Sql"); // select this by default generateType.setImmediate(true); // send the change to the server at once generateType.addListener(this); // react when the user selects something generateTypeHl.addComponent(generateType); //SQL Options sqlPanel = new Panel("SQL Options"); sqlPanel.setHeight("180px"); if (browser.isIE()) { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl1 = new VerticalLayout(); vl1.setMargin(false); Label lb1 = new Label("DataBase"); database = new Select(); database.addItem("Oracle"); database.addItem("Sql Server"); database.addItem("My Sql"); database.addItem("Postgress Sql"); database.addItem("H2"); database.select("Oracle"); database.setWidth("160px"); database.setNullSelectionAllowed(false); HorizontalLayout dbBar = new HorizontalLayout(); dbBar.setMargin(false, false, false, false); dbBar.setSpacing(true); dbBar.addComponent(lb1); dbBar.addComponent(database); vl1.addComponent(dbBar); Label tblLabel = new Label("Table Name"); tblName = new TextField(); tblName.setWidth("145px"); tblName.setStyleName("mandatory"); HorizontalLayout tableBar = new HorizontalLayout(); tableBar.setMargin(true, false, false, false); tableBar.setSpacing(true); tableBar.addComponent(tblLabel); tableBar.addComponent(tblName); vl1.addComponent(tableBar); createQuery = new CheckBox("Include CREATE TABLE query"); createQuery.setValue(true); HorizontalLayout createBar = new HorizontalLayout(); createBar.setMargin(true, false, false, false); createBar.addComponent(createQuery); vl1.addComponent(createBar); sqlPanel.addComponent(vl1); generateTypeHl.addComponent(sqlPanel); generator.addComponent(generateTypeHl); //CSV Option csvPanel = new Panel("CSV Options"); csvPanel.setHeight("130px"); if (browser.isIE()) { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } Label delimiter = new Label("Delimiter Character(s)"); VerticalLayout vl2 = new VerticalLayout(); vl2.setMargin(false); csvDelimiter = new TextField(); HorizontalLayout csvBar = new HorizontalLayout(); csvBar.setMargin(true, false, false, false); csvBar.setSpacing(true); csvBar.addComponent(delimiter); csvBar.addComponent(csvDelimiter); vl2.addComponent(csvBar); csvPanel.addComponent(vl2); //XML Options xmlPanel = new Panel("XML Options"); xmlPanel.setHeight("160px"); if (browser.isIE()) { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl3 = new VerticalLayout(); vl3.setMargin(false); Label lb4 = new Label("Root node name"); rootNode = new TextField(); rootNode.setWidth("125px"); rootNode.setStyleName("mandatory"); HorizontalLayout nodeBar = new HorizontalLayout(); nodeBar.setMargin(true, false, false, false); nodeBar.setSpacing(true); nodeBar.addComponent(lb4); nodeBar.addComponent(rootNode); vl3.addComponent(nodeBar); Label lb5 = new Label("Record node name"); recordNode = new TextField(); recordNode.setWidth("112px"); recordNode.setStyleName("mandatory"); HorizontalLayout recordBar = new HorizontalLayout(); recordBar.setMargin(true, false, false, false); recordBar.setSpacing(true); recordBar.addComponent(lb5); recordBar.addComponent(recordNode); vl3.addComponent(recordBar); xmlPanel.addComponent(vl3); HorizontalLayout noOfRowHl = new HorizontalLayout(); noOfRowHl.setSpacing(true); noOfRowHl.setMargin(true, false, false, true); noOfRowHl.addComponent(new Label("Number of Results")); resultNum = new TextField(); resultNum.setImmediate(true); resultNum.setNullSettingAllowed(false); resultNum.setStyleName("mandatory"); resultNum.addValidator(new IntegerValidator("Number of Results must be an Integer")); resultNum.setWidth("5em"); resultNum.setMaxLength(5); resultNum.setValue(50); noOfRowHl.addComponent(resultNum); generator.addComponent(noOfRowHl); HorizontalLayout addRowHl = new HorizontalLayout(); addRowHl.setMargin(true, false, true, true); addRowHl.setSpacing(true); addRowHl.addComponent(new Label("Add")); rowNum = new TextField(); rowNum.setImmediate(true); rowNum.setNullSettingAllowed(true); rowNum.addValidator(new IntegerValidator("Row number must be an Integer")); rowNum.setWidth("4em"); rowNum.setMaxLength(2); rowNum.setValue(1); addRowHl.addComponent(rowNum); rowsBttn = new Button("Row(s)"); rowsBttn.setIcon(DataGenConstant.ADD); rowsBttn.addListener(ClickEvent.class, this, "addRowButtonClick"); // react to clicks addRowHl.addComponent(rowsBttn); generator.addComponent(addRowHl); //Add the Grid generator.addComponent(listing); //Generate Button Button bttn = new Button("Generate"); bttn.setDescription("Generate Gata"); bttn.addListener(ClickEvent.class, this, "generateButtonClick"); // react to clicks bttn.setIcon(DataGenConstant.VIEW); bttn.setStyleName("generate"); generator.addComponent(bttn); //Generator Tab content end //Executer Tab content start - new class created to separate execution logic executor = new ExecutorView(this); //Executer Tab content end //Explorer Tab content start - new class created to separate execution logic explorer = new ExplorerView(this, databaseSessionManager); //explorer.setMargin(true); //Explorer Tab content end //About Tab content start VerticalLayout about = new VerticalLayout(); about.setMargin(true); Label aboutRichText = new Label(DataGenConstant.ABOUT_CONTENT); aboutRichText.setContentMode(Label.CONTENT_XHTML); about.addComponent(aboutRichText); //About Tab content end //Help Tab content start VerticalLayout help = new VerticalLayout(); help.setMargin(true); Label helpText = new Label(DataGenConstant.HELP_CONTENT); helpText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpText); Embedded helpScreen = new Embedded(); helpScreen.setSource(DataGenConstant.HELP_SCREEN); help.addComponent(helpScreen); Label helpStepsText = new Label(DataGenConstant.HELP_CONTENT_STEPS); helpStepsText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpStepsText); //Help Tab content end //Add the respective contents to the tab sheet tabSheet.addTab(generator, "Generator", DataGenConstant.HOME_ICON); executorTab = tabSheet.addTab(executor, "Executor", DataGenConstant.EXECUTOR_ICON); explorerTab = tabSheet.addTab(explorer, "Explorer", DataGenConstant.EXPLORER_ICON); tabSheet.addTab(about, "About", DataGenConstant.ABOUT_ICON); tabSheet.addTab(help, "Help", DataGenConstant.HELP_ICON); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); content.addComponent(tabSheet); rootLayout.addComponent(content); rootLayout.setExpandRatio(content, 1); log.debug("DataGenApplication - buildMainLayout() end"); }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void addChkTextField(HorizontalLayout addBar, String promptText1, String promptText2) { log.debug("DataGenEventHandler - addSingleTextField() method start"); TextField first = new TextField(); first.setInputPrompt(promptText1);/*from w w w. j a v a 2s . co m*/ first.setWidth("95px"); first.setImmediate(true); if (promptText1.endsWith("Length") || promptText1.endsWith("Number") || promptText1.equals("Starting From")) { first.addValidator(new IntegerValidator(promptText1 + " must be an Integer")); } CheckBox cb = new CheckBox(promptText2); addBar.removeAllComponents(); addBar.setSpacing(true); addBar.addComponent(first); addBar.setComponentAlignment(first, Alignment.MIDDLE_LEFT); addBar.addComponent(cb); addBar.setComponentAlignment(cb, Alignment.MIDDLE_LEFT); log.debug("DataGenEventHandler - addSingleTextField() method end"); }
From source file:com.fatminds.vaadin_cmis_integration.demo.DemoFieldFactory.java
License:Apache License
public Field createField(Item item, Object propertyId, Component uiContext) { if (null == propertyId) throw new IllegalArgumentException("Cannot create field for null propertyId"); if (null != getField(propertyId)) { return getField(propertyId); }//from ww w . j a va 2 s.co m // Identify the fields by their Property ID or other metadata String pid = (String) propertyId; CmisProperty prop = (CmisProperty) item.getItemProperty(propertyId); Class<?> type = prop.getType(); CmisItem cmisItem = (CmisItem) item; String title = prop.getTitle(); if (title == null || title.isEmpty()) { title = (String) propertyId; } // Note, THIS IS NULL if we have a transient (new) Item String thisObjId = (null == cmisItem.getCmisObject() ? null : cmisItem.getCmisObject().getId()); // This field is returned by the method. // If you don't want a TextField, set it to something else in your specialization clause. Field retField = null; // By default, a TextField is returned. Use this reference to set TextField-specific properties in your // specialization clause. TextField textField; retField = textField = new TextField(); textField.setNullRepresentation(""); //textField.setWidth("100%"); textField.setCaption(title); textField.setImmediate(true); textField.setValidationVisible(false); /*** * Handle your non-standard fields by name or id here. */ if ("fmexample:description".equals(pid)) { //RichTextArea rta = new RichTextArea(); TextArea ta = new TextArea(); ta.setCaption(title); ta.setNullRepresentation("Enter formatted description"); // rta.setSizeFull(); //rta.setImmediate(true); retField = ta; } /** * Adapt to taste for handling multi-valued CMIS properties. The following uses TokenField plus a FieldWrapper and ArrayListPropertyConverter * to provide for inline suggestion, and inline storage of newly entered values for future suggestions, for multi-valued string properties. * else if (prop.isMultivalued()) { TokenField tf = new TokenField(); tf.setWidth("1000px"); PropertyConverter pc = new ArrayListPropertyConverter(); FieldWrapper fw = new CmisManyField(tf, pc, ArrayList.class); fw.setCaption(title); fw.setReadOnly(true); retField = fw; if (null != catSvc.getCmisDatalistContainer(parentInstitution, pid)) { tf.setContainerDataSource(catSvc.getCmisDatalistContainer(parentInstitution, pid)); tf.setTokenCaptionPropertyId(propertyId); tf.setImmediate(true); } else { PropertysetItem pitem = new PropertysetItem(); pitem.addItemProperty(propertyId, new ObjectProperty(propertyId)); Set<Object> s = new HashSet<Object>(); s.add(propertyId); IndexedContainer ic = new IndexedContainer(s); tf.setContainerDataSource(ic); tf.setTokenCaptionPropertyId(propertyId); } } **/ else if (Double.class.isAssignableFrom(type) || Float.class.isAssignableFrom(type) || //Number.class.isAssignableFrom(type) || //BigInteger.class.isAssignableFrom(type) || BigDecimal.class.isAssignableFrom(type)) { textField.setMaxLength(10); textField.setCaption(title); textField.setImmediate(true); textField.setPropertyDataSource(new PropertyFormatter(item.getItemProperty(propertyId)) { public String format(Object value) { return value.toString(); } public Object parse(String formattedValue) throws Exception { return new BigDecimal(Double.parseDouble(formattedValue)); } }); retField = textField; } else if (Calendar.class.isAssignableFrom(type)) { CmisDateField dateFld = new CmisDateField(title); retField = dateFld; } else if (Boolean.class.isAssignableFrom(type)) { CheckBox cb = new CheckBox(title); cb.setDescription(title); retField = cb; } // Bind to CmisProperty retField.setPropertyDataSource(prop); // Be careful with this - if it's <mandatory> in the alfresco content model, it's mandatory in your forms. boolean isRequired = prop.isMandatory(); retField.setRequired(false); putField(propertyId, retField); //Add Validators addValidators(pid, retField, title, cmisItem); log.debug("Returning a " + retField.getClass() + " for cmis property " + propertyId); return retField; }
From source file:com.foc.vaadin.gui.windows.CreateLayoutWindow.java
License:Apache License
public CreateLayoutWindow(final FVLayout layout) { setModal(true);/* ww w. j a va 2s .co m*/ setWidth("250px"); setHeight("250px"); mainLayout = new VerticalLayout(); buttonsLayout = new HorizontalLayout(); width = new TextField("Width:"); height = new TextField("Height:"); border = new CheckBox("Border:"); if (layout instanceof FVGridLayout) { rows = new TextField("Rows:"); cols = new TextField("Columns:"); } create = new Button("Create"); cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); create.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { layout.setHeight(height.getValue().toString()); layout.setWidth(width.getValue().toString()); AttributesImpl attributesImpl = new AttributesImpl(layout.getAttributes()); attributesImpl.addAttribute("", "name", "name", "CDATA", "null"); attributesImpl.addAttribute("", "width", "width", "CDATA", width.getValue() + "px"); attributesImpl.addAttribute("", "height", "height", "CDATA", height.getValue() + "px"); if (rows != null) { ((FVGridLayout) layout).setRows(Integer.parseInt(rows.getValue().toString())); ((FVGridLayout) layout).setColumns(Integer.parseInt(cols.getValue().toString())); attributesImpl.addAttribute("", "cols", "cols", "CDATA", cols.getValue() + ""); attributesImpl.addAttribute("", "rows", "rows", "CDATA", rows.getValue() + ""); } layout.setAttributes(attributesImpl); if (border.booleanValue()) { layout.addStyleName("border"); } close(); } }); buttonsLayout.setMargin(true); buttonsLayout.setSpacing(true); buttonsLayout.addComponent(create); buttonsLayout.addComponent(cancel); mainLayout.addComponent(width); mainLayout.addComponent(height); if (rows != null) { mainLayout.addComponent(rows); mainLayout.addComponent(cols); mainLayout.setComponentAlignment(rows, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(cols, Alignment.MIDDLE_CENTER); } mainLayout.addComponent(border); mainLayout.addComponent(buttonsLayout); mainLayout.setComponentAlignment(width, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(height, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(border, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER); setContent(mainLayout); }
From source file:com.github.lsiu.MyVaadinApplication.java
private void initTopBar(HorizontalLayout topBar) { topBar.setWidth("100%"); final CheckBox editableCheckBox = new CheckBox("Editable"); topBar.addComponent(editableCheckBox); topBar.setComponentAlignment(editableCheckBox, Alignment.BOTTOM_RIGHT); editableCheckBox.setValue(table.isEditable()); editableCheckBox.setImmediate(true); editableCheckBox.addListener(new ValueChangeListener() { @Override//w w w. j av a 2s. c o m public void valueChange(ValueChangeEvent event) { table.setEditable((Boolean) editableCheckBox.getValue()); } }); }
From source file:com.github.mjvesa.herd.HerdIDE.java
License:Apache License
private Component createLogAddedWordCheckBox() { CheckBox cb = new CheckBox("log added words"); cb.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3555018128568837160L; @Override/*from w w w .j a va 2s. c o m*/ public void valueChange(ValueChangeEvent event) { interpreter.setLogNewWords((Boolean) event.getProperty().getValue()); } }); return cb; }
From source file:com.github.mjvesa.herd.HerdIDE.java
License:Apache License
private Component createLogExecutedWordsCheckBox() { CheckBox cb = new CheckBox("log executed words"); cb.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8229355957367047681L; @Override/* w ww .java 2s. co m*/ public void valueChange(ValueChangeEvent event) { interpreter.setLogExecutedWords((Boolean) event.getProperty().getValue()); } }); return cb; }