public static String getName(Object comp) { String result; Method getNameControlMethod = null; String methodName = "getName"; Class controlClass = comp.getClass(); try { getNameControlMethod = controlClass.getMethod(methodName, (Class[]) null); } catch (Exception ex) { Err.error("Missing method " + methodName + " from " + controlClass); } result = (String) SelfReferenceUtils.invoke(comp, getNameControlMethod); return result; }
public static void setEditable(Object comp, boolean b) { Class[] args1 = new Class[1]; args1[0] = Boolean.TYPE; Method setEditableControlMethod = null; String methodName = "setEditable"; Class controlClass = comp.getClass(); try { setEditableControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex) { Err.error("Missing method " + methodName + " from " + controlClass); } SelfReferenceUtils.invoke(comp, setEditableControlMethod, Boolean.valueOf(b)); }
/** * TODO - Think about reason are not going to ControlSignatures for this. Pros for not - * ControlSignatures is part of strandz core, whereas this is lgpl Pros for having in * ControlSignatures - Controls inside a table should be treated in exactly the same way as other * field controls. (This would require changes to info package). * * <p>Of course providing a service interface would be the answer, but changing info provides * inertia. Bugs because of differences will help the case for change. */ public static boolean isEditable(Object comp) { boolean result = false; Method isEditableControlMethod = null; String methodName = "isEditable"; Class controlClass = comp.getClass(); boolean noMethod = false; try { isEditableControlMethod = controlClass.getMethod(methodName, (Class[]) null); } catch (NoSuchMethodException ex1) { noMethod = true; } catch (Exception ex2) { Err.error("Missing method " + methodName + " from " + controlClass + ", ex: " + ex2); } if (!noMethod) { result = ((Boolean) SelfReferenceUtils.invoke(comp, isEditableControlMethod)).booleanValue(); } return result; }
public static void setText(Object comp, Object txt) { Class[] args1 = new Class[1]; args1[0] = String.class; Method setTextControlMethod = null; String methodName = "setText"; Class controlClass = comp.getClass(); try { setTextControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex1) { args1[0] = Object.class; try { setTextControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex2) { Err.error("Missing method " + methodName + " from " + controlClass); } } String s = null; if (txt != null) { s = txt.toString(); } SelfReferenceUtils.invoke(comp, setTextControlMethod, s); }