1 28 29 package swing; 30 import java.awt.BorderLayout ; 31 import java.io.File ; 32 import java.io.IOException ; 33 import java.net.MalformedURLException ; 34 import java.util.jar.JarFile ; 35 36 import javax.swing.JFrame ; 37 import javax.swing.JSplitPane ; 38 39 import org.objectweb.fractal.adl.ADLException; 40 import org.objectweb.fractal.adl.Factory; 41 import org.objectweb.fractal.adl.FactoryFactory; 42 import org.objectweb.fractal.api.Component; 43 import org.objectweb.fractal.api.NoSuchInterfaceException; 44 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 45 import org.objectweb.fractal.util.Fractal; 46 import org.objectweb.util.explorer.api.Tree; 47 import org.objectweb.util.explorer.parser.api.ParserConfiguration; 48 import org.objectweb.util.explorer.plugin.java.reflect.JarFileStructure; 49 import org.objectweb.util.explorer.swing.api.Explorer; 50 import org.objectweb.util.explorer.swing.api.StatusBar; 51 import org.objectweb.util.explorer.swing.api.ViewPanel; 52 import org.objectweb.util.explorer.swing.lib.DefaultTreePanel; 53 import org.objectweb.util.trace.TraceSystem; 54 55 64 public class ReflectorSwingConsole { 65 66 public ReflectorSwingConsole(String configFile){ 67 try { 68 Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 70 Component explorer = (Component)f.newComponent("swing.SwingFractalExplorer",null); 71 Fractal.getLifeCycleController(explorer).startFc(); 72 73 ParserConfiguration parser = (ParserConfiguration)explorer.getFcInterface(ParserConfiguration.PARSER_CONFIGURATION); 75 parser.addPropertyFile(configFile); 76 parser.parse(); 77 78 Tree treeItf = (Tree)explorer.getFcInterface(Tree.TREE); 80 try { 81 File archive = new File ("build/lib/reflect-plugin.jar"); 82 treeItf.addEntry(archive.getName(), new JarFileStructure(new JarFile (archive),archive.toURL()),8); 83 } catch (MalformedURLException e) { 84 e.printStackTrace(); 85 } catch (IOException e) { 86 e.printStackTrace(); 87 } 88 89 Explorer explorerItf = (Explorer)explorer.getFcInterface(Explorer.EXPLORER); 91 ViewPanel viewPanelItf = (ViewPanel)explorer.getFcInterface(ViewPanel.VIEW_PANEL); 92 StatusBar statusBar = (StatusBar)explorer.getFcInterface(StatusBar.STATUS_BAR); 93 JFrame frame = new JFrame ("Explorer GUI"); 94 frame.getContentPane().setLayout(new BorderLayout ()); 95 frame.getContentPane().add(new JSplitPane ( 96 JSplitPane.HORIZONTAL_SPLIT, 97 true, 98 new DefaultTreePanel(explorerItf.getTree()), 99 viewPanelItf.getViewPanel()), BorderLayout.CENTER); 100 frame.getContentPane().add(statusBar.getStatusBar(), BorderLayout.SOUTH); 101 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 102 frame.pack(); 103 frame.setVisible(true); 104 105 } catch (ADLException e) { 106 e.printStackTrace(); 107 } catch (IllegalLifeCycleException e) { 108 e.printStackTrace(); 109 } catch (NoSuchInterfaceException e) { 110 e.printStackTrace(); 111 } 112 113 } 114 115 public static void main(String [] args){ 116 TraceSystem.setLevel("debug"); 117 if(args.length != 0) { 118 new ReflectorSwingConsole(args[0]); 119 } else { 120 TraceSystem.get("explorer").debug("Java Archive expected!"); 121 } 122 } 123 124 } 125 | Popular Tags |