1 28 29 package org.objectweb.fractal.explorer.panel; 30 31 import javax.swing.JPanel ; 32 33 import org.objectweb.fractal.api.NoSuchInterfaceException; 34 import org.objectweb.fractal.api.control.LifeCycleController; 35 import org.objectweb.fractal.explorer.FcExplorer; 36 import org.objectweb.fractal.explorer.api.FractalViewPanel; 37 import org.objectweb.util.explorer.api.Panel; 38 import org.objectweb.util.explorer.api.TreeView; 39 import org.objectweb.util.explorer.swing.panel.WhitePanel; 40 41 46 public abstract class DefaultFractalViewPanel 47 implements Panel , 48 FractalViewPanel 49 { 50 56 57 protected final Panel whitePanel_ = new WhitePanel(); 58 59 60 protected boolean isStarted_ = true; 61 62 68 74 80 83 public void selected(TreeView treeView) { 84 LifeCycleController lcc = null; 85 try{ 86 lcc = FcExplorer.getLifeCycleController(FcExplorer.getComponent(treeView.getSelectedObject())); 87 } catch(NoSuchInterfaceException e) { 88 try { 89 selectedStarted(treeView); 90 } catch (Exception e1) { 91 isStarted_ = false; 92 selectedStopped(treeView); 93 } 94 } 95 if(lcc.getFcState().equals(LifeCycleController.STARTED)){ 96 isStarted_ = true; 97 selectedStarted(treeView); 98 } else { 99 isStarted_ = false; 100 selectedStopped(treeView); 101 } 102 } 103 104 107 public Object getPanel(){ 108 if(isStarted_){ 109 try{ 110 return getStartedPanel(); 111 } catch (Exception e) { 112 return getStoppedPanel(); 113 } 114 } else { 115 return getStoppedPanel(); 116 } 117 } 118 119 122 public void unselected(TreeView treeView) { 123 LifeCycleController lcc = null; 124 try{ 125 lcc = FcExplorer.getLifeCycleController(FcExplorer.getComponent(treeView.getSelectedObject())); 126 } catch(NoSuchInterfaceException e) { 127 try { 128 unselectedStarted(treeView); 129 } catch (Exception e1) { 130 unselectedStopped(treeView); 131 } 132 } 133 if(lcc.getFcState().equals(LifeCycleController.STARTED)) 134 unselectedStarted(treeView); 135 else 136 unselectedStopped(treeView); 137 } 138 139 145 public abstract void selectedStarted(TreeView treeView); 146 147 public void selectedStopped(TreeView treeView) { 148 } 149 150 public abstract JPanel getStartedPanel(); 151 152 public JPanel getStoppedPanel() { 153 return (JPanel )whitePanel_.getPanel(); 154 } 155 156 public abstract void unselectedStarted(TreeView treeView); 157 158 public void unselectedStopped(TreeView treeView){ 159 } 160 161 } | Popular Tags |