MECS-1454: Minor_improvements_in_search_filter_New

Signed-off-by: venu1278 <venugopal.boodidadinne@in.bosch.com>
This commit is contained in:
venu1278
2016-02-03 12:46:12 +05:30
parent 9115b01461
commit 973a5dd72a
9 changed files with 113 additions and 111 deletions

View File

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.ui.filtermanagement;
import java.util.concurrent.Executor;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -16,7 +18,6 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.documentation.DocumentationPageLink;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
@@ -25,6 +26,7 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -83,6 +85,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
@Autowired
private UINotification notification;
private transient Executor executor;
private Label headerCaption;
private TextField queryTextField;
@@ -113,7 +117,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private LayoutClickListener nameLayoutClickListner;
private Button targetFilterStatusButton;
private Label targetFilterStatusLabel;
private String newFilterQuery;
/**
* Initialize the Campaign Status History Header.
@@ -126,6 +132,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
restoreOnLoad();
setUpCaptionLayout(filterManagementUIState.isCreateFilterViewDisplayed());
eventBus.subscribe(this);
executor = (Executor) SpringContextHelper.getBean("uiExecutor");
}
/**
@@ -150,6 +157,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
setUpCaptionLayout(true);
resetComponents();
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
this.getUI().access(() -> targetFilterStatusLabel.setVisible(false));
}
}
@@ -194,31 +203,22 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
nameTextField = createNameTextField();
nameTextField.setWidth(380, Unit.PIXELS);
targetFilterStatusLabel = new Label();
targetFilterStatusLabel.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
targetFilterStatusLabel.setVisible(false);
targetFilterStatusLabel.setImmediate(true);
queryTextField = createSearchField();
addSearchLisenter();
validationIcon = createStatusIcon();
saveButton = createSaveButton();
targetFilterStatusButton = createTargetFilterStatusButton();
helpLink = DocumentationPageLink.TARGET_FILTER_VIEW.getLink();
closeIcon = createSearchResetIcon();
}
private Button createTargetFilterStatusButton() {
targetFilterStatusButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.TARGET_FILTER_STATUS_BUTTON,
"", "", "", false, null, SPUIButtonStyleSmall.class);
targetFilterStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
targetFilterStatusButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
targetFilterStatusButton.setWidth("100px");
targetFilterStatusButton.setHtmlContentAllowed(true);
targetFilterStatusButton.setVisible(false);
targetFilterStatusButton.setImmediate(true);
return targetFilterStatusButton;
}
/**
* @return
*/
@@ -299,9 +299,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
final HorizontalLayout iconLayout = new HorizontalLayout();
iconLayout.setSizeUndefined();
iconLayout.setSpacing(false);
iconLayout.setStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
iconLayout.addComponents(helpLink, saveButton, targetFilterStatusButton);
iconLayout.setComponentAlignment(targetFilterStatusButton, Alignment.MIDDLE_CENTER);
iconLayout.addComponents(helpLink, saveButton);
final HorizontalLayout queryLayout = new HorizontalLayout();
queryLayout.setSizeUndefined();
@@ -329,22 +327,50 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private void addSearchLisenter() {
queryTextField.addTextChangeListener(new TextChangeListener() {
private static final long serialVersionUID = -6668604418942689391L;
@Override
public void textChange(final TextChangeEvent event) {
enableTargetFilterStatusButton();
updateTargetFilterStatusToProgressIndicator();
onQueryChange(event.getText());
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
newFilterQuery = event.getText();
executor.execute(new StatusCircledAsync(event));
}
});
}
class StatusCircledAsync implements Runnable {
final TextChangeEvent event;
/**
*
* @param event
*/
public StatusCircledAsync(final TextChangeEvent event) {
this.event = event;
}
@Override
public void run() {
processQueryChange();
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
}
}
private void processQueryChange() {
this.getUI().access(() -> {
targetFilterStatusLabel.setVisible(true);
onQueryChange(newFilterQuery);
});
}
private void onQueryChange(final String text) {
boolean validationFailed = false;
if (!Strings.isNullOrEmpty(text)) {
final String input = text.toLowerCase();
searchLayout.addComponentAsFirst(validationIcon);
searchLayout.addComponentAsFirst(targetFilterStatusLabel);
searchLayout.setComponentAlignment(targetFilterStatusLabel, Alignment.MIDDLE_CENTER);
searchLayout.addComponent(validationIcon, 2);
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
if (!validationResult.getIsValidationFailed()) {
showValidationSuccesIcon();
@@ -366,8 +392,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query)
|| (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) {
if (validationFailed
|| (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField
.getValue().equals(oldFilterName)))) {
saveButton.setEnabled(false);
} else {
if (hasSavePermission()) {
@@ -468,8 +495,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
notification.displaySuccess(
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
notification.displaySuccess(i18n.get("message.create.filter.success",
new Object[] { targetFilterQuery.getName() }));
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
}
@@ -517,20 +544,4 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
return true;
}
protected void enableTargetFilterStatusButton() {
targetFilterStatusButton.setVisible(true);
}
protected void updateTargetFilterStatusToComplete() {
targetFilterStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
targetFilterStatusButton.setVisible(false);
}
protected void updateTargetFilterStatusToProgressIndicator() {
targetFilterStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
targetFilterStatusButton.setIcon(null);
}
}

View File

@@ -43,6 +43,7 @@ import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
/**
*
@@ -63,9 +64,6 @@ public class CreateOrUpdateFilterTable extends Table {
@Autowired
private FilterManagementUIState filterManagementUIState;
@Autowired
private CreateOrUpdateFilterHeader createOrUpdateFilterHeader;
private LazyQueryContainer container;
private static final int PROPERTY_DEPT = 3;
@@ -82,7 +80,20 @@ public class CreateOrUpdateFilterTable extends Table {
populateTableData();
setStyleName("sp-table");
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
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
@@ -92,10 +103,12 @@ public class CreateOrUpdateFilterTable extends Table {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY
|| custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
populateTableData();
UI.getCurrent().access(() -> populateTableData());
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> populateTableData());
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
}
}
@@ -149,15 +162,6 @@ public class CreateOrUpdateFilterTable extends Table {
setColumnProperties();
setPageLength(30);
setCollapsibleColumns();
this.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1236358037766785663L;
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
createOrUpdateFilterHeader.updateTargetFilterStatusToComplete();
}
});
}
/**

View File

@@ -82,7 +82,6 @@ public class FilterManagementView extends VerticalLayout implements View {
setSizeFull();
setSpacing(false);
setMargin(false);
addStyleName("table-layout");
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
viewCreateTargetFilterLayout();
} else if (filterManagementUIState.isEditViewDisplayed()) {
@@ -96,8 +95,9 @@ public class FilterManagementView extends VerticalLayout implements View {
void onEvent(final CustomFilterUIEvent custFilterUIEvent) {
if (custFilterUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
viewTargetFilterDetailLayout();
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
UI.getCurrent().access(() -> viewCreateTargetFilterLayout());
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|| custFilterUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> viewCreateTargetFilterLayout());
} else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) {
UI.getCurrent().access(() -> viewListView());
}
@@ -137,10 +137,17 @@ public class FilterManagementView extends VerticalLayout implements View {
private void viewListView() {
removeAllComponents();
addComponents(targetFilterHeader, targetFilterTable);
setComponentAlignment(targetFilterHeader, Alignment.TOP_LEFT);
setComponentAlignment(targetFilterTable, Alignment.TOP_LEFT);
setExpandRatio(targetFilterTable, 1.0f);
final VerticalLayout tableHeaderLayout = new VerticalLayout();
tableHeaderLayout.setSizeFull();
tableHeaderLayout.setSpacing(false);
tableHeaderLayout.setMargin(false);
tableHeaderLayout.setStyleName("table-layout");
tableHeaderLayout.addComponent(targetFilterHeader);
tableHeaderLayout.setComponentAlignment(targetFilterHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(targetFilterTable);
tableHeaderLayout.setComponentAlignment(targetFilterTable, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(targetFilterTable, 1.0f);
addComponent(tableHeaderLayout);
}
private HorizontalLayout addTargetFilterMessageLabel() {

View File

@@ -103,14 +103,12 @@ public class TargetFilterTable extends Table {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent filterEvent) {
UI.getCurrent().access(() -> {
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
refreshContainer();
}
});
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
UI.getCurrent().access(() -> refreshContainer());
}
}
/**
@@ -125,8 +123,8 @@ public class TargetFilterTable extends Table {
targetQF.setQueryConfiguration(queryConfig);
// create lazy query container with lazy defination and query
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetFilterContainer;
@@ -135,8 +133,8 @@ public class TargetFilterTable extends Table {
private Map<String, Object> prepareQueryConfigFilters() {
final Map<String, Object> queryConfig = new HashMap<String, Object>();
filterManagementUIState.getCustomFilterSearchText()
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
filterManagementUIState.getCustomFilterSearchText().ifPresent(
value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
return queryConfig;
}
@@ -205,8 +203,8 @@ public class TargetFilterTable extends Table {
* of the deleted custom filter.
*/
notification.displaySuccess(
i18n.get("message.delete.filter.success", new Object[] { deletedFilterName }));
notification.displaySuccess(i18n.get("message.delete.filter.success",
new Object[] { deletedFilterName }));
refreshContainer();
}
});

View File

@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
*
*/
public enum CustomFilterUIEvent {
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY,
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, TARGET_FILTER_STATUS_HIDE
}

View File

@@ -12,8 +12,6 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.filtermanagement.CreateOrUpdateFilterTable;
import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterTable;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -44,12 +42,6 @@ public class TargetFilterCountMessageLabel extends Label {
private static final long serialVersionUID = -7188528790042766877L;
@Autowired
private CreateOrUpdateFilterTable createNewFilterTable;
@Autowired
private TargetFilterTable targetFilterTable;
@Autowired
private FilterManagementUIState filterManagementUIState;
@@ -95,12 +87,10 @@ public class TargetFilterCountMessageLabel extends Label {
private void displayTargetFilterMessage() {
long totalTargets = 0;
long shownTargets = 0;
if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) {
if (null != filterManagementUIState.getFilterQueryValue()) {
totalTargets = targetManagement.countTargetByTargetFilterQuery(filterManagementUIState
.getFilterQueryValue());
shownTargets = createNewFilterTable.size();
}
final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total"));
if (filterManagementUIState.getTargetsTruncated() != null) {
@@ -115,32 +105,16 @@ public class TargetFilterCountMessageLabel extends Label {
}
targetMessage.append(totalTargets);
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(i18n.get("label.filter.shown"));
if (totalTargets > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
targetMessage.append(i18n.get("label.filter.shown"));
targetMessage.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
} else {
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(i18n.get("label.filter.shown"));
targetMessage.append(shownTargets);
targetMessage.append(totalTargets);
}
setCaption(targetMessage.toString());
} else {
final StringBuilder tarFilterMessage = new StringBuilder(i18n.get("label.custom.filter.target.count"));
createMsgLable(targetFilterTable.size(), tarFilterMessage);
}
}
private void createMsgLable(final long totalCount, final StringBuilder message) {
message.append(totalCount);
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
if (totalCount > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
message.append(i18n.get("label.filter.shown"));
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
setCaption(message.toString());
}
}

View File

@@ -234,7 +234,7 @@ public final class SPUIStyleDefinitions {
/**
* Target filter search progress indicator style.
*/
public static final String TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE = "target-filter-search-layout";
public static final String TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE = "target-filter-spinner";
/**
* Constructor.

View File

@@ -87,7 +87,7 @@
}
.footer-layout , .target-filter-search-layout{
.footer-layout{
.app-loading {
background-position: bottom;
background-repeat: no-repeat;

View File

@@ -41,5 +41,13 @@
box-shadow:none !important;
}
.target-filter-spinner{
@include valo-spinner(
$size: $v-font-size--small,
$color: $bosch-color-light-blue
);
}
}