001: package salomeTMF_plug.requirements.ihm;
002:
003: import java.awt.Cursor;
004: import java.awt.GridLayout;
005: import java.awt.event.ActionEvent;
006: import java.awt.event.ActionListener;
007: import java.util.Observer;
008: import java.util.Vector;
009:
010: import javax.swing.JComboBox;
011: import javax.swing.JLabel;
012: import javax.swing.JPanel;
013:
014: import org.objectweb.salome_tmf.ihm.languages.Language;
015: import org.objectweb.salome_tmf.ihm.main.SalomeTMF;
016: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
017: import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
018:
019: import salomeTMF_plug.requirements.data.IReqFilter;
020:
021: public class InfoFiltrePanel extends JPanel implements ActionListener {
022:
023: JComboBox catBox;
024: Vector itemCat;
025:
026: JComboBox complexeBox;
027: Vector itemComplex;
028:
029: JComboBox stateBox;
030: Vector itemState;
031:
032: int catSelected = -1;
033: int complexSelected = -1;
034: int stateSelected = -1;
035:
036: IReqFilter m_ReqFilter;
037: FilterReqTreeModel m_FilterReqTreeModel;
038: Observer pObserver = null;
039:
040: InfoFiltrePanel(FilterReqTreeModel _FilterReqTreeModel,
041: Observer _pObserver) {
042: super ();
043: m_FilterReqTreeModel = _FilterReqTreeModel;
044: if (m_FilterReqTreeModel != null) {
045: m_ReqFilter = m_FilterReqTreeModel.getFilter();
046: }
047: pObserver = _pObserver;
048: initCompnent();
049: }
050:
051: void initCompnent() {
052: setLayout(new GridLayout(2, 3));
053: itemCat = new Vector();
054: itemCat.add(Language.getInstance().getText("Tout"));
055: itemCat.add(Language.getInstance().getText("Cat_Fonctionnel"));
056: itemCat.add(Language.getInstance().getText(
057: "Cat_Interoperabilite"));
058: itemCat.add(Language.getInstance().getText("Cat_Charge"));
059: itemCat.add(Language.getInstance().getText("Cat_Performance"));
060: itemCat
061: .add(Language.getInstance()
062: .getText("Cat_Disponibilite"));
063: itemCat.add(Language.getInstance().getText("Cat_Securite"));
064: itemCat.add(Language.getInstance()
065: .getText("Cat_Exploitabilite"));
066: itemCat.add(Language.getInstance().getText("Cat_Autre"));
067:
068: itemState = new Vector();
069: itemState.add(Language.getInstance().getText("Tout"));
070: itemState.add(Language.getInstance()
071: .getText("State_A_Analyser"));
072: itemState.add(Language.getInstance().getText("State_Analysee"));
073: itemState
074: .add(Language.getInstance().getText("State_Approuvee"));
075: itemState.add(Language.getInstance().getText("State_Verifiee"));
076: itemState
077: .add(Language.getInstance().getText("State_Finalisee"));
078: itemState.add(Language.getInstance().getText("State_Reportee"));
079: itemState.add(Language.getInstance()
080: .getText("State_Abandonnee"));
081:
082: itemComplex = new Vector();
083: itemComplex.add(Language.getInstance().getText("Tout"));
084: itemComplex.add(Language.getInstance().getText("Com_C0"));
085: itemComplex.add(Language.getInstance().getText("Com_C1"));
086: itemComplex.add(Language.getInstance().getText("Com_C2"));
087: itemComplex.add(Language.getInstance().getText("Com_C3"));
088:
089: JLabel labelCat = new JLabel(Language.getInstance().getText(
090: "Categorie")
091: + " :");
092: catBox = new JComboBox(itemCat);
093: catBox.setEditable(false);
094: catBox.addActionListener(this );
095:
096: JLabel labelComplexe = new JLabel(Language.getInstance()
097: .getText("Complexite")
098: + " :");
099: complexeBox = new JComboBox(itemComplex);
100: complexeBox.setEditable(false);
101: complexeBox.addActionListener(this );
102:
103: JLabel labelState = new JLabel(Language.getInstance().getText(
104: "Etat")
105: + " :");
106: stateBox = new JComboBox(itemState);
107: stateBox.setEditable(false);
108: stateBox.addActionListener(this );
109:
110: add(labelCat);
111: add(labelComplexe);
112: add(labelState);
113: add(catBox);
114: add(complexeBox);
115: add(stateBox);
116: //setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK),"Filtre"));
117:
118: }
119:
120: public void actionPerformed(ActionEvent e) {
121: if (e.getSource().equals(stateBox)) {
122: //stateBoxPerformed(e);
123: stateSelected = stateBox.getSelectedIndex() - 1;
124: } else if (e.getSource().equals(complexeBox)) {
125: //complexeBoxPerformed(e);
126: complexSelected = complexeBox.getSelectedIndex() - 1;
127: } else if (e.getSource().equals(catBox)) {
128: //catBoxPerformed(e);
129: catSelected = catBox.getSelectedIndex() - 1;
130: }
131: applyFilter();
132: }
133:
134: void applyFilter() {
135: if (m_ReqFilter != null) {
136: SalomeTMFContext.getInstance().getSalomeFrame().setCursor(
137: new Cursor(Cursor.WAIT_CURSOR));
138: m_ReqFilter.setInfoFiltre(catSelected, complexSelected,
139: stateSelected);
140: m_FilterReqTreeModel.setFiltered(true);
141: if (pObserver != null) {
142: pObserver.update(null, new ReqEvent(
143: ReqEvent.FILTRE_REQ_CHANGE, null));
144: }
145: SalomeTMFContext.getInstance().getSalomeFrame().setCursor(
146: new Cursor(Cursor.DEFAULT_CURSOR));
147: }
148:
149: }
150:
151: void reInit(boolean filter) {
152: catSelected = -1;
153: catBox.setSelectedIndex(0);
154: complexSelected = -1;
155: complexeBox.setSelectedIndex(0);
156: stateSelected = -1;
157: stateBox.setSelectedIndex(0);
158: if (filter) {
159: m_ReqFilter.reInit();
160: }
161: }
162:
163: public int getCatSelected() {
164: return catSelected;
165: }
166:
167: public int getComplexSelected() {
168: return complexSelected;
169: }
170:
171: public int getStateSelected() {
172: return stateSelected;
173: }
174:
175: }
|