1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 import CH.ifa.draw.figures.TextFigure; 22 import org.apache.log4j.Logger; 23 import org.objectweb.jac.core.rtti.FieldItem; 24 import org.objectweb.jac.util.Log; 25 26 public class AttributeValueFigure extends TextFigure { 27 28 public AttributeValueFigure(FieldItem attribute,Object substance) { 29 this.attribute=attribute; 30 this.substance=substance; 31 DiagramView.init = true; 32 Object value=attribute.getThroughAccessor(substance); 33 if(value==null) 34 setText(""); 35 else 36 setText(value.toString()); 37 DiagramView.init = false; 38 } 39 40 FieldItem attribute; 41 42 46 public FieldItem getAttribute() { 47 return attribute; 48 } 49 50 54 public void setAttribute(FieldItem v) { 55 this.attribute = v; 56 } 57 58 Object substance; 59 60 64 public Object getSubstance() { 65 return substance; 66 } 67 68 72 public void setSubstance(Object v) { 73 this.substance = v; 74 } 75 76 public void setText(String s) { 77 super.setText(s); 78 if (substance != null && attribute != null && !DiagramView.init) { 79 try { 80 attribute.setThroughWriter(substance,s); 81 } catch (Exception e) { 82 Logger.getLogger("figures").error( 83 "Failed to set attribute value for "+ 84 substance+"."+attribute+" to "+s); 85 } 86 } 87 } 88 89 } 90 | Popular Tags |