* @param textField target
*/
private void connectAttributeAndTangoTextfield(boolean simpleCase, final TextField textField) {
//Get a key corresponding to a data source of string scalars
IKey stringScalarKey = tangoKey.getStringScalarKey();
if (simpleCase) {
//CometeBox construction
StringScalarBox stringBox = new StringScalarBox();
stringBox.connectWidget(textField, stringScalarKey);
} else {
//Data source construction
StringAttributeDataSource stringAttributeDataSource = null;
final IDataSourceProducer producer = DataSourceProducerProvider.
getProducer(stringScalarKey.getSourceProduction());
try {
stringAttributeDataSource = (StringAttributeDataSource)
((AbstractRefreshingManager<?>) producer).createDataSource(stringScalarKey, false,
true);
} catch (final Exception e) {
Logger.getLogger(Mediator.LOGGER_ACCESS).log(Level.SEVERE,
"Failed to create source for key: " +
(stringScalarKey == null ? null : stringScalarKey.getInformationKey()), e);
}
//Controller construction
GenericDescriptor sourceAndTargetType = new GenericDescriptor(String.class);
textFieldController = DataControllerProvider.getController(sourceAndTargetType , sourceAndTargetType );
if (textFieldController == null) {
textFieldController = (AbstractController<String>) new BasicTextTargetController() {
protected void setDataToTarget(ITarget target, String data,
AbstractDataSource<String> source) {
super.setDataToTarget(target, data, source);
}
protected void setDataToGenericTarget(ITarget target, String data,
AbstractDataSource<String> source) {
super.setDataToGenericTarget(target, data, source);
}
};
DataControllerProvider.pushNewController(textFieldController, sourceAndTargetType, sourceAndTargetType);
}
boolean result = textFieldController.addLink(stringAttributeDataSource, textField);
if (result) {
Logger.getLogger(Mediator.LOGGER_ACCESS).log(Level.INFO,
"Link successfully created betwen target TextField and data source " + stringScalarKey.getInformationKey());
} else {
Logger.getLogger(Mediator.LOGGER_ACCESS).log(Level.SEVERE,
"Failed to create link betwen target TextField and data source " + stringScalarKey.getInformationKey());
}
textField.addTextFieldListener(new ITextFieldListener() {
@Override