Package editor.screen.popup

Source Code of editor.screen.popup.InitSpellScreen

/*
* InitObjectScreen.java
*
* Created on 26 nov. 2011, 19:16:48
*/
package editor.screen.popup;

import beans.enumeration.Stat;
import beans.enumeration.Target;
import beans.enumeration.Utilization;
import beans.serializable.ChangeStatut;
import beans.serializable.Cost;
import beans.serializable.Spell;
import editor.model.GUIModel;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultComboBoxModel;

/**
* Fenetre de creation d'un nouvel objet
* @author Spartan
*/
public class InitSpellScreen extends javax.swing.JFrame implements ChangeStatutTemplate, CostTemplate {

    private final GUIModel guiModel;
    private List<ChangeStatut> listChangeStatut = new ArrayList<ChangeStatut>();
    private List<Cost> cost = new ArrayList<Cost>();

    /**
     * Constructeur de la fenetre
     * @param guiModel
     * @see GUIModel
     */
    public InitSpellScreen(final GUIModel guiModel) {
        this.setVisible(true);
        this.guiModel = guiModel;
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        objectNameLabel = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        SaveJButton = new javax.swing.JButton();
        annulerJButton = new javax.swing.JButton();
        objectNameLabel1 = new javax.swing.JLabel();
        description = new javax.swing.JTextField();
        objectNameLabel2 = new javax.swing.JLabel();
        objectNameLabel3 = new javax.swing.JLabel();
        target = new javax.swing.JComboBox();
        use = new javax.swing.JComboBox();
        addChangeStat = new javax.swing.JButton();
        addCost = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Editeur de sorts");
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(0, 153, 153));
        jPanel1.setPreferredSize(new java.awt.Dimension(250, 150));

        objectNameLabel.setFont(new java.awt.Font("Arial Black", 0, 11));
        objectNameLabel.setText("Nom du sort :");

        SaveJButton.setText("Sauvegarde");
        SaveJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveJButtonActionPerformed(evt);
            }
        });

        annulerJButton.setText("Fermer");
        annulerJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                annulerJButtonActionPerformed(evt);
            }
        });

        objectNameLabel1.setFont(new java.awt.Font("Arial Black", 0, 11));
        objectNameLabel1.setText("Description :");

        objectNameLabel2.setFont(new java.awt.Font("Arial Black", 0, 11));
        objectNameLabel2.setText("Type de cible :");

        objectNameLabel3.setFont(new java.awt.Font("Arial Black", 0, 11));
        objectNameLabel3.setText("type d'utilisation :");

        target.setModel(new DefaultComboBoxModel(Target.values()));

        use.setModel(new DefaultComboBoxModel(Utilization.values()));

        addChangeStat.setText("Ajouter un changement de statut");
        addChangeStat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addChangeStatActionPerformed(evt);
            }
        });

        addCost.setText("Ajouter un cout");
        addCost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addCostActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(addChangeStat)
                                .addGap(75, 75, 75)
                                .addComponent(SaveJButton)
                                .addGap(18, 18, 18)
                                .addComponent(annulerJButton))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(objectNameLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(objectNameLabel1)
                                        .addComponent(objectNameLabel2))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(target, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(description, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(objectNameLabel3)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(use, 0, 178, Short.MAX_VALUE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(addCost)))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(objectNameLabel)
                    .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(objectNameLabel1)
                    .addComponent(description, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(objectNameLabel2)
                    .addComponent(target, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(62, 62, 62)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(objectNameLabel3)
                    .addComponent(use, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addChangeStat)
                    .addComponent(SaveJButton)
                    .addComponent(annulerJButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addComponent(addCost))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SaveJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveJButtonActionPerformed
        final String sName = name.getText();
        final String sDescr = description.getText();
        final Target sTarget = (Target)target.getSelectedItem();
        final Utilization sUse = (Utilization)use.getSelectedItem();
        //TODO : Rajouter nombre de tour
        final Spell spell = new Spell (sName, sDescr, sTarget, listChangeStatut, cost, sUse, 1);
        guiModel.initSpellPopUpResponse(spell);
        this.reset();
    }//GEN-LAST:event_SaveJButtonActionPerformed

    private void annulerJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_annulerJButtonActionPerformed
        this.dispose();
    }//GEN-LAST:event_annulerJButtonActionPerformed

    private void addChangeStatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addChangeStatActionPerformed
        new InitChangeStatutScreen(this);
    }//GEN-LAST:event_addChangeStatActionPerformed

    private void addCostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCostActionPerformed
        new InitCostScreen(this);
    }//GEN-LAST:event_addCostActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton SaveJButton;
    private javax.swing.JButton addChangeStat;
    private javax.swing.JButton addCost;
    private javax.swing.JButton annulerJButton;
    private javax.swing.JTextField description;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField name;
    private javax.swing.JLabel objectNameLabel;
    private javax.swing.JLabel objectNameLabel1;
    private javax.swing.JLabel objectNameLabel2;
    private javax.swing.JLabel objectNameLabel3;
    private javax.swing.JComboBox target;
    private javax.swing.JComboBox use;
    // End of variables declaration//GEN-END:variables

    @Override
    public void addChangeStatut(final ChangeStatut changeStatut) {
        this.listChangeStatut.add(changeStatut);
    }
    @Override
    public void addCost(final Stat stat, final Integer impact) {
        this.cost.add(new Cost(stat, impact));
    }

    private void reset() {
        this.name.setText("");
        this.description.setText("");
        this.target.setSelectedIndex(1);
        this.use.setSelectedIndex(1);
        this.listChangeStatut.clear();
        this.cost.clear();
    }
}
TOP

Related Classes of editor.screen.popup.InitSpellScreen

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.