// File: ActionUmlAttr.java // Classes: ActionSetUmlAttr // Original Author: Kedar Patankar // Date 21 Jan 1997 package uci.graphedit; import java.awt.Dialog; import gjt.DialogClient; /** Action to modify the vertex name after user selects the netnode */ public class ActionSetUmlAttr extends Action implements DialogClient { private Selection _sel; private Fig _element; /** Construct a new ActionSetAttr that sets one attribute value */ public ActionSetUmlAttr(Editor editor,Document d){ super(editor,d);} public String name() { return "Set Vertex Attributes"; } public void doIt() { DiagramElement _de; if (_document == null) return; _sel = _document.selection(); if (_sel.size()!=1) return; _de = _document.selectionsingle(); if (_de instanceof Perspective) { _element=((Perspective)_de).get_first(); String name=_element.get_label(); VertDialog vd = new VertDialog(_editor,this,"Change Vertex Name",name); vd.show(); } else if (_de instanceof ArcPerspective) { _element = ((ArcPerspective)_de).get_figure(); if (_element instanceof FigAltEdge) return; String name=((FigConstEdge)_element).get_label(); String card=((FigConstEdge)_element).get_cardinality(); ConstEdgeDialog ced = new ConstEdgeDialog (_editor,this,"Change Edge Properties",name,card); ced.show(); } } public void undoIt() { } public void dialogDismissed (Dialog dl) { if (dl instanceof VertDialog) { String name = ((VertDialog)dl).get_vertex_name(); _element.set_label(name,_document); } else if (dl instanceof ConstEdgeDialog) { String name = ((ConstEdgeDialog)dl).get_edge_name(); String card = ((ConstEdgeDialog)dl).get_cardinality(); ((FigConstEdge)_element).set_label(name); ((FigConstEdge)_element).set_cardinality(card); } _document.damaged(_sel); _document.repairDamage(); _document.isSaved(false); } } /* end class ActionSetUmlAttr */