@@ -13,10 +13,17 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.tokenfield.TokenField;
|
||||
import org.vaadin.tokenfield.TokenField.InsertPosition;
|
||||
|
||||
@@ -52,13 +59,33 @@ public abstract class AbstractTagToken implements Serializable {
|
||||
protected final Map<Long, TagData> tokensAdded = new HashMap<>();
|
||||
|
||||
protected CssLayout tokenLayout = new CssLayout();
|
||||
|
||||
@Autowired
|
||||
protected SpPermissionChecker checker;
|
||||
|
||||
@Autowired
|
||||
protected I18N i18n;
|
||||
|
||||
@Autowired
|
||||
protected UINotification uinotification;
|
||||
|
||||
@Autowired
|
||||
protected transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@Autowired
|
||||
protected ManagementUIState managementUIState;
|
||||
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
createTokenField();
|
||||
checkIfTagAssignedIsAllowed();
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
private void createTokenField() {
|
||||
|
||||
@@ -8,54 +8,25 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.tagdetails;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Abstract class for target tag token layout.
|
||||
*/
|
||||
public abstract class AbstractTargetTagToken extends AbstractTagToken {
|
||||
|
||||
private static final long serialVersionUID = 7772876588903171201L;
|
||||
protected UI ui;
|
||||
|
||||
@Autowired
|
||||
protected transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@Autowired
|
||||
protected I18N i18n;
|
||||
|
||||
@Autowired
|
||||
protected transient TagManagement tagManagement;
|
||||
|
||||
@Autowired
|
||||
protected SpPermissionChecker checker;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
super.init();
|
||||
ui = UI.getCurrent();
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent;
|
||||
@@ -22,7 +21,6 @@ import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
@@ -31,10 +29,7 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
@@ -52,19 +47,6 @@ import com.vaadin.ui.UI;
|
||||
public class DistributionTagToken extends AbstractTagToken {
|
||||
|
||||
private static final long serialVersionUID = -8022738301736043396L;
|
||||
|
||||
@Autowired
|
||||
private SpPermissionChecker spChecker;
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@Autowired
|
||||
private UINotification uinotification;
|
||||
|
||||
@Autowired
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@Autowired
|
||||
private transient TagManagement tagManagement;
|
||||
|
||||
@@ -73,20 +55,9 @@ public class DistributionTagToken extends AbstractTagToken {
|
||||
|
||||
private DistributionSet selectedDS;
|
||||
|
||||
private UI ui;
|
||||
|
||||
// To Be Done : have to set this value based on view???
|
||||
private static final Boolean NOTAGS_SELECTED = Boolean.FALSE;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
super.init();
|
||||
ui = UI.getCurrent();
|
||||
eventBus.subscribe(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTagStyleName() {
|
||||
return "distribution-tag-";
|
||||
@@ -140,7 +111,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
||||
|
||||
@Override
|
||||
protected Boolean isToggleTagAssignmentAllowed() {
|
||||
return spChecker.hasUpdateDistributionPermission();
|
||||
return checker.hasUpdateDistributionPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,18 +134,15 @@ public class DistributionTagToken extends AbstractTagToken {
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE) {
|
||||
ui.access(() -> {
|
||||
/**
|
||||
* distributionTableEvent.getDistributionSet() is null when
|
||||
* table has no data.
|
||||
*/
|
||||
if (distributionTableEvent.getDistributionSet() != null) {
|
||||
selectedDS = distributionTableEvent.getDistributionSet();
|
||||
repopulateToken();
|
||||
}
|
||||
});
|
||||
if (distributionTableEvent.getDistributionComponentEvent() != DistributionComponentEvent.ON_VALUE_CHANGE) {
|
||||
return;
|
||||
}
|
||||
UI.getCurrent().access(() -> {
|
||||
if (distributionTableEvent.getDistributionSet() != null) {
|
||||
selectedDS = distributionTableEvent.getDistributionSet();
|
||||
repopulateToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -234,6 +202,7 @@ public class DistributionTagToken extends AbstractTagToken {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Implementation of Target tag token.
|
||||
@@ -175,10 +176,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
|
||||
void onEvent(final TargetTableEvent targetTableEvent) {
|
||||
if (targetTableEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET
|
||||
&& targetTableEvent.getTarget() != null) {
|
||||
ui.access(() -> {
|
||||
/**
|
||||
* targetTableEvent.getTarget() is null when table has no data.
|
||||
*/
|
||||
UI.getCurrent().access(() -> {
|
||||
selectedTarget = targetTableEvent.getTarget();
|
||||
repopulateToken();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user