1 26 package org.objectweb.openccm.explorer.menu; 27 28 import java.io.File ; 29 import java.awt.Component ; 30 import javax.swing.ImageIcon ; 31 import javax.swing.JFileChooser ; 32 33 import org.objectweb.fractal.api.NoSuchInterfaceException; 34 import org.objectweb.util.explorer.parser.api.ParserConfiguration; 35 36 42 public class LoadConfigurationFileAction extends AbstractMenuAction { 43 44 45 protected JFileChooser fileChooser_; 46 47 48 protected Component parent_; 49 50 51 protected ParserConfiguration parser_; 52 53 56 public LoadConfigurationFileAction(String nom, ImageIcon image, String desc, Integer mnemonic, org.objectweb.fractal.api.Component tree, Component parent) { 57 super(nom, image, desc, mnemonic, tree); 58 fileChooser_ = JFileChooserSingleton.getInstance(OpenCCMBrowserConstants.XML_FILE_CHOOSER, "Loads a new configuration file ...", JFileChooser.FILES_ONLY); 59 try { 60 parser_ = (ParserConfiguration)tree.getFcInterface(ParserConfiguration.PARSER_CONFIGURATION); 61 } catch (NoSuchInterfaceException e) { 62 System.err.println(ParserConfiguration.PARSER_CONFIGURATION + ": interface not found!"); 63 } 64 parent_ = parent; 65 } 66 67 70 public void actionPerformed(java.awt.event.ActionEvent ae) { 71 int returnVal = fileChooser_.showOpenDialog(parent_); 72 if (returnVal == JFileChooser.APPROVE_OPTION) { 73 File f = fileChooser_.getSelectedFile(); 74 parser_.addPropertyFile(f.getName()); 75 parser_.parse(); 76 treeItf_.refreshAll(); 77 } 78 } 79 80 } 81 | Popular Tags |