KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cve > osservatori > servizioOACesecSemantic > ConfigElementFrame


1 package cve.osservatori.servizioOACesecSemantic;
2
3 import javax.swing.JInternalFrame JavaDoc;
4 import javax.swing.tree.*;
5 import javax.swing.*;
6 import javax.swing.event.*;
7 import javax.swing.table.*;
8
9 import java.io.*;
10
11 import java.awt.event.*;
12 import java.awt.*;
13 import java.util.*;
14
15 import cve.osservatori.*;
16 import cve.core.elementLDL.*;
17 import cve.core.elementEEL.*;
18 import cve.util.ConfigurationRead;
19 import cve.staticLayout.*;
20
21 import cve.esecutori.components.specificaSem.*;
22
23 import wippog.*;
24 import wippog.tipidato.*;
25
26 import interactionGraphics.*;
27 import org.apache.log4j.Logger;
28 import cve.staticLayout.*;
29
30 /**
31 * Servizio OACBuildSemantic dedicata all'editor delle
32 * regole WIPPOG (Semantiche)
33 * Nel costruttore prende JTextArea utilizzata
34 * Mette a disposizone il metodo statico writeLog
35 *
36 * @author Francesco Guerrisi
37 */

38
39 public class ConfigElementFrame extends GenericFrame
40 implements ItemListener,ActionListener, ChangeListener {
41    private OACesecSemantic oac;
42    private IResource item;
43    private ConfigElement config;
44
45    private JPanel jpanelItem, jpanelItemPar, jpanelAll, jpanelButton;
46    private JPanel jpanelItemPar_1, jpanelItemPar_2, jpanelItemPar_3;
47    private JLabel jl_Item, jl_token, jl_maxtoken, jl_weight;
48    private JButton b_close, b_save;
49    private JTextField t_item;
50    private JTable explorerTable;
51
52    private String JavaDoc idTipo;
53
54    private JComboBox cb_maxtoken;
55    private String JavaDoc[] num_maxtoken = {"1","2","3","4","5","6","7","8","9"};
56    private int max_token;
57    private JComboBox cb_token;
58    private String JavaDoc[] num_token = {"0","1","2","3","4","5","6","7","8","9"};
59    private JComboBox cb_weight;
60    private String JavaDoc[] num_weight = {"0","1","2","3","4","5","6","7","8","9"};
61    private String JavaDoc idIstanza;
62    private int num_tok = 0;
63    private int fase;
64    final private static int CREATION=1;
65    final private static int INITIALIZE=2;
66    final private static int EXECUTION=3;
67
68    public ConfigElementFrame(String JavaDoc Title, String JavaDoc iconPath) {
69       super(Title, iconPath);
70       Cve.errLog.debug("");
71    };
72
73
74    //Inizializzazione Osservatore
75
public void setOAC(OACesecSemantic oac_in) {
76       this.oac = oac_in;
77       Cve.errLog.debug("");
78    }
79
80    //Inizializzazione Pannello di Configurazione
81
public void init(String JavaDoc idIstanza) {
82       Cve.errLog.debug("");
83       this.idIstanza = idIstanza;
84       this.config = oac.getConfigElement(idIstanza);
85       this.fase = oac.getFase();
86
87       //Pannello di Controllo Semantico
88
jpanelAll = new JPanel();
89       jpanelItem = new JPanel();
90       jpanelItemPar = new JPanel();
91       jpanelItemPar_1 = new JPanel();
92       jpanelItemPar_2 = new JPanel();
93       jpanelItemPar_3 = new JPanel();
94       jpanelButton = new JPanel();
95
96       //jpanelSemantic.setLayout(new GridLayout(1,2));
97
jpanelAll.setLayout(new BorderLayout());
98       jpanelItem.setLayout(new FlowLayout());
99       jpanelItemPar.setLayout(new GridLayout(3,1));
100       jpanelItemPar_1.setLayout(new FlowLayout());
101       jpanelItemPar_2.setLayout(new FlowLayout());
102       jpanelItemPar_3.setLayout(new FlowLayout());
103       jpanelButton.setLayout(new GridLayout(1,2));
104
105       //------------PANNELLO PRINCIPALE
106
//----PANNELLO ITEM
107
jl_Item = new JLabel("Item");
108       t_item = new JTextField(idIstanza);
109       t_item.setEnabled(false);
110
111       jpanelItem.add(jl_Item);
112       jpanelItem.add(t_item);
113
114       //---------------------PARAMETRI DI CREATION
115
//----PANNELLO MAXTOKEN
116
jl_maxtoken = new JLabel("Max Token: ");
117       cb_maxtoken = new JComboBox(num_maxtoken);
118       String JavaDoc s_maxtoken = new String JavaDoc();
119       s_maxtoken = config.getParameter("max_token");
120       if (s_maxtoken==null) {
121          //default a 1
122
max_token = 1;
123          cb_maxtoken.setSelectedIndex(0);
124          cb_maxtoken.setEnabled(false);
125       } else {
126          max_token = (Integer.valueOf(s_maxtoken)).intValue();
127          cb_maxtoken.setSelectedIndex(max_token-1);
128          cb_maxtoken.setEnabled(true);
129       }
130       if (fase != CREATION) {
131          cb_maxtoken.setEnabled(false);
132       }
133       jpanelItemPar_1.add(jl_maxtoken);
134       jpanelItemPar_1.add(cb_maxtoken);
135
136       //----PANNELLO WEIGHT
137
jl_weight = new JLabel("Weight: ");
138       cb_weight = new JComboBox(num_weight);
139       String JavaDoc s_weight = new String JavaDoc();
140       s_weight = config.getParameter("weight");
141       if (s_weight==null) {
142          cb_weight.setSelectedIndex(0);
143          cb_weight.setEnabled(false);
144       } else {
145          cb_weight.setSelectedIndex((Integer.valueOf(s_weight)).intValue());
146          cb_weight.setEnabled(true);
147       }
148       if (fase != CREATION) {
149          cb_weight.setEnabled(false);
150       }
151       jpanelItemPar_2.add(jl_weight);
152       jpanelItemPar_2.add(cb_weight);
153
154       //--------PARAMETRI DI INIT----------------------
155
//----PANNELLO TOKEN
156
jl_token = new JLabel("n. Token: ");
157
158       //Visualizzazione solo dei token possibili in base a max_token
159
num_token = new String JavaDoc[max_token+1];
160       for(int i=0; i<=max_token;i++) {
161          num_token[i] = String.valueOf(i);
162       }
163
164       cb_token = new JComboBox(num_token);
165       String JavaDoc s_token = new String JavaDoc();
166       s_token = config.getParameter("num_token");
167       if (s_token==null) {
168          cb_token.setSelectedIndex(0);
169          cb_token.setEnabled(false);
170       } else {
171          int n_token = (Integer.valueOf(s_token)).intValue();
172          if (n_token > max_token) n_token = 0;
173          cb_token.setSelectedIndex(n_token);
174          cb_token.setEnabled(true);
175       }
176       if (oac.getFase()!=INITIALIZE) {
177          cb_token.setEnabled(false);
178       }
179
180       jpanelItemPar_3.add(jl_token);
181       jpanelItemPar_3.add(cb_token);
182
183       //----COSTRUZIONE PANNELLO PRINCIPALE PARAMETRI
184
jpanelItemPar.add(jpanelItemPar_1);
185       jpanelItemPar.add(jpanelItemPar_2);
186       jpanelItemPar.add(jpanelItemPar_3);
187
188       //----PANNELLO PULSANTI
189
ImageIcon iconsave = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//SAVE.gif");
190       b_save = new JButton("Save", iconsave);
191       b_save.addActionListener(this);
192
193       ImageIcon iconcancel = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//CANCEL.gif");
194       b_close = new JButton("Close",iconcancel);
195       b_close.addActionListener(this);
196
197       jpanelButton.add(b_save);
198       jpanelButton.add(b_close);
199
200       //-------------- POSIZIONAMENTO DI TUTTI I PANNELLI
201
jpanelAll.add(jpanelItem, BorderLayout.NORTH);
202       jpanelAll.add(jpanelItemPar, BorderLayout.CENTER);
203       jpanelAll.add(jpanelButton, BorderLayout.SOUTH);
204
205       this.getContentPane().add(jpanelAll,BorderLayout.CENTER);
206    }
207
208    //GESTIONE EVENTI
209

210    /** Gestione Eventi cambio di Stato Oggetti Maschera
211    * @param ItemEvent Evento Oggetto
212    */

213    public void itemStateChanged(ItemEvent e) {
214       Cve.errLog.debug("");
215    }
216
217    //---------------------------------------------
218
/** Gestione Evento Pulsanti
219    * @param e Azione Evento
220    */

221    public void actionPerformed(ActionEvent e) {
222       Cve.errLog.debug("");
223       //----------Semantic
224
//Save
225
if (e.getSource().equals(b_save)) {
226          if (cb_maxtoken.isEnabled()) {
227             //Impostazione Numero Token
228
int num_maxtok = cb_maxtoken.getSelectedIndex()+1;
229             System.out.println("Num.Token Selezionati : " + num_maxtok);
230             oac.updateMaxToken(idIstanza,num_maxtok);
231          }
232          if (cb_weight.isEnabled()) {
233             //Impostazione Peso dell'arco
234
int num_weight = cb_weight.getSelectedIndex();
235             System.out.println("Weight Selezionato : " + num_weight);
236             oac.updateWeight(idIstanza,num_weight);
237          }
238          if (cb_token.isEnabled()) {
239             //Impostazione Numero Token
240
int num_tok = Integer.valueOf((String JavaDoc)cb_token.getSelectedItem()).intValue();
241             System.out.println("Num.Token Selezionati : " + num_tok);
242             oac.addInternalPool(idIstanza,num_tok);
243          }
244          dispose();
245       }
246       //Chiusura
247
if (e.getSource().equals(b_close)) {
248          dispose();
249       }
250    }
251    /** Evento Cambio Valore Slider
252    * @param changeevent Evento Cambio Valore Slider
253    */

254    public void stateChanged(ChangeEvent changeevent) {
255       Cve.errLog.debug("");
256       /*
257       if (changeevent.getSource().equals(jslider14)) {
258       //Cambio Velocità
259       w_trace("stateChanged : Simulated Speed " + jslider14.getValue());
260
261       //Aggiorno Label
262       Global.setSimulatedTimeDelay(jslider14.getValue());
263       label34.setText(String.valueOf(Global.getSimulatedTimeDelay()));
264       }
265       */

266    }
267
268 }
Popular Tags