Validate all drag and drop events
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -40,7 +40,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -215,21 +214,13 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
protected AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return uploadViewAcceptCriteria;
|
return uploadViewAcceptCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
/* Not required */
|
return false;
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -237,8 +228,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
|
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Button createManageMetadataButton(final String nameVersionStr) {
|
||||||
private Button createManageMetadataButton(String nameVersionStr) {
|
|
||||||
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
||||||
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
||||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||||
@@ -254,9 +244,9 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
return name + "." + version;
|
return name + "." + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMetadataDetails(Long itemId, String nameVersionStr) {
|
private void showMetadataDetails(final Long itemId, final String nameVersionStr) {
|
||||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
||||||
/* display the window */
|
/* display the window */
|
||||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null));
|
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
|
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract table to handling {@link NamedVersionedEntity}
|
* Abstract table to handling {@link NamedVersionedEntity}
|
||||||
@@ -54,4 +56,30 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
|
|||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
|
// subclass can implement
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
// subclass can implement
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hasDropPermission() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDropTableId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,20 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
|
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
|
||||||
|
import com.google.gwt.thirdparty.guava.common.collect.Sets;
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.Transferable;
|
||||||
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
import com.vaadin.event.dd.DropHandler;
|
||||||
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
@@ -51,12 +58,17 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 4856562746502217630L;
|
private static final long serialVersionUID = 4856562746502217630L;
|
||||||
|
|
||||||
|
protected static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected transient EventBus.SessionEventBus eventBus;
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected I18N i18n;
|
protected I18N i18n;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected UINotification notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the components.
|
* Initialize the components.
|
||||||
*/
|
*/
|
||||||
@@ -359,12 +371,100 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
|||||||
return DEFAULT_COLUMN_NAME_MIN_SIZE;
|
return DEFAULT_COLUMN_NAME_MIN_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private DropHandler getTableDropHandler() {
|
||||||
* Get drop handler for the table.
|
return new DropHandler() {
|
||||||
*
|
private static final long serialVersionUID = 1L;
|
||||||
* @return reference of {@link DropHandler}
|
|
||||||
*/
|
@Override
|
||||||
protected abstract DropHandler getTableDropHandler();
|
public AcceptCriterion getAcceptCriterion() {
|
||||||
|
return getDropAcceptCriterion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drop(final DragAndDropEvent event) {
|
||||||
|
if (!isDropValid(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
||||||
|
onDropEventFromTable(event);
|
||||||
|
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper) {
|
||||||
|
onDropEventFromWrapper(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<I> getDraggedTargetList(final DragAndDropEvent event) {
|
||||||
|
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
|
||||||
|
final Table targetTable = (Table) taregtDet.getTarget();
|
||||||
|
final Set<I> targetSelected = getTableValue(targetTable);
|
||||||
|
|
||||||
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
|
final Object targetItemId = dropData.getItemIdOver();
|
||||||
|
|
||||||
|
if (!targetSelected.contains(targetItemId)) {
|
||||||
|
return Sets.newHashSet((I) targetItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<Object> getDraggedTargetList(final TableTransferable transferable, final Table source) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final AbstractTable<NamedEntity, Object> table = (AbstractTable<NamedEntity, Object>) source;
|
||||||
|
return table.getDeletedEntityByTransferable(transferable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateDropList(final Set<?> droplist) {
|
||||||
|
if (droplist.isEmpty()) {
|
||||||
|
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
|
||||||
|
notification.displayValidationError(actionDidNotWork);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
|
final Transferable transferable = dragEvent.getTransferable();
|
||||||
|
final Component compsource = transferable.getSourceComponent();
|
||||||
|
|
||||||
|
if (!hasDropPermission()) {
|
||||||
|
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compsource instanceof Table) {
|
||||||
|
return validateTable((Table) compsource)
|
||||||
|
&& validateDropList(getDraggedTargetList((TableTransferable) transferable, (Table) compsource));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compsource instanceof DragAndDropWrapper) {
|
||||||
|
return validateDragAndDropWrapper((DragAndDropWrapper) compsource)
|
||||||
|
&& validateDropList(getDraggedTargetList(dragEvent));
|
||||||
|
}
|
||||||
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateTable(final Table compsource) {
|
||||||
|
if (!compsource.getId().equals(getDropTableId())) {
|
||||||
|
notification.displayValidationError(ACTION_NOT_ALLOWED_MSG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean hasDropPermission();
|
||||||
|
|
||||||
|
protected abstract boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource);
|
||||||
|
|
||||||
|
protected abstract void onDropEventFromWrapper(DragAndDropEvent event);
|
||||||
|
|
||||||
|
protected abstract void onDropEventFromTable(DragAndDropEvent event);
|
||||||
|
|
||||||
|
protected abstract String getDropTableId();
|
||||||
|
|
||||||
|
protected abstract AcceptCriterion getDropAcceptCriterion();
|
||||||
|
|
||||||
protected abstract void setDataAvailable(boolean available);
|
protected abstract void setDataAvailable(boolean available);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -58,7 +57,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -97,9 +95,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
|
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UINotification notification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient TargetManagement targetManagement;
|
private transient TargetManagement targetManagement;
|
||||||
|
|
||||||
@@ -189,9 +184,9 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
|
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
|
||||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
|
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
|
||||||
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
||||||
if(distributionSet!=null){
|
if (distributionSet != null) {
|
||||||
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
||||||
distributionSet.getName(),distributionSet.getVersion()));
|
distributionSet.getName(), distributionSet.getVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,25 +196,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return distributionsViewAcceptCriteria;
|
return distributionsViewAcceptCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
if (doValidation(event)) {
|
|
||||||
onDrop(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDrop(final DragAndDropEvent event) {
|
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
|
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
|
||||||
@@ -232,6 +214,22 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
|
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
|
||||||
handleDropEvent(source, softwareModulesIdList, item);
|
handleDropEvent(source, softwareModulesIdList, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
|
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
||||||
|
if (!(compsource instanceof Table)) {
|
||||||
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.isDropValid(dragEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Item item) {
|
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Item item) {
|
||||||
@@ -334,7 +332,8 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
||||||
notification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
|
notification.displayValidationError(
|
||||||
|
i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -385,31 +384,14 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Validate event.
|
protected String getDropTableId() {
|
||||||
*
|
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||||
* @param dragEvent
|
|
||||||
* as event
|
|
||||||
* @return boolean as flag
|
|
||||||
*/
|
|
||||||
private Boolean doValidation(final DragAndDropEvent dragEvent) {
|
|
||||||
if (!permissionChecker.hasUpdateDistributionPermission()) {
|
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
|
||||||
final Table source = (Table) compsource;
|
|
||||||
if (compsource instanceof Table) {
|
|
||||||
if (!source.getId().equals(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
|
|
||||||
notification.displayValidationError(i18n.get("message.action.not.allowed"));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
notification.displayValidationError(i18n.get("message.action.not.allowed"));
|
@Override
|
||||||
return false;
|
protected boolean hasDropPermission() {
|
||||||
}
|
return permissionChecker.hasUpdateDistributionPermission();
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTableStyleGenerator() {
|
private void addTableStyleGenerator() {
|
||||||
@@ -488,13 +470,13 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||||
final String nameVersionStr = getNameAndVerion(itemId);
|
final String nameVersionStr = getNameAndVerion(itemId);
|
||||||
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
||||||
manageMetaDataBtn.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
manageMetaDataBtn
|
||||||
|
.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
||||||
return manageMetaDataBtn;
|
return manageMetaDataBtn;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TableColumn> getTableVisibleColumns() {
|
protected List<TableColumn> getTableVisibleColumns() {
|
||||||
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
||||||
@@ -515,7 +497,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
|
|
||||||
private void showMetadataDetails(final Long itemId) {
|
private void showMetadataDetails(final Long itemId) {
|
||||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
||||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNameAndVerion(final Object itemId) {
|
private String getNameAndVerion(final Object itemId) {
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.server.Page;
|
import com.vaadin.server.Page;
|
||||||
@@ -180,9 +179,10 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
|
|
||||||
addGeneratedColumn(SPUILabelDefinitions.ARTIFACT_ICON, new ColumnGenerator() {
|
addGeneratedColumn(SPUILabelDefinitions.ARTIFACT_ICON, new ColumnGenerator() {
|
||||||
private static final long serialVersionUID = -5982361782989980277L;
|
private static final long serialVersionUID = -5982361782989980277L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||||
HorizontalLayout iconLayout = new HorizontalLayout();
|
final HorizontalLayout iconLayout = new HorizontalLayout();
|
||||||
// add artifactory details popup
|
// add artifactory details popup
|
||||||
final String nameVersionStr = getNameAndVerion(itemId);
|
final String nameVersionStr = getNameAndVerion(itemId);
|
||||||
final Button showArtifactDtlsBtn = createShowArtifactDtlsButton(nameVersionStr);
|
final Button showArtifactDtlsBtn = createShowArtifactDtlsButton(nameVersionStr);
|
||||||
@@ -214,7 +214,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
@Override
|
@Override
|
||||||
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
|
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
|
||||||
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
|
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
|
||||||
if(selectedLastEntity!=null){
|
if (selectedLastEntity != null) {
|
||||||
manageDistUIState.setSelectedBaseSwModuleId(selectedLastEntity.getId());
|
manageDistUIState.setSelectedBaseSwModuleId(selectedLastEntity.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,21 +252,13 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
protected AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6175865860867652573L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return distributionsViewAcceptCriteria;
|
return distributionsViewAcceptCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
/* sw module dont accept drops */
|
return false;
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All Private Methods */
|
/* All Private Methods */
|
||||||
@@ -326,7 +318,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
return showArtifactDtlsBtn;
|
return showArtifactDtlsBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createManageMetadataButton(String nameVersionStr) {
|
private Button createManageMetadataButton(final String nameVersionStr) {
|
||||||
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
||||||
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
||||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||||
@@ -407,9 +399,9 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMetadataDetails(Long itemId) {
|
private void showMetadataDetails(final Long itemId) {
|
||||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
||||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null));
|
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,12 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
@@ -308,36 +306,23 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return managementViewAcceptCriteria;
|
return managementViewAcceptCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
if (doValidation(event)) {
|
|
||||||
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
|
||||||
assignTargetToDs(event);
|
assignTargetToDs(event);
|
||||||
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper) {
|
|
||||||
processWrapperDrop(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processWrapperDrop(final DragAndDropEvent event) {
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
if (event.getTransferable().getSourceComponent().getId()
|
if (event.getTransferable().getSourceComponent().getId()
|
||||||
.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
||||||
assignDsTag(event);
|
assignDsTag(event);
|
||||||
} else {
|
} else {
|
||||||
assignTargetTag(event);
|
assignTargetTag(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignDsTag(final DragAndDropEvent event) {
|
private void assignDsTag(final DragAndDropEvent event) {
|
||||||
@@ -410,43 +395,27 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean doValidation(final DragAndDropEvent dragEvent) {
|
@Override
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
protected boolean hasDropPermission() {
|
||||||
if (compsource instanceof Table) {
|
return permissionChecker.hasUpdateTargetPermission();
|
||||||
return validateTable(compsource);
|
|
||||||
} else if (compsource instanceof DragAndDropWrapper) {
|
|
||||||
return validateDragAndDropWrapper(compsource);
|
|
||||||
} else {
|
|
||||||
notification.displayValidationError(notAllowedMsg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateTable(final Component compsource) {
|
@Override
|
||||||
if (!permissionChecker.hasUpdateTargetPermission()) {
|
protected String getDropTableId() {
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
return SPUIComponentIdProvider.TARGET_TABLE_ID;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (compsource instanceof Table && !compsource.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
|
|
||||||
notification.displayValidationError(notAllowedMsg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
@Override
|
||||||
final DragAndDropWrapper wrapperSource = (DragAndDropWrapper) compsource;
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
final String tagData = wrapperSource.getData().toString();
|
final String tagData = wrapperSource.getData().toString();
|
||||||
if (wrapperSource.getId().startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
if (wrapperSource.getId().startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
||||||
return !isNoTagButton(tagData, SPUIDefinitions.DISTRIBUTION_TAG_BUTTON);
|
return !isNoTagButton(tagData, SPUIDefinitions.DISTRIBUTION_TAG_BUTTON);
|
||||||
} else if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
} else if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
||||||
return !isNoTagButton(tagData, SPUIDefinitions.TARGET_TAG_BUTTON);
|
return !isNoTagButton(tagData, SPUIDefinitions.TARGET_TAG_BUTTON);
|
||||||
} else {
|
}
|
||||||
notification.displayValidationError(notAllowedMsg);
|
notification.displayValidationError(notAllowedMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
||||||
if (tagData.equals(targetNoTagData)) {
|
if (tagData.equals(targetNoTagData)) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
|||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
@@ -57,7 +58,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -71,7 +71,6 @@ import com.google.common.base.Strings;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
import com.vaadin.shared.ui.label.ContentMode;
|
||||||
@@ -79,7 +78,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
@@ -99,7 +97,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
private static final long serialVersionUID = -2300392868806614568L;
|
private static final long serialVersionUID = -2300392868806614568L;
|
||||||
|
|
||||||
private static final int PROPERTY_DEPT = 3;
|
private static final int PROPERTY_DEPT = 3;
|
||||||
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient TargetManagement targetManagement;
|
private transient TargetManagement targetManagement;
|
||||||
@@ -110,9 +107,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SpPermissionChecker permChecker;
|
private SpPermissionChecker permChecker;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UINotification notification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
|
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
|
||||||
|
|
||||||
@@ -307,24 +301,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return managementViewAcceptCriteria;
|
return managementViewAcceptCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
if (doValidations(event)) {
|
|
||||||
doAssignments(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onTargetDeletedEvent(final List<TargetDeletedEvent> events) {
|
private void onTargetDeletedEvent(final List<TargetDeletedEvent> events) {
|
||||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||||
@@ -522,14 +502,16 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAssignments(final DragAndDropEvent event) {
|
@Override
|
||||||
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
dsToTargetAssignment(event);
|
dsToTargetAssignment(event);
|
||||||
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper
|
|
||||||
&& isNoTagAssigned(event)) {
|
|
||||||
tagAssignment(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
if (isNoTagAssigned(event)) {
|
||||||
|
tagAssignment(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
|
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
|
||||||
@@ -544,17 +526,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tagAssignment(final DragAndDropEvent event) {
|
private void tagAssignment(final DragAndDropEvent event) {
|
||||||
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
|
final List<String> targetList = getDraggedTargetList(event).stream()
|
||||||
final Table targetTable = (Table) taregtDet.getTarget();
|
.map(targetIdName -> targetIdName.getControllerId()).collect(Collectors.toList());
|
||||||
final Set<TargetIdName> targetSelected = getTableValue(targetTable);
|
|
||||||
final Set<String> targetList = new HashSet<>();
|
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
|
||||||
final Object targetItemId = dropData.getItemIdOver();
|
|
||||||
if (!targetSelected.contains(targetItemId)) {
|
|
||||||
targetList.add(((TargetIdName) targetItemId).getControllerId());
|
|
||||||
} else {
|
|
||||||
targetList.addAll(targetSelected.stream().map(t -> t.getControllerId()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
|
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
if (targetList.isEmpty()) {
|
if (targetList.isEmpty()) {
|
||||||
@@ -572,52 +546,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Check Validation on Drop.
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
*
|
final String tagName = HawkbitCommonUtil.removePrefix(wrapperSource.getId(),
|
||||||
* @param dragEvent
|
|
||||||
* as drop event
|
|
||||||
* @return Boolean as flag
|
|
||||||
*/
|
|
||||||
private Boolean doValidations(final DragAndDropEvent dragEvent) {
|
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
|
||||||
if (compsource instanceof Table) {
|
|
||||||
return validateTable(compsource, (TableTransferable) dragEvent.getTransferable());
|
|
||||||
} else if (compsource instanceof DragAndDropWrapper) {
|
|
||||||
validateDragAndDropWrapper(compsource);
|
|
||||||
} else {
|
|
||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean validateTable(final Component compsource, final TableTransferable transferable) {
|
|
||||||
final Table source = (Table) compsource;
|
|
||||||
if (!(source.getId().equals(SPUIComponentIdProvider.DIST_TABLE_ID)
|
|
||||||
|| source.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS))) {
|
|
||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
|
||||||
return false;
|
|
||||||
} else if (!permChecker.hasUpdateTargetPermission()) {
|
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
|
||||||
return false;
|
|
||||||
} else if (getDraggedDistributionSet(transferable, source).size() > 1) {
|
|
||||||
notification.displayValidationError(i18n.get("message.onlyone.distribution.assigned"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<DistributionSetIdName> getDraggedDistributionSet(final TableTransferable transferable,
|
|
||||||
final Table source) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) source;
|
|
||||||
return distTable.getDeletedEntityByTransferable(transferable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
|
||||||
final DragAndDropWrapper wrapperSource = (DragAndDropWrapper) compsource;
|
|
||||||
final String tagName = HawkbitCommonUtil.removePrefix(compsource.getId(),
|
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
||||||
if ("NO TAG".equals(tagName)) {
|
if ("NO TAG".equals(tagName)) {
|
||||||
@@ -628,19 +559,32 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDropTableId() {
|
||||||
|
return SPUIComponentIdProvider.DIST_TABLE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hasDropPermission() {
|
||||||
|
return permChecker.hasUpdateTargetPermission();
|
||||||
|
}
|
||||||
|
|
||||||
private void dsToTargetAssignment(final DragAndDropEvent event) {
|
private void dsToTargetAssignment(final DragAndDropEvent event) {
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<NamedEntity, DistributionSetIdName> source = (AbstractTable<NamedEntity, DistributionSetIdName>) transferable
|
||||||
|
.getSourceComponent();
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
final Object targetItemId = dropData.getItemIdOver();
|
final Object targetItemId = dropData.getItemIdOver();
|
||||||
LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId);
|
LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId);
|
||||||
if (targetItemId != null) {
|
if (targetItemId != null) {
|
||||||
final TargetIdName targetId = (TargetIdName) targetItemId;
|
final TargetIdName targetId = (TargetIdName) targetItemId;
|
||||||
String message = null;
|
String message = null;
|
||||||
for (final DistributionSetIdName distributionNameId : getDraggedDistributionSet(transferable, source)) {
|
|
||||||
|
for (final DistributionSetIdName distributionNameId : source.getDeletedEntityByTransferable(transferable)) {
|
||||||
if (null != distributionNameId) {
|
if (null != distributionNameId) {
|
||||||
if (managementUIState.getAssignedList().keySet().contains(targetId)
|
if (managementUIState.getAssignedList().keySet().contains(targetId)
|
||||||
&& managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) {
|
&& managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.vaadin.spring.events.EventScope;
|
|||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.Transferable;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
import com.vaadin.event.dd.DropHandler;
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
@@ -183,18 +184,28 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private Boolean validate(final DragAndDropEvent event) {
|
private Boolean validate(final DragAndDropEvent event) {
|
||||||
final Component compsource = event.getTransferable().getSourceComponent();
|
final Transferable transferable = event.getTransferable();
|
||||||
if (!(compsource instanceof Table)) {
|
final Component compsource = transferable.getSourceComponent();
|
||||||
|
if (!(compsource instanceof AbstractTable)) {
|
||||||
notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
|
notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
final Table source = ((TableTransferable) event.getTransferable()).getSourceComponent();
|
|
||||||
|
final TableTransferable tabletransferable = (TableTransferable) transferable;
|
||||||
|
|
||||||
|
final AbstractTable<?, ?> source = (AbstractTable<?, ?>) tabletransferable.getSourceComponent();
|
||||||
|
|
||||||
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
|
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Set<?> deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable);
|
||||||
|
if (deletedEntityByTransferable.isEmpty()) {
|
||||||
|
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
|
||||||
|
notification.displayValidationError(actionDidNotWork);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,11 +233,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
.getSourceComponent();
|
.getSourceComponent();
|
||||||
|
|
||||||
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
|
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
|
||||||
if (targetSelected.isEmpty()) {
|
|
||||||
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
|
|
||||||
notification.displayValidationError(actionDidNotWork);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
|
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|||||||
Reference in New Issue
Block a user