Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Converter(Model converter Class does not contains public constructor(s): )
Converter [message #890221] Thu, 21 June 2012 09:52 Go to next message
Peter Nagy is currently offline Peter Nagy
Messages: 4
Registered: September 2011
Junior Member
Hi!

I am trying to use the GUI's "Edit Data Binding" window to attach a Converter to one of my data bindings. After selecting the Converter(ExchangeMailToStringConverter) I get the following error message:

"Model converter Class does not contains public constructor(s):"
ExchangeMailToStringConverter().


The source of the Converter class:


import java.util.List;
import org.eclipse.core.databinding.conversion.Converter;
import com.moyosoft.exchange.mail.ExchangeMail;

public class ExchangeMailToStringConverter extends Converter{

public ExchangeMailToStringConverter(Object fromType, Object toType) {
super(fromType, toType);
}

@Override
public Object convert(Object fromObject) {
List<ExchangeMail> mails = (List<ExchangeMail>)fromObject;
return mails.get(Main.getInstance().getN());
}
}


Modifying the GUI's source manually works fine:

UpdateValueStrategy uvs = new UpdateValueStrategy();
uvs.setConverter(new ExchangeMailToStringConverter(ExchangeMail.class,String.class));
bindingContext.bindValue(text_4ObserveTextObserveWidget, logicKurtIpListObserveValue, null, uvs);


Any suggestions?

Thanks!
NagPer
Re: Converter [message #890257 is a reply to message #890221] Thu, 21 June 2012 11:58 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric Clayberg
Messages: 856
Registered: July 2009
Location: Boston, MA
Senior Member
That error message seems very specific...it is looking for a default constructor. Presumably, your custom converter class should know what it wants to convert from/to. Have you tried something like this?

public ExchangeMailToStringConverter() {
    super(ExchangeMail.class,String.class);
}
Re: Converter [message #902736 is a reply to message #890257] Mon, 20 August 2012 04:14 Go to previous message
Peter Nagy is currently offline Peter Nagy
Messages: 4
Registered: September 2011
Junior Member
Eric Clayberg wrote on Thu, 21 June 2012 11:58
That error message seems very specific...it is looking for a default constructor. Presumably, your custom converter class should know what it wants to convert from/to. Have you tried something like this?

public ExchangeMailToStringConverter() {
    super(ExchangeMail.class,String.class);
}



That works Eric! Thank you!
Previous Topic:Avoiding user to change the source
Next Topic:Label ICON in a modal dialog doesn't display! Why?
Goto Forum:
  


Current Time: Thu Aug 21 22:12:07 EDT 2014

Powered by FUDForum. Page generated in 0.01618 seconds