use of com.haulmont.cuba.desktop.sys.vcl.ToolTipButton in project cuba by cuba-platform.
the class ComponentCaption method takeOwnerProperties.
private void takeOwnerProperties() {
if (!(owner instanceof DesktopCheckBox)) {
if (label == null) {
label = new JLabel();
add(label);
}
label.setText(((Component.HasCaption) owner).getCaption());
}
String contextHelpText = getContextHelpText();
boolean hasContextHelpIconClickListeners = hasContextHelpIconClickListeners();
if (StringUtils.isNotEmpty(contextHelpText) || hasContextHelpIconClickListeners) {
if (toolTipButton == null) {
toolTipButton = new ToolTipButton();
toolTipButton.setFocusable(false);
add(toolTipButton);
}
if (hasContextHelpIconClickListeners) {
if (toolTipButtonActionListener == null) {
toolTipButtonActionListener = e -> fireContextHelpIconClickEvent();
toolTipButton.addActionListener(toolTipButtonActionListener);
}
toolTipButton.setToolTipText(null);
} else {
removeToolTipButtonActionListener();
toolTipButton.setToolTipText(contextHelpText);
}
DesktopToolTipManager.getInstance().registerTooltip(toolTipButton);
} else if (toolTipButton != null) {
removeToolTipButtonActionListener();
remove(toolTipButton);
toolTipButton = null;
}
setVisible(owner.isVisible());
setEnabled(owner.isEnabled());
}
use of com.haulmont.cuba.desktop.sys.vcl.ToolTipButton in project cuba by cuba-platform.
the class DesktopFieldGroup method reattachColumnFields.
protected void reattachColumnFields(int colIndex) {
fields.values().stream().filter(FieldConfig::isBound).map(fieldConfig -> ((FieldConfigImpl) fieldConfig)).filter(fci -> fci.getColumn() == colIndex).forEach(fci -> {
impl.remove(fci.getCompositionNN().getComposition());
if (fci.getLabel() != null) {
impl.remove(fci.getLabel());
}
if (fci.getToolTipButton() != null) {
impl.remove(fci.getToolTipButton());
}
});
List<FieldConfig> columnFCs = columnFieldMapping.get(colIndex);
int insertRowIndex = 0;
for (FieldConfig fc : columnFCs) {
if (fc.isBound()) {
FieldConfigImpl fci = (FieldConfigImpl) fc;
Component fieldComponent = fci.getComponentNN();
JComponent composition = fieldComponent.unwrapComposition(JComponent.class);
JLabel label = fci.getLabel();
if (label != null) {
int preferredCaptionWidth = getPreferredCaptionWidth(colIndex);
if (preferredCaptionWidth > 0) {
label.setPreferredSize(new Dimension(preferredCaptionWidth, 25));
label.setMaximumSize(new Dimension(preferredCaptionWidth, 25));
label.setMinimumSize(new Dimension(preferredCaptionWidth, 25));
} else {
label.setPreferredSize(new Dimension(label.getPreferredSize().width, 25));
}
label.setVisible(fieldComponent.isVisible());
CC labelCc = new CC();
MigLayoutHelper.applyAlignment(labelCc, Alignment.TOP_LEFT);
impl.add(label, labelCc.cell(colIndex * 3, insertRowIndex, 1, 1));
}
ToolTipButton toolTipButton = fci.getToolTipButton();
if (fci.getToolTipButton() != null) {
updateTooltipButton(fci, fieldComponent);
DesktopToolTipManager.getInstance().registerTooltip(toolTipButton);
impl.add(toolTipButton, new CC().cell(colIndex * 3 + 2, insertRowIndex, 1, 1).alignY("top"));
}
CC cell = new CC().cell(colIndex * 3 + 1, insertRowIndex, 1, 1);
MigLayoutHelper.applyWidth(cell, (int) fieldComponent.getWidth(), fieldComponent.getWidthUnits(), false);
MigLayoutHelper.applyHeight(cell, (int) fieldComponent.getHeight(), fieldComponent.getHeightUnits(), false);
MigLayoutHelper.applyAlignment(cell, fieldComponent.getAlignment());
composition.putClientProperty(getSwingPropertyId(), fci.getId());
impl.add(composition, cell);
insertRowIndex++;
}
}
impl.validate();
impl.repaint();
}
use of com.haulmont.cuba.desktop.sys.vcl.ToolTipButton in project cuba by cuba-platform.
the class DesktopFieldGroup method updateTooltipButton.
protected void updateTooltipButton(FieldConfigImpl fci, Component component) {
ToolTipButton toolTipButton = fci.getToolTipButton();
boolean hasContextHelpIconClickListeners = hasContextHelpIconClickListeners(component);
String contextHelpText = DesktopComponentsHelper.getContextHelpText(fci.getContextHelpText(), BooleanUtils.isTrue(fci.isContextHelpTextHtmlEnabled()));
ActionListener toolTipButtonActionListener = fci.getToolTipButtonActionListener();
if (hasContextHelpIconClickListeners) {
if (toolTipButtonActionListener == null) {
toolTipButtonActionListener = e -> fireContextHelpIconClickEvent(component);
toolTipButton.addActionListener(toolTipButtonActionListener);
}
toolTipButton.setToolTipText(null);
} else {
if (toolTipButtonActionListener != null) {
toolTipButton.removeActionListener(toolTipButtonActionListener);
fci.setToolTipButtonActionListener(null);
}
toolTipButton.setToolTipText(contextHelpText);
}
toolTipButton.setVisible(component.isVisible() && (StringUtils.isNotEmpty(contextHelpText) || hasContextHelpIconClickListeners));
}
Aggregations