1 18 19 package org.objectweb.jac.aspects.gui.swing; 20 21 22 import java.util.Arrays ; 23 import javax.swing.JLabel ; 24 import org.objectweb.jac.aspects.gui.Border; 25 import org.objectweb.jac.aspects.gui.DisplayContext; 26 import org.objectweb.jac.aspects.gui.Length; 27 import org.objectweb.jac.aspects.gui.View; 28 import org.objectweb.jac.aspects.gui.ViewFactory; 29 import org.objectweb.jac.aspects.gui.ViewIdentity; 30 import org.objectweb.jac.core.rtti.FieldItem; 31 import org.objectweb.jac.core.rtti.MethodItem; 32 33 public class SwingLabel extends JLabel implements View { 34 35 ViewFactory factory; 36 DisplayContext context; 37 Object [] parameters; 38 String type; 39 40 public SwingLabel() { 41 } 42 43 Border viewBorder; 44 45 49 public Border getViewBorder() { 50 return viewBorder; 51 } 52 53 57 public void setViewBorder(Border v) { 58 this.viewBorder = v; 59 } 60 61 62 String style; 64 65 public void setStyle(String style) { 66 this.style = style; 67 } 68 69 public String getStyle() { 70 return style; 71 } 72 73 74 MethodItem message; 75 76 80 public MethodItem getMessage() { 81 return message; 82 } 83 84 88 public void setMessage(MethodItem v) { 89 this.message = v; 90 } 91 92 public void setContext(DisplayContext context) { 93 this.context = context; 94 } 95 public DisplayContext getContext() { 96 return context; 97 } 98 99 String description; 100 101 105 public String getDescription() { 106 return description; 107 } 108 109 113 public void setDescription(String v) { 114 this.description = v; 115 } 116 117 View parentView; 118 119 123 public View getParentView() { 124 return parentView; 125 } 126 127 131 public void setParentView(View v) { 132 this.parentView = v; 133 } 134 135 public View getRootView() { 136 if (parentView==null) 137 return this; 138 return parentView.getRootView(); 139 } 140 141 public boolean isDescendantOf(View ancestor) { 142 if (this==ancestor) 143 return true; 144 else if (parentView==null) 145 return false; 146 else 147 return parentView.isDescendantOf(ancestor); 148 } 149 150 public void setLabel(String label) { 151 setText(label); 152 } 153 154 public String getLabel() { 155 return getText(); 156 } 157 158 public void setSize(Length width, Length height) { 159 SwingUtils.setSize(this,width,height); 160 } 161 162 public void close(boolean validate) { 163 closed = true; 164 } 165 166 boolean closed = false; 167 168 public boolean isClosed() { 169 return closed; 170 } 171 172 public void setFactory(ViewFactory factory) { 173 this.factory = factory; 174 } 175 176 public ViewFactory getFactory() { 177 return factory; 178 } 179 180 public void setType(String type) { 181 this.type = type; 182 } 183 184 public String getType() { 185 return type; 186 } 187 188 public void setParameters(Object [] parameters) { 189 this.parameters = parameters; 190 } 191 192 public Object [] getParameters() { 193 return parameters; 194 } 195 196 public boolean equalsView(ViewIdentity view) { 197 return 198 ( ( type!=null && 199 type.equals(view.getType()) ) 200 || (type==null && view.getType()==null ) ) 201 && ( ( parameters!=null && 202 Arrays.equals(parameters,view.getParameters()) ) 203 || (parameters==null && view.getParameters()==null) ); 204 } 205 206 public boolean equalsView(String type, Object [] parameters) { 207 return this.type.equals(type) 208 && Arrays.equals(this.parameters,parameters); 209 } 210 211 public void setFocus(FieldItem field, Object option) { 212 } 213 214 public String toString() { 215 return Integer.toString(hashCode()); 216 } 217 } 218 | Popular Tags |