MECS-145_Minor_improvements_in_search_filter_New.
Signed-off-by: venu1278 <venugopal.boodidadinne@in.bosch.com>
This commit is contained in:
@@ -117,7 +117,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
private LayoutClickListener nameLayoutClickListner;
|
private LayoutClickListener nameLayoutClickListner;
|
||||||
|
|
||||||
private String newFilterQuery;
|
boolean validationFailed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Campaign Status History Header.
|
* Initialize the Campaign Status History Header.
|
||||||
@@ -133,9 +133,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
executor = (Executor) SpringContextHelper.getBean("uiExecutor");
|
executor = (Executor) SpringContextHelper.getBean("uiExecutor");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void restoreOnLoad() {
|
private void restoreOnLoad() {
|
||||||
if (filterManagementUIState.isEditViewDisplayed()) {
|
if (filterManagementUIState.isEditViewDisplayed()) {
|
||||||
populateComponents();
|
populateComponents();
|
||||||
@@ -168,7 +165,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
oldFilterName = filterManagementUIState.getTfQuery().get().getName();
|
oldFilterName = filterManagementUIState.getTfQuery().get().getName();
|
||||||
oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery();
|
oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery();
|
||||||
}
|
}
|
||||||
searchLayout.addComponentAsFirst(validationIcon);
|
|
||||||
showValidationSuccesIcon();
|
showValidationSuccesIcon();
|
||||||
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
||||||
headerCaption.setVisible(false);
|
headerCaption.setVisible(false);
|
||||||
@@ -179,20 +175,26 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
headerCaption.setVisible(true);
|
headerCaption.setVisible(true);
|
||||||
nameLabel.setValue("");
|
nameLabel.setValue("");
|
||||||
queryTextField.setValue("");
|
queryTextField.setValue("");
|
||||||
removeStatusIcon();
|
setInitialStatusIconStyle(validationIcon);
|
||||||
|
validationFailed = false;
|
||||||
saveButton.setEnabled(false);
|
saveButton.setEnabled(false);
|
||||||
titleFilterIconsLayout.removeStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
titleFilterIconsLayout.removeStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label createStatusIcon() {
|
private Label createStatusIcon() {
|
||||||
final Label statusIcon = new Label(FontAwesome.CHECK_CIRCLE.getHtml(), ContentMode.HTML);
|
final Label statusIcon = new Label();
|
||||||
statusIcon.setValue(null);
|
setInitialStatusIconStyle(statusIcon);
|
||||||
statusIcon.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
|
|
||||||
statusIcon.setVisible(false);
|
|
||||||
statusIcon.setImmediate(true);
|
|
||||||
return statusIcon;
|
return statusIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setInitialStatusIconStyle(final Label statusIcon) {
|
||||||
|
statusIcon.setContentMode(ContentMode.HTML);
|
||||||
|
statusIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||||
|
statusIcon.setImmediate(true);
|
||||||
|
statusIcon.setStyleName("hide-status-label");
|
||||||
|
statusIcon.setSizeFull();
|
||||||
|
}
|
||||||
|
|
||||||
private void createComponents() {
|
private void createComponents() {
|
||||||
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
|
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||||
@@ -288,8 +290,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
searchLayout = new HorizontalLayout();
|
searchLayout = new HorizontalLayout();
|
||||||
searchLayout.setSizeUndefined();
|
searchLayout.setSizeUndefined();
|
||||||
searchLayout.setSpacing(false);
|
searchLayout.setSpacing(false);
|
||||||
searchLayout.addComponent(queryTextField);
|
searchLayout.addComponents(validationIcon, queryTextField);
|
||||||
searchLayout.addStyleName("custom-search-layout");
|
searchLayout.addStyleName("custom-search-layout");
|
||||||
|
searchLayout.setComponentAlignment(validationIcon, Alignment.MIDDLE_CENTER);
|
||||||
|
|
||||||
final HorizontalLayout iconLayout = new HorizontalLayout();
|
final HorizontalLayout iconLayout = new HorizontalLayout();
|
||||||
iconLayout.setSizeUndefined();
|
iconLayout.setSizeUndefined();
|
||||||
@@ -326,50 +329,30 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void textChange(final TextChangeEvent event) {
|
public void textChange(final TextChangeEvent event) {
|
||||||
newFilterQuery = event.getText();
|
validationIcon.addStyleName("show-status-label");
|
||||||
executor.execute(new StatusCircledAsync(event));
|
showValidationInProgress();
|
||||||
|
onQueryChange(event.getText());
|
||||||
|
executor.execute(new StatusCircledAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class StatusCircledAsync implements Runnable {
|
class StatusCircledAsync implements Runnable {
|
||||||
final TextChangeEvent event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
public StatusCircledAsync(final TextChangeEvent event) {
|
|
||||||
this.event = event;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
processQueryChange();
|
|
||||||
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
|
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processQueryChange() {
|
|
||||||
this.getUI().access(() -> {
|
|
||||||
validationIcon.setVisible(true);
|
|
||||||
onQueryChange(newFilterQuery);
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onQueryChange(final String text) {
|
private void onQueryChange(final String text) {
|
||||||
boolean validationFailed = false;
|
|
||||||
if (!Strings.isNullOrEmpty(text)) {
|
if (!Strings.isNullOrEmpty(text)) {
|
||||||
final String input = text.toLowerCase();
|
final String input = text.toLowerCase();
|
||||||
searchLayout.addComponentAsFirst(validationIcon);
|
|
||||||
searchLayout.setComponentAlignment(validationIcon, Alignment.MIDDLE_CENTER);
|
|
||||||
showValidationInProgress();
|
|
||||||
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
|
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
|
||||||
if (!validationResult.getIsValidationFailed()) {
|
if (!validationResult.getIsValidationFailed()) {
|
||||||
filterManagementUIState.setFilterQueryValue(input);
|
filterManagementUIState.setFilterQueryValue(input);
|
||||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
|
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
|
||||||
|
validationFailed = false;
|
||||||
} else {
|
} else {
|
||||||
validationFailed = true;
|
validationFailed = true;
|
||||||
filterManagementUIState.setFilterQueryValue(null);
|
filterManagementUIState.setFilterQueryValue(null);
|
||||||
@@ -383,6 +366,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
filterManagementUIState.setFilterQueryValue(null);
|
filterManagementUIState.setFilterQueryValue(null);
|
||||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
queryTextField.setValue(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
||||||
@@ -411,17 +395,15 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showValidationSuccesIcon() {
|
private void showValidationSuccesIcon() {
|
||||||
if (null != filterManagementUIState.getFilterQueryValue()) {
|
if (!validationFailed) {
|
||||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||||
validationIcon.setDescription("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showValidationFailureIcon() {
|
private void showValidationFailureIcon() {
|
||||||
validationIcon.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
validationIcon.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||||
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
|
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showValidationInProgress() {
|
private void showValidationInProgress() {
|
||||||
|
|||||||
@@ -82,18 +82,6 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||||
setSelectable(false);
|
setSelectable(false);
|
||||||
eventBus.subscribe(this);
|
eventBus.subscribe(this);
|
||||||
addItemSetChangeListener(new ItemSetChangeListener() {
|
|
||||||
private static final long serialVersionUID = 9006291573733911656L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void containerItemSetChange(final com.vaadin.data.Container.ItemSetChangeEvent event) {
|
|
||||||
if (size() > 0) {
|
|
||||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
@@ -48,6 +48,14 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hide-status-label {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-status-label {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user