
net.ulrice.databinding.viewadapter.impl.DetailedTooltipHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ulrice-databinding Show documentation
Show all versions of ulrice-databinding Show documentation
Ulrice-Databinding is a databinding-extension for Ulrice
The newest version!
package net.ulrice.databinding.viewadapter.impl;
import java.util.List;
import javax.swing.JComponent;
import net.ulrice.databinding.IFBinding;
import net.ulrice.databinding.bufferedbinding.IFAttributeModel;
import net.ulrice.databinding.viewadapter.IFTooltipHandler;
/**
* Displays the detailed state of an attribute model as a tooltip in the
* component.
*
* @author christof
*/
public class DetailedTooltipHandler implements IFTooltipHandler {
/**
* @see net.ulrice.databinding.viewadapter.IFTooltipHandler#updateTooltip(net.ulrice.databinding.IFAttributeModel,
* net.ulrice.databinding.IFGuiAccessor, javax.swing.JComponent)
*/
@Override
public void updateTooltip(IFBinding binding, JComponent component) {
boolean initialized = true;
if (binding instanceof IFAttributeModel) {
initialized = ((IFAttributeModel) binding).isInitialized();
}
if (!initialized) {
component.setToolTipText("State: Not initalized");
} else if (!binding.isValid()) {
StringBuffer buffer = new StringBuffer();
// TODO Add to UI class
buffer.append("State: Invalid");
List validationFailures = binding.getValidationFailures();
if (validationFailures != null) {
for (String message : validationFailures) {
buffer.append("
");
buffer.append(message);
}
}
buffer.append("");
component.setToolTipText(buffer.toString());
} else {
if (binding.isDirty()) {
component.setToolTipText("State: Changed
Old value: " + binding.getOriginalValue() + "
New value: "
+ binding.getCurrentValue() + "");
} else {
component.setToolTipText("State: Not changed");
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy