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 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 30 public class ConfigurationFrame extends GenericFrame 31 implements ItemListener,ActionListener, ChangeListener { 32 private OACesecSemantic oac; 33 34 private JTabbedPane tab; 36 private JPanel jpanelButton; 37 private JButton b_save_semantic, b_cancel_semantic, b_selActivator; 38 39 private JPanel jpanelSemantic, jpanelSemanticO, jpanelSemanticS; 41 42 private JLabel jl_orientation; 43 private JComboBox cb_orientation; 44 private String [] values_orientation = {"TOKEN","HOLDER"}; 45 46 private JPanel jpanelSemantic2, jpanelSemanticF, jpanelSemanticA, jpanelSemanticCenter2; 48 49 private JLabel jl_fase; 50 private JComboBox cb_fase; 51 private String [] 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 [] values_activator = {"StepActivator","SeqActivator"}; 60 private String activator; 61 62 public ConfigurationFrame(String Title, String iconPath) { 63 super(Title, iconPath); 64 Cve.errLog.debug(""); 65 }; 66 67 public void init() { 70 71 tab= new JTabbedPane(JTabbedPane.BOTTOM); 73 tab.setBackground(Color.white); 74 75 jpanelSemantic = new JPanel(); 77 jpanelSemantic.setLayout(new GridLayout(2,1)); 78 79 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 tab.add("Pre-Configuration",jpanelSemantic); 93 94 jpanelSemantic2 = new JPanel(); 96 jpanelSemanticF = new JPanel(); 97 jpanelSemanticA = new JPanel(); 98 99 jpanelSemanticCenter2 = new JPanel(); 100 101 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 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 jl_activator = new JLabel("Activator Semantic: "); 120 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(l_activator); 131 jpanelSemanticA.add(b_selActivator); 132 jpanelSemanticCenter2.add(jpanelSemanticF); 133 jpanelSemanticCenter2.add(jpanelSemanticA); 134 jpanelSemantic2.add(jpanelSemanticCenter2,BorderLayout.CENTER); 135 136 tab.add("Post-Configuration",jpanelSemantic2); 138 139 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 if (oac.getSemanticFlag()) { 154 tab.setEnabledAt(0, false); 155 tab.setEnabledAt(1, true); 156 tab.setSelectedIndex(1); 158 } else { 159 tab.setEnabledAt(0, true); 160 tab.setEnabledAt(1, false); 161 tab.setSelectedIndex(0); 162 } 163 164 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 public void setOAC(OACesecSemantic oac_in){ 179 Cve.errLog.debug(""); 180 this.oac = oac_in; 181 } 182 183 185 188 public void itemStateChanged(ItemEvent e) { 189 Cve.errLog.debug(""); 190 } 191 192 195 public void actionPerformed(ActionEvent e) { 196 Cve.errLog.debug(""); 197 if (e.getSource().equals(cb_fase)) { 200 String appo_fase = (String )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 if (e.getSource().equals(b_selActivator)) { 212 activator = selectActivator(); 213 l_activator.setText(activator); 214 repaint(); 215 } 216 217 if (e.getSource().equals(b_save_semantic)) { 220 if (oac != null){ 221 String orientation_value = (String )cb_orientation.getSelectedItem(); 223 int ori_int = cb_orientation.getSelectedIndex(); 224 System.out.println("Orientazione selezionata : " + orientation_value); 225 oac.setOrientation(ori_int+1); 227 if (tab.isEnabledAt(1)==true) { 229 String fase_value = (String )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 oac.setFase(fase_int); 244 245 if (fase_int!=1) { 247 if (oac.getDisButton() == false){ 249 oac.disableButton(); 251 } 252 } else { 253 oac.setStateButton(oac.getDisabledButton(),false); 254 } 255 } 257 oac.setActivator(activator); 259 } oac.setConfigFrameOpen(false); 261 dispose(); 262 } 263 264 if (e.getSource().equals(b_cancel_semantic)) { 266 oac.setConfigFrameOpen(false); 267 dispose(); 268 } 269 } 270 271 275 public void stateChanged(ChangeEvent changeevent) { 276 Cve.errLog.debug(""); 277 287 } 288 289 292 private String selectActivator() 293 { 294 Cve.errLog.debug(""); 295 JFileChooser chooser = new JFileChooser(); 297 chooser.setCurrentDirectory(new File( ConfigurationRead.getCveRoot() + "//lib//wippog//activator" )); 298 javax.swing.filechooser.FileFilter 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 String sClassName = chooser.getSelectedFile().getName(); 306 sClassName = sClassName.substring(0,sClassName.length()-6); 308 return sClassName; 309 } 310 return activator; 312 } 313 314 } 315 | Popular Tags |