Package cari.gui

Source Code of cari.gui.PSAMusteriSecimEkrani

package cari.gui;

import hibernateSwingApi.component.TablePanel;
import hibernateSwingApi.hibernate.HibernateManager;

import java.awt.Container;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.LayoutStyle.ComponentPlacement;

import service.AutoClosingMessageDialog;
import service.PSAUtil;
import cari.pojos.Musteri;

public class PSAMusteriSecimEkrani extends JDialog {

  private static final long serialVersionUID = 1L;

  private JButton jButtonIptal;
  private Musteri musteri;
  private Container contentPane;
  private JButton jButtonMusteriEkle;
  private TablePanel cTablePanelMusteri;
  private JButton jBUttonMusteriSec;

  public PSAMusteriSecimEkrani(Frame owner) {
    super(owner, true);
    setResizable(false);
    setModal(false);
    setModalityType(ModalityType.DOCUMENT_MODAL);
    setTitle("PSA MÜŞTERİ SECİM EKRANI");
    setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
        .getImage());
    contentPane = getContentPane();
    contentPane.setBounds(100, 100, 470, 300);

    jButtonIptal = new JButton("İPTAL");
    jButtonIptal.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/geriButonu.png"));

    jButtonIptal.setFont(new Font("Tahoma", Font.BOLD, 12));
    jButtonIptal.setBounds(70, 273, 144, 23);

    jButtonMusteriEkle = new JButton("YENİ MÜŞTERİ EKLE");
    jButtonMusteriEkle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/ekle.png"));
    jButtonMusteriEkle.setFont(new Font("Tahoma", Font.BOLD, 12));

    cTablePanelMusteri = new TablePanel((String) null, Musteri.class);
    cTablePanelMusteri.getRaporButton().setVisible(false);

    jBUttonMusteriSec = new JButton("SEÇ");
    jBUttonMusteriSec.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/onay.png"));
    jBUttonMusteriSec.setFont(new Font("Tahoma", Font.BOLD, 12));
    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout
        .setHorizontalGroup(groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(
                                Alignment.LEADING)
                            .addComponent(
                                cTablePanelMusteri,
                                GroupLayout.DEFAULT_SIZE,
                                589,
                                Short.MAX_VALUE)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        jButtonIptal,
                                        GroupLayout.DEFAULT_SIZE,
                                        291,
                                        Short.MAX_VALUE)
                                    .addGap(7)
                                    .addComponent(
                                        jBUttonMusteriSec,
                                        GroupLayout.PREFERRED_SIZE,
                                        291,
                                        GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            .addGroup(
                Alignment.TRAILING,
                groupLayout
                    .createSequentialGroup()
                    .addGap(308)
                    .addComponent(jButtonMusteriEkle,
                        GroupLayout.DEFAULT_SIZE, 291,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addGap(13)
            .addComponent(jButtonMusteriEkle,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cTablePanelMusteri,
                GroupLayout.PREFERRED_SIZE, 386,
                GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(
                groupLayout
                    .createParallelGroup(Alignment.LEADING)
                    .addComponent(jButtonIptal,
                        GroupLayout.DEFAULT_SIZE, 41,
                        Short.MAX_VALUE)
                    .addComponent(jBUttonMusteriSec,
                        GroupLayout.PREFERRED_SIZE, 41,
                        GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
    getContentPane().setLayout(groupLayout);

    refreshTable();
    initListener();
    pack();
  }

  @SuppressWarnings("unchecked")
  private void refreshTable() {
    List<Musteri> musteriListesi = (List<Musteri>) HibernateManager
        .getInstance().getWithCriteria(Musteri.class, "musteriGrubu",
            "MUSTERI", false);
    cTablePanelMusteri.setObjects(musteriListesi);
  }

  private void initListener() {

    addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        closeFrame();

      }
    });

    cTablePanelMusteri.getTable().addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        if (e.getClickCount() == 2) {
          musteriSecClicked();
        }
      }
    });

    jBUttonMusteriSec.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        musteriSecClicked();
      }
    });

    jButtonIptal.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        closeFrame();
      }
    });

    jButtonMusteriEkle.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        musteriEkleClicked();
      }
    });
  }

  protected void musteriSecClicked() {
    musteri = (Musteri) cTablePanelMusteri.getSelectedObject();
    if (musteri == null) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "Musteri seçiniz.", 2);
      return;
    }
    dispose();
  }

  protected void closeFrame() {
    musteri = null;
    dispose();
  }

  protected void musteriEkleClicked() {
    PSAMusteriEklemeEkrani.getInstance(2).setVisible(true);
  }

  public Musteri showDialog() {
    setVisible(true);
    return musteri;
  }
}
TOP

Related Classes of cari.gui.PSAMusteriSecimEkrani

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.