1 26 27 package swing; 28 29 import java.awt.BorderLayout ; 30 import java.util.Vector ; 31 32 import javax.swing.JFrame ; 33 import javax.swing.JSplitPane ; 34 35 import org.objectweb.fractal.adl.ADLException; 36 import org.objectweb.fractal.adl.Factory; 37 import org.objectweb.fractal.adl.FactoryFactory; 38 import org.objectweb.fractal.api.Component; 39 import org.objectweb.fractal.api.NoSuchInterfaceException; 40 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 41 import org.objectweb.fractal.util.Fractal; 42 import org.objectweb.util.explorer.api.Tree; 43 import org.objectweb.util.explorer.core.common.api.ContextContainer; 44 import org.objectweb.util.explorer.core.common.lib.DefaultContextContainer; 45 import org.objectweb.util.explorer.parser.api.ParserConfiguration; 46 import org.objectweb.util.explorer.swing.api.Explorer; 47 import org.objectweb.util.explorer.swing.api.StatusBar; 48 import org.objectweb.util.explorer.swing.api.ViewPanel; 49 import org.objectweb.util.explorer.swing.lib.DefaultTreePanel; 50 import org.objectweb.util.trace.TraceSystem; 51 52 53 62 public class BasicSwingConsole { 63 64 public BasicSwingConsole(String configFile){ 65 66 try { 67 Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 69 Component explorer = (Component)f.newComponent("swing.SwingFractalExplorer",null); 70 Fractal.getLifeCycleController(explorer).startFc(); 71 72 ParserConfiguration parser = (ParserConfiguration)explorer.getFcInterface(ParserConfiguration.PARSER_CONFIGURATION); 74 parser.addPropertyFile(configFile); 75 parser.parse(); 76 77 Tree treeItf = (Tree)explorer.getFcInterface(Tree.TREE); 79 treeItf.addEntry("Java Properties", System.getProperties()); 80 ContextContainer contextContainer = new DefaultContextContainer(); 81 contextContainer.addEntry("Object 1", new Object ()); 82 contextContainer.addEntry("Object 2", new Object ()); 83 treeItf.addEntry("Context", contextContainer); 84 treeItf.addEntry("Vector", new Vector ()); 85 86 Explorer explorerItf = (Explorer)explorer.getFcInterface(Explorer.EXPLORER); 88 ViewPanel viewPanelItf = (ViewPanel)explorer.getFcInterface(ViewPanel.VIEW_PANEL); 89 StatusBar statusBar = (StatusBar)explorer.getFcInterface(StatusBar.STATUS_BAR); 90 JFrame frame = new JFrame ("Explorer GUI"); 91 frame.getContentPane().setLayout(new BorderLayout ()); 92 frame.getContentPane().add(new JSplitPane ( 93 JSplitPane.HORIZONTAL_SPLIT, 94 true, 95 new DefaultTreePanel(explorerItf.getTree()), 96 viewPanelItf.getViewPanel()), BorderLayout.CENTER); 97 frame.getContentPane().add(statusBar.getStatusBar(), BorderLayout.SOUTH); 98 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 99 frame.pack(); 100 frame.setVisible(true); 101 102 } catch (ADLException e) { 103 e.printStackTrace(); 104 } catch (IllegalLifeCycleException e) { 105 e.printStackTrace(); 106 } catch (NoSuchInterfaceException e) { 107 e.printStackTrace(); 108 } 109 110 } 111 112 public static void main(String [] args){ 113 TraceSystem.setLevel("debug"); 114 if(args.length != 0) { 115 new BasicSwingConsole(args[0]); 116 } else { 117 TraceSystem.get("explorer").debug("No available argument!"); 118 } 119 } 120 121 } 122
| Popular Tags
|