public void traverse(EditorVisitor visitor, AbstractEditorDelegate<?, ?> next) { if (visitor.visit(this) && next != null) { next.accept(visitor); } visitor.endVisit(this); }
@SuppressWarnings(value = {"rawtypes", "unchecked"}) public void doTraverseSyntheticCompositeEditor(EditorVisitor visitor) { Editor<?> sample = this.asCompositeEditor().createEditorForTraversal(); AbstractEditorDelegate subDelegate = delegate.createComposedDelegate(); delegate.addSubDelegate(subDelegate, path, sample); delegate.getEditorChain().traverse(visitor, subDelegate); }
protected String appendPath(String path) { if (path.length() == 0) { return this.path; } return appendPath(this.path, path); }
@Override public <Q> boolean visit(EditorContext<Q> ctx) { Q toSet = ctx.getFromModel(); @SuppressWarnings("unchecked") AbstractEditorDelegate<Q, ?> delegate = (AbstractEditorDelegate<Q, ?>) ctx.getEditorDelegate(); if (delegate != null) { delegate.setObject(delegate.ensureMutable(toSet)); delegate.setDirty(false); } ValueAwareEditor<Q> asValue = ctx.asValueAwareEditor(); if (asValue != null) { // Call setValue for ValueAware, non-leaf editors asValue.setValue(toSet); } else { LeafValueEditor<Q> asLeaf = ctx.asLeafValueEditor(); if (asLeaf != null) { // Call setvalue for LeafValueEditors. asLeaf.setValue(toSet); } } // CompositeEditor's setValue should create sub-editors and attach them to // the EditorChain, which will traverse them. Returning true here for a // CompositeEditor would then traverse it twice. See issue 7038. return ctx.asCompositeEditor() == null; } }
protected void doEdit(T object) { checkEditor(); object = delegate.ensureMutable(object); this.object = object; delegate.setObject(object); accept(createInitializerVisitor()); DirtCollector c = new DirtCollector(); accept(c); leafValueMap = c.getLeafValues(); }
delegate.recordError(error.getMessage(), null, error.getUserDataObject()); } else { delegate.recordError(error.getMessage(), null, error.getUserDataObject(), addlPath, delegate.getEditor());
/** * Used to construct an error for an Editor that does not have a delegate. */ SimpleError(AbstractEditorDelegate<?, ?> delegate, String message, Object value, Object userData, String extraPath, Editor<?> leafEditor) { assert extraPath != null && extraPath.length() > 0; this.absolutePath = delegate.getPath() + extraPath; this.editor = leafEditor; this.message = message; this.value = value; this.userData = userData; }
protected <R, S extends Editor<R>> void createChain( Class<R> composedElementType) { @SuppressWarnings("unchecked") CompositeEditor<T, R, S> editor = (CompositeEditor<T, R, S>) getEditor(); editorChain = new Chain<R, S>(editor, composedElementType); }
@Override public <T> void endVisit(EditorContext<T> ctx) { toReturn.put(ctx.getAbsolutePath(), ctx.getEditor()); @SuppressWarnings("unchecked") AbstractEditorDelegate<T, ?> delegate = (AbstractEditorDelegate<T, ?>) ctx.getEditorDelegate(); if (delegate != null) { toReturn.put(delegate.getObject(), delegate); } } });
@Override public <Q> boolean visit(EditorContext<Q> ctx) { @SuppressWarnings("unchecked") AbstractEditorDelegate<Q, ?> delegate = (AbstractEditorDelegate<Q, ?>) ctx.getEditorDelegate(); // Pass in the EditorDelegate HasEditorDelegate<Q> asHasDelegate = ctx.asHasEditorDelegate(); if (asHasDelegate != null) { asHasDelegate.setDelegate(delegate); } // Set the EditorChain CompositeEditor<Q, ?, ?> asComposite = ctx.asCompositeEditor(); if (asComposite != null) { // Various javac generics compilation problems here @SuppressWarnings("rawtypes") EditorChain chain = delegate.getEditorChain(); asComposite.setEditorChain(chain); } return super.visit(ctx); } }
List<EditorError> errors = delegate.getErrors(); lastAdded = new ArrayList<EditorError>(errors); lastAddedPath = ctx.getAbsolutePath();
@Override public <Q> boolean visit(EditorContext<Q> ctx) { Q toSet = ctx.getFromModel(); @SuppressWarnings("unchecked") AbstractEditorDelegate<Q, ?> delegate = (AbstractEditorDelegate<Q, ?>) ctx.getEditorDelegate(); if (delegate != null) { delegate.setObject(delegate.ensureMutable(toSet)); delegate.setDirty(false); } ValueAwareEditor<Q> asValue = ctx.asValueAwareEditor(); if (asValue != null) { // Call setValue for ValueAware, non-leaf editors asValue.setValue(toSet); } else { LeafValueEditor<Q> asLeaf = ctx.asLeafValueEditor(); if (asLeaf != null) { // Call setvalue for LeafValueEditors. asLeaf.setValue(toSet); } } // CompositeEditor's setValue should create sub-editors and attach them to // the EditorChain, which will traverse them. Returning true here for a // CompositeEditor would then traverse it twice. See issue 7038. return ctx.asCompositeEditor() == null; } }
protected void doEdit(T object) { checkEditor(); object = delegate.ensureMutable(object); this.object = object; delegate.setObject(object); accept(createInitializerVisitor()); DirtCollector c = new DirtCollector(); accept(c); leafValueMap = c.getLeafValues(); }
delegate.recordError(error.getMessage(), null, error.getUserDataObject()); } else { delegate.recordError(error.getMessage(), null, error.getUserDataObject(), addlPath, delegate.getEditor());
<T> void put(T object, AbstractEditorDelegate<T, ?> delegate) { add(delegatesByPath, delegate.getPath(), delegate); Object key = keyMethod.key(object); if (key == null) { return; } add(map, key, delegate); } }
protected <R, S extends Editor<R>> void createChain( Class<R> composedElementType) { @SuppressWarnings("unchecked") CompositeEditor<T, R, S> editor = (CompositeEditor<T, R, S>) getEditor(); editorChain = new Chain<R, S>(editor, composedElementType); }