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
|
/*
* Copyright (c) 2002-2004 OSLO All Rights Reserved
* This software is the confidential and proprietary information
* of OSLO. (Confidential Information). You shall not
* disclose such Confidential Information and shall use it only
* in accordance with the terms of the licence agreement you
* entered into with OSLO
*
* Created on 27 mai 2004
*
* @author <a href="mailto:noel.perez@oslo.fr">Perez Noël</a><br> web site:<a href="http://www.oslo.fr">http://www.oslo.fr</a>
*/
package com.oslo.logistique.ui.structure.proprietesZL;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import com.borland.jbcl.layout.VerticalFlowLayout;
import com.oslo.logistique.structure.agents.*;
import com.oslo.logistique.structure.gamme.Etape;
import com.oslo.logistique.structure.gamme.ProduitIntermediaire;
import com.oslo.logistique.structure.*;
import com.oslo.macro.framework.ui.Propriete;
/**
* @author qsiraut
*/
public class PanelActivite extends JPanel implements ItemListener, TableModelListener
{
Vector colsTableProduits = new Vector();
Vector rowsTableProduits = new Vector();
int [] colEditablesTableProduits = {0,1};
ZoneLogistique zone;
Hashtable etapes = new Hashtable();
JPanel panelPrincipal = new JPanel();
JPanel panelEtape = new JPanel();
JPanel panelProduits = new JPanel();
JScrollPane jScrollPaneTableProduits = new JScrollPane();
JLabel jLblEtape = new JLabel();
JComboBox jCbEtape = new JComboBox();
JTable jTableProduits;
/**
* @return Returns the zone.
*/
public ZoneLogistique getZone()
{
return zone;
}
/**
* @param zone The zone to set.
*/
public void setZone(ZoneLogistique zone)
{
this.zone = zone;
}
public PanelActivite(Propriete properties, ZoneLogistique zl)
{
super();
init(properties, zl);
}
private void init(Propriete properties, ZoneLogistique zl)
{
setZone(zl);
this.setLayout(new BorderLayout());
panelPrincipal.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), properties.getApplicationLabel("ProprietesZoneLogistiqueDialog_ongletActivite_cadrePrincipal_titre")));
this.add(panelPrincipal, BorderLayout.CENTER);
panelPrincipal.setLayout(new VerticalFlowLayout());
panelEtape.setLayout(new FlowLayout(FlowLayout.LEFT));
jLblEtape.setText(properties.getApplicationLabel("ProprietesZoneLogistiqueDialog_ongletActivite_labelEtape"));
panelEtape.add(jLblEtape);
chargerComboboxEtapes(zl);
panelEtape.add(jCbEtape);
panelPrincipal.add(panelEtape);
panelProduits.setLayout(new BorderLayout());
jTableProduits = new JTable();
colsTableProduits = getColonnes(properties.getApplicationLabel("ProprietesZoneLogistiqueDialog_ongletActivite_cadrePrincipal_tableau_colonnes"));
jTableProduits.setModel(new TableModelPersonnalise(colsTableProduits, rowsTableProduits, colEditablesTableProduits));
initialiserTableauProduits();
jScrollPaneTableProduits.getViewport().add(jTableProduits);
jScrollPaneTableProduits.setPreferredSize(new Dimension(400,100));
panelProduits.add(jScrollPaneTableProduits, BorderLayout.CENTER);
panelPrincipal.add(panelProduits);
jCbEtape.addItemListener(this);
jTableProduits.getModel().addTableModelListener(this);
}
private Vector getColonnes(String propertie)
{
Vector tmp = new Vector();
String[] temp = propertie.split(";");
for(int i=0; i<temp.length;i++)
{
tmp.add(temp[i]);
}
return tmp;
}
private void chargerComboboxEtapes(ZoneLogistique zl)
{
Enumeration enumRessourcesZone = zl.getMesTypesRessources().elements();
while(enumRessourcesZone.hasMoreElements())
{
RessourceZone rz = (RessourceZone)enumRessourcesZone.nextElement();
Enumeration enumEtapesRessource = rz.getMesProductionsRealisables().elements();
while(enumEtapesRessource.hasMoreElements())
{
Production prod = (Production)enumEtapesRessource.nextElement();
if(prod.getTypeProduction() == Production.PRODUCTION_GAMME)
{
ProductionGamme prodGamme = (ProductionGamme)prod;
if(etapes.get(prodGamme.getEtape().getNom()) == null)
{
etapes.put(prodGamme.getEtape().getNom(), prodGamme.getEtape());
jCbEtape.addItem(prodGamme.getEtape().getNom());
}
}
}
}
}
public void itemStateChanged(ItemEvent e)
{
if(e.getStateChange() == ItemEvent.SELECTED)
{
JComboBox c = (JComboBox)e.getSource();
Etape etape = (Etape)etapes.get(c.getSelectedItem().toString());
System.out.println("Etape sélectionnée : "+etape.getNom()+" nbProduits en sortie : "+etape.getProduitSortie().size());
remplirTableauProduits(etape);
}
}
public void tableChanged(TableModelEvent e)
{
System.out.println("une valeur a changée");
}
public void initialiserTableauProduits()
{
if(etapes.size() > 0)
{
Etape etape = (Etape)etapes.elements().nextElement();
remplirTableauProduits(etape);
}
}
public void remplirTableauProduits(Etape etape)
{
Vector contenu = new Vector();
for(int i=0; i<etape.getProduitSortie().size(); i++)
{
Vector ligne = new Vector();
ProduitIntermediaire prod = (ProduitIntermediaire)etape.getProduitSortie().get(i);
ligne.add(prod.getNom());
if(getZone().getMesProduitsIntermediairesSortants().get("pi-"+prod.getIdentifiant()) != null)
{
ligne.add(new Boolean("true"));
}
else
{
ligne.add(new Boolean("false"));
}
contenu.add(ligne);
}
jTableProduits.setModel(new TableModelPersonnalise(colsTableProduits, contenu, colEditablesTableProduits));
jTableProduits.getModel().addTableModelListener(this);
}
} |
Partager