1 28 package org.objectweb.util.explorer.swing.lib; 29 30 import java.awt.BorderLayout ; 31 32 import javax.swing.JFrame ; 33 import javax.swing.JSplitPane ; 34 35 import org.objectweb.fractal.adl.Factory; 36 import org.objectweb.fractal.adl.FactoryFactory; 37 import org.objectweb.fractal.api.Component; 38 import org.objectweb.fractal.util.Fractal; 39 import org.objectweb.util.explorer.api.Tree; 40 import org.objectweb.util.explorer.parser.api.ParserConfiguration; 41 import org.objectweb.util.explorer.swing.api.Explorer; 42 import org.objectweb.util.explorer.swing.api.StatusBar; 43 import org.objectweb.util.explorer.swing.api.ViewPanel; 44 45 59 public class SwingExplorer 60 extends JFrame 61 implements org.objectweb.util.explorer.swing.api.SwingExplorer 62 { 63 64 70 73 private Component explorer_; 74 75 81 84 protected void createFrame(){ 85 getContentPane().setLayout(new BorderLayout ()); 86 getContentPane().add(new JSplitPane ( 87 JSplitPane.HORIZONTAL_SPLIT, 88 true, 89 new DefaultTreePanel(getExplorerItf().getTree()), 90 getViewPanelItf().getViewPanel()), BorderLayout.CENTER); 91 getContentPane().add(getStatusBarItf().getStatusBar(), BorderLayout.SOUTH); 92 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 93 pack(); 94 } 95 96 100 public SwingExplorer(String name){ 101 super(name); 102 try { 103 Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 105 this.explorer_ = (Component)f.newComponent("org.objectweb.util.explorer.swing.SwingFractalExplorer",null); 106 Fractal.getLifeCycleController(this.explorer_).startFc(); 107 } catch (Exception e) { 108 e.printStackTrace(); 109 } 110 createFrame(); 111 } 112 113 119 122 protected Object getFcInterface(String name){ 123 try { 124 return explorer_.getFcInterface(name); 125 } catch (Exception e) { 126 return null; 128 } 129 } 130 131 137 140 public ParserConfiguration getParserConfigurationItf() { 141 return (ParserConfiguration)getFcInterface(ParserConfiguration.PARSER_CONFIGURATION); 142 } 143 144 147 public Tree getTreeItf(){ 148 return (Tree)getFcInterface(Tree.TREE); 149 } 150 151 154 public Explorer getExplorerItf(){ 155 return (Explorer)getFcInterface(Explorer.EXPLORER); 156 } 157 158 161 public ViewPanel getViewPanelItf(){ 162 return (ViewPanel)getFcInterface(ViewPanel.VIEW_PANEL); 163 } 164 165 168 public StatusBar getStatusBarItf() { 169 return (StatusBar)getFcInterface(StatusBar.STATUS_BAR); 170 } 171 } 172 | Popular Tags |