com.save.area.DeleteAreaWindow.java Source code

Java tutorial

Introduction

Here is the source code for com.save.area.DeleteAreaWindow.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 com.save.area;

import com.save.abstractclasses.AbstractWindow;
import com.save.common.CommonComboBox;
import com.save.service.AreaService;
import com.save.area.serviceprovider.AreaServiceImpl;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Notification;
import com.vaadin.ui.VerticalLayout;

/**
 *
 * @author jetdario
 */
public class DeleteAreaWindow extends AbstractWindow implements Button.ClickListener {

    AreaService as = new AreaServiceImpl();
    CommonComboBox cbox = new CommonComboBox();

    ComboBox area = cbox.areas();

    public DeleteAreaWindow() {
        setCaption("DELETE AREA");
        setWidth("250px");
        setResizable(false);

        setContent(getLayout());
        getContent().setHeightUndefined();
    }

    VerticalLayout getLayout() {
        VerticalLayout vlayout = new VerticalLayout();
        vlayout.setSizeFull();
        vlayout.setMargin(true);
        vlayout.setSpacing(true);

        vlayout.addComponent(area);

        Button deleteBtn = new Button("DELETE", this);
        deleteBtn.setWidth("100%");
        vlayout.addComponent(deleteBtn);

        return vlayout;
    }

    @Override
    public void buttonClick(Button.ClickEvent event) {
        if (area.getValue() == null) {
            Notification.show("Select Area to Delete", Notification.Type.WARNING_MESSAGE);
            return;
        }

        boolean result = as.deleteArea((int) area.getValue(), area.getItemCaption(area.getValue()));
        if (result) {
            close();
        }
    }

}