KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.*;
8
9 import java.awt.event.*;
10 import java.awt.*;
11 import java.util.*;
12
13 import cve.osservatori.*;
14 import cve.core.elementLDL.*;
15 import cve.core.elementEEL.*;
16 import cve.util.*;
17 import cve.staticLayout.*;
18
19 import interactionGraphics.*;
20
21 import org.apache.log4j.Logger;
22
23 import wippog.*;
24
25 /**
26 * Servizio OACEsecSemantic dedicata alla configurazione della Sentenza
27 *
28 * @author Francesco Guerrisi
29 */

30 public class ConfigurationFrame extends GenericFrame
31 implements ItemListener,ActionListener, ChangeListener {
32    private OACesecSemantic oac;
33
34    //GENERAL
35
private JTabbedPane tab;
36    private JPanel jpanelButton;
37    private JButton b_save_semantic, b_cancel_semantic, b_selActivator;
38
39    //PRE-CONFIGURAZIONE
40
private JPanel jpanelSemantic, jpanelSemanticO, jpanelSemanticS;
41
42    private JLabel jl_orientation;
43    private JComboBox cb_orientation;
44    private String JavaDoc[] values_orientation = {"TOKEN","HOLDER"};
45
46    //POST-CONFIGURAZIONE
47
private JPanel jpanelSemantic2, jpanelSemanticF, jpanelSemanticA, jpanelSemanticCenter2;
48
49    private JLabel jl_fase;
50    private JComboBox cb_fase;
51    private String JavaDoc[] values_fase = {"CREATION","INIZIALIZE","EXECUTION"};
52    private int ifase;
53    final private static int CREATION=1;
54    final private static int INITIALIZE=2;
55    final private static int EXECUTION=3;
56
57    private JLabel jl_activator, l_activator;
58    private JComboBox cb_activator;
59    private String JavaDoc[] values_activator = {"StepActivator","SeqActivator"};
60    private String JavaDoc activator;
61
62    public ConfigurationFrame(String JavaDoc Title, String JavaDoc iconPath) {
63       super(Title, iconPath);
64       Cve.errLog.debug("");
65    };
66
67    //Il Costruttore è rimandato al Padre
68
//Inizializzazione Pannello di Configurazione
69
public void init() {
70
71       //****Inizializzazione TAB di Contenimento
72
tab= new JTabbedPane(JTabbedPane.BOTTOM);
73       tab.setBackground(Color.white);
74
75       //*****FOLDER PRE-CONFIGURATION
76
jpanelSemantic = new JPanel();
77       jpanelSemantic.setLayout(new GridLayout(2,1));
78
79       //Panel Orientation
80
jpanelSemanticO = new JPanel();
81       jpanelSemanticO.setLayout(new FlowLayout());
82       jl_orientation = new JLabel("Orientation: ");
83       cb_orientation = new JComboBox(values_orientation);
84       cb_orientation.setSelectedIndex(oac.getOrientation()-1);
85
86       jpanelSemanticO.add(jl_orientation);
87       jpanelSemanticO.add(cb_orientation);
88
89       jpanelSemantic.add(jpanelSemanticO);
90
91       //Creazione TAB PRE-CONFIGURAZIONE
92
tab.add("Pre-Configuration",jpanelSemantic);
93
94       //*****FOLDER POST-CONFIGURATION
95
jpanelSemantic2 = new JPanel();
96       jpanelSemanticF = new JPanel();
97       jpanelSemanticA = new JPanel();
98
99       jpanelSemanticCenter2 = new JPanel();
100
101       //jpanelSemantic2.setLayout(new BorderLayout());
102
jpanelSemantic2.setLayout(new GridLayout(1,1));
103       jpanelSemanticF.setLayout(new FlowLayout());
104       jpanelSemanticA.setLayout(new FlowLayout());
105
106       jpanelSemanticCenter2.setLayout(new GridLayout(2,1));
107
108       //FASE
109
jl_fase = new JLabel("Manipolation Fase: ");
110       cb_fase = new JComboBox(values_fase);
111       ifase = oac.getFase();
112       cb_fase.setSelectedIndex(ifase-1);
113       cb_fase.addActionListener(this);
114
115       jpanelSemanticF.add(jl_fase);
116       jpanelSemanticF.add(cb_fase);
117
118       //ACTIVATOR
119
jl_activator = new JLabel("Activator Semantic: ");
120       //cb_activator = new JComboBox(values_activator);
121
activator = oac.getActivator();
122       l_activator = new JLabel(activator);
123
124       b_selActivator = new JButton("select");
125       b_selActivator.addActionListener(this);
126       b_selActivator.setEnabled(false);
127
128       jpanelSemanticA.add(jl_activator);
129       //jpanelSemanticA.add(cb_activator);
130
jpanelSemanticA.add(l_activator);
131       jpanelSemanticA.add(b_selActivator);
132       jpanelSemanticCenter2.add(jpanelSemanticF);
133       jpanelSemanticCenter2.add(jpanelSemanticA);
134       jpanelSemantic2.add(jpanelSemanticCenter2,BorderLayout.CENTER);
135
136       //Inserimento in Tab
137
tab.add("Post-Configuration",jpanelSemantic2);
138
139       //****************PULSANTI DI COMANDO
140
jpanelButton = new JPanel();
141       jpanelButton.setLayout(new GridLayout(1,2));
142       ImageIcon iconsave = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//SAVE.gif");
143       b_save_semantic = new JButton("Save",iconsave);
144       b_save_semantic.addActionListener(this);
145       ImageIcon iconcancel = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//CANCEL.gif");
146       b_cancel_semantic = new JButton("Cancel", iconcancel);
147       b_cancel_semantic.addActionListener(this);
148       jpanelButton.add(b_save_semantic);
149       jpanelButton.add(b_cancel_semantic);
150
151       //******Abilitazione Tab
152
//PRE-CONFIG
153
if (oac.getSemanticFlag()) {
154          tab.setEnabledAt(0, false);
155          tab.setEnabledAt(1, true);
156          //Seleziono il primo pannello utile
157
tab.setSelectedIndex(1);
158       } else {
159          tab.setEnabledAt(0, true);
160          tab.setEnabledAt(1, false);
161          tab.setSelectedIndex(0);
162       }
163
164       //******Abilitazione Impostazione Info in base alla Fase
165
if (ifase == EXECUTION) {
166          b_selActivator.setEnabled(true);
167       } else {
168          b_selActivator.setEnabled(false);
169       }
170
171       this.getContentPane().add(tab,BorderLayout.CENTER);
172       this.getContentPane().add(jpanelButton,BorderLayout.SOUTH);
173
174       repaint();
175    }
176
177    //Inizializzazione Osservatore
178
public void setOAC(OACesecSemantic oac_in){
179       Cve.errLog.debug("");
180       this.oac = oac_in;
181    }
182
183    //GESTIONE EVENTI
184

185    /** Gestione Eventi cambio di Stato Oggetti Maschera
186    * @param ItemEvent Evento Oggetto
187    */

188    public void itemStateChanged(ItemEvent e) {
189       Cve.errLog.debug("");
190    }
191
192    /** Gestione Evento Pulsanti
193    * @param e Azione Evento
194    */

195    public void actionPerformed(ActionEvent e) {
196       Cve.errLog.debug("");
197       /////INTERAZIONE IN MASCHERA
198
//CAMBIO FASE
199
if (e.getSource().equals(cb_fase)) {
200          String JavaDoc appo_fase = (String JavaDoc)cb_fase.getSelectedItem();
201          if (appo_fase.equals("EXECUTION")){
202             b_selActivator.setEnabled(true);
203          } else {
204             b_selActivator.setEnabled(false);
205          }
206
207          repaint();
208       }
209
210       //----------PRE - Semantic
211
if (e.getSource().equals(b_selActivator)) {
212          activator = selectActivator();
213          l_activator.setText(activator);
214          repaint();
215       }
216
217       /////PULSANTI DI COMANDO
218
//----------PRE - Semantic
219
if (e.getSource().equals(b_save_semantic)) {
220          if (oac != null){
221             //ORIENTATION
222
String JavaDoc orientation_value = (String JavaDoc)cb_orientation.getSelectedItem();
223             int ori_int = cb_orientation.getSelectedIndex();
224             System.out.println("Orientazione selezionata : " + orientation_value);
225             //Impostazione in Osservatore
226
oac.setOrientation(ori_int+1);
227             //Abilitazione Pulsanti (solo nel caso in cui lo stato è Pre-Configurazione)
228
if (tab.isEnabledAt(1)==true) {
229                //FASE
230
String JavaDoc fase_value = (String JavaDoc)cb_fase.getSelectedItem();
231                int fase_int = cb_fase.getSelectedIndex()+1;
232                System.out.println("Fase selezionata : " + fase_value);
233                if (fase_int==1){
234                   oac.enableCreate();
235                }
236                if (fase_int==2) {
237                   oac.enableInit();
238                }
239                if (fase_int==3) {
240                   oac.enableExecution();
241                }
242                //Impostazione in Osservatore
243
oac.setFase(fase_int);
244
245                //Abilitazione/Disabilitazione Pulsanti
246
if (fase_int!=1) {
247                   //Verifica che non siano già stati disabilitati
248
if (oac.getDisButton() == false){
249                      //Disabilitazione Pulsanti
250
oac.disableButton();
251                   }
252                } else {
253                   oac.setStateButton(oac.getDisabledButton(),false);
254                }
255             } //in Post-configuration
256

257             //Imnpostazione Attivatore
258
oac.setActivator(activator);
259          } //oac !=null
260
oac.setConfigFrameOpen(false);
261          dispose();
262       }
263
264       //----------POST - Semantic
265
if (e.getSource().equals(b_cancel_semantic)) {
266          oac.setConfigFrameOpen(false);
267          dispose();
268       }
269    }
270
271    //---------------------------------------------
272
/** Evento Cambio Valore Slider
273    * @param changeevent Evento Cambio Valore Slider
274    */

275    public void stateChanged(ChangeEvent changeevent) {
276       Cve.errLog.debug("");
277       /*
278       if (changeevent.getSource().equals(jslider14)) {
279       //Cambio Velocità
280       w_trace("stateChanged : Simulated Speed " + jslider14.getValue());
281
282       //Aggiorno Label
283       Global.setSimulatedTimeDelay(jslider14.getValue());
284       label34.setText(String.valueOf(Global.getSimulatedTimeDelay()));
285       }
286       */

287    }
288
289    /**
290    * Variazione tipo di Attivatore
291    */

292    private String JavaDoc selectActivator()
293    {
294       Cve.errLog.debug("");
295       //Apertura finestra selezione Attivatore
296
JFileChooser chooser = new JFileChooser();
297       chooser.setCurrentDirectory(new File( ConfigurationRead.getCveRoot() + "//lib//wippog//activator" ));
298       javax.swing.filechooser.FileFilter JavaDoc filter = new ClassFileFilter("class","Java Class files (*.class)");
299       chooser.addChoosableFileFilter( filter );
300       chooser.setFileFilter(filter);
301
302       int result = chooser.showOpenDialog(this);
303       if(result == JFileChooser.APPROVE_OPTION) {
304          //Prelevamento Nome della Classe
305
String JavaDoc sClassName = chooser.getSelectedFile().getName();
306          // Elimina l'estensione ".class"
307
sClassName = sClassName.substring(0,sClassName.length()-6);
308          return sClassName;
309       }
310       //Ritorno il vecchio valore
311
return activator;
312    }
313
314 }
315
Popular Tags