cz.iivos.todo.dialogs.TaskDlg.java Source code

Java tutorial

Introduction

Here is the source code for cz.iivos.todo.dialogs.TaskDlg.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.iivos.todo.dialogs;

import com.vaadin.data.Item;
import com.vaadin.data.util.sqlcontainer.SQLContainer;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

import cz.iivos.todo.components.InputFormLayout;
import cz.iivos.todo.listeners.OkCancelListener;
import cz.iivos.todo.listeners.RenewTodoListener;
import cz.iivos.todo.model.Task;

/**
 * Dialog pro editaci vlastnosti jedne ulohy
 * 
 * @author Marek Svarc
 * @author Stefan
 */
public class TaskDlg extends Window implements OkCancelListener {

    /**
     * Formul na zadvn/pravu kol.
     */
    final private InputFormLayout<Task> flInputForm;

    /**
     * Listener na obnovu zkladnho view, ze kterho se 
     * do fromulovho okna vstupuje, po vyplnn formule.
     */
    private final RenewTodoListener listener;

    //0.
    /**
     * Konstruktor.
     * 
     * @param caption nadpis okna
     * @param sqlCont sqlcontainer na kterm je postavena tabulka s koly.
     * @param item vybran poloka z SQLcontaineru (dek z tabulky).
     * @param lis Listener na obnovu view.
     */
    public TaskDlg(String caption, SQLContainer sqlCont, Item item, RenewTodoListener lis) {
        this.listener = lis;
        this.setCaption(caption);
        setModal(true);
        flInputForm = new InputFormLayout<Task>(Task.class, item, sqlCont, this);

        // obsah dialogu
        VerticalLayout content = new VerticalLayout(flInputForm);
        content.setSpacing(true);
        content.setMargin(true);

        setContent(content);
    }

    // pozri na popis OkCancelListener
    @Override
    public void doAdditionalOkAction() {
        listener.refreshTodo();
        close();
    }

    @Override
    public void doAdditionalCancelAction() {
        listener.refreshTodo();
        close();
    }

    @Override
    public void obnovFilter() {
        listener.refreshFilters();
    }

}