/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mobirent.gui;

import com.mobirent.abstracttags.Epitomize;
import com.mobirent.datacollector.Customer;
import gr.bluevibe.fire.components.Component;
import gr.bluevibe.fire.components.Panel;
import gr.bluevibe.fire.components.Row;
import gr.bluevibe.fire.displayables.FireScreen;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Font;

/**
 *
 * @author Budai Attila
 */
public class RePanel extends Epitomize {

    private Command exit = new Command("Kilépés", Command.BACK, 0);
    private Command cancel = new Command("Vissza", Command.OK, 0);
    private static RePanel INSTANCE;
    private Panel panel;
    private String kerd;
    private String id;

    private RePanel() {
        panel = getRePanel();
    }

    public Panel getPanel() {
        return panel;
    }

    public void setId(String id) {
        this.id = id;
    }

    private Panel getRePanel() {
        Panel p = new Panel();



        p.addCommand(exit);


        p.setCommandListener(this);
        return p;
    }

    public void setupRePanel(Customer data) {


        Row e4 = new Row();

        e4.setLabel(data.getName(), FireScreen.defaultLabelFont, new Integer(screen.getWidth() / 1), FireScreen.LEFT);

        e4.setEditable(false);
        e4.setIs(true);
        panel.add(e4);

        Row e3 = new Row();
        e3.setLabel(data.getAddress(), FireScreen.defaultLabelFont, new Integer(screen.getWidth() / 1), FireScreen.LEFT);
        e3.setEditable(false);
        e3.setIs(false);
        panel.add(e3);

        Row e2 = new Row();
        e2.setLabel(data.getPhone(), FireScreen.defaultLabelFont, new Integer(screen.getWidth() / 1), FireScreen.LEFT);
        e2.setEditable(false);
        e2.setIs(false);
        panel.add(e2);

        panel.add(new Row());
        panel.add(new Row());
        panel.add(getChoose1("Jelentés", Font.STYLE_BOLD));


    }

    public void setKerd(String kerd) {
        this.kerd = kerd;
    }

    public String getKerd() {
        return kerd;
    }

    public static RePanel getINSTANCE() {
        if (INSTANCE == null) {
            INSTANCE = new RePanel();
        }
        return INSTANCE;
    }

    public void commandAction(Command cmd, Component c) {
        if (cmd == choose1) {

            Epitomize.threadWait();

            new Thread(new Runnable() {

                public void run() {

                    AnswerPanel gap = AnswerPanel.getInstance();

                    gap.setLabelem("Visszavivendőek");

                    gap.setData(id);

                    gap.panelSetup();

                    screen.setCurrent(gap.getPanel(), FireScreen.RIGHT);

                    screen.closePopup();

                }
            }).start();

            return;
        }

        if (cmd == exit) {

            putSessionId2RecordStore();

            myMidlet.exit();
        }
    }
}


