/** * Constructs an EditorAccess for an IsEditor type. */ public static EditorAccess via(EditorAccess access, JClassType type) { return new EditorAccess(access.getPath(), type, access.getExpresson() + ".asEditor()"); }
private EditorAccess(String path, JClassType type, String expression) { this.expression = expression; this.path = path; this.type = type; isEditor = isEditor(type); }
private List<EditorData> createEditorData(EditorAccess access) throws UnableToCompleteException { TreeLogger subLogger = logger.branch(TreeLogger.DEBUG, "Examining " + access.toString()); List<EditorData> toReturn = new ArrayList<EditorData>(); // Are we looking at a view that implements IsEditor? if (access.isEditor()) { EditorAccess subAccess = EditorAccess.via(access, calculateIsEditedType(subLogger, access.getEditorType())); toReturn = createEditorData(subAccess); // If an object only implements IsEditor, return now if (!editorIntf.isAssignableFrom(access.getEditorType())) { return toReturn; } } // Determine the Foo in Editor<Foo> JClassType expectedToEdit = calculateEditedType(subLogger, access.getEditorType()); EditorData.Builder builder = new EditorData.Builder(subLogger); builder.access(access); builder.parent(editorSoFar); // Find the bean methods on the proxy interface findBeanPropertyMethods(access.getPath(), expectedToEdit, builder); toReturn.add(builder.build()); return toReturn; }
public Builder access(EditorAccess access) throws UnableToCompleteException { this.access = access; data.declaredPath = access.getPath(); data.editorType = access.getEditorType(); data.editedType = EditorModel.calculateEditedType(logger, data.editorType); data.simpleExpression = access.getExpresson(); TypeOracle oracle = data.editorType.getOracle(); JClassType leafType = oracle.findType(LeafValueEditor.class.getName()); data.isLeaf = leafType.isAssignableFrom(data.editorType); JClassType composedType = oracle.findType(CompositeEditor.class.getName()); data.isCompositeEditor = composedType.isAssignableFrom(data.editorType); JClassType hasDelegateType = oracle.findType(HasEditorDelegate.class.getName()); JClassType hasEditorErrorsType = oracle.findType(HasEditorErrors.class.getName()); data.isDelegateRequired = hasDelegateType.isAssignableFrom(data.editorType) || hasEditorErrorsType.isAssignableFrom(data.editorType) || !ModelUtils.isValueType(oracle, data.editedType); JClassType valueAwareType = oracle.findType(ValueAwareEditor.class.getName()); data.isValueAware = valueAwareType.isAssignableFrom(data.editorType); return this; }
public EditorData build() throws UnableToCompleteException { if (data == null) { throw new IllegalStateException(); } try { data.editorExpression = (parent == null ? "" : (parent.getExpression() + ".")) + access.getExpresson(); data.path = (parent == null ? "" : (parent.getPath() + ".")) + access.getPath(); if (data.isCompositeEditor) { TreeLogger compositeLogger = logger.branch(TreeLogger.DEBUG, "Examining composite editor at " + data.path); JClassType subEditorType = EditorModel.calculateCompositeTypes(data.editorType)[1]; data.composedData = new Builder(compositeLogger).access( EditorAccess.root(subEditorType)).parent(data).build(); } return data; } finally { data = null; } }
List<EditorData> data = createEditorData(EditorAccess.via(field)); accumulateEditorData(data, flatData, toReturn); if (shouldExamine(methodReturnType) && method.getParameters().length == 0) { EditorAccess access = EditorAccess.via(method); if (access.getPath().equals("as") && isEditorIntf.isAssignableFrom(editorType)) { } else if (access.getPath().equals("createEditorForTraversal") && compositeEditorIntf.isAssignableFrom(editorType)) { EditorAccess access = EditorAccess.root(subEditorType); EditorData subEditor = new EditorData.Builder(logger).access(access).parent( editorSoFar).build();
public static EditorAccess root(JClassType rootType) { return new EditorAccess("", rootType, ""); }
public EditorData getRootData() throws UnableToCompleteException { TreeLogger rootLogger = logger.branch(TreeLogger.DEBUG, "Calculating root data for " + getEditorType().getParameterizedQualifiedSourceName()); return new EditorData.Builder(rootLogger).access( EditorAccess.root(getEditorType())).build(); }
private List<EditorData> createEditorData(EditorAccess access) throws UnableToCompleteException { TreeLogger subLogger = logger.branch(TreeLogger.DEBUG, "Examining " + access.toString()); List<EditorData> toReturn = new ArrayList<EditorData>(); // Are we looking at a view that implements IsEditor? if (access.isEditor()) { EditorAccess subAccess = EditorAccess.via(access, calculateIsEditedType(subLogger, access.getEditorType())); toReturn = createEditorData(subAccess); // If an object only implements IsEditor, return now if (!editorIntf.isAssignableFrom(access.getEditorType())) { return toReturn; } } // Determine the Foo in Editor<Foo> JClassType expectedToEdit = calculateEditedType(subLogger, access.getEditorType()); EditorData.Builder builder = new EditorData.Builder(subLogger); builder.access(access); builder.parent(editorSoFar); // Find the bean methods on the proxy interface findBeanPropertyMethods(access.getPath(), expectedToEdit, builder); toReturn.add(builder.build()); return toReturn; }
public Builder access(EditorAccess access) throws UnableToCompleteException { this.access = access; data.declaredPath = access.getPath(); data.editorType = access.getEditorType(); data.editedType = EditorModel.calculateEditedType(logger, data.editorType); data.simpleExpression = access.getExpresson(); TypeOracle oracle = data.editorType.getOracle(); JClassType leafType = oracle.findType(LeafValueEditor.class.getName()); data.isLeaf = leafType.isAssignableFrom(data.editorType); JClassType composedType = oracle.findType(CompositeEditor.class.getName()); data.isCompositeEditor = composedType.isAssignableFrom(data.editorType); JClassType hasDelegateType = oracle.findType(HasEditorDelegate.class.getName()); JClassType hasEditorErrorsType = oracle.findType(HasEditorErrors.class.getName()); data.isDelegateRequired = hasDelegateType.isAssignableFrom(data.editorType) || hasEditorErrorsType.isAssignableFrom(data.editorType) || !ModelUtils.isValueType(oracle, data.editedType); JClassType valueAwareType = oracle.findType(ValueAwareEditor.class.getName()); data.isValueAware = valueAwareType.isAssignableFrom(data.editorType); return this; }
public EditorData build() throws UnableToCompleteException { if (data == null) { throw new IllegalStateException(); } try { data.editorExpression = (parent == null ? "" : (parent.getExpression() + ".")) + access.getExpresson(); data.path = (parent == null ? "" : (parent.getPath() + ".")) + access.getPath(); if (data.isCompositeEditor) { TreeLogger compositeLogger = logger.branch(TreeLogger.DEBUG, "Examining composite editor at " + data.path); JClassType subEditorType = EditorModel.calculateCompositeTypes(data.editorType)[1]; data.composedData = new Builder(compositeLogger).access( EditorAccess.root(subEditorType)).parent(data).build(); } return data; } finally { data = null; } }
List<EditorData> data = createEditorData(EditorAccess.via(field)); accumulateEditorData(data, flatData, toReturn); if (shouldExamine(methodReturnType) && method.getParameters().length == 0) { EditorAccess access = EditorAccess.via(method); if (access.getPath().equals("as") && isEditorIntf.isAssignableFrom(editorType)) { } else if (access.getPath().equals("createEditorForTraversal") && compositeEditorIntf.isAssignableFrom(editorType)) { EditorAccess access = EditorAccess.root(subEditorType); EditorData subEditor = new EditorData.Builder(logger).access(access).parent( editorSoFar).build();
public static EditorAccess root(JClassType rootType) { return new EditorAccess("", rootType, ""); }
public EditorData getRootData() throws UnableToCompleteException { TreeLogger rootLogger = logger.branch(TreeLogger.DEBUG, "Calculating root data for " + getEditorType().getParameterizedQualifiedSourceName()); return new EditorData.Builder(rootLogger).access( EditorAccess.root(getEditorType())).build(); }
/** * Constructs an EditorAccess for an IsEditor type. */ public static EditorAccess via(EditorAccess access, JClassType type) { return new EditorAccess(access.getPath(), type, access.getExpresson() + ".asEditor()"); }
public static EditorAccess via(JMethod method) { String path = method.getName(); Path pathAnnotation = method.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, method.getReturnType().isClassOrInterface(), method.getName() + "()"); }
private EditorAccess(String path, JClassType type, String expression) { this.expression = expression; this.path = path; this.type = type; isEditor = isEditor(type); }
public static EditorAccess via(JField field) { String path = field.getName(); Path pathAnnotation = field.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, field.getType().isClassOrInterface(), field.getName()); }
public static EditorAccess via(JMethod method) { String path = method.getName(); Path pathAnnotation = method.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, method.getReturnType().isClassOrInterface(), method.getName() + "()"); }
public static EditorAccess via(JField field) { String path = field.getName(); Path pathAnnotation = field.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, field.getType().isClassOrInterface(), field.getName()); }