// File: ActionCreateVertex.java // Classes: ActionCreateVertex // Original Author:Kedar Patankar + Alberto Medina // Date 11 Feb 1997 package uci.graphedit; import gjt.DialogClient; import java.awt.Dialog; import java.awt.Point; /** * Editor Action to create a new Perspective on a new Construction class. When * this Action is executed it makes the new objects as per its * arguments, and then it sets the global next mode to ModePlace so * that the user can place the new node in any editor window. * @see ModePlace * @see FigConstVert * @see Perspective */ public class ActionCreateVertex extends Action implements DialogClient { /** the class of the new NetNode */ private Class _nodeClass; private Point _click; public ActionCreateVertex(String className, Editor editor,Point p) { super(editor); _args.put("className", className); try { _nodeClass = Class.forName(className); } catch (java.lang.ClassNotFoundException i) { System.out.println("Class " + className + " could not be found!"); return; } _click=p; } public String name() { return "Create Vertex"; } /** Actually instanciate the NetNode and Perspective objects and * set the global next mode to ModePlace */ public void doIt() { if (_nodeClass==null) return; VertDialog dialog = new VertDialog(_editor,this,"Enter Vertex Name"); dialog.show(); } public void undoIt() { } public void dialogDismissed(Dialog dl) { String name = ((VertDialog)dl).get_vertex_name(); NetNode newNode; Document _document=_editor.curDocument(); try { newNode = (NetNode) _nodeClass.newInstance();} catch (java.lang.IllegalAccessException ignore) { return; } catch (java.lang.InstantiationException ignore) { return; } newNode.initialize(newNode, name,_document,_click); Perspective defaultPerspective = newNode.get_Perspective(); _document.add(defaultPerspective); } } /* end class ActionCreateVertex */