1 28 29 package test.swing; 30 31 import java.awt.BorderLayout ; 32 import java.awt.Dimension ; 33 import java.util.HashMap ; 34 35 import javax.swing.JFrame ; 36 import javax.swing.JSplitPane ; 37 38 import org.objectweb.fractal.adl.ADLException; 39 import org.objectweb.fractal.adl.Factory; 40 import org.objectweb.fractal.adl.FactoryFactory; 41 import org.objectweb.fractal.api.Component; 42 import org.objectweb.fractal.api.NoSuchInterfaceException; 43 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 44 import org.objectweb.fractal.util.Fractal; 45 import org.objectweb.util.explorer.api.Tree; 46 import org.objectweb.util.explorer.core.common.api.ContextContainer; 47 import org.objectweb.util.explorer.core.common.lib.DefaultContextContainer; 48 import org.objectweb.util.explorer.parser.api.ParserConfiguration; 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 54 import test.Calculate; 55 56 62 public class Main 63 extends JFrame 64 { 65 66 69 protected void populateTree(Tree tree) { 70 tree.addEntry("Java Properties", System.getProperties()); 71 Calculate c = new Calculate(); 72 ContextContainer contextContainer_ = new DefaultContextContainer(); 73 contextContainer_.addEntry("Calculate", c); 74 tree.addEntry("Test", contextContainer_, 1); 75 tree.addEntry("Object", new Object (), 1); 76 tree.addEntry("Calculatrice", new Calculate()); 77 tree.addEntry("HashMap class", HashMap .class); 78 } 79 80 83 public Main(String explorerPropertyFile) { 84 super("Explorer GUI"); 85 86 try { 87 Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 89 Component explorer = (Component)f.newComponent("test.swing.SwingFractalExplorer",null); 90 Fractal.getLifeCycleController(explorer).startFc(); 91 92 ParserConfiguration parser = (ParserConfiguration)explorer.getFcInterface(ParserConfiguration.PARSER_CONFIGURATION); 94 parser.addPropertyFile(explorerPropertyFile); 95 parser.parse(); 96 97 populateTree((Tree)explorer.getFcInterface(Tree.TREE)); 99 100 Explorer explorerItf = (Explorer)explorer.getFcInterface(Explorer.EXPLORER); 102 ViewPanel viewPanelItf = (ViewPanel)explorer.getFcInterface(ViewPanel.VIEW_PANEL); 103 StatusBar statusBar = (StatusBar)explorer.getFcInterface(StatusBar.STATUS_BAR); 104 JFrame frame = new JFrame ("Explorer GUI"); 105 frame.getContentPane().setLayout(new BorderLayout ()); 106 frame.getContentPane().add(new JSplitPane ( 107 JSplitPane.HORIZONTAL_SPLIT, 108 true, 109 new DefaultTreePanel(explorerItf.getTree()), 110 viewPanelItf.getViewPanel()), BorderLayout.CENTER); 111 frame.getContentPane().add(statusBar.getStatusBar(), BorderLayout.SOUTH); 112 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 113 frame.pack(); 114 115 Dimension screenSize = 117 java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 118 setLocation( 119 (screenSize.width - getWidth()) / 2, 120 (screenSize.height - getHeight()) / 2); 121 122 frame.setVisible(true); 123 124 } catch (ADLException e) { 125 e.printStackTrace(); 126 } catch (IllegalLifeCycleException e) { 127 e.printStackTrace(); 128 } catch (NoSuchInterfaceException e) { 129 e.printStackTrace(); 130 } 131 } 132 133 public static void main(String [] args) { 134 new Main("resources/config/demoConfig.xml"); 135 } 136 137 } 138 139 140 141 | Popular Tags |