1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
| /*
* WindowAddAssociation.java
*
* Created on 19 mars 2007, 16:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package agl;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
/**
*
* @author Anthony
*/
public class WindowAddAssociation extends JFrame implements ActionListener{
private Agl a = null;
private JPanel conteneur=null;
private JPanel choixEntite=null;
private JPanel association=null;
private JPanel barre=null;
private JPanel milieu=null;
private JButton ok_ajout;
private JButton non_ajout;
private JButton enlever_entite;
private JButton ajout_entite;
private JButton ajout_attribut;
private JLabel titre;
private JTextField text;
private JList list;
MonModel l = new MonModel();
MonModel l2 = new MonModel();
/** Creates a new instance of WindowAddAssociation */
public WindowAddAssociation(Agl a,CollectionEntite col) throws SQLException {
this.a=a;
conteneur=new JPanel();
this.setContentPane(conteneur);
this.setTitle("AGL-Ajout d'une Association");
conteneur.setLayout(null);
this.setSize(700,600);
this.setLocationRelativeTo(null);
this.setResizable(false);
choixEntite=new JPanel();
choixEntite.setLayout(null);
choixEntite.setBorder(new TitledBorder("Choix Entité"));
choixEntite.setBounds(5,5,285,495);
conteneur.add(choixEntite);
association=new JPanel();
association.setLayout(null);
association.setBorder(new TitledBorder("Association"));
association.setBounds(405,5,285,495);
conteneur.add(association);
barre=new JPanel();
barre.setLayout(null);
barre.setBounds(5,500,685,65);
conteneur.add(barre);
milieu=new JPanel();
milieu.setLayout(null);
milieu.setBounds(290,5,120,495);
conteneur.add(milieu);
this.setVisible(true);
ok_ajout=new JButton("ok");
ok_ajout.setBounds(150,20,100,25);
ok_ajout.setForeground(Color.black);
ok_ajout.setBackground(Color.WHITE);
ok_ajout.addActionListener(this) ;
barre.add(ok_ajout);
non_ajout=new JButton("annuler");
non_ajout.setBounds(450,20,100,25);
non_ajout.setForeground(Color.black);
non_ajout.setBackground(Color.WHITE);
non_ajout.addActionListener(this) ;
barre.add(non_ajout);
ajout_entite=new JButton(">>");
ajout_entite.setBounds(10,140,100,25);
ajout_entite.setForeground(Color.black);
ajout_entite.setBackground(Color.WHITE);
ajout_entite.addActionListener(this) ;
milieu.add(ajout_entite);
enlever_entite=new JButton("<<");
enlever_entite.setBounds(10,340,100,25);
enlever_entite.setForeground(Color.black);
enlever_entite.setBackground(Color.WHITE);
enlever_entite.addActionListener(this) ;
milieu.add(enlever_entite);
titre = new JLabel() ;//On crée notre objet
titre.setText("Liste Entité : ");
titre.setBounds(113,20,80,25);
choixEntite.add(titre);
CollectionEntite c = col;
for (int i=0;i<c.tab.length;i++)
{
if(c.tab[2][i]=="oui")//si elle est affiché
{
Entite E = (Entite) c.tab[1][i];
l.ajouterElement(E.Titre);
}
}
list=new JList(l);//il faut mettre les entités affichées dedans
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setBounds(10,50,265,435);
choixEntite.add(list);
titre=new JLabel();
titre.setText("Nom de l'association :");
titre.setBounds(10,20,130,25);
association.add(titre);
text=new JTextField();
text.setText("Association");
text.setBounds(140,20,135,21);
association.add(text);
titre=new JLabel();
titre.setText("Entités ajoutées :");
titre.setBounds(92,50,100,25);
association.add(titre);
list=new JList(l2);//il faut mettre les entités associé dedans
list.setBounds(10,80,265,320);
association.add(list);
titre=new JLabel();
titre.setText("Attribut :");
titre.setBounds(123,415,70,25);
association.add(titre);
ajout_attribut=new JButton("Ajouter Attribut");
ajout_attribut.setBounds(85,450,120,25);
ajout_attribut.setForeground(Color.black);
ajout_attribut.setBackground(Color.WHITE);
ajout_attribut.addActionListener(this) ;
association.add(ajout_attribut);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==non_ajout)
this.dispose();
if (e.getSource()==ajout_entite)
{
int index= list.getSelectedIndex();
Object o = l.getElementAt(index);
l.supprimerElement(index);
l2.ajouterElement(o);
}
}
} |
Partager