List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:org.jumpmind.metl.ui.views.deploy.EditAgentDeploymentPanel.java
License:Open Source License
public EditAgentDeploymentPanel(ApplicationContext context, AgentDeployment agentDeployment, AgentDeploymentChangeListener listener, TabbedPanel tabbedPanel) { this.context = context; this.agentDeployment = agentDeployment; this.listener = listener; this.tabbedPanel = tabbedPanel; VerticalLayout vlay = new VerticalLayout(); FormLayout form = new FormLayout(); form.setSpacing(true);//from w w w .j a v a 2s.c o m form.setMargin(true); form.addComponent(getNameComponent()); form.addComponent(getLogLevelComponent()); form.addComponent(getStartTypeComponent()); vlay.addComponent(form); cronLayout = new HorizontalLayout(); cronLayout.setSpacing(true); cronLayout.setMargin(true); cronLayout.addComponent(getScheduleComponent("Second")); cronLayout.addComponent(getScheduleComponent("Minute")); cronLayout.addComponent(getScheduleComponent("Hour")); cronLayout.addComponent(getScheduleComponent("Day")); cronLayout.addComponent(getScheduleComponent("Month")); cronLayout.addComponent(getScheduleComponent("Day of Week")); cronLayout.addComponent(getScheduleComponent("Year")); vlay.addComponent(cronLayout); FormLayout cronForm = new FormLayout(); cronForm.setSpacing(true); cronForm.setMargin(true); cronForm.addComponent(getCronComponent()); vlay.addComponent(cronForm); table = new Table(); table.setSizeFull(); BeanItemContainer<AgentDeploymentParameter> container = new BeanItemContainer<AgentDeploymentParameter>( AgentDeploymentParameter.class); table.setContainerDataSource(container); table.setEditable(true); table.setSelectable(true); table.setTableFieldFactory(new EditFieldFactory()); table.setVisibleColumns("name", "value"); table.setColumnHeaders("Parameter Name", "Value"); container.addAll(agentDeployment.getAgentDeploymentParameters()); setSplitPosition(60f); setFirstComponent(vlay); setSecondComponent(table); updateScheduleEnable(); updateScheduleFields(); }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
@SuppressWarnings("unchecked") public void setSource(Object obj) { value = obj;//from w w w . j av a 2 s . c om editButton.setVisible(hasAdvancedEditor()); FormLayout formLayout = new FormLayout(); formLayout.setWidth(100, Unit.PERCENTAGE); formLayout.setMargin(false); formLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); if (obj != null) { if (obj instanceof List<?>) { List<Object> l = (List<Object>) obj; if (l.size() == 1) { if (l.get(0) instanceof FlowStep) { obj = (FlowStep) l.get(0); } } } if (obj instanceof FlowStep) { obj = ((FlowStep) obj).getComponent(); } if (obj instanceof Component) { Component component = (Component) obj; context.getConfigurationService().refresh(component, true); addComponentProperties(formLayout, component); } if (obj instanceof Resource) { Resource resource = (Resource) obj; addResourceProperties(formLayout, resource); } if (obj instanceof AbstractObjectWithSettings) { List<XMLSetting> settings = buildSettings(obj); if (settings != null) { for (XMLSetting definition : settings) { addSettingField(definition, (AbstractObjectWithSettings) obj, formLayout); } } } if (obj instanceof Component) { Component component = (Component) obj; XMLComponent componentDefintion = context.getComponentDefinitionFactory() .getDefinition(component.getType()); addThreadCount(componentDefintion, formLayout, component); addComponentShared(formLayout, component); } if (obj instanceof List<?>) { addCommonComponentSettings(formLayout, obj); } } panel.setContent(formLayout); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbExportDialog.java
License:Open Source License
protected void createOptionLayout() { optionLayout = new VerticalLayout(); optionLayout.addStyleName("v-scrollable"); optionLayout.setMargin(true);/*ww w. j a v a 2 s . c o m*/ optionLayout.setSpacing(true); optionLayout.setSizeFull(); optionLayout.addComponent(new Label("Please choose from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); optionLayout.addComponent(formLayout); optionLayout.setExpandRatio(formLayout, 1); formatSelect = new ComboBox("Format"); formatSelect.setImmediate(true); for (DbExportFormat format : DbExportFormat.values()) { formatSelect.addItem(format); } formatSelect.setNullSelectionAllowed(false); formatSelect.setValue(DbExportFormat.SQL); formatSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { DbExportFormat format = (DbExportFormat) formatSelect.getValue(); switch (format) { case SQL: compatibilitySelect.setEnabled(true); compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case CSV: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; case SYM_XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; } } }); formatSelect.select(DbExportFormat.SQL); formLayout.addComponent(formatSelect); compatibilitySelect = new ComboBox("Compatibility"); for (Compatible compatability : Compatible.values()) { compatibilitySelect.addItem(compatability); } compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); formLayout.addComponent(compatibilitySelect); createInfo = new CheckBox("Create Tables"); formLayout.addComponent(createInfo); dropTables = new CheckBox("Drop Tables"); formLayout.addComponent(dropTables); data = new CheckBox("Insert Data"); data.setValue(true); formLayout.addComponent(data); foreignKeys = new CheckBox("Create Foreign Keys"); formLayout.addComponent(foreignKeys); indices = new CheckBox("Create Indices"); formLayout.addComponent(indices); quotedIdentifiers = new CheckBox("Qualify with Quoted Identifiers"); formLayout.addComponent(quotedIdentifiers); whereClauseField = new TextArea("Where Clause"); whereClauseField.setWidth(100, Unit.PERCENTAGE); whereClauseField.setRows(2); formLayout.addComponent(whereClauseField); exportFormatOptionGroup = new OptionGroup("Export Format"); exportFormatOptionGroup.setImmediate(true); exportFormatOptionGroup.addItem(EXPORT_AS_A_FILE); if (queryPanel != null) { exportFormatOptionGroup.addItem(EXPORT_TO_THE_SQL_EDITOR); } exportFormatOptionGroup.setValue(EXPORT_AS_A_FILE); exportFormatOptionGroup.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { setExportButtonsEnabled(); } }); formLayout.addComponent(exportFormatOptionGroup); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbFillDialog.java
License:Open Source License
protected void createOptionLayout() { optionLayout = new VerticalLayout(); optionLayout.addStyleName("v-scrollable"); optionLayout.setMargin(true);/* w w w . j a v a 2s . c o m*/ optionLayout.setSpacing(true); optionLayout.setSizeFull(); optionLayout.addComponent(new Label("Please choose from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); optionLayout.addComponent(formLayout); optionLayout.setExpandRatio(formLayout, 1); countField = new TextField("Count (# of rows to fill)"); countField.setValue("1"); countField.setTextChangeEventMode(TextChangeEventMode.EAGER); countField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { countField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(countField); intervalField = new TextField("Interval (ms)"); intervalField.setValue("0"); intervalField.setTextChangeEventMode(TextChangeEventMode.EAGER); intervalField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { intervalField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(intervalField); insertWeightField = new TextField("Insert Weight"); insertWeightField.setValue("1"); insertWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); insertWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { insertWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(insertWeightField); updateWeightField = new TextField("Update Weight"); updateWeightField.setValue("0"); updateWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); updateWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { updateWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(updateWeightField); deleteWeightField = new TextField("Delete Weight"); deleteWeightField.setValue("0"); deleteWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); deleteWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { deleteWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(deleteWeightField); continueBox = new CheckBox("Continue (ignore ANY errors and continue to modify)"); continueBox.setValue(true); formLayout.addComponent(continueBox); cascadeBox = new CheckBox("Fill dependent tables also."); cascadeBox.setValue(false); formLayout.addComponent(cascadeBox); cascadeSelectBox = new CheckBox("Fill dependent tables by selecting existing data."); cascadeSelectBox.setValue(false); formLayout.addComponent(cascadeSelectBox); verboseBox = new CheckBox("Turn on verbose logging during fill."); verboseBox.setValue(false); formLayout.addComponent(verboseBox); truncateBox = new CheckBox("Truncate table(s) before filling."); truncateBox.setValue(false); formLayout.addComponent(truncateBox); oGroup = new OptionGroup(); oGroup.addItem("Fill Table(s)"); oGroup.addItem("Send to Sql Editor"); oGroup.select("Fill Table(s)"); oGroup.setNullSelectionAllowed(false); formLayout.addComponent(oGroup); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbImportDialog.java
License:Open Source License
protected void createImportLayout() { importLayout = new VerticalLayout(); importLayout.setSizeFull();/*from w w w .jav a2 s .c o m*/ importLayout.addStyleName("v-scrollable"); importLayout.setMargin(true); importLayout.setSpacing(true); importLayout.addComponent(new Label("Please select from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); importLayout.addComponent(formLayout); importLayout.setExpandRatio(formLayout, 1); formatSelect = new ComboBox("Format"); for (DbImportFormat format : DbImportFormat.values()) { formatSelect.addItem(format); } formatSelect.setNullSelectionAllowed(false); formatSelect.setValue(DbImportFormat.SQL); formatSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { DbImportFormat format = (DbImportFormat) formatSelect.getValue(); switch (format) { case SQL: listOfTablesSelect.setEnabled(false); alter.setEnabled(false); alterCase.setEnabled(false); break; case XML: listOfTablesSelect.setEnabled(false); alter.setEnabled(true); alterCase.setEnabled(true); break; case CSV: listOfTablesSelect.setEnabled(true); alter.setEnabled(false); alterCase.setEnabled(false); importButton.setEnabled(importButtonEnable()); break; case SYM_XML: listOfTablesSelect.setEnabled(false); alter.setEnabled(false); alterCase.setEnabled(false); break; } } }); formLayout.addComponent(formatSelect); catalogSelect = new ComboBox("Catalog"); catalogSelect.setImmediate(true); CommonUiUtils.addItems(getCatalogs(), catalogSelect); catalogSelect.select(databasePlatform.getDefaultCatalog()); catalogSelect.setNullSelectionAllowed(false); formLayout.addComponent(catalogSelect); schemaSelect = new ComboBox("Schema"); schemaSelect.setImmediate(true); CommonUiUtils.addItems(getSchemas(), schemaSelect); if (selectedTablesSet.iterator().hasNext()) { schemaSelect.select(selectedTablesSet.iterator().next().getSchema()); } else { schemaSelect.select(databasePlatform.getDefaultSchema()); } schemaSelect.setNullSelectionAllowed(false); schemaSelect.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { populateListOfTablesSelect(); } }); formLayout.addComponent(schemaSelect); listOfTablesSelect = new ComboBox("Tables"); populateListOfTablesSelect(); listOfTablesSelect.setEnabled(false); listOfTablesSelect.setNullSelectionAllowed(false); if (!this.selectedTablesSet.isEmpty()) { if (this.selectedTablesSet.size() == 1) { this.selectedTable = this.selectedTablesSet.iterator().next(); listOfTablesSelect.select(this.selectedTable.getName()); this.selectedTablesSet.clear(); } else { List<Table> list = new ArrayList<Table>(this.selectedTablesSet); listOfTablesSelect.select(list.get(0).getName()); this.selectedTable = list.get(0); this.selectedTablesSet.clear(); } } formLayout.addComponent(listOfTablesSelect); commitField = new TextField("Rows to Commit"); commitField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { commitField.setValue(event.getText()); if (fileSelected) { importButton.setEnabled(importButtonEnable()); } } }); commitField.setImmediate(true); commitField.setTextChangeEventMode(TextChangeEventMode.EAGER); commitField.setValue("10000"); formLayout.addComponent(commitField); force = new CheckBox("Force"); formLayout.addComponent(force); ignore = new CheckBox("Ignore"); formLayout.addComponent(ignore); replace = new CheckBox("Replace"); formLayout.addComponent(replace); alter = new CheckBox("Alter"); alter.setEnabled(false); formLayout.addComponent(alter); alterCase = new CheckBox("Alter Case"); alterCase.setEnabled(false); formLayout.addComponent(alterCase); upload = new Upload("File", new Receiver() { private static final long serialVersionUID = 1L; @Override public OutputStream receiveUpload(String filename, String mimeType) { try { file = File.createTempFile("dbimport", formatSelect.getValue().toString()); out = new FileOutputStream(file); return new BufferedOutputStream(new FileOutputStream(file)); } catch (Exception e) { log.warn(e.getMessage(), e); CommonUiUtils.notify("Failed to import " + filename, e); } return null; } }); upload.addSucceededListener(new SucceededListener() { private static final long serialVersionUID = 1L; @Override public void uploadSucceeded(SucceededEvent event) { createDbImport(); try { doDbImport(); } catch (FileNotFoundException e) { log.warn(e.getMessage(), e); Notification.show(e.getMessage()); } deleteFileAndResource(); close(); } }); upload.addChangeListener(new ChangeListener() { private static final long serialVersionUID = 1L; public void filenameChanged(ChangeEvent event) { fileSelected = true; importButton.setEnabled(importButtonEnable()); } }); upload.setButtonCaption(null); formLayout.addComponent(upload); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(DbImportDialog.this); } }); importButton = CommonUiUtils.createPrimaryButton("Import", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { upload.submitUpload(); } }); importButton.setEnabled(false); addComponent(importLayout, 1); addComponent(buildButtonFooter(cancelButton, importButton)); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.SettingsDialog.java
License:Open Source License
protected AbstractLayout createSettingsLayout() { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();/* ww w . j a v a2 s. c o m*/ layout.setMargin(new MarginInfo(false, true, false, true)); layout.addStyleName("v-scrollable"); FormLayout settingsLayout = new FormLayout(); Settings settings = settingsProvider.get(); TypedProperties properties = settings.getProperties(); rowsToFetchField = new TextField("Max Results"); rowsToFetchField.setColumns(6); rowsToFetchField.setValidationVisible(true); rowsToFetchField.setConverter(Integer.class); rowsToFetchField.setValue(properties.getProperty(SQL_EXPLORER_MAX_RESULTS, "100")); settingsLayout.addComponent(rowsToFetchField); delimiterField = new TextField("Delimiter"); delimiterField.setValue(properties.getProperty(SQL_EXPLORER_DELIMITER, ";")); settingsLayout.addComponent(delimiterField); excludeTablesWithPrefixField = new TextField("Hide Tables (regex)"); excludeTablesWithPrefixField.setValue(properties.getProperty(SQL_EXPLORER_EXCLUDE_TABLES_REGEX)); settingsLayout.addComponent(excludeTablesWithPrefixField); resultAsTextBox = new CheckBox("Result As Text"); String resultAsTextValue = (properties.getProperty(SQL_EXPLORER_RESULT_AS_TEXT, "false")); if (resultAsTextValue.equals("true")) { resultAsTextBox.setValue(true); } else { resultAsTextBox.setValue(false); } settingsLayout.addComponent(resultAsTextBox); ignoreErrorsWhenRunningScript = new CheckBox("Ignore Errors When Running Scripts"); String ignoreErrorsWhenRunningScriptTextValue = (properties .getProperty(SQL_EXPLORER_IGNORE_ERRORS_WHEN_RUNNING_SCRIPTS, "false")); if (ignoreErrorsWhenRunningScriptTextValue.equals("true")) { ignoreErrorsWhenRunningScript.setValue(true); } else { ignoreErrorsWhenRunningScript.setValue(false); } settingsLayout.addComponent(ignoreErrorsWhenRunningScript); autoCommitBox = new CheckBox("Auto Commit"); String autoCommitValue = (properties.getProperty(SQL_EXPLORER_AUTO_COMMIT, "true")); if (autoCommitValue.equals("true")) { autoCommitBox.setValue(true); } else { autoCommitBox.setValue(false); } settingsLayout.addComponent(autoCommitBox); showRowNumbersBox = new CheckBox("Show Row Numbers"); String showRowNumbersValue = (properties.getProperty(SQL_EXPLORER_SHOW_ROW_NUMBERS, "true")); if (showRowNumbersValue.equals("true")) { showRowNumbersBox.setValue(true); } else { showRowNumbersBox.setValue(false); } settingsLayout.addComponent(showRowNumbersBox); showResultsInNewTabsBox = new CheckBox("Always Put Results In New Tabs"); String showResultsInNewTabsValue = (properties.getProperty(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS, "false")); if (showResultsInNewTabsValue.equals("true")) { showResultsInNewTabsBox.setValue(true); } else { showResultsInNewTabsBox.setValue(false); } settingsLayout.addComponent(showResultsInNewTabsBox); layout.addComponent(settingsLayout); return layout; }
From source file:org.lunarray.model.generation.vaadin.components.impl.FormComponentImpl.java
License:Open Source License
/** Initializes the form. */ private void init() { this.form = new Form(new FormLayout()); final Composer<RenderContext<E>, S, E> composer = new Composer<RenderContext<E>, S, E>(); final Model<S> model = this.getModel(); composer.setContext(new RenderContext<E>(model)); composer.setPropertyRenderStrategyFactory(new FormPropertyRenderStrategyFactoryImpl<E>(this)); composer.setVariableResolver(new ComponentVariableResolver()); this.form.setCaption(composer.getLabel()); this.setCompositionRoot(this.form); this.subForm = this.form; composer.compose(true);//from w w w . j a va2s . c om this.form.setFooter(new HorizontalLayout()); this.submitButton = new Button(MessageUtil.getMessage(FormComponentImpl.BUTTON_SUBMIT), this.form, "commit"); if (!CheckUtil.isNull(this.getModel().getExtension(EntityValidator.class))) { this.submitButton.addListener(new EntityValidationListener<S, E>(this)); } this.form.getFooter().addComponent(this.submitButton); this.cancelButton = new Button(MessageUtil.getMessage(FormComponentImpl.BUTTON_CANCEL)); this.form.getFooter().addComponent(this.cancelButton); }
From source file:org.lunifera.mobile.vaadin.ecview.presentation.internal.MobileSearchPanelPresentation.java
License:Open Source License
@Override public ComponentContainer doCreateWidget(Object parent) { if (horizontalLayout == null) { horizontalLayout = new HorizontalLayout(); setupComponent(horizontalLayout, getCastedModel()); associateWidget(horizontalLayout, modelAccess.yLayout); if (modelAccess.isCssIdValid()) { horizontalLayout.setId(modelAccess.getCssID()); } else {/*from w w w . j a va2 s. c om*/ horizontalLayout.setId(getEditpart().getId()); } if (modelAccess.isMargin()) { horizontalLayout.addStyleName(IConstants.CSS_CLASS_MARGIN); horizontalLayout.setMargin(true); } if (!modelAccess.isSpacing()) { horizontalLayout.setSpacing(false); } else { horizontalLayout.addStyleName(IConstants.CSS_CLASS_SPACING); horizontalLayout.setSpacing(true); } if (modelAccess.isCssClassValid()) { horizontalLayout.addStyleName(modelAccess.getCssClass()); } else { horizontalLayout.addStyleName(CSS_CLASS_CONTROL); } horizontalLayout.addStyleName(IConstants.CSS_CLASS_HORIZONTALLAYOUT); leftForm = new FormLayout(); leftForm.setSizeFull(); horizontalLayout.addComponent(leftForm); rightForm = new FormLayout(); rightForm.setSizeFull(); horizontalLayout.addComponent(rightForm); // creates the binding for the field createBindings(modelAccess.yLayout, horizontalLayout, null); // initialize all children initializeChildren(); // and now render children renderChildren(false); } return horizontalLayout; }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.FormLayoutPresentation.java
License:Open Source License
@Override public ComponentContainer doCreateWidget(Object parent) { if (componentBase == null) { componentBase = new CssLayout(); componentBase.addStyleName(CSS_CLASS_CONTROL_BASE); if (modelAccess.isCssIdValid()) { componentBase.setId(modelAccess.getCssID()); } else {// w w w . j a v a 2 s .co m componentBase.setId(getEditpart().getId()); } associateWidget(componentBase, modelAccess.yLayout); formLayout = new FormLayout(); componentBase.addComponent(formLayout); associateWidget(formLayout, modelAccess.yLayout); if (modelAccess.isMargin()) { formLayout.addStyleName(IConstants.CSS_CLASS_MARGIN); formLayout.setMargin(true); } if (!modelAccess.isSpacing()) { formLayout.setSpacing(false); } else { formLayout.setData(IConstants.CSS_CLASS_SPACING); formLayout.setSpacing(true); } if (modelAccess.isCssClassValid()) { formLayout.addStyleName(modelAccess.getCssClass()); } else { formLayout.addStyleName(CSS_CLASS_CONTROL); } // creates the binding for the field createBindings(modelAccess.yLayout, formLayout, componentBase); // initialize all children initializeChildren(); renderChildren(false); } return componentBase; }
From source file:org.milleni.dunning.ui.customer.CustomerSearchPanel.java
License:Apache License
protected void initInputField() { /*/*from ww w .j a v a2 s. co m*/ BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class); personBinder.setItemDataSource(person); myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName")); myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name")); */ formLayout = new FormLayout(); //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID)); //formLayout.addComponent(txtCustomerId); txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME)); //formLayout.addComponent(txtCustomerName); formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will // display scrollbars //formLayout.setSpacing(true); //formLayout.setMargin(false, false, true, true); customer = new Customer(); Form customerSearchForm = new Form(); customerSearchForm.setFormFieldFactory(new FormFieldFactory() { @Override public Field createField(Item item, Object propertyId, Component uiContext) { Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext); if (field instanceof TextField) { ((TextField) field).setNullRepresentation(""); } if ("customerId".equals(propertyId)) { ((TextField) field).setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID)); txtCustomerId = (TextField) field; ((TextField) field).setPropertyDataSource(new PropertyFormatter() { @Override public Object parse(String formattedValue) throws Exception { if (StringUtils.hasText(formattedValue)) try { return Long.parseLong(formattedValue); } catch (Exception e) { return null; } else return null; } @Override public String format(Object value) { return String.valueOf(value); } }); } else if ("customerName".equals(propertyId)) { ((TextField) field).setCaption(i18nManager.getMessage(Constants.CUSTOMER_NAME)); } else if ("customerType".equals(propertyId)) { List<CustomerType> customerTypesList = new ArrayList<CustomerType>(); Iterable<CustomerType> types = DaoHelper.getInstance().getCustomerService() .listAllCustomerTypes(); for (CustomerType customerType : types) { customerTypesList.add(customerType); } BeanItemContainer<CustomerType> objects = new BeanItemContainer(CustomerType.class, customerTypesList); ComboBox combo = new ComboBox(i18nManager.getMessage(Constants.CUSTOMER_TYPE), objects); combo.setItemCaptionPropertyId("typeName"); return combo; } else if ("customerGroup".equals(propertyId)) { List<CustomerGroup> customerGroupList = new ArrayList<CustomerGroup>(); Iterable<CustomerGroup> groups = DaoHelper.getInstance().getCustomerService() .listAllCustomerGroups(); for (CustomerGroup customerGroup : groups) { customerGroupList.add(customerGroup); } BeanItemContainer<CustomerGroup> objects = new BeanItemContainer(CustomerGroup.class, customerGroupList); ComboBox combo = new ComboBox(i18nManager.getMessage(Constants.CUSTOMER_GROUP), objects); combo.setItemCaptionPropertyId("groupName"); return combo; } return field; } }); BeanItem<Customer> item = new BeanItem<Customer>(customer, new String[] { "customerId", "customerName", "customerType", "customerGroup" }); //item.addItemProperty(i18nManager.getMessage(Constants.CUSTOMER_ID), new NestedMethodProperty(customer, "customerId")); customerSearchForm.setItemDataSource(item); formLayout.addComponent(customerSearchForm); setContent(formLayout); }