Issue with flush when implementing a NullableSetEditor by wrapping a NullalbleListEditor

2012-09-04 Thread Jeff
HI, 

I spent a lot of time on the following issue but couldn't figure it out. 
Any clue is appreciated. Thanks!

I have a working NullableStringListEditor implementation:
public class NullableStringListEditor extends Composite implements 
IsEditorOptionalFieldEditor ListString, ListEditorString, 
StringEditor  {...}

Now, I am building a NullableStringSetEditor by wrapping it. With the 
following implementation, values are displayed by the wrapped editor 
successfully, however any modifications(the NullableStringListEditor 
supports edit/add strings) are not reflected after flush(). I am using 
SimpleBeanEditorDriver. I debugged into it and it looks like the underline 
values(List) in the wrappedEditor(NullableStringListEditor) have been 
changed, but they are not populated to NullableStringSetEditor. Am I still 
missing something?

public class NullableStringSetEditor extends Composite implements 
CompositeEditorSetString, ListString, ListEditorString, 
StringEditor, LeafValueEditorSetString {
private final NullableStringListEditor wrappedEditor = new 
NullableStringListEditor();

@Override
public void 
setEditorChain(com.google.gwt.editor.client.CompositeEditor.EditorChainListString,
 
ListEditorString, StringEditor chain) {
wrappedEditor.asEditor().setEditorChain(chain);
}

@Override
public SetString getValue() {
ListString list = wrappedEditor.asEditor().getValue();
return (list != null) ? new TreeSetString(list) : null;
}

@Override
public void setValue(SetString values) {
ListString list = new ArrayListString();
list.addAll(values);
wrappedEditor.asEditor().setValue(list);
   }

   //no-op implementation for other required @Override such as flush() and 
setDelegate(EditorDelegateSetString delegate)
   //...
}

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/4Zas7biq27EJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Issue with flush when implementing a NullableSetEditor by wrapping a NullalbleListEditor

2012-09-04 Thread Thomas Broyer
You say you implemented flush() as a no-op, so it's no surprise it doesn't 
do what you expect, right?

On Tuesday, September 4, 2012 9:08:16 AM UTC+2, Jeff wrote:

 HI, 

 I spent a lot of time on the following issue but couldn't figure it out. 
 Any clue is appreciated. Thanks!

 I have a working NullableStringListEditor implementation:
 public class NullableStringListEditor extends Composite implements 
 IsEditorOptionalFieldEditor ListString, ListEditorString, 
 StringEditor  {...}
 
 Now, I am building a NullableStringSetEditor by wrapping it. With the 
 following implementation, values are displayed by the wrapped editor 
 successfully, however any modifications(the NullableStringListEditor 
 supports edit/add strings) are not reflected after flush(). I am using 
 SimpleBeanEditorDriver. I debugged into it and it looks like the underline 
 values(List) in the wrappedEditor(NullableStringListEditor) have been 
 changed, but they are not populated to NullableStringSetEditor. Am I still 
 missing something?

 public class NullableStringSetEditor extends Composite implements 
 CompositeEditorSetString, ListString, ListEditorString, 
 StringEditor, LeafValueEditorSetString {
 private final NullableStringListEditor wrappedEditor = new 
 NullableStringListEditor();

 @Override
 public void 
 setEditorChain(com.google.gwt.editor.client.CompositeEditor.EditorChainListString,
  
 ListEditorString, StringEditor chain) {
 wrappedEditor.asEditor().setEditorChain(chain);
 }

 @Override
 public SetString getValue() {
 ListString list = wrappedEditor.asEditor().getValue();
 return (list != null) ? new TreeSetString(list) : null;
 }

 @Override
 public void setValue(SetString values) {
 ListString list = new ArrayListString();
 list.addAll(values);
 wrappedEditor.asEditor().setValue(list);
}

//no-op implementation for other required @Override such as flush() and 
 setDelegate(EditorDelegateSetString delegate)
//...
 }



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/rZBQJsX2UX8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Issue with flush when implementing a NullableSetEditor by wrapping a NullalbleListEditor

2012-09-04 Thread Jeff
Hi Thomas,

In the original post, I forgot to mention that, I tried the following 
flush() implementation but it didn't make a difference:
@Override public void flush() {wrappedEditor.asEditor().flush();}

I am not sure what else I can do within flush() since the only member 
variable of the class is the wrappedEditor.

Thanks!


On Tuesday, September 4, 2012 1:33:38 AM UTC-7, Thomas Broyer wrote:

 You say you implemented flush() as a no-op, so it's no surprise it doesn't 
 do what you expect, right?

 On Tuesday, September 4, 2012 9:08:16 AM UTC+2, Jeff wrote:

 HI, 

 I spent a lot of time on the following issue but couldn't figure it out. 
 Any clue is appreciated. Thanks!

 I have a working NullableStringListEditor implementation:
 public class NullableStringListEditor extends Composite implements 
 IsEditorOptionalFieldEditor ListString, ListEditorString, 
 StringEditor  {...}
 
 Now, I am building a NullableStringSetEditor by wrapping it. With the 
 following implementation, values are displayed by the wrapped editor 
 successfully, however any modifications(the NullableStringListEditor 
 supports edit/add strings) are not reflected after flush(). I am using 
 SimpleBeanEditorDriver. I debugged into it and it looks like the underline 
 values(List) in the wrappedEditor(NullableStringListEditor) have been 
 changed, but they are not populated to NullableStringSetEditor. Am I still 
 missing something?

 public class NullableStringSetEditor extends Composite implements 
 CompositeEditorSetString, ListString, ListEditorString, 
 StringEditor, LeafValueEditorSetString {
 private final NullableStringListEditor wrappedEditor = new 
 NullableStringListEditor();

 @Override
 public void 
 setEditorChain(com.google.gwt.editor.client.CompositeEditor.EditorChainListString,
  
 ListEditorString, StringEditor chain) {
 
 wrappedEditor.asEditor().setEditorChain(chain);
 }

 @Override
 public SetString getValue() {
 ListString list = wrappedEditor.asEditor().getValue();
 return (list != null) ? new TreeSetString(list) : null;
 }

 @Override
 public void setValue(SetString values) {
 ListString list = new ArrayListString();
 list.addAll(values);
 wrappedEditor.asEditor().setValue(list);
}

//no-op implementation for other required @Override such as flush() 
 and setDelegate(EditorDelegateSetString delegate)
//...
 }



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/qI1NbNylT4MJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Issue with flush when implementing a NullableSetEditor by wrapping a NullalbleListEditor

2012-09-04 Thread Thomas Broyer


On Tuesday, September 4, 2012 5:49:01 PM UTC+2, Jeff wrote:

 Hi Thomas,

 In the original post, I forgot to mention that, I tried the following 
 flush() implementation but it didn't make a difference:
 @Override public void flush() {wrappedEditor.asEditor().flush();}

 I am not sure what else I can do within flush() since the only member 
 variable of the class is the wrappedEditor.

 Thanks!



OK, looking a bit more in details, I really think you should follow the 
same pattern as OptionalFieldEditor (as I already told you on 
StackOverflow), with setValue() transforming the Set into a List and 
calling chain.attach(theList, theListEditor), and getValue() calling 
chain.getValue(theListEditor) and transforming the List back to a String.
Not tested but it has more chances to work than your strategy of hiding 
the underlying ListEditor.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/sBaLVnD-k-cJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.