@Override
public void setValue(Object valueObject) throws Exception {
String valueString = valueObject instanceof String ? (String) valueObject : null;
final AstEditor editor = m_this.getEditor();
final MethodInvocation invocation = getInvocation();
final String signaturePrefix = "setColumnWidth(com.google.gwt.user.cellview.client.Column,";
// remove value
if (StringUtils.isEmpty(valueString)) {
if (invocation != null) {
ExecutionUtils.run(m_this, new RunnableEx() {
public void run() throws Exception {
editor.removeEnclosingStatement(invocation);
}
});
}
return;
}
// new value
if (invocation == null) {
final String valueSource = StringConverter.INSTANCE.toJavaSource(m_this, valueString);
ExecutionUtils.run(m_this, new RunnableEx() {
public void run() throws Exception {
StatementTarget target = new StatementTarget(getAssociation().getStatement(), false);
String signature = signaturePrefix + "java.lang.String)";
String argumentsSource = TemplateUtils.format("{0}, {1}", m_this, valueSource);
MethodInvocation newInvocation =
getParentJava().addMethodInvocation(target, signature, argumentsSource);
addRelatedNodes(newInvocation);
}
});
return;