Skip to content

Commit

Permalink
moving initialization of tooltip to js (MID-6990)
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jul 10, 2021
1 parent 6322f6f commit 0a7e6d9
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,22 @@ public class TriStateFormGroup extends BasePanel<Boolean> {
private static final String ID_ROW = "row";

public TriStateFormGroup(String id, IModel<Boolean> value, IModel<String> label, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
this(id, value, label, null, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
}

public TriStateFormGroup(String id, IModel<Boolean> value, IModel<String> label, String labelCssClass, String textCssClass, boolean required) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, false);
public TriStateFormGroup(String id, IModel<Boolean> value, IModel<String> label,
String labelCssClass, String textCssClass, boolean required) {
this(id, value, label, null, labelCssClass, textCssClass, required, false);
}

public TriStateFormGroup(String id, IModel<Boolean> value, IModel<String> label, String tooltipKey,
boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, false);
}

public TriStateFormGroup(String id, IModel<Boolean> value, IModel<String> label, String tooltipKey,
boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
super(id, value);

initLayout(label, tooltipKey, isTooltipInModal, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
initLayout(label, tooltipKey, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
}

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass,
private void initLayout(IModel<String> label, final String tooltipKey, String labelCssClass, String textCssClass,
boolean required, boolean isSimilarAsPropertyPanel) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
add(labelContainer);
Expand All @@ -76,7 +72,7 @@ private void initLayout(IModel<String> label, final String tooltipKey, boolean i
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title",
(IModel<String>) () -> getString(tooltipKey)));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void initLayout(){

DropDownFormGroup<QName> type = new DropDownFormGroup<QName>(ID_OBJECT_TYPE, Model.of(getDefaultObjectType()), Model.ofList(getSupportedObjectTypes()),
new QNameObjectTypeChoiceRenderer(), createStringResource("chooseFocusTypeAndRelationDialogPanel.type"),
"chooseFocusTypeAndRelationDialogPanel.tooltip.type", true, "col-md-4", "col-md-8", true);
"chooseFocusTypeAndRelationDialogPanel.tooltip.type", "col-md-4", "col-md-8", true);
type.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
type.setOutputMarkupId(true);
type.add(new VisibleBehaviour(() -> isFocusTypeSelectorVisible()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ public AceEditorFormGroup(String id, IModel<String> value, IModel<String> label,

public AceEditorFormGroup(String id, IModel<String> value, IModel<String> label, String labelSize, String textSize,
boolean required, int rowNumber) {
this(id, value, label, null, false, labelSize, textSize, required, rowNumber);
this(id, value, label, null, labelSize, textSize, required, rowNumber);
}

public AceEditorFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey,
boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) {
String labelSize, String textSize, boolean required, int rowNumber) {
super(id, value);

initLayout(label, tooltipKey, isTooltipInModal, labelSize, textSize, required, rowNumber);
initLayout(label, tooltipKey, labelSize, textSize, required, rowNumber);
}

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize,
private void initLayout(IModel<String> label, final String tooltipKey, String labelSize,
String textSize, boolean required, int rowNumber) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
add(labelContainer);
Expand All @@ -68,7 +68,7 @@ private void initLayout(IModel<String> label, final String tooltipKey, boolean i
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title",
(IModel<String>) () -> getString(tooltipKey)));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public class CheckFormGroup extends BasePanel<Boolean> {
private static final String ID_TOOLTIP = "tooltip";

public CheckFormGroup(String id, IModel<Boolean> value, IModel<String> label, String labelSize, String textSize) {
this(id, value, label, null, false, labelSize, textSize);
this(id, value, label, null, labelSize, textSize);
}

public CheckFormGroup(String id, IModel<Boolean> value, IModel<String> label, String tooltipKey,
boolean isTooltipInModal, String labelSize, String textSize) {
String labelSize, String textSize) {
super(id, value);

initLayout(label, tooltipKey, isTooltipInModal, labelSize, textSize);
initLayout(label, tooltipKey, labelSize, textSize);
}

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize) {
private void initLayout(IModel<String> label, final String tooltipKey, String labelSize, String textSize) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
add(labelContainer);
Expand All @@ -56,7 +56,7 @@ private void initLayout(IModel<String> label, final String tooltipKey, boolean i
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title",
(IModel<String>) () -> getString(tooltipKey)));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ public class DropDownFormGroup<T> extends BasePanel<T> {

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer,
IModel<String> label, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
this(id, value, choices, renderer, label, Model.of(), false, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
this(id, value, choices, renderer, label, Model.of(), labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
}

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer,
IModel<String> label, String labelCssClass, String textCssClass, boolean required) {
this(id, value, choices, renderer, label, Model.of(), false, labelCssClass, textCssClass, required, false);
this(id, value, choices, renderer, label, Model.of(), labelCssClass, textCssClass, required, false);
}

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer,
IModel<String> label, String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required) {
this(id, value, choices, renderer, label, Model.of(tooltipKey), isTooltipInModal, labelCssClass, textCssClass, required, false);
IModel<String> label, String tooltipKey, String labelCssClass, String textCssClass, boolean required) {
this(id, value, choices, renderer, label, Model.of(tooltipKey), labelCssClass, textCssClass, required, false);
}

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer, IModel<String> label, IModel<String> tooltipModel,
boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) {
super(id, value);

initLayout(choices, renderer, label, tooltipModel, isTooltipInModal, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
initLayout(choices, renderer, label, tooltipModel, labelCssClass, textCssClass, required, isSimilarAsPropertyPanel);
}

private void initLayout(IModel<List<T>> choices, IChoiceRenderer<T> renderer, IModel<String> label, final IModel<String> tooltipModel,
boolean isTooltipInModal, String labelCssClass, String textCssClass, final boolean required,
String labelCssClass, String textCssClass, final boolean required,
boolean isSimilarAsPropertyPanel) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.add(new VisibleBehaviour(() -> label != null && StringUtils.isNotEmpty(label.getObject())));
Expand All @@ -84,7 +84,7 @@ private void initLayout(IModel<List<T>> choices, IChoiceRenderer<T> renderer, IM

Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title", tooltipModel));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public TextAreaFormGroup(String id, IModel<String> value, IModel<String> label,

public TextAreaFormGroup(String id, IModel<String> value, IModel<String> label, String labelSize, String textSize,
boolean required, int rowNumber) {
this(id, value, label, null, false, labelSize, textSize, required, rowNumber);
this(id, value, label, null, labelSize, textSize, required, rowNumber);
}

public TextAreaFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey,
boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) {
String labelSize, String textSize, boolean required, int rowNumber) {
super(id, value);

initLayout(label, tooltipKey, isTooltipInModal, labelSize, textSize, required, rowNumber);
initLayout(label, tooltipKey, labelSize, textSize, required, rowNumber);
}

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize,
private void initLayout(IModel<String> label, final String tooltipKey, String labelSize,
String textSize, boolean required, int rowNumber) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
add(labelContainer);
Expand All @@ -67,7 +67,7 @@ private void initLayout(IModel<String> label, final String tooltipKey, boolean i
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title",
(IModel<String>) () -> getString(tooltipKey)));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ public class TextFormGroup extends BasePanel<String> {

public TextFormGroup(String id, IModel<String> value, IModel<String> label, String labelCssClass, String textCssClass,
boolean required, boolean isSimilarAsPropertyPanel) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, required, isSimilarAsPropertyPanel);
this(id, value, label, null, labelCssClass, textCssClass, required, required, isSimilarAsPropertyPanel);
}

public TextFormGroup(String id, IModel<String> value, IModel<String> label, String labelCssClass, String textCssClass,
boolean required) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, required, false);
this(id, value, label, null, labelCssClass, textCssClass, required, required, false);
}

public TextFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey, boolean isTooltipInModel, String labelCssClass,
public TextFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey, String labelCssClass,
String textCssClass, boolean required, boolean markAsRequired) {
this(id, value, label, null, false, labelCssClass, textCssClass, required, markAsRequired, false);
this(id, value, label, tooltipKey, labelCssClass, textCssClass, required, markAsRequired, false);
}

public TextFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey, boolean isTooltipInModel, String labelCssClass,
public TextFormGroup(String id, IModel<String> value, IModel<String> label, String tooltipKey, String labelCssClass,
String textCssClass, boolean required, boolean markAsRequired, boolean isSimilarAsPropertyPanel) {
super(id, value);

initLayout(label, tooltipKey, isTooltipInModel, labelCssClass, textCssClass, required, markAsRequired, isSimilarAsPropertyPanel);
initLayout(label, tooltipKey, labelCssClass, textCssClass, required, markAsRequired, isSimilarAsPropertyPanel);
}

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass, final boolean required,
private void initLayout(IModel<String> label, final String tooltipKey, String labelCssClass, String textCssClass, final boolean required,
final boolean markAsRequired, boolean isSimilarAsPropertyPanel) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
add(labelContainer);
Expand All @@ -81,7 +81,7 @@ public String getObject() {
return getString(tooltipKey);
}
}));
tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void onInitialize() {
defaultRelation = supportedRelations.size() > 0 ? supportedRelations.get(0) : PrismConstants.Q_ANY;
}
DropDownFormGroup<QName> input = new DropDownFormGroup<QName>(ID_INPUT, Model.of(defaultRelation), supportedRelationsModel, getRenderer(),
getRelationLabelModel(), "relationDropDownChoicePanel.tooltip.relation", true, "col-md-4",
getRelationLabelModel(), "relationDropDownChoicePanel.tooltip.relation", "col-md-4",
getRelationLabelModel() == null || StringUtils.isEmpty(getRelationLabelModel().getObject()) ? "" : "col-md-8", !allowNull) {
private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,36 +272,26 @@ private void initLimitationBody(final WebMarkupContainer body, ListItem<Property
body.add(modify);

TextFormGroup minOccurs = new TextFormGroup(ID_MIN_OCCURS, new PropertyModel<>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".minOccurs"),
createStringResource("LimitationsEditorDialog.label.minOccurs"), "SchemaHandlingStep.limitations.tooltip.minOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
createStringResource("LimitationsEditorDialog.label.minOccurs"), "SchemaHandlingStep.limitations.tooltip.minOccurs", ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
minOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
body.add(minOccurs);

TextFormGroup maxOccurs = new TextFormGroup(ID_MAX_OCCURS, new PropertyModel<>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".maxOccurs"),
createStringResource("LimitationsEditorDialog.label.maxOccurs"), "SchemaHandlingStep.limitations.tooltip.maxOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
createStringResource("LimitationsEditorDialog.label.maxOccurs"), "SchemaHandlingStep.limitations.tooltip.maxOccurs", ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
maxOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
body.add(maxOccurs);

CheckFormGroup ignore = new CheckFormGroup(ID_IGNORE, new PropertyModel<>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".ignore"),
createStringResource("LimitationsEditorDialog.label.ignore"), "SchemaHandlingStep.limitations.tooltip.ignore", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
createStringResource("LimitationsEditorDialog.label.ignore"), "SchemaHandlingStep.limitations.tooltip.ignore", ID_LABEL_SIZE, ID_INPUT_SIZE);
ignore.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
body.add(ignore);

Label layersTooltip = new Label(ID_T_LAYERS);
layersTooltip.add(new InfoTooltipBehavior(true) {
@Override
public String getModalContainer(Component component) {
return body.getMarkupId();
}
});
layersTooltip.add(new InfoTooltipBehavior());
body.add(layersTooltip);

Label propertyTooltip = new Label(ID_T_PROPERTY);
propertyTooltip.add(new InfoTooltipBehavior(true) {
@Override
public String getModalContainer(Component component) {
return body.getMarkupId();
}
});
propertyTooltip.add(new InfoTooltipBehavior());
body.add(propertyTooltip);
}

Expand Down

0 comments on commit 0a7e6d9

Please sign in to comment.