KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cve > osservatori > servizioOACBuildSemantic > ConfigurationSemantic


1 package cve.osservatori.servizioOACBuildSemantic;
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 import interactionGraphics.*;
19
20 import wippog.*;
21
22 import org.apache.log4j.Logger;
23
24 /**
25 * Servizio OACEsecSemantic dedicata alla configurazione della Sentenza
26 *
27 * @author Francesco Guerrisi
28 */

29 public class ConfigurationSemantic extends GenericFrame
30 implements ItemListener,ActionListener, ChangeListener {
31    private OACBuildSemantic oac;
32
33    //GENERAL
34
private JPanel jpanelButton;
35    private JButton b_save_semantic, b_cancel_semantic, b_selTraslation;
36
37    //POST-CONFIGURAZIONE
38
private JPanel jpanelSemantic2, jpanelSemanticF, jpanelSemanticA, jpanelSemanticCenter2;
39
40    private JLabel jl_traslation, l_traslation;
41    private JComboBox cb_traslation;
42    //private String[] values_activator = {"StepActivator","SeqActivator"};
43
private String JavaDoc traslationClass;
44
45    public ConfigurationSemantic(String JavaDoc Title, String JavaDoc iconPath){
46       super(Title, iconPath);
47       Cve.errLog.debug("");
48    };
49
50    //Il Costruttore è rimandato al Padre
51

52    //Inizializzazione Pannello di Configurazione
53
public void init(){
54
55       Cve.errLog.debug("");
56       jpanelSemantic2 = new JPanel();
57       jpanelSemanticF = new JPanel();
58       jpanelSemanticA = new JPanel();
59
60       jpanelSemanticCenter2 = new JPanel();
61
62       //jpanelSemantic2.setLayout(new BorderLayout());
63
jpanelSemantic2.setLayout(new GridLayout(1,1));
64       jpanelSemanticA.setLayout(new FlowLayout());
65
66       jpanelSemanticCenter2.setLayout(new GridLayout(2,1));
67
68       //ACTIVATOR
69
jl_traslation = new JLabel("Semantic Traslation: ");
70       traslationClass = oac.getTranslationSemantic();
71       l_traslation = new JLabel(traslationClass);
72
73       b_selTraslation = new JButton("select");
74       b_selTraslation.addActionListener(this);
75       b_selTraslation.setEnabled(true);
76
77       jpanelSemanticA.add(jl_traslation);
78       //jpanelSemanticA.add(cb_activator);
79
jpanelSemanticA.add(l_traslation);
80       jpanelSemanticA.add(b_selTraslation);
81
82       jpanelSemanticCenter2.add(jpanelSemanticA);
83
84       jpanelSemantic2.add(jpanelSemanticCenter2,BorderLayout.CENTER);
85
86       //****************PULSANTI DI COMANDO
87
jpanelButton = new JPanel();
88       jpanelButton.setLayout(new GridLayout(1,2));
89
90       ImageIcon iconsave = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//SAVE.gif");
91
92       b_save_semantic = new JButton("Save",iconsave);
93       b_save_semantic.addActionListener(this);
94
95       ImageIcon iconcancel = new ImageIcon(ConfigurationRead.getCveRoot() + "//resource//CANCEL.gif");
96
97       b_cancel_semantic = new JButton("Cancel", iconcancel);
98       b_cancel_semantic.addActionListener(this);
99
100       jpanelButton.add(b_save_semantic);
101       jpanelButton.add(b_cancel_semantic);
102       this.getContentPane().add(jpanelSemantic2,BorderLayout.CENTER);
103       this.getContentPane().add(jpanelButton,BorderLayout.SOUTH);
104
105       repaint();
106
107    }
108
109    //Inizializzazione Osservatore
110
public void setOAC(OACBuildSemantic oac_in){
111       Cve.errLog.debug("");
112       this.oac = oac_in;
113    }
114
115    //GESTIONE EVENTI
116

117    //---------------------------------------------
118
/** Gestione Eventi cambio di Stato Oggetti Maschera
119    * @param ItemEvent Evento Oggetto
120    */

121    public void itemStateChanged(ItemEvent e) {
122       Cve.errLog.debug("");
123    }
124
125    //---------------------------------------------
126
/** Gestione Evento Pulsanti
127    * @param e Azione Evento
128    */

129    public void actionPerformed(ActionEvent e) {
130
131       Cve.errLog.debug("");
132       /////INTERAZIONE IN MASCHERA
133
//----------PRE - Semantic
134
if (e.getSource().equals(b_selTraslation)) {
135          traslationClass = selectTraslation();
136          l_traslation.setText(traslationClass);
137          repaint();
138       }
139
140       /////PULSANTI DI COMANDO
141
//----------PRE - Semantic
142
if (e.getSource().equals(b_save_semantic)) {
143          if (oac != null){
144             System.out.println("Traduzione Semantica selezionata : " + traslationClass);
145             //Impostazione in Osservatore
146
oac.setTranslationSemantic(traslationClass);
147             oac.setConfigFrameOpen(false);
148          }
149          dispose();
150       }
151       //----------Exit
152
if (e.getSource().equals(b_cancel_semantic)) {
153          oac.setConfigFrameOpen(false);
154          dispose();
155       }
156
157       /*
158       //Livello di Difficoltà
159       if (e.getSource().equals(combo14)) {
160
161       JComboBox cb = (JComboBox)e.getSource();
162       String diff_selected = (String)cb.getSelectedItem();
163
164       //Gestione Livelli difficoltà
165       switch (Integer.valueOf(diff_selected).intValue()) {
166       case 1:
167       //Level 1
168       //Impostazione Simulated Speed
169       setDifficult(10,20,450,50,2);
170       break;
171       case 2:
172       //Level 2
173       //Impostazione Simulated Speed
174       setDifficult(20,20,350,100,4);
175       break;
176       case 3:
177       //Level 3
178       //Impostazione Simulated Speed
179       setDifficult(40,30,250,250,6);
180       break;
181       case 4:
182       //Level 4
183       //Impostazione Simulated Speed
184       setDifficult(60,40,150,350,7);
185       break;
186       case 5:
187       //Level 5
188       //Impostazione Simulated Speed
189       setDifficult(100,50,100,1600,9);
190       break;
191       }
192       w_trace("actionPerformed : change Level Difficult " + Integer.valueOf(diff_selected).intValue());
193       }
194       */

195    }
196
197    //---------------------------------------------
198
/** Evento Cambio Valore Slider
199    * @param changeevent Evento Cambio Valore Slider
200    */

201    public void stateChanged(ChangeEvent changeevent) {
202       Cve.errLog.debug("");
203    }
204
205    //////////////////////////////////METODI PRIVATI DI UTILITA'///////////////////////
206

207    /**
208    * Variazione tipo di Attivatore
209    */

210    private String JavaDoc selectTraslation()
211    {
212       Cve.errLog.debug("");
213       //Apertura finestra selezione Attivatore
214
JFileChooser chooser = new JFileChooser();
215       chooser.setCurrentDirectory(new File( ConfigurationRead.getCveRoot() + ConfigurationRead.getIntSemTranslation()));
216       javax.swing.filechooser.FileFilter JavaDoc filter = new ClassFileFilter("class","Java Class files (*.class)");
217       chooser.addChoosableFileFilter( filter );
218       chooser.setFileFilter(filter);
219       chooser.setDialogTitle("Selection Translation Semantic Class");
220
221       int result = chooser.showOpenDialog(this);
222       if(result == JFileChooser.APPROVE_OPTION)
223       {
224          //Prelevamento Nome della Classe
225
String JavaDoc sClassName = chooser.getSelectedFile().getName();
226          // Elimina l'estensione ".class"
227
sClassName = sClassName.substring(0,sClassName.length()-6);
228
229          return sClassName;
230       }
231       //Ritorno il vecchio valore
232
return traslationClass;
233    }
234
235 }
Popular Tags