org.bidib.wizard.nodes.client.view.DccAspectConverter Maven / Gradle / Ivy
package org.bidib.wizard.nodes.client.view;
import com.jidesoft.converter.ConverterContext;
import com.jidesoft.converter.ObjectConverter;
public class DccAspectConverter implements ObjectConverter {
/**
* ConverterContext for a font name.
*/
public static ConverterContext CONTEXT = new ConverterContext("DccAspect");
private final String[] dccAspectNames;
public DccAspectConverter(final String[] dccAspectNames) {
this.dccAspectNames = dccAspectNames;
}
public String toString(Object object, ConverterContext context) {
if (object == null || !(object instanceof Integer)) {
return null;
} else {
Integer value = (Integer) object;
return dccAspectNames[value];
// if (value.intValue() == 0) {
// return "red";
// }
//// return value.toString();
// return "green";
}
}
public boolean supportToString(Object object, ConverterContext context) {
return true;
}
public Object fromString(String string, ConverterContext context) {
if (string.length() == 0) {
return null;
}
else {
if (string.equals(dccAspectNames[0])) {
return 0;
}
else {
return 1;
}
}
}
@Override
public boolean supportFromString(String s, ConverterContext converterContext) {
return true;
}
}