1 28 29 package org.objectweb.fractal.explorer.menu; 30 31 import java.awt.Dimension ; 32 33 import org.objectweb.fractal.api.Component; 34 import org.objectweb.fractal.api.control.ContentController; 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 import org.objectweb.util.explorer.resolver.api.PropertyResolver; 39 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 40 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 41 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 42 import org.objectweb.util.explorer.swing.gui.lib.TreeBox; 43 44 49 public class AddSubComponentAction 50 implements MenuItem, 51 DialogAction 52 { 53 59 60 protected TreeBox treeBox_; 61 62 63 protected ContentController contentInterface_; 64 65 71 77 83 86 public int getStatus(TreeView treeView) { 87 return MenuItem.ENABLED_STATUS; 88 } 89 90 93 public void actionPerformed(MenuItemTreeView e) throws Exception { 94 contentInterface_ = (ContentController)e.getSelectedObject(); 95 Component comp = e.getTree().duplicate(); 96 97 PropertyResolver pr = (PropertyResolver)comp.getFcInterface(PropertyResolver.PROPERTY_RESOLVER); 100 101 treeBox_ = new TreeBox(comp); 102 treeBox_.setPreferredSize(new Dimension (450, 350)); 103 104 DialogBox dialog = new DefaultDialogBox("Select a component to add"); 105 dialog.setValidateAction(this); 106 dialog.addElementBox(treeBox_); 107 dialog.show(); 108 } 109 110 116 119 public void executeAction() throws Exception { 120 Object o = treeBox_.getObject(); 121 try{ 122 Component subComponent = (Component)o; 123 contentInterface_.addFcSubComponent(subComponent); 124 }catch(ClassCastException e){ 125 throw new Exception ("You must select a component!"); 126 } 127 } 128 129 } | Popular Tags |