mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
PL-10693 Filter with invisible border has unusual caption
This commit is contained in:
parent
3192d6026b
commit
36d6df4e3e
@ -25,6 +25,7 @@ import org.dom4j.Element;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Encapsulates common generic filter behaviour. All filter components delegates their method invocations
|
||||
@ -131,6 +132,8 @@ public interface FilterDelegate {
|
||||
|
||||
void requestFocus();
|
||||
|
||||
void setCaptionChangedListener(Consumer<String> captionChangedListener);
|
||||
|
||||
class FDExpandedStateChangeEvent {
|
||||
private final FilterDelegate delegate;
|
||||
private final boolean expanded;
|
||||
|
@ -74,6 +74,7 @@ import javax.annotation.Nullable;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@ -200,6 +201,7 @@ public class FilterDelegateImpl implements FilterDelegate {
|
||||
protected boolean borderVisible = true;
|
||||
|
||||
protected Set<String> ftsLastDatasourceRefreshParamsNames = new HashSet<>();
|
||||
protected Consumer<String> captionChangedListener;
|
||||
|
||||
protected enum ConditionsFocusType {
|
||||
NONE,
|
||||
@ -1013,15 +1015,16 @@ public class FilterDelegateImpl implements FilterDelegate {
|
||||
saveAction.setEnabled(filterSavingPossible && filterModified);
|
||||
saveWithValuesAction.setEnabled(filterSavingPossible);
|
||||
|
||||
String currentCaption = groupBoxLayout.getCaption();
|
||||
String currentCaption = filter.isBorderVisible() ? groupBoxLayout.getCaption() : filter.getCaption();
|
||||
|
||||
if (StringUtils.isEmpty(currentCaption))
|
||||
return;
|
||||
|
||||
if (filterModified && !currentCaption.endsWith(MODIFIED_INDICATOR_SYMBOL)) {
|
||||
groupBoxLayout.setCaption(currentCaption + MODIFIED_INDICATOR_SYMBOL);
|
||||
captionChangedListener.accept(currentCaption + MODIFIED_INDICATOR_SYMBOL);
|
||||
}
|
||||
if (!filterModified && currentCaption.endsWith(MODIFIED_INDICATOR_SYMBOL)) {
|
||||
groupBoxLayout.setCaption(currentCaption.substring(0, currentCaption.length() - 1));
|
||||
captionChangedListener.accept(currentCaption.substring(0, currentCaption.length() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1650,7 +1653,6 @@ public class FilterDelegateImpl implements FilterDelegate {
|
||||
@Override
|
||||
public void setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
groupBoxLayout.setCaption(caption);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2116,7 +2118,8 @@ public class FilterDelegateImpl implements FilterDelegate {
|
||||
|
||||
windowManager.setWindowCaption(window, initialWindowCaption, filterTitle);
|
||||
|
||||
groupBoxLayout.setCaption(Strings.isNullOrEmpty(filterTitle) ? caption : caption + ": " + filterTitle);
|
||||
String newCaption = Strings.isNullOrEmpty(filterTitle) ? caption : caption + ": " + filterTitle;
|
||||
captionChangedListener.accept(newCaption);
|
||||
}
|
||||
|
||||
protected ControlsLayoutBuilder createControlsLayoutBuilder(String layoutDescription) {
|
||||
@ -2156,6 +2159,11 @@ public class FilterDelegateImpl implements FilterDelegate {
|
||||
this.afterFilterAppliedHandler = afterFilterAppliedHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaptionChangedListener(Consumer<String> captionChangedListener) {
|
||||
this.captionChangedListener = captionChangedListener;
|
||||
}
|
||||
|
||||
protected class FiltersLookupChangeListener implements Component.ValueChangeListener {
|
||||
public FiltersLookupChangeListener() {
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public class WebFilter extends WebAbstractComponent<CubaCssActionsLayout> implem
|
||||
component.setPrimaryStyleName(FILTER_STYLENAME);
|
||||
|
||||
delegate.addExpandedStateChangeListener(e -> fireExpandStateChange(e.isExpanded()));
|
||||
delegate.setCaptionChangedListener(this::updateCaptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,12 +193,18 @@ public class WebFilter extends WebAbstractComponent<CubaCssActionsLayout> implem
|
||||
|
||||
@Override
|
||||
public void setCaption(String caption) {
|
||||
if (delegate.isBorderVisible()) {
|
||||
delegate.setCaption(caption);
|
||||
|
||||
updateCaptions(caption);
|
||||
}
|
||||
|
||||
protected void updateCaptions(String caption) {
|
||||
if (delegate.isBorderVisible()) {
|
||||
component.setCaption(null);
|
||||
((HasCaption) delegate.getLayout()).setCaption(caption);
|
||||
} else {
|
||||
component.setCaption(caption);
|
||||
delegate.setCaption(null);
|
||||
((HasCaption) delegate.getLayout()).setCaption(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user