1 28 29 package org.objectweb.fractal.explorer.menu; 30 31 import org.objectweb.fractal.api.NoSuchInterfaceException; 32 import org.objectweb.fractal.api.control.LifeCycleController; 33 import org.objectweb.fractal.explorer.FcExplorer; 34 import org.objectweb.fractal.explorer.api.FractalMenuItem; 35 import org.objectweb.util.explorer.api.MenuItem; 36 import org.objectweb.util.explorer.api.MenuItemTreeView; 37 import org.objectweb.util.explorer.api.TreeView; 38 39 44 public abstract class DefaultFractalMenuItem 45 implements MenuItem, 46 FractalMenuItem 47 { 48 54 60 66 72 75 78 public int getStatus(TreeView arg0) { 79 LifeCycleController lcc = null; 80 try{ 81 lcc = FcExplorer.getLifeCycleController(FcExplorer.getComponent(arg0.getSelectedObject())); 82 } catch(NoSuchInterfaceException e) { 83 try { 84 return getStartedStatus(arg0); 85 } catch (Exception e1) { 86 return getStoppedStatus(arg0); 87 } 88 } 89 if(lcc.getFcState().equals(LifeCycleController.STARTED)) 90 return getStartedStatus(arg0); 91 else 92 return getStoppedStatus(arg0); 93 } 94 95 98 101 public void actionPerformed(MenuItemTreeView arg0) throws Exception { 102 LifeCycleController lcc = null; 103 try { 104 lcc = FcExplorer.getLifeCycleController(FcExplorer.getComponent(arg0.getSelectedObject())); 105 } catch(NoSuchInterfaceException e) { 106 try { 107 actionStartedPerformed(arg0); 108 } catch (Exception e1) { 109 actionStoppedPerformed(arg0); 110 } 111 } 112 if(lcc.getFcState().equals(LifeCycleController.STARTED)) 113 actionStartedPerformed(arg0); 114 else 115 actionStoppedPerformed(arg0); 116 } 117 118 public int getStartedStatus(TreeView arg0) { 119 return MenuItem.ENABLED_STATUS; 120 } 121 122 public int getStoppedStatus(TreeView arg0) { 123 return MenuItem.NOT_VISIBLE_STATUS; 124 } 125 126 public void actionStoppedPerformed(MenuItemTreeView arg0) throws Exception { 127 } 129 130 public abstract void actionStartedPerformed(MenuItemTreeView arg0) throws Exception ; 131 } | Popular Tags |