1 26 27 package org.objectweb.util.explorer.plugin.java.reflect; 28 29 import java.io.File ; 30 import java.util.jar.JarFile ; 31 32 import javax.swing.JFileChooser ; 33 import javax.swing.JOptionPane ; 34 35 import org.objectweb.fractal.api.Component; 36 import org.objectweb.util.explorer.api.MenuItem; 37 import org.objectweb.util.explorer.api.MenuItemTreeView; 38 import org.objectweb.util.explorer.api.Tree; 39 import org.objectweb.util.explorer.api.TreeView; 40 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 41 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 42 import org.objectweb.util.explorer.swing.gui.api.TreeChooserObserver; 43 import org.objectweb.util.explorer.swing.gui.api.TreeProvider; 44 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 45 import org.objectweb.util.explorer.swing.gui.lib.FileChooserBox; 46 import org.objectweb.util.explorer.swing.gui.lib.TreeChooserBox; 47 48 56 public class SelectClassAction 57 implements MenuItem, DialogAction, TreeChooserObserver 58 { 59 60 66 67 protected FileChooserBox jarFile_; 68 69 70 protected TreeChooserBox classFile_; 71 72 73 protected JFileChooser fileChooser_; 74 75 76 protected Tree tree_; 77 78 79 protected TreeView treeView_; 80 81 82 protected TreeProvider treeProvider_; 83 84 85 protected DialogBox action_; 86 87 93 99 105 108 public int getStatus(TreeView treeView) { 109 return MenuItem.ENABLED_STATUS; 110 } 111 112 115 public void actionPerformed(MenuItemTreeView treeView) throws Exception { 116 treeView_ = treeView; 117 118 action_ = new DefaultDialogBox("Choose a class"); 119 fileChooser_ = new JFileChooser (); 120 jarFile_ = new FileChooserBox("Jar file",fileChooser_,true,false); 121 action_.addElementBox(jarFile_); 122 123 Component treeCpt = treeView.getTree().duplicate(false); 124 tree_ = (Tree)treeCpt.getFcInterface(Tree.TREE); 125 126 classFile_ = new TreeChooserBox("Class File", treeCpt); 127 classFile_.setTreeChooserObserver(this); 128 action_.addElementBox(classFile_); 129 130 action_.setValidateAction(this); 131 action_.show(); 132 } 133 134 140 143 public Component refresh(){ 144 Component treeCpt = null; 145 File f = jarFile_.getFile(); 146 if(f!=null) { 147 treeCpt = treeView_.getTree().duplicate(false); 148 try { 149 Tree treeItf = (Tree)treeCpt.getFcInterface(Tree.TREE); 150 JarFile jf = new JarFile (f); 151 tree_.addEntry(f.getName(), new JarFileStructure(jf,f.toURL())); 152 } catch (Exception e) { 153 JOptionPane.showMessageDialog(null, "Jar file expected !", "Exception", JOptionPane.ERROR_MESSAGE); 154 } 155 } 156 return treeCpt; 157 } 158 159 165 168 public void executeAction() throws Exception { 169 System.out.println("OK"); 170 } 171 172 } 173 174 175 | Popular Tags |