1 23 package org.objectweb.clif.scenario.util.isac.gui.action; 24 25 import java.net.URL ; 26 27 import org.apache.log4j.Category; 28 import org.eclipse.jface.action.Action; 29 import org.eclipse.jface.resource.ImageDescriptor; 30 import org.eclipse.jface.window.ApplicationWindow; 31 import org.objectweb.clif.scenario.util.isac.gui.Icons; 32 import org.objectweb.clif.scenario.util.isac.gui.ScenarioGUIEditor; 33 import org.objectweb.clif.scenario.util.isac.gui.tree.ScenarioTreeViewer; 34 import org.objectweb.clif.scenario.util.isac.util.tree.Node; 35 import org.objectweb.clif.scenario.util.isac.util.tree.NodeDescription; 36 import org.objectweb.clif.scenario.util.isac.util.tree.ScenarioNode; 37 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager; 38 44 public class AddPluginAction extends Action { 45 48 ScenarioGUIEditor window; 49 NodeDescription node; 50 static Category cat = Category.getInstance(AddPluginAction.class 51 .getName()); 52 61 public AddPluginAction(ApplicationWindow w, NodeDescription node) { 62 cat.debug("-> constructor"); 63 this.window = (ScenarioGUIEditor) w; 64 this.node = node; 65 String type = node.getType(); 68 if (Node.isPluginNode(type)) { 69 this.setText(type + "." + node.getPlugin() + "." 70 + node.getActionName()); 71 this.setToolTipText("Add a new " + type + "." + node.getPlugin() 72 + "." + node.getActionName() + "to the tree"); 73 } else { 74 this.setText(node.getType()); 75 this.setToolTipText("Add a new " + node.getType() + "to the tree"); 76 } 77 String fileName = (String )Icons.getImageDescriptorFileName().get(type) ; 79 if (fileName != null) { 80 try { 81 this.setImageDescriptor(ImageDescriptor.createFromURL( 82 new URL ("file:" + fileName))); 83 } catch (Exception e) { 84 cat.warn("Unable to find "+fileName+" icon file"); 85 } 86 } 87 } 88 89 public void run() { 90 cat.debug("-> run"); 91 ScenarioTreeViewer viewer = this.window.getTreeViewer(); 93 ScenarioNode temp = null; 94 if (Node.isStructureNode(this.node.getType())) 95 temp = (TreeManager.getTreeManager(null)).addNode(this.node, null); 96 else 97 temp = (TreeManager.getTreeManager(null)).addNode(this.node, viewer 98 .getSelectedNode()); 99 viewer.expand(temp, true); 101 102 String type = node.getType(); 104 if (type.equals(Node.USE)) { 105 (TreeManager.getTreeManager(null)).idGenerator(this.node); 107 } 108 this.window.updateAddMenu(viewer.getSelectedNode()); 110 viewer.refresh(); 112 this.window.setScenarioSavedState(false) ; 114 } 115 } | Popular Tags |