Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
TagPicker styleName attribute removes tag-picker styles #671
Browse files Browse the repository at this point in the history
Reworked get/set/remove style name methods to work the same as other components
  • Loading branch information
Flaurite committed Oct 18, 2021
1 parent 016a929 commit 8a4539d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
12 changes: 2 additions & 10 deletions ui/src/main/java/io/jmix/ui/widget/JmixComboBoxPickerField.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.vaadin.ui.IconGenerator;
import com.vaadin.ui.ItemCaptionGenerator;
import com.vaadin.ui.StyleGenerator;
import org.apache.commons.lang3.StringUtils;

import javax.annotation.Nullable;
import java.util.Collection;
Expand Down Expand Up @@ -62,12 +63,7 @@ public void setStyleName(String style) {

@Override
public String getStyleName() {
return removeComponentStyles(super.getStyleName());
}

@Override
public void removeStyleName(String style) {
super.removeStyleName(removeComponentStyles(style));
return StringUtils.normalizeSpace(super.getStyleName().replace(COMBOBOX_PICKERFIELD_STYLENAME, ""));
}

@Override
Expand Down Expand Up @@ -188,8 +184,4 @@ public void setNewItemHandler(@Nullable ComboBox.NewItemHandler newItemHandler)
public void setStyleGenerator(StyleGenerator<T> generateItemStylename) {
getFieldInternal().setStyleGenerator(generateItemStylename);
}

protected String removeComponentStyles(String styleName) {
return styleName.replaceAll(COMBOBOX_PICKERFIELD_STYLENAME, "");
}
}
19 changes: 9 additions & 10 deletions ui/src/main/java/io/jmix/ui/widget/JmixTagPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import javax.annotation.Nullable;
import java.util.*;
Expand Down Expand Up @@ -147,7 +148,14 @@ public void setReadOnly(boolean readOnly) {
public void setStyleName(String style) {
super.setStyleName(TAGPICKER_STYLENAME
+ " " + getTagContainerPositionStyle(getTagContainerPosition())
+ " " + removeComponentStyles(style));
+ " " + style);
}

@Override
public String getStyleName() {
return StringUtils.normalizeSpace(super.getStyleName()
.replace(TAGPICKER_STYLENAME, "")
.replace(getTagContainerPositionStyle(getTagContainerPosition()), ""));
}

public boolean isInlineTags() {
Expand Down Expand Up @@ -265,13 +273,4 @@ protected String getTagContainerPositionStyle(TagContainerPosition containerPosi
return TAGS_BOTTOM_STYLENAME;
}
}

protected String removeComponentStyles(String styleName) {
String style = super.removeComponentStyles(styleName);
return style.replaceAll(TAGPICKER_STYLENAME
+ "|" + TAGS_TOP_STYLENAME
+ "|" + TAGS_RIGHT_STYLENAME
+ "|" + TAGS_BOTTOM_STYLENAME
+ "|" + TAGS_LEFT_STYLENAME, "");
}
}

0 comments on commit 8a4539d

Please sign in to comment.