List of usage examples for com.vaadin.server FontAwesome EDIT
FontAwesome EDIT
To view the source code for com.vaadin.server FontAwesome EDIT.
Click Source Link
From source file:uk.co.intec.keyDatesApp.pages.KeyDateView.java
License:Apache License
/** * Loads the main content for the page. Only called on first entry to the * page, because calling method sets <i>isLoaded</i> to true after * successfully completing./*from www . j av a 2s . c om*/ */ public void loadContent() { getEditForm().setSizeUndefined(); getEditForm().setWidth("100%"); getBeanFields().setBuffered(false); getBeanFields().setItemDataSource(getCurrDocBean()); getBeanFields().setFieldFactory(DefaultFieldGroupFieldFactory.get()); getBeanFields().setReadOnly(getCurrDoc().isReadOnly()); final TextField t1 = (TextField) getBeanFields().buildAndBind("Title: ", "title"); t1.setNullRepresentation(""); t1.setSizeFull(); t1.setRequired(true); t1.setRequiredError("Please enter title"); final DateField d1 = getBeanFields().buildAndBind("Date: ", "date", DateField.class); d1.setRequired(true); d1.setRequiredError("Please enter date"); d1.setRangeStart(getStartDate()); d1.setRangeEnd(getEndDate()); final TextArea ta1 = getBeanFields().buildAndBind("Description: ", "description", TextArea.class); ta1.setSizeFull(); setCustomerCombo(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer())); getCustomerCombo().setInputPrompt("No Customer Selected"); getCustomerCombo().setFilteringMode(FilteringMode.STARTSWITH); getCustomerCombo().setImmediate(true); getCustomerCombo().setNewItemsAllowed(true); getCustomerCombo().setInvalidAllowed(false); getCustomerCombo().setNullSelectionAllowed(true); getCustomerCombo().setPageLength(5); getCustomerCombo().setWidth("100%"); getCustomerCombo().setResponsive(true); getBeanFields().bind(getCustomerCombo(), "customer"); getCustomerCombo().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { getContactCombo().setContainerDataSource( KeyDateDatabaseUtils.getContactContainer((String) event.getProperty().getValue())); getContactCombo().setValue(""); } }); setContactCombo(new ComboBox("Contact:")); getContactCombo().setInputPrompt("No Contact Selected"); getContactCombo().setFilteringMode(FilteringMode.STARTSWITH); getContactCombo().setImmediate(true); getContactCombo().setNewItemsAllowed(true); getContactCombo().setInvalidAllowed(false); getContactCombo().setNullSelectionAllowed(true); getContactCombo().setPageLength(5); getContactCombo().setWidth("100%"); getContactCombo().setResponsive(true); getBeanFields().bind(getContactCombo(), "contact"); final HorizontalLayout buttonRow = new HorizontalLayout(); setSaveButton(new Button("Save")); getSaveButton().addStyleName(ValoTheme.BUTTON_PRIMARY); getSaveButton().setIcon(FontAwesome.SAVE); getSaveButton().setVisible(getCurrDoc().isEditable()); getSaveButton().addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { getCurrDocBean().saveDocumentWrapper(getCurrDoc()); getCurrDoc().setEditMode(false); getCurrDoc().setReadOnly(true); getBeanFields().setReadOnly(true); getSaveButton().setVisible(false); getEditButton().setVisible(true); } }); setEditButton(new Button("Edit")); getEditButton().addStyleName(ValoTheme.BUTTON_PRIMARY); getEditButton().setIcon(FontAwesome.EDIT); getEditButton().setVisible(!getCurrDoc().isEditable()); getEditButton().addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { getCurrDoc().setEditMode(true); getCurrDoc().setReadOnly(false); getBeanFields().setReadOnly(false); getEditButton().setVisible(false); getSaveButton().setVisible(true); } }); final Button cancelButton = new Button("Cancel"); cancelButton.addStyleName(ValoTheme.BUTTON_QUIET); cancelButton.setIcon(FontAwesome.UNDO); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { MainUI.get().getNavigator().navigateTo(MainView.VIEW_NAME); } }); buttonRow.addComponents(getEditButton(), getSaveButton(), cancelButton); getEditForm().addComponents(t1, d1, ta1, getCustomerCombo(), getContactCombo(), buttonRow); addComponent(editForm); }