1 package cve.osservatori.servizioOACBuildSemantic; 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 import interactionGraphics.*; 19 20 import wippog.*; 21 22 import org.apache.log4j.Logger; 23 24 29 public class ConfigurationSemantic extends GenericFrame 30 implements ItemListener,ActionListener, ChangeListener { 31 private OACBuildSemantic oac; 32 33 private JPanel jpanelButton; 35 private JButton b_save_semantic, b_cancel_semantic, b_selTraslation; 36 37 private JPanel jpanelSemantic2, jpanelSemanticF, jpanelSemanticA, jpanelSemanticCenter2; 39 40 private JLabel jl_traslation, l_traslation; 41 private JComboBox cb_traslation; 42 private String traslationClass; 44 45 public ConfigurationSemantic(String Title, String iconPath){ 46 super(Title, iconPath); 47 Cve.errLog.debug(""); 48 }; 49 50 52 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 GridLayout(1,1)); 64 jpanelSemanticA.setLayout(new FlowLayout()); 65 66 jpanelSemanticCenter2.setLayout(new GridLayout(2,1)); 67 68 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(l_traslation); 80 jpanelSemanticA.add(b_selTraslation); 81 82 jpanelSemanticCenter2.add(jpanelSemanticA); 83 84 jpanelSemantic2.add(jpanelSemanticCenter2,BorderLayout.CENTER); 85 86 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 public void setOAC(OACBuildSemantic oac_in){ 111 Cve.errLog.debug(""); 112 this.oac = oac_in; 113 } 114 115 117 121 public void itemStateChanged(ItemEvent e) { 122 Cve.errLog.debug(""); 123 } 124 125 129 public void actionPerformed(ActionEvent e) { 130 131 Cve.errLog.debug(""); 132 if (e.getSource().equals(b_selTraslation)) { 135 traslationClass = selectTraslation(); 136 l_traslation.setText(traslationClass); 137 repaint(); 138 } 139 140 if (e.getSource().equals(b_save_semantic)) { 143 if (oac != null){ 144 System.out.println("Traduzione Semantica selezionata : " + traslationClass); 145 oac.setTranslationSemantic(traslationClass); 147 oac.setConfigFrameOpen(false); 148 } 149 dispose(); 150 } 151 if (e.getSource().equals(b_cancel_semantic)) { 153 oac.setConfigFrameOpen(false); 154 dispose(); 155 } 156 157 195 } 196 197 201 public void stateChanged(ChangeEvent changeevent) { 202 Cve.errLog.debug(""); 203 } 204 205 207 210 private String selectTraslation() 211 { 212 Cve.errLog.debug(""); 213 JFileChooser chooser = new JFileChooser(); 215 chooser.setCurrentDirectory(new File( ConfigurationRead.getCveRoot() + ConfigurationRead.getIntSemTranslation())); 216 javax.swing.filechooser.FileFilter 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 String sClassName = chooser.getSelectedFile().getName(); 226 sClassName = sClassName.substring(0,sClassName.length()-6); 228 229 return sClassName; 230 } 231 return traslationClass; 233 } 234 235 } | Popular Tags |