1 package org.sapia.regis.gui.model; 2 3 import java.util.List ; 4 5 import javax.swing.JTextField ; 6 7 import org.sapia.gumby.RenderContext; 8 import org.sapia.regis.Node; 9 import org.sapia.regis.gui.GlobalContext; 10 import org.sapia.regis.gui.command.NodeCreateCommand; 11 import org.sapia.regis.gui.widgets.NewNodePanel; 12 13 public class NewNodeModel extends NodeModel{ 14 15 private Node parent; 16 private String name; 17 18 public NewNodeModel(Node node){ 19 super(node); 20 } 21 22 public String getName() { 23 return name; 24 } 25 26 public void setName(String name) { 27 this.name = name; 28 } 29 30 public Node getParent() { 31 return parent; 32 } 33 34 public void setParent(Node parent) { 35 this.parent = parent; 36 } 37 38 public synchronized void create() throws Exception { 39 NewNodePanel panel = (NewNodePanel)GlobalContext.getInstance() 40 .getRenderContext().getEnv().get(NEW_NODE_PANE); 41 42 JTextField txtField = (JTextField )GlobalContext.getInstance() 43 .getRenderContext().getEnv().get(NEW_NODE_PANE_NAME); 44 45 RenderContext child = GlobalContext.getInstance().getRenderContext().newChildInstance(); 46 List properties = panel.getProperties(); 47 child.getEnv().put("properties", properties, "local"); 48 if(txtField.getText() == null || txtField.getText().trim().length() == 0){ 49 GlobalContext.getInstance().error("No node name specified"); 50 return; 51 } 52 setName(txtField.getText()); 53 child.getEnv().put("name", txtField.getText(), "local"); 54 NodeCreateCommand command = new NodeCreateCommand(this); 55 command.execute(child); 56 _props.clear(); 57 } 58 59 } 60 | Popular Tags |