Merge pull request #28 from bsinno/Custom_target_filter_bug_fixes
Custom target filter bug fixes
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -54,6 +56,7 @@ import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@@ -119,8 +122,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
private LayoutClickListener nameLayoutClickListner;
|
||||
|
||||
boolean validationFailed = false;
|
||||
|
||||
private boolean validationFailed = false;
|
||||
|
||||
/**
|
||||
* Initialize the Campaign Status History Header.
|
||||
*/
|
||||
@@ -146,19 +149,20 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||
populateComponents();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
setUpCaptionLayout(true);
|
||||
resetComponents();
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
|
||||
this.getUI().access(() -> showValidationSuccesIcon());
|
||||
}
|
||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||
populateComponents();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
setUpCaptionLayout(true);
|
||||
resetComponents();
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
|
||||
this.getUI().access(() -> updateStatusIconAfterTablePopulated());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void populateComponents() {
|
||||
if (filterManagementUIState.getTfQuery().isPresent()) {
|
||||
queryTextField.setValue(filterManagementUIState.getTfQuery().get().getQuery());
|
||||
@@ -184,16 +188,16 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
private Label createStatusIcon() {
|
||||
final Label statusIcon = new Label();
|
||||
statusIcon.setImmediate(true);
|
||||
statusIcon.setContentMode(ContentMode.HTML);
|
||||
statusIcon.setSizeFull();
|
||||
setInitialStatusIconStyle(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() {
|
||||
@@ -216,10 +220,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
closeIcon = createSearchResetIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
private TextField createNameTextField() {
|
||||
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
@@ -255,10 +257,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
private void onFiterNameChange(final TextChangeEvent event) {
|
||||
if (isNameAndQueryEmpty(event.getText(), queryTextField.getValue())
|
||||
|| (event.getText().equals(oldFilterName) && queryTextField.getValue().equals(oldFilterQuery))) {
|
||||
@@ -363,7 +361,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
enableDisableSaveButton(validationFailed, input);
|
||||
} else {
|
||||
removeStatusIcon();
|
||||
setInitialStatusIconStyle(validationIcon);
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
||||
}
|
||||
@@ -389,17 +387,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
return false;
|
||||
}
|
||||
|
||||
private void removeStatusIcon() {
|
||||
if (searchLayout.getComponentIndex(validationIcon) != -1) {
|
||||
searchLayout.removeComponent(validationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
private void showValidationSuccesIcon() {
|
||||
if (!validationFailed) {
|
||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
private void showValidationFailureIcon() {
|
||||
@@ -506,9 +497,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private boolean doesAlreadyExists() {
|
||||
if (targetFilterQueryManagement.findTargetFilterQueryByName(nameTextField.getValue()) != null) {
|
||||
notification.displayValidationError(i18n.get("message.target.filter.duplicate", nameTextField.getValue()));
|
||||
@@ -517,9 +505,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private boolean manadatoryFieldsPresent() {
|
||||
if (Strings.isNullOrEmpty(nameTextField.getValue())
|
||||
|| Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
|
||||
@@ -528,5 +513,12 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateStatusIconAfterTablePopulated() {
|
||||
queryTextField.focus();
|
||||
if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) {
|
||||
showValidationSuccesIcon();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
import com.google.common.base.Strings;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.server.Sizeable.Unit;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
@@ -44,6 +45,7 @@ import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -73,12 +75,16 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
setStyleName("sp-table");
|
||||
setSizeFull();
|
||||
setImmediate(true);
|
||||
setHeight(100.0f, Unit.PERCENTAGE);
|
||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_SMALL);
|
||||
setColumnCollapsingAllowed(true);
|
||||
addCustomGeneratedColumns();
|
||||
restoreOnLoad();
|
||||
populateTableData();
|
||||
setStyleName("sp-table");
|
||||
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||
setSelectable(false);
|
||||
eventBus.subscribe(this);
|
||||
@@ -95,12 +101,13 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
UI.getCurrent().access(() -> populateTableData());
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
||||
this.getUI().access(() -> populateTableData());
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
||||
this.getUI().access(() -> onQuery());
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreOnLoad() {
|
||||
|
||||
|
||||
private void restoreOnLoad() {
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
} else {
|
||||
@@ -152,9 +159,6 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
setCollapsibleColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void setCollapsibleColumns() {
|
||||
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
|
||||
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
|
||||
@@ -178,8 +182,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|
||||
private List<TableColumn> getVisbleColumns() {
|
||||
final List<TableColumn> columnList = new ArrayList<>();
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"),0.15f));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||
@@ -237,5 +241,9 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
protected void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
|
||||
}
|
||||
|
||||
|
||||
private void onQuery() {
|
||||
populateTableData();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,6 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
|
||||
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
|
||||
messageLabelLayout.addStyleName("footer-layout");
|
||||
messageLabelLayout.setWidth("100%");
|
||||
return messageLabelLayout;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.server.Sizeable.Unit;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Button;
|
||||
@@ -83,18 +84,20 @@ public class TargetFilterTable extends Table {
|
||||
* Initialize the Action History Table.
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
addCustomGeneratedColumns();
|
||||
populateTableData();
|
||||
setStyleName("sp-table");
|
||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_SMALL);
|
||||
setColumnCollapsingAllowed(true);
|
||||
setColumnProperties();
|
||||
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
|
||||
eventBus.subscribe(this);
|
||||
setSizeFull();
|
||||
}
|
||||
public void init() {
|
||||
setStyleName("sp-table");
|
||||
setSizeFull();
|
||||
setImmediate(true);
|
||||
setHeight(100.0f, Unit.PERCENTAGE);
|
||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_SMALL);
|
||||
addCustomGeneratedColumns();
|
||||
populateTableData();
|
||||
setColumnCollapsingAllowed(true);
|
||||
setColumnProperties();
|
||||
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
|
||||
@@ -197,33 +197,36 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable {
|
||||
}
|
||||
|
||||
private void setRolloutStatusIcon(final Status targetUpdateStatus, final Label statusLabel) {
|
||||
switch (targetUpdateStatus) {
|
||||
case ERROR:
|
||||
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconRed");
|
||||
break;
|
||||
case SCHEDULED:
|
||||
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
|
||||
statusLabel.addStyleName("statusIconBlue");
|
||||
break;
|
||||
case FINISHED:
|
||||
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconGreen");
|
||||
break;
|
||||
case RUNNING:
|
||||
case RETRIEVED:
|
||||
case WARNING:
|
||||
case DOWNLOAD:
|
||||
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
|
||||
statusLabel.addStyleName("statusIconYellow");
|
||||
break;
|
||||
case CANCELED:
|
||||
case CANCELING:
|
||||
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconPending");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (targetUpdateStatus) {
|
||||
case ERROR:
|
||||
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconRed");
|
||||
break;
|
||||
case SCHEDULED:
|
||||
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
|
||||
statusLabel.addStyleName("statusIconBlue");
|
||||
break;
|
||||
case FINISHED:
|
||||
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconGreen");
|
||||
break;
|
||||
case RUNNING:
|
||||
case RETRIEVED:
|
||||
case WARNING:
|
||||
case DOWNLOAD:
|
||||
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
|
||||
statusLabel.addStyleName("statusIconYellow");
|
||||
break;
|
||||
case CANCELED:
|
||||
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconGreen");
|
||||
break;
|
||||
case CANCELING:
|
||||
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
|
||||
statusLabel.addStyleName("statusIconPending");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user