1 package cve.osservatori.servizioOACesecSemantic; 2 3 import javax.swing.JInternalFrame ; 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 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 idTipo; 53 54 private JComboBox cb_maxtoken; 55 private String [] num_maxtoken = {"1","2","3","4","5","6","7","8","9"}; 56 private int max_token; 57 private JComboBox cb_token; 58 private String [] num_token = {"0","1","2","3","4","5","6","7","8","9"}; 59 private JComboBox cb_weight; 60 private String [] num_weight = {"0","1","2","3","4","5","6","7","8","9"}; 61 private String 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 Title, String iconPath) { 69 super(Title, iconPath); 70 Cve.errLog.debug(""); 71 }; 72 73 74 public void setOAC(OACesecSemantic oac_in) { 76 this.oac = oac_in; 77 Cve.errLog.debug(""); 78 } 79 80 public void init(String idIstanza) { 82 Cve.errLog.debug(""); 83 this.idIstanza = idIstanza; 84 this.config = oac.getConfigElement(idIstanza); 85 this.fase = oac.getFase(); 86 87 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 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 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 jl_maxtoken = new JLabel("Max Token: "); 117 cb_maxtoken = new JComboBox(num_maxtoken); 118 String s_maxtoken = new String (); 119 s_maxtoken = config.getParameter("max_token"); 120 if (s_maxtoken==null) { 121 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 jl_weight = new JLabel("Weight: "); 138 cb_weight = new JComboBox(num_weight); 139 String s_weight = new String (); 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 jl_token = new JLabel("n. Token: "); 157 158 num_token = new String [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 s_token = new String (); 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 jpanelItemPar.add(jpanelItemPar_1); 185 jpanelItemPar.add(jpanelItemPar_2); 186 jpanelItemPar.add(jpanelItemPar_3); 187 188 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 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 210 213 public void itemStateChanged(ItemEvent e) { 214 Cve.errLog.debug(""); 215 } 216 217 221 public void actionPerformed(ActionEvent e) { 222 Cve.errLog.debug(""); 223 if (e.getSource().equals(b_save)) { 226 if (cb_maxtoken.isEnabled()) { 227 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 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 int num_tok = Integer.valueOf((String )cb_token.getSelectedItem()).intValue(); 241 System.out.println("Num.Token Selezionati : " + num_tok); 242 oac.addInternalPool(idIstanza,num_tok); 243 } 244 dispose(); 245 } 246 if (e.getSource().equals(b_close)) { 248 dispose(); 249 } 250 } 251 254 public void stateChanged(ChangeEvent changeevent) { 255 Cve.errLog.debug(""); 256 266 } 267 268 } | Popular Tags |