Replace server-side dnd validation with client-side validation: (#368)

* Replace server-side dnd validation with client-side validation:

Client-side validation means:
* Custom widgetset is used to introduce the client-side validation
* Accept-calculation is performed on client-side
* Drop-hints are calculated on client-side (show/hide)
* Row count decoration is calculated on client-side (multi-selection)
* Notification box is triggered from client-side

Beside the migration from server-side validation to client-side
validation there are few improvements:
* Improvement1: If drag is aborted outside the components by releasing
the mouse or the drag aborts by pressing the ESC key) -> drop area hints
are removed
* Improvement2: If multiple rows are selected in table, but drag is
performed on a non-selected single element from table -> the single
drag-element is not decorated with the row selection count
* Improvement3: Upload View: Component 'Drop files to upload' only
accepts files (and no drags from filter and software module component)

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>

* Improve code quality

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>

* Fix formatting of license headers

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>

* Fix scopes and modifiers

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>

* Externalize key-strings used for dnd-data transfer from server to client

Minor issues:
* improve naming schema of control variables (no more i-s)
* add final modifier

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>

* Add license header

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
Marcel Mager
2016-12-06 19:56:10 +01:00
committed by Kai Zimmermann
parent 8e7943dc4f
commit 11fa4469dd
64 changed files with 2181 additions and 992 deletions

View File

@@ -252,7 +252,6 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
@@ -265,6 +264,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.gwtmockito</groupId>
<artifactId>gwtmockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert-core</artifactId>

View File

@@ -33,9 +33,11 @@
<inherits name="org.eclipse.hawkbit.ui.customrenderers.CustomRendererWidgetSet" />
<inherits name="org.eclipse.hawkbit.ui.filtermanagement.TextFieldSuggestionBox" />
<inherits name="org.eclipse.hawkbit.ui.dd.CustomAcceptCriteria" />
<inherits name="org.vaadin.hene.flexibleoptiongroup.widgetset.FlexibleOptionGroupWidgetset" />
<inherits name="org.vaadin.alump.distributionbar.gwt.DistributionBarWidgetset" />
</module>

View File

@@ -20,14 +20,13 @@ import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.footer.SMDeleteActionsLayout;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleTableLayout;
import org.eclipse.hawkbit.ui.artifacts.smtype.SMTypeFilterLayout;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -38,7 +37,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.Page;
@@ -50,7 +48,6 @@ import com.vaadin.ui.Alignment;
import com.vaadin.ui.DragAndDropWrapper;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
/**
@@ -94,7 +91,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
UploadArtifactView(final UIEventBus eventBus, final SpPermissionChecker permChecker, final I18N i18n,
final UINotification uiNotification, final ArtifactUploadState artifactUploadState,
final TagManagement tagManagement, final EntityFactory entityFactory,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria,
final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion,
final SPInfo spInfo, final ArtifactManagement artifactManagement) {
this.eventBus = eventBus;
this.permChecker = permChecker;
@@ -102,15 +99,15 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
this.uiNotification = uiNotification;
this.artifactUploadState = artifactUploadState;
this.filterByTypeLayout = new SMTypeFilterLayout(artifactUploadState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, softwareManagement, uploadViewAcceptCriteria);
tagManagement, entityFactory, uiNotification, softwareManagement, uploadViewClientCriterion);
this.smTableLayout = new SoftwareModuleTableLayout(i18n, permChecker, artifactUploadState, uiNotification,
eventBus, softwareManagement, entityFactory, uploadViewAcceptCriteria);
eventBus, softwareManagement, entityFactory, uploadViewClientCriterion);
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
this.uploadLayout = new UploadLayout(i18n, uiNotification, eventBus, artifactUploadState, spInfo,
artifactManagement);
this.deleteActionsLayout = new SMDeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
artifactUploadState, softwareManagement, uploadViewAcceptCriteria);
artifactUploadState, softwareManagement, uploadViewClientCriterion);
}
@PostConstruct
@@ -161,7 +158,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
createMainLayout();
addComponents(mainLayout);
setExpandRatio(mainLayout, 1);
hideDropHints();
}
}
@@ -257,17 +253,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
}
private void hideDropHints() {
UI.getCurrent().addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void click(final com.vaadin.event.MouseEvents.ClickEvent event) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
});
}
private void checkNoDataAvaialble() {
if (artifactUploadState.isNoDataAvilableSoftwareModule()) {

View File

@@ -1,79 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.artifacts.event;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Component;
/**
* Upload UI View for Accept criteria.
*
*/
@SpringComponent
@UIScope
public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static final long serialVersionUID = 5158811326115667378L;
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
UploadViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
super(uiNotification, eventBus);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
if (id != null && id.startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
id = UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
}
return id;
}
@Override
protected Map<String, Object> getDropHintConfigurations() {
return DROP_HINTS_CONFIGS;
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;
}
private static Map<String, List<String>> createDropConfigurations() {
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(1);
// Delete drop area droppable components
config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
return config;
}
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(2);
config.put(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
config.put(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
return config;
}
}

View File

@@ -13,11 +13,10 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
@@ -44,16 +43,16 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
private final UploadViewConfirmationWindowLayout uploadViewConfirmationWindowLayout;
private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private final UploadViewClientCriterion uploadViewClientCriterion;
public SMDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final ArtifactUploadState artifactUploadState,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion) {
super(i18n, permChecker, eventBus, notification);
this.artifactUploadState = artifactUploadState;
this.uploadViewConfirmationWindowLayout = new UploadViewConfirmationWindowLayout(i18n, eventBus,
softwareManagement, artifactUploadState);
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
this.uploadViewClientCriterion = uploadViewClientCriterion;
init();
}
@@ -74,10 +73,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
updateSWActionCount();
});
}
if (event == UploadArtifactUIEvent.SOFTWARE_DRAG_START
|| event == UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START) {
showDropHints();
}
}
private boolean isSoftwareEvent(final UploadArtifactUIEvent event) {
@@ -92,14 +87,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|| event == UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE;
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
UI.getCurrent().access(() -> hideDropHints());
}
}
@Override
protected boolean hasDeletePermission() {
return permChecker.hasDeleteDistributionPermission();
@@ -127,7 +114,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return uploadViewAcceptCriteria;
return uploadViewClientCriterion;
}
@Override
@@ -152,7 +139,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
}
hideDropHints();
}
private void deleteSWModuleType(final String swModuleTypeName) {

View File

@@ -16,11 +16,11 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -59,18 +59,18 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
private final transient SoftwareManagement softwareManagement;
private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private final UploadViewClientCriterion uploadViewClientCriterion;
private final SwMetadataPopupLayout swMetadataPopupLayout;
SoftwareModuleTable(final UIEventBus eventBus, final I18N i18n, final UINotification uiNotification,
final ArtifactUploadState artifactUploadState, final SoftwareManagement softwareManagement,
final UploadViewAcceptCriteria uploadViewAcceptCriteria,
final UploadViewClientCriterion uploadViewClientCriterion,
final SwMetadataPopupLayout swMetadataPopupLayout) {
super(eventBus, i18n, uiNotification);
this.artifactUploadState = artifactUploadState;
this.softwareManagement = softwareManagement;
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
this.uploadViewClientCriterion = uploadViewClientCriterion;
this.swMetadataPopupLayout = swMetadataPopupLayout;
addNewContainerDS();
@@ -224,7 +224,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Override
protected AcceptCriterion getDropAcceptCriterion() {
return uploadViewAcceptCriteria;
return uploadViewClientCriterion;
}
@Override

View File

@@ -11,9 +11,9 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -29,7 +29,7 @@ public class SoftwareModuleTableLayout extends AbstractTableLayout {
public SoftwareModuleTableLayout(final I18N i18n, final SpPermissionChecker permChecker,
final ArtifactUploadState artifactUploadState, final UINotification uiNotification,
final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
final UploadViewClientCriterion uploadViewClientCriterion) {
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
uiNotification, eventBus, softwareManagement, entityFactory);
@@ -41,7 +41,7 @@ public class SoftwareModuleTableLayout extends AbstractTableLayout {
new SoftwareModuleTableHeader(i18n, permChecker, eventBus, artifactUploadState,
softwareModuleAddUpdateWindow),
new SoftwareModuleTable(eventBus, i18n, uiNotification, artifactUploadState, softwareManagement,
uploadViewAcceptCriteria, swMetadataPopupLayout),
uploadViewClientCriterion, swMetadataPopupLayout),
new SoftwareModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow,
artifactUploadState, softwareManagement, swMetadataPopupLayout, entityFactory));
}

View File

@@ -14,10 +14,10 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -40,13 +40,13 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
private final ArtifactUploadState artifactUploadState;
private final UploadViewAcceptCriteria uploadViewAcceptCriteria;
private final UploadViewClientCriterion uploadViewClientCriterion;
SMTypeFilterButtons(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState,
final UploadViewAcceptCriteria uploadViewAcceptCriteria, final SoftwareManagement softwareManagement) {
final UploadViewClientCriterion uploadViewClientCriterion, final SoftwareManagement softwareManagement) {
super(eventBus, new SMTypeFilterButtonClick(eventBus, artifactUploadState, softwareManagement));
this.artifactUploadState = artifactUploadState;
this.uploadViewAcceptCriteria = uploadViewAcceptCriteria;
this.uploadViewClientCriterion = uploadViewClientCriterion;
}
@EventBusListenerMethod(scope = EventScope.UI)
@@ -93,7 +93,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Override
public AcceptCriterion getAcceptCriterion() {
return uploadViewAcceptCriteria;
return uploadViewClientCriterion;
}
@Override

View File

@@ -13,9 +13,9 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -34,10 +34,10 @@ public class SMTypeFilterLayout extends AbstractFilterLayout {
public SMTypeFilterLayout(final ArtifactUploadState artifactUploadState, final I18N i18n,
final SpPermissionChecker permChecker, final UIEventBus eventBus, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement, final UploadViewAcceptCriteria uploadViewAcceptCriteria) {
final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion) {
super(new SMTypeFilterHeader(i18n, permChecker, eventBus, artifactUploadState, tagManagement, entityFactory,
uiNotification, softwareManagement),
new SMTypeFilterButtons(eventBus, artifactUploadState, uploadViewAcceptCriteria, softwareManagement));
new SMTypeFilterButtons(eventBus, artifactUploadState, uploadViewClientCriterion, softwareManagement));
this.artifactUploadState = artifactUploadState;
restoreState();

View File

@@ -30,6 +30,8 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEven
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ServerItemIdClientCriterion;
import org.eclipse.hawkbit.ui.dd.criteria.ServerItemIdClientCriterion.Mode;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -50,8 +52,8 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.base.Strings;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptAll;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptcriteria.Not;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.server.StreamVariable;
@@ -109,6 +111,9 @@ public class UploadLayout extends VerticalLayout {
private Button uploadStatusButton;
private static AcceptCriterion acceptAllExceptBlacklisted = new Not(new ServerItemIdClientCriterion(Mode.PREFIX,
UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
private final transient ArtifactManagement artifactManagement;
public UploadLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
@@ -229,7 +234,7 @@ public class UploadLayout extends VerticalLayout {
@Override
public AcceptCriterion getAcceptCriterion() {
return AcceptAll.get();
return acceptAllExceptBlacklisted;
}
@Override

View File

@@ -1,193 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
import com.vaadin.server.Page;
import com.vaadin.ui.Component;
import com.vaadin.ui.DragAndDropWrapper;
import com.vaadin.ui.DragAndDropWrapper.WrapperTargetDetails;
import com.vaadin.ui.Table;
/**
* Abstract class for Accept criteria.
*
*/
public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
private static final long serialVersionUID = 3218899104852691974L;
private int previousRowCount;
protected UINotification uiNotification;
protected transient EventBus.UIEventBus eventBus;
protected AbstractAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
this.uiNotification = uiNotification;
this.eventBus = eventBus;
}
@Override
public boolean accept(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
final Component compdestination = dragEvent.getTargetDetails().getTarget();
final int typeVal = getMouseEventType(compdestination, dragEvent);
showHideDropAreaHighlights(typeVal, compsource, dragEvent);
if (isValidDrop(compsource, compdestination)) {
return true;
} else {
// Display action not allowed notification for invalid drop
/* mouse event will be TenantAwareEvent.ONMOUSEUP on drop */
// From com.google.gwt.user.client.Event
if (typeVal == 8) {
invalidDrop();
}
return false;
}
}
private int getMouseEventType(final Component compdestination, final DragAndDropEvent dragEvent) {
int typeVal = 0;
if (compdestination instanceof DragAndDropWrapper) {
final WrapperTargetDetails details = (WrapperTargetDetails) dragEvent.getTargetDetails();
typeVal = details.getMouseEvent().getType();
} else if (compdestination instanceof Table && dragEvent.getTargetDetails().getData("mouseEvent") != null) {
final String mouseEventDetails = dragEvent.getTargetDetails().getData("mouseEvent").toString();
final String[] strArray = mouseEventDetails.split("\\,");
typeVal = Integer.parseInt(strArray[7]);
}
return typeVal;
}
private void showHideDropAreaHighlights(final int typeVal, final Component compsource,
final DragAndDropEvent dragEvent) {
/* mouse event will be TenantAwareEvent.ONMOUSEUP on drop */
// From com.google.gwt.user.client.Event
if (typeVal == 8) {
hideDropHints();
} else {
if (compsource instanceof Table) {
showRowCount(dragEvent, (Table) compsource);
}
analyseDragComponent(compsource);
}
}
/**
*
* @param dragEvent
* @param compsource
*/
protected void showRowCount(final DragAndDropEvent dragEvent, final Table compsource) {
/* Show the number of rows that are dragging in the drag image */
final Set<String> targetSelectedList = new HashSet<>((Set<String>) compsource.getValue());
/**
* Remove null value if any .
*/
targetSelectedList.remove(null);
if (previousRowCount != targetSelectedList.size()) {
previousRowCount = targetSelectedList.size();
/*
* Prepare the hava script to add the <style> tag to the head of the
* html
*/
if (!targetSelectedList.contains(dragEvent.getTransferable().getData(SPUIDefinitions.ITEMID))) {
previousRowCount = 1;
}
final String exeJS = HawkbitCommonUtil.getDragRowCountJavaScript(previousRowCount);
Page.getCurrent().getJavaScript().execute(exeJS);
}
}
/**
* Analyze the dragging component and do respective actions.
*
* @param compsource
* reference of drag component.
*/
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = getDropHintConfigurations().get(sourceID);
eventBus.publish(this, event);
}
/**
* Check if source is valid drop on destination.
*
* @param compsource
* is the component which is dragging.
* @param compdestination
* is the destination component trying to drop.
* @return
*/
private boolean isValidDrop(final Component compsource, final Component compdestination) {
final String sourceID = getComponentId(compsource);
final String destinationID = getComponentId(compdestination);
final List<String> acceptableComponents = getDropConfigurations().get(destinationID);
// check if the destination component Id is available in acceptable
// components
return acceptableComponents != null && acceptableComponents.contains(sourceID);
}
/**
* Find the id the component if it is button get its prefix.
*
* @param component
* for the id has to identify.
* @return 'id' of the component.
*/
protected abstract String getComponentId(final Component component);
/**
* Hide the drop hints. Dragging is stopped.
*/
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
/**
* Display invalid drop message.
*/
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
/**
* @return
*/
protected abstract Map<String, Object> getDropHintConfigurations();
/**
* Get drop configurations in Map collection like component Id as "key" and
* its list of acceptable component Id as "value".
*
* @return reference of {@link Map} of component Id
*/
protected abstract Map<String, List<String>> getDropConfigurations();
}

View File

@@ -12,7 +12,6 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -25,7 +24,6 @@ import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
@@ -143,7 +141,6 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
wrapper.setId(getDeleteAreaId());
wrapper.setDropHandler(this);
wrapper.addStyleName("delete-button-border");
wrapper.addStyleName(SPUIStyleDefinitions.SHOW_DELETE_DROP_HINT);
return wrapper;
}
@@ -249,24 +246,6 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
}
/**
* Hide the drop hints.
*/
protected void hideDropHints() {
if (hasDeletePermission()) {
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.hideDeleteDropHintScript());
}
}
/**
* show the drop hints.
*/
protected void showDropHints() {
if (hasDeletePermission()) {
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.dispDeleteDropHintScript());
}
}
protected void hideBulkUploadStatusButton() {
if (null != bulkUploadStatusButton) {
bulkUploadStatusButton.setCaption(null);

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.logging.Logging" />
<inherits name="com.vaadin.DefaultWidgetSet" />
<inherits name="org.vaadin.alump.distributionbar.gwt.DistributionBarWidgetset" />
<inherits name="org.eclipse.hawkbit.ui.AppWidgetSet" />
<inherits name="org.vaadin.peter.contextmenu.ContextmenuWidgetset" />
<inherits name="org.vaadin.tokenfield.TokenfieldWidgetset" />
<inherits name="org.eclipse.hawkbit.ui.customrenderers.CustomRendererWidgetSet" />
<inherits name="org.vaadin.hene.flexibleoptiongroup.widgetset.FlexibleOptionGroupWidgetset" />
<!--add logging module -->
<inherits name="com.google.gwt.logging.Logging" />
<!--To change the default logLevel -->
<set-property name="gwt.logging.logLevel" value="SEVERE" />
<!--To enable logging -->
<set-property name="gwt.logging.enabled" value="TRUE" />
</module>

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.COMPONENT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.COMPONENT_COUNT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.MODE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.STRICT_MODE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.PREFIX_MODE;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.hawkbit.ui.dd.criteria.ServerItemIdClientCriterion;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.dd.VAcceptCriterion;
import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.shared.ui.dd.AcceptCriterion;
/**
* Client-side accept criterion used to verify if the selected drag source is
* valid for the proposed drop target on an id base. Valid drag sources are
* pre-configured for the criterion. If one pre-configured value matches the
* selected drag source, the drag source is accepted. The match mode is
* configurable and may either be STRICT or PREFIX.
*/
@AcceptCriterion(ServerItemIdClientCriterion.class)
public final class ItemIdClientCriterion extends VAcceptCriterion {
private static final Logger LOGGER = Logger.getLogger(ItemIdClientCriterion.class.getName());
@Override
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
protected boolean accept(VDragEvent drag, UIDL configuration) {
try {
String component = drag.getTransferable().getDragSource().getWidget().getElement().getId();
int c = configuration.getIntAttribute(COMPONENT_COUNT);
String mode = configuration.getStringAttribute(MODE);
for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) {
String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex);
if ((STRICT_MODE.equals(mode) && component.equals(requiredPid))
|| (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) {
return true;
}
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
}
return false;
}
}

View File

@@ -0,0 +1,303 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_CONFIG;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_CONFIG_COUNT;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.hawkbit.ui.dd.criteria.ServerViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.HeadElement;
import com.google.gwt.dom.client.StyleElement;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.VNotification;
import com.vaadin.client.ui.VScrollTable;
import com.vaadin.client.ui.dd.VAcceptCallback;
import com.vaadin.client.ui.dd.VAcceptCriteria;
import com.vaadin.client.ui.dd.VAcceptCriterion;
import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.shared.Position;
import com.vaadin.shared.ui.dd.AcceptCriterion;
/**
* Client part for the client-side accept criterion.<br>
* This class represents a composite for
* <code>ViewComponentClientCriterion</code> elements.<br>
* The criterion is not only responsible to check if the current drop location
* is a valid drop target, but also concerns about:
* <ul>
* <li>Hide drop hints when drop operation is finished or aborted.</li>
* <li>Show error message (via message box) if the drop location is not a valid
* drop target.</li>
* <li>In case of multi-row selection: Decorate the drag element with the number
* of dragged elements.</li>
* </ul>
*/
@AcceptCriterion(ServerViewClientCriterion.class)
public final class ViewClientCriterion extends VAcceptCriterion implements VAcceptCallback {
private static final Logger LOGGER = Logger.getLogger(ViewClientCriterion.class.getName());
static final String SP_DRAG_COUNT = "sp-drag-count";
private boolean accepted;
private ViewCriterionTemplates multiRowSelectStyle;
private VDragEvent previousDragEvent;
private HandlerRegistration nativeEventHandlerRegistration;
/**
* This interface is used to compile string templates in the GWT context (as
* other approaches like <code>MessageFormat</code> would fail).
*/
interface ViewCriterionTemplates extends SafeHtmlTemplates {
/**
* @param theme
* the current UI schema
* @param rowCount
* the amount of selected rows
* @return compiled template
*/
@Template(".{0} tbody.v-drag-element tr:after{ content:\"{1}\"; } "
+ ".{0} tr.v-drag-element:after{ content:\"{1}\"; } "
+ ".{0} table.v-drag-element:after{ content:\"{1}\"; } ")
SafeHtml multiSelectionStyle(String theme, String rowCount);
/**
* @param msg
* the message to style
* @return compiled style template
*/
@Template("<p class=\"v-Notification-description\"><span class=\"v-icon\" style=\"font-family: FontAwesome;\">&#xF071;</span> {0}</p>")
SafeHtml notificationMsg(String msg);
}
private static VAcceptCriterion getCriteria(UIDL configuration, int i) {
UIDL childUIDL = configuration.getChildUIDL(i);
return VAcceptCriteria.get(childUIDL.getStringAttribute("name"));
}
/**
* Lazy compile the string templates.
*
* @return templates
*/
private ViewCriterionTemplates getDraggableTemplate() {
// no need to synchronize, JavaScript in the browser is single-threaded
if (multiRowSelectStyle == null) {
multiRowSelectStyle = GWT.create(ViewCriterionTemplates.class);
}
return multiRowSelectStyle;
}
@Override
// Exception squid:S1604 - GWT 2.7 does not support Java 8
@SuppressWarnings("squid:S1604")
public void accept(final VDragEvent drag, final UIDL configuration, final VAcceptCallback callback) {
if (isDragStarting(drag)) {
final NativePreviewHandler nativeEventHandler = new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
if (isEscKey(event) || isMouseUp(event)) {
try {
hideDropTargetHints(configuration);
} finally {
nativeEventHandlerRegistration.removeHandler();
}
}
}
};
nativeEventHandlerRegistration = Event.addNativePreviewHandler(nativeEventHandler);
setMultiRowDragDecoration(drag);
}
int childCount = configuration.getChildCount();
accepted = false;
for (int childIndex = 0; childIndex < childCount; childIndex++) {
VAcceptCriterion crit = getCriteria(configuration, childIndex);
crit.accept(drag, configuration.getChildUIDL(childIndex), this);
if (Boolean.TRUE.equals(accepted)) {
callback.accepted(drag);
return;
}
}
// if no VAcceptCriterion accepts and the mouse is release, an error
// message is shown
if (Event.ONMOUSEUP == Event.getTypeInt(drag.getCurrentGwtEvent().getType())) {
showErrorNotification(drag);
}
}
@Override
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) {
return false;
}
@Override
protected boolean accept(VDragEvent drag, UIDL configuration) {
// not used here:
return false;
}
@Override
public void accepted(VDragEvent event) {
accepted = true;
}
/**
* Styles a multi-row selection with the number of elements.
*
* @param drag
* the current drag event holding the context.
*/
void setMultiRowDragDecoration(VDragEvent drag) {
Widget widget = drag.getTransferable().getDragSource().getWidget();
if (widget instanceof VScrollTable) {
VScrollTable table = (VScrollTable) widget;
int rowCount = table.selectedRowKeys.size();
Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
if (dragCountElement == null) {
dragCountElement = Document.get().createStyleElement();
dragCountElement.setId(SP_DRAG_COUNT);
HeadElement head = HeadElement.as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
head.appendChild(dragCountElement);
}
SafeHtml formattedCssStyle = getDraggableTemplate().multiSelectionStyle(determineActiveTheme(drag),
String.valueOf(rowCount));
StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
} else if (dragCountElement != null) {
dragCountElement.removeFromParent();
}
}
}
/**
* Checks if the origin of the given event is a pressed ESC key.
*
* @param event
* the event to analyze
* @return <code>true</code> if the origin of the event is a pressed ESC
* key, otherwise <code>false</code>.
*/
private static boolean isEscKey(final NativePreviewEvent event) {
int typeInt = event.getTypeInt();
if (typeInt == Event.ONKEYDOWN) {
int keyCode = event.getNativeEvent().getKeyCode();
if (KeyCodes.KEY_ESCAPE == keyCode) {
return true;
}
}
return false;
}
/**
* Checks if the given event is of type <code>Event.ONMOUSEUP</code>.
*
* @param event
* the event to analyze
* @return <code>true</code> if the given event is of type
* <code>Event.ONMOUSEUP</code>, otherwise <code>false</code>.
*/
private static boolean isMouseUp(final NativePreviewEvent event) {
return Event.ONMOUSEUP == Event.getTypeInt(event.getNativeEvent().getType());
}
/**
* Hides the highlighted drop target hints.
*
* @param configuration
* for the accept criterion to retrieve the drop target hints.
*/
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
void hideDropTargetHints(UIDL configuration) {
int totalDropTargetHintsCount = configuration.getIntAttribute(DROP_AREA_CONFIG_COUNT);
for (int dropAreaIndex = 0; dropAreaIndex < totalDropTargetHintsCount; dropAreaIndex++) {
try {
String dropArea = configuration.getStringAttribute(DROP_AREA_CONFIG + dropAreaIndex);
Element hideHintFor = Document.get().getElementById(dropArea);
if (hideHintFor != null) {
hideHintFor.removeClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error highlighting valid drop targets: " + e.getLocalizedMessage());
}
}
}
/**
* Displays a message box telling that the action is not allowed.
*
* @param drag
* the current drag event holding the context.
*/
private void showErrorNotification(VDragEvent drag) {
VNotification n = VNotification.createNotification(SPUILabelDefinitions.SP_DELAY,
drag.getTransferable().getDragSource().getWidget());
n.show(getDraggableTemplate().notificationMsg(SPUILabelDefinitions.ACTION_NOT_ALLOWED).asString(),
Position.BOTTOM_RIGHT, SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE);
}
/**
* Determines the active UI theme for a given event.
*
* @param drag
* the event the UI theme is retrieved for.
* @return the active theme (e.g. "hawkbit").
*/
private static String determineActiveTheme(VDragEvent drag) {
return drag.getTransferable().getDragSource().getConnection().getUIConnector().getActiveTheme();
}
/**
* Tests whether this drag operation has just started or if it is just
* proceeded.
*
* @param drag
* the event that indicates if this is a starting drag operation
* or a proceeding one.
* @return <code>true</code> if the drag operation is starting, otherwise
* <code>false</code>
*/
private boolean isDragStarting(VDragEvent drag) {
boolean result = false;
if (!drag.equals(previousDragEvent)) {
result = true;
previousDragEvent = drag;
}
return result;
}
}

View File

@@ -0,0 +1,168 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DRAG_SOURCE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_TARGET;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_TARGET_COUNT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_COUNT;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.hawkbit.ui.dd.criteria.ServerViewComponentClientCriterion;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.dd.VAcceptCriterion;
import com.vaadin.client.ui.dd.VDragAndDropManager;
import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.shared.ui.dd.AcceptCriterion;
/**
* Client part for the client-side accept criterion.<br>
* The criterion is not only responsible to check if the current drop location
* is a valid drop target, but also concerns about:
* <ul>
* <li>Fail fast, if the criterion is not responsible of the current drag source
* (some other criterion will do the job)</li>
* <li>Highlight the drop target hints for the drag source (only if the
* criterion is responsible for)</li>
* <li>Check if the current drop location is valid for the criterion</li>
* </ul>
*
*/
@AcceptCriterion(ServerViewComponentClientCriterion.class)
public final class ViewComponentClientCriterion extends VAcceptCriterion {
private static final Logger LOGGER = Logger.getLogger(ViewComponentClientCriterion.class.getName());
/**
* Css style class for drop hints.
*/
public static final String HINT_AREA_STYLE = "show-drop-hint";
@Override
protected boolean accept(VDragEvent drag, UIDL configuration) {
// 1. check if this component is responsible for the drag source:
if (!isValidDragSource(drag, configuration)) {
return false;
}
// 2. Highlight the valid drop areas
showDropTargetHints(configuration);
// 3. Check if the current drop location is a valid drop target
return isValidDropTarget(configuration);
}
/**
* Checks if this accept criterion is responsible for the current drag
* source. Therefore the current drag source id has to start with the drag
* source id-prefix configured for the criterion.
*
* @param drag
* the current drag event holding the context.
* @param configuration
* for the accept criterion to retrieve the configured drag
* source id-prefix.
* @return <code>true</code> if the criterion is responsible for the current
* drag source, otherwise <code>false</code>.
*/
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
boolean isValidDragSource(VDragEvent drag, UIDL configuration) {
try {
String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId();
String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE);
if (dragSource.startsWith(dragSourcePrefix)) {
return true;
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage());
}
return false;
}
/**
* Highlights the valid drop targets configured for the criterion.
*
* @param configuration
* for the accept criterion to retrieve the configured drop hint
* areas.
*/
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
void showDropTargetHints(UIDL configuration) {
int dropAreaCount = configuration.getIntAttribute(DROP_AREA_COUNT);
for (int dropAreaIndex = 0; dropAreaIndex < dropAreaCount; dropAreaIndex++) {
try {
String dropArea = configuration.getStringAttribute(DROP_AREA + dropAreaIndex);
LOGGER.log(Level.FINE, "Hint Area: " + dropArea);
Element showHintFor = Document.get().getElementById(dropArea);
if (showHintFor != null) {
showHintFor.addClassName(HINT_AREA_STYLE);
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error highlighting drop targets: " + e.getLocalizedMessage());
}
}
}
/**
* Checks if the current drop location is a valid drop target for the
* criterion. Therefore the current drop location id has to start with one
* of the drop target id-prefixes configured for the criterion.
*
* @param configuration
* for the accept criterion to retrieve the configured drop
* target id-prefixes.
* @return <code>true</code> if the current drop location is a valid drop
* target for the criterion, otherwise <code>false</code>.
*/
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
boolean isValidDropTarget(UIDL configuration) {
try {
String dropTarget = VDragAndDropManager.get().getCurrentDropHandler().getConnector().getWidget()
.getElement().getId();
int dropTargetCount = configuration.getIntAttribute(DROP_TARGET_COUNT);
for (int dropTargetIndex = 0; dropTargetIndex < dropTargetCount; dropTargetIndex++) {
String dropTargetPrefix = configuration.getStringAttribute(DROP_TARGET + dropTargetIndex);
LOGGER.log(Level.FINE, "Drop Target: " + dropTargetPrefix);
if (dropTarget.startsWith(dropTargetPrefix)) {
return true;
}
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
}
return false;
}
@Override
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) {
// client-side only
return false;
}
}

View File

@@ -0,0 +1,86 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
/**
* Constants that are used to transfer data between server-side and client-side
* accept criteria.
*
*/
public final class AcceptCriteriaConstants {
/**
* Key for the configured valid drag source.
*/
public static final String DRAG_SOURCE = "ds";
/**
* Key-prefix for a configured valid drop target.
*/
public static final String DROP_TARGET = "dt";
/**
* Key for the number of configured valid drop targets.
*/
public static final String DROP_TARGET_COUNT = "cdt";
/**
* Key-prefix for a configured drop area.
*/
public static final String DROP_AREA = "da";
/**
* Key for the number of configured drop areas.
*/
public static final String DROP_AREA_COUNT = "cda";
/**
* Key-prefix for a configured drop area of the entire drop area
* configuration.
*/
public static final String DROP_AREA_CONFIG = "dac";
/**
* Key for the number of drop areas in the entire configuration.
*/
public static final String DROP_AREA_CONFIG_COUNT = "cdac";
/**
* Key-prefix for a valid drag source component.
*/
public static final String COMPONENT = "component";
/**
* Key for the number of configured valid drag source components.
*/
public static final String COMPONENT_COUNT = "c";
/**
* Key for the selected mode.
*/
public static final String MODE = "m";
/**
* Strict-mode.
*/
public static final String STRICT_MODE = "s";
/**
* Prefix-mode.
*/
public static final String PREFIX_MODE = "p";
/**
* Constants class.
*/
private AcceptCriteriaConstants() {
}
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
/**
* Distribution UI View for Accept criteria.
*
*/
@SpringComponent
@UIScope
public final class DistributionsViewClientCriterion extends ServerViewClientCriterion {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = 8602945302654554257L;
private static final ServerViewComponentClientCriterion[] COMPONENT_CRITERIA = createViewComponentClientCriteria();
/**
* Constructor.
*/
public DistributionsViewClientCriterion() {
super(COMPONENT_CRITERIA);
}
/**
* Configures the elements of the composite accept criterion for the
* Distributions View.
*
* @return accept criterion elements
*/
static ServerViewComponentClientCriterion[] createViewComponentClientCriteria() {
ServerViewComponentClientCriterion[] criteria = new ServerViewComponentClientCriterion[4];
// Distribution table acceptable components.
criteria[0] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.DIST_TABLE_ID)
.dropTargetIdPrefixes(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Distribution set type acceptable components.
criteria[1] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS)
.dropTargetIdPrefixes(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Upload software module table acceptable components.
criteria[2] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)
.dropTargetIdPrefixes(UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DIST_TABLE_ID, UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Software module tag acceptable components.
criteria[3] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS)
.dropTargetIdPrefixes(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
return criteria;
}
}

View File

@@ -0,0 +1,83 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
/**
* Management UI View for Accept criteria.
*
*/
@SpringComponent
@UIScope
public final class ManagementViewClientCriterion extends ServerViewClientCriterion {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = 927303094996626180L;
private static final ServerViewComponentClientCriterion[] COMPONENT_CRITERIA = createViewComponentClientCriteria();
/**
* Constructor.
*/
public ManagementViewClientCriterion() {
super(COMPONENT_CRITERIA);
}
/**
* Configures the elements of the composite accept criterion for the
* Management View.
*
* @return accept criterion elements
*/
static ServerViewComponentClientCriterion[] createViewComponentClientCriteria() {
ServerViewComponentClientCriterion[] criteria = new ServerViewComponentClientCriterion[4];
// Target table acceptable components.
criteria[0] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.TARGET_TABLE_ID)
.dropTargetIdPrefixes(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.TARGET_TAG_DROP_AREA_ID, UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Target Tag acceptable components.
criteria[1] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)
.dropTargetIdPrefixes(UIComponentIdProvider.TARGET_TABLE_ID, UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.TARGET_TABLE_ID, UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Distribution table acceptable components.
criteria[2] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.DIST_TABLE_ID)
.dropTargetIdPrefixes(UIComponentIdProvider.TARGET_TABLE_ID,
UIComponentIdProvider.TARGET_DROP_FILTER_ICON, SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.TARGET_TABLE_ID, UIComponentIdProvider.TARGET_DROP_FILTER_ICON,
UIComponentIdProvider.DISTRIBUTION_TAG_TABLE_ID, UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
// Distribution tag acceptable components.
criteria[3] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)
.dropTargetIdPrefixes(UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DIST_TABLE_ID, UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.build();
return criteria;
}
}

View File

@@ -0,0 +1,127 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.COMPONENT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.COMPONENT_COUNT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.MODE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.STRICT_MODE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.PREFIX_MODE;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
/**
* Server part for the client-side accept criterion that verifies the selected
* drag source id-based for for the proposed drop target. Valid drag sources are
* pre-configured for the criterion. If one pre-configured value matches the
* selected drag source, the drag source is accepted. The match mode is
* configurable and may either be {@value Mode#STRICT} or {@value Mode#PREFIX}.
*/
public class ServerItemIdClientCriterion extends ClientSideCriterion {
/**
* Specifies the mode for the ServerItemIdClientCriterion.
*
*/
public enum Mode {
/**
* Valid drop targets are found using {@link String#equals(Object)}.
*/
STRICT(STRICT_MODE),
/**
* Valid drop targets are found using {@link String#startsWith(String)}
*/
PREFIX(PREFIX_MODE);
String modeShort;
/**
* Constructor.
*
* @param modeShort
* short string representation
*/
Mode(String modeShort) {
this.modeShort = modeShort;
}
/**
* Gets the mode short string representation
*
* @return mode short string representation
*/
String getShort() {
return modeShort;
}
}
/**
* serialVersionUID.
*/
private static final long serialVersionUID = 131826179001511177L;
private final String[] componentIds;
private final Mode verificationMode;
/**
* Constructor.
*
* @param verificationMode
* for {@value Mode#STRICT} verification is done using
* {@link String#equals(Object)}, for {@value Mode#PREFIX}
* verification is done using {@link String#startsWith(String)}
* @param componentIds
* valid drag source IDs (respectively ID-prefixes) for the
* proposed drop target verified against the selected drag
* source.
*/
public ServerItemIdClientCriterion(Mode verificationMode, String... componentIds) {
this.componentIds = componentIds;
this.verificationMode = verificationMode;
}
@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
int paintedComponents = 0;
for (String cId : componentIds) {
target.addAttribute(COMPONENT + paintedComponents, cId);
paintedComponents++;
}
target.addAttribute(COMPONENT_COUNT, paintedComponents);
target.addAttribute(MODE, verificationMode.getShort());
}
@Override
public boolean accept(DragAndDropEvent dragEvent) {
String sourceComponentid = dragEvent.getTransferable().getSourceComponent().getId();
if (sourceComponentid == null) {
// if there is no source id, criterion fails
return false;
}
for (String cId : componentIds) {
if ((verificationMode == Mode.PREFIX && sourceComponentid.startsWith(cId))
|| (verificationMode == Mode.STRICT && sourceComponentid.equals(cId))) {
return true;
}
}
return false;
}
@Override
protected String getIdentifier() {
// extending classes use client side implementation from this class
return ServerItemIdClientCriterion.class.getCanonicalName();
}
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_CONFIG;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_CONFIG_COUNT;
import java.util.Arrays;
import java.util.Set;
import com.google.common.collect.Sets;
import com.vaadin.event.dd.acceptcriteria.Or;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
/**
* Server part for the client-side accept criterion
* <code>ViewClientCriterion</code>.<br>
* This class is intended to be sub-classed. Each sub-class takes over
* responsibility of a UI view.<br>
* NOTE: Only the server part of the criterion has to be sub-classed, not the
* client part.<br>
* This class represents a composite for
* <code>ServerViewComponentClientCriterion</code> elements. To find out if the
* current drop location is a valid drop target for the current drag source, the
* list of elements is iterated through to retrieve:
* <ol>
* <li>a <code>ServerViewComponentClientCriterion</code> responsible for the
* drag source (the one that has a matching drag source id-prefix)</li>
* <li>if the drop location is a valid drop target for the responsible
* <code>ServerViewComponentClientCriterion</code> (by testing the valid drop
* target id-prefixes)</li>
* </ol>
*/
public class ServerViewClientCriterion extends Or {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = 3208301105751198826L;
private final Set<String> dropAreaHints;
/**
* Constructor for the server part of the client-side accept criterion.
*
* @param criteria
* elements the composite consists of.
*/
public ServerViewClientCriterion(ServerViewComponentClientCriterion... criteria) {
super(criteria);
dropAreaHints = Sets.newHashSet();
for (ServerViewComponentClientCriterion criterion : criteria) {
dropAreaHints.addAll(Arrays.asList(criterion.getValidDropAreaIds()));
}
}
@Override
public void paintContent(PaintTarget target) throws PaintException {
int dropAreaStylesConfigCount = 0;
for (String dropAreaEntry : dropAreaHints) {
target.addAttribute(DROP_AREA_CONFIG + dropAreaStylesConfigCount, dropAreaEntry);
dropAreaStylesConfigCount++;
}
target.addAttribute(DROP_AREA_CONFIG_COUNT, dropAreaStylesConfigCount);
super.paintContent(target);
}
@Override
protected String getIdentifier() {
return ServerViewClientCriterion.class.getCanonicalName();
}
}

View File

@@ -0,0 +1,208 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DRAG_SOURCE;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_TARGET;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_TARGET_COUNT;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA;
import static org.eclipse.hawkbit.ui.dd.criteria.AcceptCriteriaConstants.DROP_AREA_COUNT;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
/**
* Server part for the client-side accept criterion
* <code>ViewComponentClientCriterion</code>. Specifies valid drop targets (and
* the associated drop areas) for a drag source.
*/
public class ServerViewComponentClientCriterion extends ClientSideCriterion {
private static final long serialVersionUID = -2744174296987361607L;
private final String dragSourceIdPrefix;
private final String[] validDropTargetIdPrefixes;
private final String[] validDropAreaIds;
/**
* Constructor for the accept criterion using a builder.
*
* @param builder
* the associated builder for convenient use.
*/
protected ServerViewComponentClientCriterion(Builder builder) {
this.dragSourceIdPrefix = builder.dragSourceIdPrefix;
this.validDropTargetIdPrefixes = builder.validDropTargetIdPrefixes;
this.validDropAreaIds = builder.validDropAreaIds;
}
/**
* Constructor for the accept criterion with direct parameter use.
*
* @param dragSourceIdPrefix
* specifies the drag source (as id-prefix) the accept criterion
* is responsible for. A current drag source matches the
* configured prefix if its id starts with this prefix.
* @param validDropTargetIdPrefixes
* specifies the valid drop targets the drag source is valid for.
* The current drop target (the one the mouse is over) accepts
* the drag source if it starts with one of these prefixes.
* @param validDropAreaIds
* these ids are used to highlight the drop areas valid for the
* configured drag source (prefix) - if it matches the current
* current drag source.
*/
public ServerViewComponentClientCriterion(String dragSourceIdPrefix, String[] validDropTargetIdPrefixes,
String[] validDropAreaIds) {
this.dragSourceIdPrefix = dragSourceIdPrefix;
this.validDropTargetIdPrefixes = validDropTargetIdPrefixes;
this.validDropAreaIds = validDropAreaIds;
}
/**
* Gets the drag source (as id-prefix) the accept criterion is responsible
* for.
*
* @return drag source the accept criterion is responsible for (as
* id-prefix)
*/
String getDragSourcePrefix() {
return dragSourceIdPrefix;
}
/**
* Gets id of valid drop areas used to highlight drop hints.
*
* @return drop area ids to be highlighted if the configured drag source is
* active.
*/
String[] getValidDropAreaIds() {
return validDropAreaIds;
}
@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
target.addAttribute(DRAG_SOURCE, dragSourceIdPrefix);
int countDropTarget = 0;
for (String prefix : validDropTargetIdPrefixes) {
target.addAttribute(DROP_TARGET + countDropTarget, prefix);
countDropTarget++;
}
target.addAttribute(DROP_TARGET_COUNT, countDropTarget);
int countDropAreas = 0;
for (String dropArea : validDropAreaIds) {
target.addAttribute(DROP_AREA + countDropAreas, dropArea);
countDropAreas++;
}
target.addAttribute(DROP_AREA_COUNT, countDropAreas);
}
@Override
public boolean accept(DragAndDropEvent dragEvent) {
String dragSourceId = dragEvent.getTransferable().getSourceComponent().getId();
// double-check if this is the right handler:
if (!dragSourceId.startsWith(getDragSourcePrefix())) {
return false;
}
final String dropTargetId = dragEvent.getTargetDetails().getTarget().getId();
for (String cId : validDropTargetIdPrefixes) {
if (dropTargetId.startsWith(cId)) {
return true;
}
}
return false;
}
@Override
protected String getIdentifier() {
// extending classes use client side implementation from this class
return ServerViewComponentClientCriterion.class.getCanonicalName();
}
/**
* Creates a builder to build
* <code>ServerViewComponentClientCriterion</code> objects in a convenient
* way.
*
* @return builder
*/
public static Builder createBuilder() {
return new Builder();
}
/**
* Builds <code>ServerViewComponentClientCriterion</code> objects in a
* convenient way.
*/
public static class Builder {
private String dragSourceIdPrefix;
private String[] validDropTargetIdPrefixes;
private String[] validDropAreaIds;
/**
* Configures the id-prefix of the drag-source the accept criterion is
* responsible for.
*
* @param dragSourceIdPrefix
* the id-prefix of the drag source the criterion is
* responsible for.
* @return builder
*/
public Builder dragSourceIdPrefix(String dragSourceIdPrefix) {
this.dragSourceIdPrefix = dragSourceIdPrefix;
return this;
}
/**
* Configures the prefixes of drop-target ids used by the accept
* criterion to match valid drop-targets.
*
* @param validDropTargetIdPrefixes
* id-prefixes of drop targets valid for the configured drag
* source (id-prefix).
* @return builder
*/
public Builder dropTargetIdPrefixes(String... validDropTargetIdPrefixes) {
this.validDropTargetIdPrefixes = validDropTargetIdPrefixes;
return this;
}
/**
* Configures the drop area ids used to be highlighted when a drag
* operation starts for the associated drag source.
*
* @param validDropAreaIds
* @return builder
*/
public Builder dropAreaIds(String... validDropAreaIds) {
this.validDropAreaIds = validDropAreaIds;
return this;
}
/**
* Builds the previously configured accept criterion.
*
* @return accept criterion
*/
public ServerViewComponentClientCriterion build() {
return new ServerViewComponentClientCriterion(this);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.criteria;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
/**
* Upload UI View for Accept criteria.
*
*/
@SpringComponent
@UIScope
public final class UploadViewClientCriterion extends ServerViewClientCriterion {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = 6271501901430079353L;
private static final ServerViewComponentClientCriterion[] COMPONENT_CRITERIA = createViewComponentClientCriteria();
/**
* Constructor.
*/
public UploadViewClientCriterion() {
super(COMPONENT_CRITERIA);
}
/**
* Configures the elements of the composite accept criterion for the Upload
* View.
*
* @return accept criterion elements
*/
static ServerViewComponentClientCriterion[] createViewComponentClientCriteria() {
ServerViewComponentClientCriterion[] criteria = new ServerViewComponentClientCriterion[2];
// Upload type acceptable components.
criteria[0] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)
.dropTargetIdPrefixes(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID).build();
// Upload software module table acceptable components.
criteria[1] = ServerViewComponentClientCriterion.createBuilder()
.dragSourceIdPrefix(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)
.dropTargetIdPrefixes(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID)
.dropAreaIds(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID).build();
return criteria;
}
}

View File

@@ -23,10 +23,9 @@ import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterLayout;
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTableLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.footer.DSDeleteActionsLayout;
import org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTableLayout;
import org.eclipse.hawkbit.ui.distributions.smtype.DistSMTypeFilterLayout;
@@ -41,7 +40,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.Page;
@@ -91,7 +89,7 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
final UINotification uiNotification, final ManageDistUIState manageDistUIState,
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
final TargetManagement targetManagement, final EntityFactory entityFactory,
final TagManagement tagManagement, final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final TagManagement tagManagement, final DistributionsViewClientCriterion distributionsViewClientCriterion,
final ArtifactUploadState artifactUploadState, final SystemManagement systemManagement,
final ArtifactManagement artifactManagement) {
this.permChecker = permChecker;
@@ -100,17 +98,17 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
this.uiNotification = uiNotification;
this.filterByDSTypeLayout = new DSTypeFilterLayout(manageDistUIState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, softwareManagement, distributionSetManagement,
distributionsViewAcceptCriteria);
distributionsViewClientCriterion);
this.distributionTableLayout = new DistributionSetTableLayout(i18n, eventBus, permChecker, manageDistUIState,
softwareManagement, distributionSetManagement, targetManagement, entityFactory, uiNotification,
tagManagement, distributionsViewAcceptCriteria, systemManagement);
tagManagement, distributionsViewClientCriterion, systemManagement);
this.softwareModuleTableLayout = new SwModuleTableLayout(i18n, uiNotification, eventBus, softwareManagement,
entityFactory, manageDistUIState, permChecker, distributionsViewAcceptCriteria, artifactUploadState,
entityFactory, manageDistUIState, permChecker, distributionsViewClientCriterion, artifactUploadState,
artifactManagement);
this.filterBySMTypeLayout = new DistSMTypeFilterLayout(eventBus, i18n, permChecker, manageDistUIState,
tagManagement, entityFactory, uiNotification, softwareManagement, distributionsViewAcceptCriteria);
tagManagement, entityFactory, uiNotification, softwareManagement, distributionsViewClientCriterion);
this.deleteActionsLayout = new DSDeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
systemManagement, manageDistUIState, distributionsViewAcceptCriteria, distributionSetManagement,
systemManagement, manageDistUIState, distributionsViewClientCriterion, distributionSetManagement,
softwareManagement);
this.manageDistUIState = manageDistUIState;
}
@@ -149,7 +147,6 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
createMainLayout();
addComponents(mainLayout);
setExpandRatio(mainLayout, 1);
hideDropHints();
}
}
@@ -168,15 +165,6 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
}
private void hideDropHints() {
UI.getCurrent().addClickListener(new ClickListener() {
@Override
public void click(final com.vaadin.event.MouseEvents.ClickEvent event) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
});
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {

View File

@@ -11,8 +11,8 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -37,14 +37,14 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
private final ManageDistUIState manageDistUIState;
private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
DSTypeFilterButtons(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final DistributionSetManagement distributionSetManagement) {
super(eventBus, new DSTypeFilterButtonClick(eventBus, manageDistUIState, distributionSetManagement));
this.manageDistUIState = manageDistUIState;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
}
@Override
@@ -78,7 +78,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
@Override
public AcceptCriterion getAcceptCriterion() {
return distributionsViewAcceptCriteria;
return distributionsViewClientCriterion;
}
@Override

View File

@@ -14,8 +14,8 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -36,10 +36,10 @@ public class DSTypeFilterLayout extends AbstractFilterLayout {
final SpPermissionChecker permChecker, final UIEventBus eventBus, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria) {
final DistributionsViewClientCriterion distributionsViewClientCriterion) {
super(new DSTypeFilterHeader(i18n, permChecker, eventBus, manageDistUIState, tagManagement, entityFactory,
uiNotification, softwareManagement, distributionSetManagement),
new DSTypeFilterButtons(eventBus, manageDistUIState, distributionsViewAcceptCriteria,
new DSTypeFilterButtons(eventBus, manageDistUIState, distributionsViewClientCriterion,
distributionSetManagement));
this.manageDistUIState = manageDistUIState;

View File

@@ -8,8 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.dstable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -33,10 +31,9 @@ import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
@@ -81,9 +78,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private static final Logger LOG = LoggerFactory.getLogger(DistributionSetTable.class);
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(
Arrays.asList(DragEvent.SOFTWAREMODULE_DRAG));
private final SpPermissionChecker permissionChecker;
private final ManageDistUIState manageDistUIState;
@@ -92,7 +86,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private final transient SoftwareManagement softwareManagement;
private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
private final transient TargetManagement targetManagement;
@@ -101,14 +95,14 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
DistributionSetTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification,
final SpPermissionChecker permissionChecker, final ManageDistUIState manageDistUIState,
final DistributionSetManagement distributionSetManagement, final SoftwareManagement softwareManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final TargetManagement targetManagement, final DsMetadataPopupLayout dsMetadataPopupLayout) {
super(eventBus, i18n, notification);
this.permissionChecker = permissionChecker;
this.manageDistUIState = manageDistUIState;
this.distributionSetManagement = distributionSetManagement;
this.softwareManagement = softwareManagement;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
this.targetManagement = targetManagement;
this.dsMetadataPopupLayout = dsMetadataPopupLayout;
addTableStyleGenerator();
@@ -118,15 +112,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
setDataAvailable(getContainerDataSource().size() != 0);
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
} else if (DISPLAY_DROP_HINT_EVENTS.contains(event)) {
UI.getCurrent().access(() -> addStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
@@ -139,7 +124,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private void handleSelectedAndUpdatedDs(final List<DistributionSetUpdateEvent> events) {
manageDistUIState.getLastSelectedDistribution()
.ifPresent(lastSelectedDsIdName -> events.stream().map(event -> event.getEntity())
.ifPresent(lastSelectedDsIdName -> events.stream().map(DistributionSetUpdateEvent::getEntity)
.filter(set -> set.getId().equals(lastSelectedDsIdName.getId())).findFirst()
.ifPresent(selectedSetUpdated -> eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated))));
@@ -258,7 +243,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
public AcceptCriterion getDropAcceptCriterion() {
return distributionsViewAcceptCriteria;
return distributionsViewClientCriterion;
}
@Override
@@ -380,7 +365,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
private boolean validSoftwareModule(final Long distId, final SoftwareModule sm) {

View File

@@ -12,7 +12,6 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
@@ -156,7 +155,6 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
newDistWindow.setCaption(i18n.get("caption.add.new.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -35,7 +35,7 @@ public class DistributionSetTableLayout extends AbstractTableLayout {
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
final TargetManagement targetManagement, final EntityFactory entityFactory,
final UINotification uiNotification, final TagManagement tagManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final SystemManagement systemManagement) {
final DsMetadataPopupLayout popupLayout = new DsMetadataPopupLayout(i18n, uiNotification, eventBus,
@@ -43,7 +43,7 @@ public class DistributionSetTableLayout extends AbstractTableLayout {
final DistributionSetTable distributionSetTable = new DistributionSetTable(eventBus, i18n, uiNotification,
permissionChecker, manageDistUIState, distributionSetManagement, softwareManagement,
distributionsViewAcceptCriteria, targetManagement, popupLayout);
distributionsViewClientCriterion, targetManagement, popupLayout);
final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout = new DistributionAddUpdateWindowLayout(
i18n, uiNotification, eventBus, distributionSetManagement, systemManagement, entityFactory,

View File

@@ -1,101 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.distributions.event;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Component;
/**
* Distributions View for Accept criteria.
*
*/
@SpringComponent
@UIScope
public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static final long serialVersionUID = -7686564967583118935L;
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
@Autowired
DistributionsViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
super(uiNotification, eventBus);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
if (isDistributionTypeButtonId(component.getId())) {
id = SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS;
} else if (isSoftwareTypeButtonId(component.getId())) {
id = SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS;
}
return id;
}
@Override
protected Map<String, Object> getDropHintConfigurations() {
return DROP_HINTS_CONFIGS;
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;
}
private boolean isDistributionTypeButtonId(final String id) {
return id != null && (id.startsWith(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS)
|| id.startsWith(SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS));
}
private boolean isSoftwareTypeButtonId(final String id) {
return id != null && id.startsWith(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS);
}
private static Map<String, List<String>> createDropConfigurations() {
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(2);
// Delete drop area droppable components
config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, UIComponentIdProvider.DIST_TABLE_ID,
UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS));
// Distribution table drop components
config.put(UIComponentIdProvider.DIST_TABLE_ID,
Arrays.asList(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));
return config;
}
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(4);
config.put(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, DragEvent.DISTRIBUTION_TYPE_DRAG);
config.put(UIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
config.put(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS, DragEvent.SOFTWAREMODULE_TYPE_DRAG);
return config;
}
}

View File

@@ -1,20 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.distributions.event;
/**
* Manage distributions drag events.
*
*
*
*
*/
public enum DragEvent {
DISTRIBUTION_DRAG, DISTRIBUTION_TYPE_DRAG, HIDE_DROP_HINT, SOFTWAREMODULE_DRAG, SOFTWAREMODULE_TYPE_DRAG
}

View File

@@ -8,8 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.footer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
@@ -24,9 +22,8 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -53,42 +50,29 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = 3494052985006132714L;
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(
Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
DragEvent.SOFTWAREMODULE_TYPE_DRAG));
private final transient SystemManagement systemManagement;
private final ManageDistUIState manageDistUIState;
private final DistributionsConfirmationWindowLayout distConfirmationWindowLayout;
private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
public DSDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final SystemManagement systemManagement,
final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final DistributionSetManagement dsManagement, final SoftwareManagement softwareManagement) {
super(i18n, permChecker, eventBus, notification);
this.systemManagement = systemManagement;
this.manageDistUIState = manageDistUIState;
this.distConfirmationWindowLayout = new DistributionsConfirmationWindowLayout(i18n, eventBus, dsManagement,
softwareManagement, manageDistUIState);
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
init();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
hideDropHints();
} else if (DISPLAY_DROP_HINT_EVENTS.contains(event)) {
showDropHints();
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) {
if (event != null) {
@@ -130,7 +114,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return distributionsViewAcceptCriteria;
return distributionsViewClientCriterion;
}
@Override
@@ -151,8 +135,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
processDeleteSWType(sourceComponent.getId());
}
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
hideDropHints();
}

View File

@@ -23,9 +23,9 @@ import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -70,7 +70,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
private final transient SoftwareManagement softwareManagement;
private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
private final ArtifactDetailsLayout artifactDetailsLayout;
@@ -78,13 +78,13 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
SwModuleTable(final UIEventBus eventBus, final I18N i18n, final UINotification uiNotification,
final ManageDistUIState manageDistUIState, final SoftwareManagement softwareManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final ArtifactManagement artifactManagement, final SwMetadataPopupLayout swMetadataPopupLayout,
final ArtifactUploadState artifactUploadState) {
super(eventBus, i18n, uiNotification);
this.manageDistUIState = manageDistUIState;
this.softwareManagement = softwareManagement;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
this.swMetadataPopupLayout = swMetadataPopupLayout;
@@ -258,7 +258,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
@Override
protected AcceptCriterion getDropAcceptCriterion() {
return distributionsViewAcceptCriteria;
return distributionsViewClientCriterion;
}
@Override

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -31,7 +31,7 @@ public class SwModuleTableLayout extends AbstractTableLayout {
public SwModuleTableLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus,
final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final ManageDistUIState manageDistUIState, final SpPermissionChecker permChecker,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final ArtifactUploadState artifactUploadState, final ArtifactManagement artifactManagement) {
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
@@ -43,7 +43,7 @@ public class SwModuleTableLayout extends AbstractTableLayout {
super.init(
new SwModuleTableHeader(i18n, permChecker, eventBus, manageDistUIState, softwareModuleAddUpdateWindow),
new SwModuleTable(eventBus, i18n, uiNotification, manageDistUIState, softwareManagement,
distributionsViewAcceptCriteria, artifactManagement, swMetadataPopupLayout,
distributionsViewClientCriterion, artifactManagement, swMetadataPopupLayout,
artifactUploadState),
new SwModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow, manageDistUIState,
softwareManagement, swMetadataPopupLayout, entityFactory));

View File

@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -44,14 +44,14 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private final ManageDistUIState manageDistUIState;
private final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
DistSMTypeFilterButtons(final UIEventBus eventBus, final ManageDistUIState manageDistUIState,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final SoftwareManagement softwareManagement) {
super(eventBus, new DistSMTypeFilterButtonClick(eventBus, manageDistUIState, softwareManagement));
this.manageDistUIState = manageDistUIState;
this.distributionsViewAcceptCriteria = distributionsViewAcceptCriteria;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
}
@Override
@@ -91,7 +91,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@Override
public AcceptCriterion getAcceptCriterion() {
return distributionsViewAcceptCriteria;
return distributionsViewClientCriterion;
}
@Override

View File

@@ -13,8 +13,8 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -35,10 +35,10 @@ public class DistSMTypeFilterLayout extends AbstractFilterLayout {
final ManageDistUIState manageDistUIState, final TagManagement tagManagement,
final EntityFactory entityFactory, final UINotification uiNotification,
final SoftwareManagement softwareManagement,
final DistributionsViewAcceptCriteria distributionsViewAcceptCriteria) {
final DistributionsViewClientCriterion distributionsViewClientCriterion) {
super(new DistSMTypeFilterHeader(i18n, permChecker, eventBus, manageDistUIState, tagManagement, entityFactory,
uiNotification, softwareManagement),
new DistSMTypeFilterButtons(eventBus, manageDistUIState, distributionsViewAcceptCriteria,
new DistSMTypeFilterButtons(eventBus, manageDistUIState, distributionsViewClientCriterion,
softwareManagement));
this.manageDistUIState = manageDistUIState;

View File

@@ -22,13 +22,12 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.actionhistory.ActionHistoryComponent;
import org.eclipse.hawkbit.ui.management.dstable.DistributionTableLayout;
import org.eclipse.hawkbit.ui.management.dstag.DistributionTagLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.footer.DeleteActionsLayout;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
@@ -46,7 +45,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.Page;
@@ -101,7 +99,7 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
final DistributionTableFilters distFilterParameters,
final DistributionSetManagement distributionSetManagement, final TargetManagement targetManagement,
final EntityFactory entityFactory, final UiProperties uiproperties,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final TagManagement tagManagement,
final ManagementViewClientCriterion managementViewClientCriterion, final TagManagement tagManagement,
final TargetFilterQueryManagement targetFilterQueryManagement, final SystemManagement systemManagement) {
this.eventbus = eventbus;
this.permChecker = permChecker;
@@ -113,23 +111,23 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout = new CreateUpdateTargetTagLayoutWindow(
i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification);
this.targetTagFilterLayout = new TargetTagFilterLayout(i18n, createUpdateTargetTagLayout, managementUIState,
managementViewAcceptCriteria, permChecker, eventBus, uiNotification, entityFactory, targetManagement,
managementViewClientCriterion, permChecker, eventBus, uiNotification, entityFactory, targetManagement,
targetFilterQueryManagement);
final TargetTable targetTable = new TargetTable(eventBus, i18n, uiNotification, targetManagement,
managementUIState, permChecker, managementViewAcceptCriteria);
managementUIState, permChecker, managementViewClientCriterion);
this.targetTableLayout = new TargetTableLayout(eventbus, targetTable, targetManagement, entityFactory, i18n,
eventBus, uiNotification, managementUIState, managementViewAcceptCriteria, deploymentManagement,
eventBus, uiNotification, managementUIState, managementViewClientCriterion, deploymentManagement,
uiproperties, permChecker, uiNotification, tagManagement);
this.distributionTagLayout = new DistributionTagLayout(eventbus, managementUIState, i18n, permChecker, eventBus,
tagManagement, entityFactory, uiNotification, distFilterParameters, distributionSetManagement,
managementViewAcceptCriteria);
managementViewClientCriterion);
this.distributionTableLayoutNew = new DistributionTableLayout(i18n, eventBus, permChecker, managementUIState,
distributionSetManagement, managementViewAcceptCriteria, entityFactory, uiNotification, tagManagement,
distributionSetManagement, managementViewClientCriterion, entityFactory, uiNotification, tagManagement,
systemManagement, targetManagement);
this.deleteAndActionsLayout = new DeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
tagManagement, managementViewAcceptCriteria, managementUIState, targetManagement, targetTable,
tagManagement, managementViewClientCriterion, managementUIState, targetManagement, targetTable,
deploymentManagement, distributionSetManagement);
}
@@ -196,7 +194,6 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
createMainLayout();
addComponents(mainLayout);
setExpandRatio(mainLayout, 1);
hideDropHints();
}
}
@@ -275,15 +272,6 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
}
}
private void hideDropHints() {
UI.getCurrent().addClickListener(new ClickListener() {
@Override
public void click(final com.vaadin.event.MouseEvents.ClickEvent event) {
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
}
});
}
private void maximizeTargetTable() {
if (permChecker.hasReadDistributionPermission()) {
mainLayout.removeComponent(distributionTableLayoutNew);

View File

@@ -27,7 +27,6 @@ import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -299,7 +298,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
* @return window
*/
public CommonDialogWindow getWindow(final Long editDistId) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
resetComponents();
populateDistSetTypeNameCombo();
populateValuesOfDistribution(editDistId);

View File

@@ -31,13 +31,12 @@ import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
@@ -81,7 +80,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
private final SpPermissionChecker permissionChecker;
private final ManagementUIState managementUIState;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final transient TargetManagement targetService;
private final DsMetadataPopupLayout dsMetadataPopupLayout;
private final transient DistributionSetManagement distributionSetManagement;
@@ -92,13 +91,13 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
DistributionTable(final UIEventBus eventBus, final I18N i18n, final SpPermissionChecker permissionChecker,
final UINotification notification, final ManagementUIState managementUIState,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final TargetManagement targetService,
final ManagementViewClientCriterion managementViewClientCriterion, final TargetManagement targetService,
final DsMetadataPopupLayout dsMetadataPopupLayout,
final DistributionSetManagement distributionSetManagement) {
super(eventBus, i18n, notification);
this.permissionChecker = permissionChecker;
this.managementUIState = managementUIState;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
this.targetService = targetService;
this.dsMetadataPopupLayout = dsMetadataPopupLayout;
this.distributionSetManagement = distributionSetManagement;
@@ -216,16 +215,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent dragEvent) {
if (dragEvent == DragEvent.TARGET_DRAG || dragEvent == DragEvent.TARGET_TAG_DRAG
|| dragEvent == DragEvent.DISTRIBUTION_TAG_DRAG) {
UI.getCurrent().access(() -> addStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
} else {
UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableEvent event) {
onBaseEntityEvent(event);
@@ -399,7 +388,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
@Override
public AcceptCriterion getDropAcceptCriterion() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
@Override
@@ -629,7 +618,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
private void addPinClickListener(final ClickEvent event) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
checkifAlreadyPinned(event.getButton());
if (isDistPinned) {
pinDitribution(event.getButton());

View File

@@ -13,7 +13,6 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -158,7 +157,6 @@ public class DistributionTableHeader extends AbstractTableHeader {
newDistWindow.setCaption(i18n.get("caption.add.new.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override

View File

@@ -15,8 +15,8 @@ import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -32,7 +32,7 @@ public class DistributionTableLayout extends AbstractTableLayout {
public DistributionTableLayout(final I18N i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState,
final DistributionSetManagement distributionSetManagement,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final EntityFactory entityFactory,
final ManagementViewClientCriterion managementViewClientCriterion, final EntityFactory entityFactory,
final UINotification notification, final TagManagement tagManagement,
final SystemManagement systemManagement, final TargetManagement targetService) {
@@ -43,7 +43,7 @@ public class DistributionTableLayout extends AbstractTableLayout {
distributionSetManagement, entityFactory, permissionChecker);
final DistributionTable distributionTable = new DistributionTable(eventBus, i18n, permissionChecker,
notification, managementUIState, managementViewAcceptCriteria, targetService, dsMetadataPopupLayout,
notification, managementUIState, managementViewClientCriterion, targetService, dsMetadataPopupLayout,
distributionSetManagement);
super.init(

View File

@@ -15,9 +15,8 @@ import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.DistributionTagDropEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
@@ -28,7 +27,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -39,7 +37,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.ui.UI;
/**
*
@@ -58,10 +55,10 @@ public class DistributionTagButtons extends AbstractFilterButtons {
final EntityFactory entityFactory, final I18N i18n, final UINotification notification,
final SpPermissionChecker permChecker, final DistributionTableFilters distFilterParameters,
final DistributionSetManagement distributionSetManagement,
final ManagementViewAcceptCriteria managementViewAcceptCriteria) {
final ManagementViewClientCriterion managementViewClientCriterion) {
super(eventBus, new DistributionTagButtonClick(eventBus, managementUIState));
this.spDistTagDropEvent = new DistributionTagDropEvent(i18n, notification, permChecker, distFilterParameters,
distributionSetManagement, eventBus, managementViewAcceptCriteria);
distributionSetManagement, eventBus, managementViewClientCriterion);
this.managementUIState = managementUIState;
this.entityFactory = entityFactory;
@@ -89,15 +86,6 @@ public class DistributionTagButtons extends AbstractFilterButtons {
refreshTagTable();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent dragEvent) {
if (dragEvent == DragEvent.DISTRIBUTION_DRAG) {
UI.getCurrent().access(() -> addStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_FILTER_BUTTON));
} else {
UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_FILTER_BUTTON));
}
}
@Override
protected String getButtonsTableId() {
return UIComponentIdProvider.DISTRIBUTION_TAG_TABLE_ID;

View File

@@ -13,8 +13,8 @@ import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -38,12 +38,12 @@ public class DistributionTagLayout extends AbstractFilterLayout {
final EntityFactory entityFactory, final UINotification uiNotification,
final DistributionTableFilters distFilterParameters,
final DistributionSetManagement distributionSetManagement,
final ManagementViewAcceptCriteria managementViewAcceptCriteria) {
final ManagementViewClientCriterion managementViewClientCriterion) {
super(new DistributionTagHeader(i18n, managementUIState, permChecker, eventBus, tagManagement, entityFactory,
uiNotification),
new DistributionTagButtons(eventBus, managementUIState, entityFactory, i18n, uiNotification,
permChecker, distFilterParameters, distributionSetManagement, managementViewAcceptCriteria));
permChecker, distFilterParameters, distributionSetManagement, managementViewClientCriterion));
this.managementUIState = managementUIState;
restoreState();

View File

@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -55,19 +56,19 @@ public class DistributionTagDropEvent implements DropHandler {
private final transient EventBus.UIEventBus eventBus;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
public DistributionTagDropEvent(final I18N i18n, final UINotification notification,
final SpPermissionChecker permChecker, final DistributionTableFilters distFilterParameters,
final DistributionSetManagement distributionSetManagement, final UIEventBus eventBus,
final ManagementViewAcceptCriteria managementViewAcceptCriteria) {
final ManagementViewClientCriterion managementViewClientCriterion) {
this.i18n = i18n;
this.notification = notification;
this.permChecker = permChecker;
this.distFilterParameters = distFilterParameters;
this.distributionSetManagement = distributionSetManagement;
this.eventBus = eventBus;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
}
@Override
@@ -160,7 +161,7 @@ public class DistributionTagDropEvent implements DropHandler {
*/
@Override
public AcceptCriterion getAcceptCriterion() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
}

View File

@@ -1,18 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.management.event;
/**
*
*
*
*/
public enum DragEvent {
TARGET_DRAG, DISTRIBUTION_DRAG, TARGET_TAG_DRAG, DISTRIBUTION_TAG_DRAG, HIDE_DROP_HINT
}

View File

@@ -1,109 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.management.event;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Component;
/**
* Management View for Accept criteria.
*/
@SpringComponent
@UIScope
public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
private static final long serialVersionUID = 1718217664674701006L;
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
ManagementViewAcceptCriteria(final UINotification uiNotification, final UIEventBus eventBus) {
super(uiNotification, eventBus);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
if (isTargetTagId(component.getId())) {
id = SPUIDefinitions.TARGET_TAG_ID_PREFIXS;
} else if (isDistributionTagId(component.getId())) {
id = SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS;
}
return id;
}
@Override
protected Map<String, Object> getDropHintConfigurations() {
return DROP_HINTS_CONFIGS;
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;
}
private boolean isDistributionTagId(final String id) {
return id != null && id.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);
}
private boolean isTargetTagId(final String id) {
return id != null && id.startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
}
private static Map<String, List<String>> createDropConfigurations() {
final Map<String, List<String>> config = Maps.newHashMapWithExpectedSize(6);
// Delete drop area acceptable components
config.put(UIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, UIComponentIdProvider.TARGET_TABLE_ID,
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, UIComponentIdProvider.DIST_TABLE_ID));
// Target Tag acceptable components
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, Arrays.asList(UIComponentIdProvider.TARGET_TABLE_ID));
// Target table acceptable components
config.put(UIComponentIdProvider.TARGET_TABLE_ID,
Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, UIComponentIdProvider.DIST_TABLE_ID));
// Target table header acceptable components
config.put(UIComponentIdProvider.TARGET_DROP_FILTER_ICON, Arrays.asList(UIComponentIdProvider.DIST_TABLE_ID));
// Distribution table acceptable components
config.put(UIComponentIdProvider.DIST_TABLE_ID, Arrays.asList(SPUIDefinitions.TARGET_TAG_ID_PREFIXS,
UIComponentIdProvider.TARGET_TABLE_ID, SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS));
// Distribution tag acceptable components.
config.put(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, Arrays.asList(UIComponentIdProvider.DIST_TABLE_ID));
return config;
}
private static Map<String, Object> createDropHintConfigurations() {
final Map<String, Object> config = Maps.newHashMapWithExpectedSize(4);
config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, DragEvent.TARGET_TAG_DRAG);
config.put(UIComponentIdProvider.TARGET_TABLE_ID, DragEvent.TARGET_DRAG);
config.put(UIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
config.put(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS, DragEvent.DISTRIBUTION_TAG_DRAG);
return config;
}
}

View File

@@ -19,10 +19,9 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
@@ -55,7 +54,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private final transient TagManagement tagManagementService;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final ManagementUIState managementUIState;
@@ -65,13 +64,13 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
public DeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final TagManagement tagManagementService,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final ManagementUIState managementUIState,
final ManagementViewClientCriterion managementViewClientCriterion, final ManagementUIState managementUIState,
final TargetManagement targetManagement, final TargetTable targetTable,
final DeploymentManagement deploymentManagement,
final DistributionSetManagement distributionSetManagement) {
super(i18n, permChecker, eventBus, notification);
this.tagManagementService = tagManagementService;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
this.managementUIState = managementUIState;
this.manangementConfirmationWindowLayout = new ManangementConfirmationWindowLayout(i18n, eventBus,
managementUIState, targetManagement, deploymentManagement, distributionSetManagement);
@@ -88,28 +87,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
hideDropHints();
} else if (event == DragEvent.TARGET_TAG_DRAG || event == DragEvent.TARGET_DRAG) {
/**
* Duplicate permission check required as hasDeletePermission() is
* generic both for target and ds.
*/
if (permChecker.hasDeleteTargetPermission()) {
showDropHints();
}
} else if ((event == DragEvent.DISTRIBUTION_TAG_DRAG || event == DragEvent.DISTRIBUTION_DRAG)
&& permChecker.hasDeleteDistributionPermission()) {
/**
* Duplicate permission check required as hasDeletePermission() is
* generic both for target and ds.
*/
showDropHints();
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) {
if (event != null) {
@@ -173,7 +150,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
@Override
@@ -184,8 +161,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
} else {
processDeletion(event, source);
}
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
hideDropHints();
}
private void processDeletion(final DragAndDropEvent event, final Component source) {

View File

@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -157,7 +156,6 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
}
public Window getWindow() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.target"))
.content(this).layout(formLayout).i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener())
.buildCommonDialogWindow();

View File

@@ -42,9 +42,8 @@ import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.event.TargetAddUpdateWindowEvent;
@@ -107,7 +106,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
private final SpPermissionChecker permChecker;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final ManagementUIState managementUIState;
@@ -116,11 +115,11 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
public TargetTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification,
final TargetManagement targetManagement, final ManagementUIState managementUIState,
final SpPermissionChecker permChecker, final ManagementViewAcceptCriteria managementViewAcceptCriteria) {
final SpPermissionChecker permChecker, final ManagementViewClientCriterion managementViewClientCriterion) {
super(eventBus, i18n, notification);
this.targetManagement = targetManagement;
this.permChecker = permChecker;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
this.managementUIState = managementUIState;
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
@@ -194,15 +193,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
refreshTargets();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent dragEvent) {
if (dragEvent == DragEvent.TARGET_TAG_DRAG || dragEvent == DragEvent.DISTRIBUTION_DRAG) {
UI.getCurrent().access(() -> addStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
} else {
UI.getCurrent().access(() -> removeStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_TABLE));
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final PinUnpinEvent pinUnpinEvent) {
UI.getCurrent().access(() -> {
@@ -344,7 +334,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
@Override
public AcceptCriterion getDropAcceptCriterion() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
private void reSelectItemsAfterDeletionEvent() {
@@ -453,7 +443,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
* as event
*/
private void addPinClickListener(final ClickEvent event) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
checkifAlreadyPinned(event.getButton());
if (isTargetPinned) {
pinTarget(event.getButton());

View File

@@ -21,12 +21,11 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
import org.eclipse.hawkbit.ui.management.event.BulkUploadValidationMessageEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.TargetFilterEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
@@ -63,7 +62,7 @@ public class TargetTableHeader extends AbstractTableHeader {
private final UINotification notification;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final TargetAddUpdateWindowLayout targetAddUpdateWindow;
@@ -73,13 +72,13 @@ public class TargetTableHeader extends AbstractTableHeader {
TargetTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
final UINotification notification, final ManagementUIState managementUIState,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final TargetManagement targetManagement,
final ManagementViewClientCriterion managementViewClientCriterion, final TargetManagement targetManagement,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final UIEventBus eventBus,
final EntityFactory entityFactory, final UINotification uinotification, final TagManagement tagManagement,
final TargetTable targetTable) {
super(i18n, permChecker, eventbus, managementUIState, null, null);
this.notification = notification;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
this.targetAddUpdateWindow = new TargetAddUpdateWindowLayout(i18n, targetManagement, eventBus, uinotification,
entityFactory, targetTable);
this.targetBulkUpdateWindow = new TargetBulkUpdateWindowLayout(i18n, targetManagement, eventBus,
@@ -157,17 +156,6 @@ public class TargetTableHeader extends AbstractTableHeader {
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent dragEvent) {
if (dragEvent == DragEvent.DISTRIBUTION_DRAG) {
if (!isComplexFilterViewDisplayed) {
UI.getCurrent().access(() -> addStyleName("show-table-header-drop-hint"));
}
} else {
UI.getCurrent().access(() -> removeStyleName("show-table-header-drop-hint"));
}
}
@Override
protected String getHeaderCaption() {
return i18n.get("header.target.table");
@@ -282,7 +270,6 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
protected void addNewItem(final ClickEvent event) {
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
targetAddUpdateWindow.resetComponents();
final Window addTargetWindow = targetAddUpdateWindow.getWindow();
addTargetWindow.setCaption(i18n.get("caption.add.new.target"));
@@ -327,7 +314,7 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
public AcceptCriterion getAcceptCriterion() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
};
@@ -408,7 +395,6 @@ public class TargetTableHeader extends AbstractTableHeader {
private void closeFilterByDistribution() {
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
/* Remove filter by distribution information. */
getFilterDroppedInfo().removeAllComponents();
getFilterDroppedInfo().setSizeUndefined();

View File

@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
@@ -40,7 +40,7 @@ public class TargetTableLayout extends AbstractTableLayout {
public TargetTableLayout(final UIEventBus eventBus, final TargetTable targetTable,
final TargetManagement targetManagement, final EntityFactory entityFactory, final I18N i18n,
final UIEventBus eventbus, final UINotification notification, final ManagementUIState managementUIState,
final ManagementViewAcceptCriteria managementViewAcceptCriteria,
final ManagementViewClientCriterion managementViewClientCriterion,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties,
final SpPermissionChecker permissionChecker, final UINotification uinotification,
final TagManagement tagManagement) {
@@ -48,7 +48,7 @@ public class TargetTableLayout extends AbstractTableLayout {
this.targetDetails = new TargetDetails(i18n, eventbus, permissionChecker, managementUIState, uinotification,
tagManagement, targetManagement, entityFactory, targetTable);
this.targetTableHeader = new TargetTableHeader(i18n, permissionChecker, eventBus, notification,
managementUIState, managementViewAcceptCriteria, targetManagement, deploymentManagement, uiproperties,
managementUIState, managementViewClientCriterion, targetManagement, deploymentManagement, uiproperties,
eventbus, entityFactory, uinotification, tagManagement, targetTable);
super.init(targetTableHeader, targetTable, targetDetails);

View File

@@ -13,9 +13,9 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -58,10 +58,10 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange
MultipleTargetFilter(final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout,
final SpPermissionChecker permChecker, final ManagementUIState managementUIState, final I18N i18n,
final UIEventBus eventBus, final ManagementViewAcceptCriteria managementViewAcceptCriteria,
final UIEventBus eventBus, final ManagementViewClientCriterion managementViewClientCriterion,
final UINotification notification, final EntityFactory entityFactory,
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement) {
this.filterByButtons = new TargetTagFilterButtons(eventBus, managementUIState, managementViewAcceptCriteria,
this.filterByButtons = new TargetTagFilterButtons(eventBus, managementUIState, managementViewClientCriterion,
i18n, notification, permChecker, entityFactory, targetManagement);
this.targetFilterQueryButtonsTab = new TargetFilterQueryButtons(managementUIState, eventBus);
this.filterByStatusFotter = new FilterByStatusLayout(i18n, eventBus, managementUIState);
@@ -124,7 +124,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange
}
targetTagTableLayout.addComponent(filterByButtons);
targetTagTableLayout.setComponentAlignment(filterByButtons, Alignment.MIDDLE_CENTER);
targetTagTableLayout.addStyleName("target-tag-drop-hint");
targetTagTableLayout.setId(UIComponentIdProvider.TARGET_TAG_DROP_AREA_ID);
targetTagTableLayout.setExpandRatio(filterByButtons, 1.0F);
simpleFilterTab.setCaption(i18n.get("caption.filter.simple"));
simpleFilterTab.addComponent(targetTagTableLayout);

View File

@@ -20,9 +20,8 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
@@ -45,7 +44,6 @@ import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.server.Page;
import com.vaadin.ui.Component;
import com.vaadin.ui.DragAndDropWrapper;
import com.vaadin.ui.Table;
@@ -61,7 +59,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private final ManagementUIState managementUIState;
private final ManagementViewAcceptCriteria managementViewAcceptCriteria;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final I18N i18n;
@@ -74,12 +72,12 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private final transient TargetManagement targetManagement;
TargetTagFilterButtons(final UIEventBus eventBus, final ManagementUIState managementUIState,
final ManagementViewAcceptCriteria managementViewAcceptCriteria, final I18N i18n,
final ManagementViewClientCriterion managementViewClientCriterion, final I18N i18n,
final UINotification notification, final SpPermissionChecker permChecker, final EntityFactory entityFactory,
final TargetManagement targetManagement) {
super(eventBus, new TargetTagFilterButtonClick(eventBus, managementUIState));
this.managementUIState = managementUIState;
this.managementViewAcceptCriteria = managementViewAcceptCriteria;
this.managementViewClientCriterion = managementViewClientCriterion;
this.i18n = i18n;
this.notification = notification;
this.permChecker = permChecker;
@@ -89,21 +87,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
addNewTargetTag(entityFactory.tag().create().name(NO_TAG).build());
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DragEvent dragEvent) {
/*
* this has some flickering issue for addStyleName(
* "show-filter-drop-hint" ); Hence, doing with Javascripts
*/
if (dragEvent == DragEvent.TARGET_DRAG) {
UI.getCurrent().access(
() -> Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.dispTargetTagsDropHintScript()));
} else {
UI.getCurrent().access(
() -> Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.hideTargetTagsDropHintScript()));
}
}
@Override
protected String getButtonsTableId() {
return UIComponentIdProvider.TARGET_TAG_TABLE_ID;
@@ -140,7 +123,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
@Override
public AcceptCriterion getAcceptCriterion() {
return managementViewAcceptCriteria;
return managementViewClientCriterion;
}
@Override

View File

@@ -12,8 +12,8 @@ import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -29,13 +29,14 @@ public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout {
private static final long serialVersionUID = 2153612878428575009L;
public TargetTagFilterLayout(final I18N i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout,
final ManagementUIState managementUIState, final ManagementViewAcceptCriteria managementViewAcceptCriteria,
final ManagementUIState managementUIState,
final ManagementViewClientCriterion managementViewClientCriterion,
final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification,
final EntityFactory entityFactory, final TargetManagement targetManagement,
final TargetFilterQueryManagement targetFilterQueryManagement) {
super(new TargetTagFilterHeader(i18n, createUpdateTargetTagLayout, managementUIState, permChecker, eventBus),
new MultipleTargetFilter(createUpdateTargetTagLayout, permChecker, managementUIState, i18n, eventBus,
managementViewAcceptCriteria, notification, entityFactory, targetManagement,
managementViewClientCriterion, notification, entityFactory, targetManagement,
targetFilterQueryManagement),
managementUIState);
eventBus.subscribe(this);

View File

@@ -63,16 +63,9 @@ public final class HawkbitCommonUtil {
public static final String HTML_UL_CLOSE_TAG = "</ul>";
public static final String HTML_UL_OPEN_TAG = "<ul>";
private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } ";
public static final String DIV_DESCRIPTION_START = "<div id=\"desc-length\"><p id=\"desciption-p\">";
public static final String DIV_DESCRIPTION_END = "</p></div>";
private static final String DRAG_COUNT_ELEMENT = "var x = document.getElementById('sp-drag-count'); ";
private static final String CLOSE_BRACE = "\"; }';";
private static final String CLOSE_BRACE_NOSEMICOLON = "\"; } ";
private static final String COUNT_STYLE = " countStyle = document.createElement('style'); ";
private static final String COUNT_STYLE_ID = " countStyle.id=\"sp-drag-count\"; ";
private static final String APPEND_CHILD = " document.head.appendChild(countStyle);";
private static final String SM_HIGHLIGHT_CREATE_SCRIPT = "smHighlight = document.createElement('style'); smHighlight.id=\"sm-table-highlight\"; document.head.appendChild(smHighlight); ";
private static final String SM_HIGHLIGHT_REMOVE_SCRIPT = "var y = document.getElementById('sm-table-highlight'); if(y) { document.head.removeChild(y); } ";
private static final String SM_HIGHLIGHT_RESET_SCRIPT = SM_HIGHLIGHT_REMOVE_SCRIPT + SM_HIGHLIGHT_CREATE_SCRIPT
@@ -85,10 +78,6 @@ public final class HawkbitCommonUtil {
private static final String PREVIEW_BUTTON_COLOR_CREATE_SCRIPT = "tagColorPreview = document.createElement('style'); tagColorPreview.id=\"tag-color-preview\"; document.head.appendChild(tagColorPreview); ";
private static final String PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT = "var a = document.getElementById('tag-color-preview'); if(a) { document.head.removeChild(a); } ";
private static final String PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT = "document.getElementById('tag-color-preview').innerHTML = tagColorPreviewStyle;";
private static final String TARGET_TAG_DROP_CREATE_SCRIPT = "var p = document.getElementById('show-filter-drop-hint'); if(p) { } else { showTargetTagDrop = document.createElement('style'); showTargetTagDrop.id=\"show-filter-drop-hint\"; document.head.appendChild(showTargetTagDrop); }";
private static final String TARGET_TAG_DROP_REMOVE_SCRIPT = "var m = document.getElementById('show-filter-drop-hint'); if(m) { document.head.removeChild(m); } ";
private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }";
private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } ";
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
@@ -299,27 +288,6 @@ public final class HawkbitCommonUtil {
return null;
}
/**
* Create javascript to display number of targets or distributions your are
* dragging in the drag image.
*
* @param count
* @return
*/
public static String getDragRowCountJavaScript(final int count) {
final StringBuilder exeJS = new StringBuilder(DRAG_COUNT_ELEMENT).append(JS_DRAG_COUNT_REM_CHILD);
final String currentTheme = UI.getCurrent().getTheme();
if (count > 1) {
exeJS.append(COUNT_STYLE).append(COUNT_STYLE_ID)
.append(" countStyle.innerHTML = '." + currentTheme + " tbody.v-drag-element tr:after { content:\""
+ count + "\";top:-15px } ." + currentTheme + " tr.v-drag-element:after { content:\""
+ count + CLOSE_BRACE_NOSEMICOLON + "." + currentTheme
+ " table.v-drag-element:after{ content:\"" + count + CLOSE_BRACE)
.append(APPEND_CHILD);
}
return exeJS.toString();
}
/**
* Get formatted label.Appends ellipses if content does not fit the label.
*
@@ -522,46 +490,6 @@ public final class HawkbitCommonUtil {
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT).toString();
}
/**
* Java script to display drop hints for tags.
*
* @return javascript
*/
public static String dispTargetTagsDropHintScript() {
final String targetDropStyle = "document.getElementById('show-filter-drop-hint').innerHTML = '."
+ UI.getCurrent().getTheme() + " .target-tag-drop-hint { border: 1px dashed #26547a !important; }';";
return new StringBuilder().append(TARGET_TAG_DROP_CREATE_SCRIPT).append(targetDropStyle).toString();
}
/**
* Java script to hide drop hints for tags.
*
* @return javascript
*/
public static String hideTargetTagsDropHintScript() {
return TARGET_TAG_DROP_REMOVE_SCRIPT;
}
/**
* Java script to display drop hint for Delete button.
*
* @return javascript
*/
public static String dispDeleteDropHintScript() {
final String deleteTagDropStyle = "document.getElementById('show-delete-drop-hint').innerHTML = '."
+ UI.getCurrent().getTheme() + " .show-delete-drop-hint { border: 1px dashed #26547a !important; }';";
return new StringBuilder().append(DELETE_DROP_CREATE_SCRIPT).append(deleteTagDropStyle).toString();
}
/**
* Java script to hide drop hint for delete button.
*
* @return javascript
*/
public static String hideDeleteDropHintScript() {
return DELETE_TAG_DROP_REMOVE_SCRIPT;
}
/**
* Add target table container properties.
*

View File

@@ -58,11 +58,6 @@ public final class SPUIStyleDefinitions {
*/
public static final String SP_SMALL_TABLE_STYLE = "sp-table-small";
/**
* Show drop hint style.
*/
public static final String SHOW_DROP_HINT = "show-drop-hint";
/**
* Drag highligh layout style.
*/
@@ -169,21 +164,6 @@ public final class SPUIStyleDefinitions {
*/
public static final String COUNT_MSG_BOX_SHOW = "count-msg-box";
/**
* Style to display drop hints for filter buttons.
*/
public static final String SHOW_DROP_HINT_FILTER_BUTTON = "show-filter-drop-hint";
/**
* Style to display drop hints for table.
*/
public static final String SHOW_DROP_HINT_TABLE = "show-table-drop-hint";
/**
* Style to display drop hint for delete area.
*/
public static final String SHOW_DELETE_DROP_HINT = "show-delete-drop-hint";
/**
* Action button style- footer buttons.
*/

View File

@@ -379,6 +379,12 @@ public final class UIComponentIdProvider {
* ID-Target tag table.
*/
public static final String TARGET_TAG_TABLE_ID = "target.tag.tableId";
/**
* ID-Target tag table drop area.
*/
public static final String TARGET_TAG_DROP_AREA_ID = "target.tag.drop.area";
/**
* ID-Distibution tag table.
*/

View File

@@ -9,32 +9,30 @@
// scss-lint:disable ImportantRule, PropertySortOrder
@mixin drop-hint {
//Distribution tag table -Drop hint - Dashed border displayed
.show-filter-drop-hint {
border: 1px dashed $hawkbit-primary-color !important;
//Border for delete button wrapper.Which will be displayed when deletable components are dragged
.delete-button-border {
border: 1px dashed transparent;
}
//Style to display drop hint on tables
.show-table-drop-hint {
.show-drop-hint {
.type-button-layout {
border: 1px dashed $hawkbit-primary-color !important;
}
}
.show-drop-hint.type-button-layout {
border-style: dashed !important;
border-width: 1px !important;
border-color: $hawkbit-primary-color !important;
}
.show-drop-hint.sp-table {
.v-table-body {
border-style: dashed !important;
border-width: 1px !important;
border-color: $hawkbit-primary-color !important;
}
}
//Style for target table header drop hint
.show-table-header-drop-hint {
.filter-drop-hint-layout {
border-style: dashed;
border-width: 1px;
border-color: $hawkbit-primary-color;
}
}
//Border for delete button wrapper.Which will be displayed when deletable components are dragged
.delete-button-border {
border: 1px dashed transparent;
.show-drop-hint.v-ddwrapper {
border: 1px dashed $hawkbit-primary-color !important;
}
//Target table header - distribution filter text field style

View File

@@ -29,6 +29,8 @@
&[style*="hidden"] {
}
right: -10px;
top: -15px;
}
@mixin table {
@@ -87,7 +89,6 @@
&:after {
@include count-sp-drag-image;
right: -10px;
}
&.v-table-focus {
@@ -128,7 +129,6 @@
&:after {
@include count-sp-drag-image;
right: -10px;
}
}
}

View File

@@ -0,0 +1,68 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.mockito.Mockito.when;
import org.mockito.Mockito;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.client.ui.dd.VDropHandler;
import com.vaadin.client.ui.dd.VTransferable;
import com.vaadin.client.ui.ui.UIConnector;
public class CriterionTestHelper {
static VDragEvent createMockedVDragEvent(String dragSourceId, Widget widget, String theme) {
VDragEvent dragEvent = createMockedVDragEvent(dragSourceId, widget);
ApplicationConnection connection = Mockito.mock(ApplicationConnection.class);
when(dragEvent.getTransferable().getDragSource().getConnection()).thenReturn(connection);
UIConnector uiConnector = Mockito.mock(UIConnector.class);
when(connection.getUIConnector()).thenReturn(uiConnector);
when(uiConnector.getActiveTheme()).thenReturn(theme);
return dragEvent;
}
static VDropHandler createMockedVDropHandler(String dropTargetId) {
com.google.gwt.user.client.Element element = Mockito.mock(com.google.gwt.user.client.Element.class);
when(element.getId()).thenReturn(dropTargetId);
Widget widget = Mockito.mock(Widget.class);
when(widget.getElement()).thenReturn(element);
ComponentConnector connector = Mockito.mock(ComponentConnector.class);
when(connector.getWidget()).thenReturn(widget);
VDropHandler dropHandler = Mockito.mock(VDropHandler.class);
when(dropHandler.getConnector()).thenReturn(connector);
return dropHandler;
}
static VDragEvent createMockedVDragEvent(String dragSourceId, Widget widget) {
com.google.gwt.user.client.Element element = Mockito.mock(com.google.gwt.user.client.Element.class);
when(element.getId()).thenReturn(dragSourceId);
when(widget.getElement()).thenReturn(element);
ComponentConnector dragSource = Mockito.mock(ComponentConnector.class);
when(dragSource.getWidget()).thenReturn(widget);
VTransferable transferable = Mockito.mock(VTransferable.class);
when(transferable.getDragSource()).thenReturn(dragSource);
VDragEvent dragEvent = Mockito.mock(VDragEvent.class);
when(dragEvent.getTransferable()).thenReturn(transferable);
return dragEvent;
}
static VDragEvent createMockedVDragEvent(String dragSourceId) {
Widget widget = Mockito.mock(Widget.class);
return createMockedVDragEvent(dragSourceId, widget);
}
}

View File

@@ -0,0 +1,139 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.Description;
import com.google.gwt.core.client.GWT;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.dd.VDragEvent;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Unit Tests - Drag And Drop")
@Stories("Client-side Accept criteria")
@RunWith(GwtMockitoTestRunner.class)
public class ItemIdClientCriterionTest {
@Test
@Description("Verifies that drag source is not valid for the configured id (strict mode)")
public void noMatchInStrictMode() {
ItemIdClientCriterion cut = new ItemIdClientCriterion();
// prepare drag-event:
String testId = "thisId";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
String configuredId = "component0";
String id = "this";
when(uidl.getStringAttribute(configuredId)).thenReturn(id);
String configuredMode = "m";
String strictMode = "s";
when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
String count = "c";
when(uidl.getIntAttribute(count)).thenReturn(1);
// act
boolean result = cut.accept(dragEvent, uidl);
// verify that in strict mode: [thisId !equals this]
assertThat(result).as("Expected: [" + id + " !equals " + testId + "].").isFalse();
}
@Test
@Description("Verifies that drag source is valid for the configured id (strict mode)")
public void matchInStrictMode() {
ItemIdClientCriterion cut = new ItemIdClientCriterion();
// prepare drag-event:
String testId = "thisId";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
String configuredId = "component0";
String id = "thisId";
when(uidl.getStringAttribute(configuredId)).thenReturn(id);
String configuredMode = "m";
String strictMode = "s";
when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
String count = "c";
when(uidl.getIntAttribute(count)).thenReturn(1);
// act
boolean result = cut.accept(dragEvent, uidl);
// verify that in strict mode: [thisId equals thisId]
assertThat(result).as("Expected: [" + id + " equals " + testId + "].").isTrue();
}
@Test
@Description("Verifies that drag source is not valid for the configured id (prefix mode)")
public void noMatchInPrefixMode() {
ItemIdClientCriterion cut = new ItemIdClientCriterion();
// prepare drag-event:
String testId = "thisId";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
String configuredId = "component0";
String prefix = "any";
when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
String configuredMode = "m";
String prefixMode = "p";
when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
String count = "c";
when(uidl.getIntAttribute(count)).thenReturn(1);
// act
boolean result = cut.accept(dragEvent, uidl);
// verify that in strict mode: [thisId !startsWith any]
assertThat(result).as("Expected: [" + testId + " !startsWith " + prefix + "].").isFalse();
}
@Test
@Description("Verifies that drag source is valid for the configured id (prefix mode)")
public void matchInPrefixMode() {
ItemIdClientCriterion cut = new ItemIdClientCriterion();
// prepare drag-event:
String testId = "thisId";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
String configuredId = "component0";
String prefix = "this";
when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
String configuredMode = "m";
String prefixMode = "p";
when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
String count = "c";
when(uidl.getIntAttribute(count)).thenReturn(1);
// act
boolean result = cut.accept(dragEvent, uidl);
// verify that in strict mode: [thisId startsWith this]
assertThat(result).as("Expected: [" + testId + " startsWith " + prefix + "].").isTrue();
}
}

View File

@@ -0,0 +1,241 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.ViewCriterionTemplates;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.context.annotation.Description;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.StyleElement;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.google.gwtmockito.WithClassesToStub;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.VDragAndDropWrapper;
import com.vaadin.client.ui.VScrollTable;
import com.vaadin.client.ui.dd.VDragEvent;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Unit Tests - Drag And Drop")
@Stories("Client-side Accept criteria")
@RunWith(GwtMockitoTestRunner.class)
@WithClassesToStub({ RootPanel.class })
public class ViewClientCriterionTest {
@Test
@Description("Verfies compilation of template strings.")
public void verifyCompiledTemplateStrings() {
ViewCriterionTemplates templates = GWT.create(ViewCriterionTemplates.class);
// compile templates
String multiSelectionStyle = templates.multiSelectionStyle("my-theme", "10").asString();
String notificationMsg = templates.notificationMsg("some-message").asString();
// assure compilation
assertThat(multiSelectionStyle).as("Expected: Compiled template string").isNotNull();
assertThat(notificationMsg).as("Expected: Compiled template string").isNotNull();
}
@Test
@Description("Process serialized config for hiding the drop hints.")
public void processSerializedDropTargetHintsConfig() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare configuration:
Document document = Document.get();
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getIntAttribute("cdac")).thenReturn(3);
Element[] elements = new Element[3];
for (int i = 0; i < 3; i++) {
when(uidl.getStringAttribute("dac" + String.valueOf(i))).thenReturn("itemId" + String.valueOf(i));
elements[i] = Mockito.mock(Element.class);
when(document.getElementById("itemId" + String.valueOf(i))).thenReturn(elements[i]);
}
// act
try {
cut.hideDropTargetHints(uidl);
// assure invocation
for (int i = 0; i < 3; i++) {
verify(document).getElementById("itemId" + String.valueOf(i));
verify(elements[i]).removeClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
}
// cross-check
verify(document, Mockito.never()).getElementById("itemId3");
} finally {
reset(Document.get());
}
}
@Test
@Description("Exception occures when processing serialized config for hiding the drop hints.")
public void exceptionWhenProcessingDropTargetHintsDataStructure() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare configuration:
Document document = Document.get();
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getIntAttribute("cdac")).thenReturn(2);
when(uidl.getStringAttribute("dac0")).thenReturn("no-problem");
when(uidl.getStringAttribute("dac1")).thenReturn("problem-bear");
doThrow(new RuntimeException()).when(uidl).getStringAttribute("dac1");
// act
try {
cut.hideDropTargetHints(uidl);
// assure that no-problem was invoked anyway
verify(document).getElementById("no-problem");
// cross-check that problem-bear was never invoked
verify(document, Mockito.never()).getElementById("problem-bear");
} catch (RuntimeException re) {
fail("Exception is not re-thrown in order to continue with the loop");
} finally {
reset(Document.get());
}
}
@Test
@Description("Check multi row drag decoration with non-table widget")
public void processMultiRowDragDecorationNonTable() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare drag-event with non table widget:
VDragAndDropWrapper nonTable = Mockito.mock(VDragAndDropWrapper.class);
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", nonTable);
Document document = Document.get();
// act
cut.setMultiRowDragDecoration(dragEvent);
// assure that multi-row decoration processing was skipped
verify(document, Mockito.never()).getElementById(ViewClientCriterion.SP_DRAG_COUNT);
}
@Test
@Description("Check multi row drag decoration with single selection")
public void processMultiRowDragDecorationSingleSelection() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare table
VScrollTable table = Mockito.spy(new VScrollTable());
table.selectedRowKeys.add("one");
// prepare drag-event with table widget:
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
// prepare document
Document document = Document.get();
Element ele = Mockito.mock(Element.class);
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
try {
// act
cut.setMultiRowDragDecoration(dragEvent);
// assure that multi-row decoration for the table was processed
verify(document).getElementById(ViewClientCriterion.SP_DRAG_COUNT);
// assure that no multi selection was detected
verify(ele).removeFromParent();
} finally {
reset(Document.get());
}
}
@Test
@Description("Check multi row drag decoration with a single item dragged while a multi selection is active in table")
public void processMultiRowDragDecorationMultiSelectionNotDragged() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare table
VScrollTable table = Mockito.spy(new VScrollTable());
table.selectedRowKeys.add("one");
table.selectedRowKeys.add("two");
table.focusedRow = Mockito.mock(VScrollTable.VScrollTableBody.VScrollTableRow.class);
when(table.focusedRow.getKey()).thenReturn("another");
// prepare drag-event with table widget:
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table);
// prepare document
Document document = Document.get();
Element ele = Mockito.mock(Element.class);
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
try {
// act
cut.setMultiRowDragDecoration(dragEvent);
// assure that multi-row decoration for the table was processed
verify(document).getElementById(ViewClientCriterion.SP_DRAG_COUNT);
// assure that no multi selection was detected
verify(ele).removeFromParent();
} finally {
reset(Document.get());
}
}
@Test
@Description("Check multi row drag decoration with a valid multi selection")
public void processMultiRowDragDecorationMultiSelection() {
ViewClientCriterion cut = new ViewClientCriterion();
// prepare table
VScrollTable table = Mockito.spy(new VScrollTable());
table.selectedRowKeys.add("one");
table.selectedRowKeys.add("two");
table.focusedRow = Mockito.mock(VScrollTable.VScrollTableBody.VScrollTableRow.class);
when(table.focusedRow.getKey()).thenReturn("one");
// prepare drag-event with table widget:
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table, "myTheme");
dragEvent.getTransferable().getDragSource().getConnection().getUIConnector();
// prepare document
Document document = Document.get();
StyleElement ele = Mockito.spy(StyleElement.class);
when(ele.getTagName()).thenReturn(StyleElement.TAG);
when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);
try {
// act
cut.setMultiRowDragDecoration(dragEvent);
// assure that multi-row decoration for the table was processed
verify(document).getElementById(ViewClientCriterion.SP_DRAG_COUNT);
// assure that no multi selection was detected
verify(ele).setInnerSafeHtml(any(SafeHtml.class));
} finally {
reset(Document.get());
}
}
}

View File

@@ -0,0 +1,242 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.dd.client.criteria;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.context.annotation.Description;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.dd.VDragAndDropManager;
import com.vaadin.client.ui.dd.VDragEvent;
import com.vaadin.client.ui.dd.VDropHandler;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Unit Tests - Drag And Drop")
@Stories("Client-side Accept criteria")
@RunWith(GwtMockitoTestRunner.class)
public class ViewComponentClientCriterionTest {
@Test
@Description("Process serialized data structure for preparing the drop targets to show.")
public void processSerializedDropTargetHintsDataStructure() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare configuration:
Document document = Document.get();
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getIntAttribute("cda")).thenReturn(3);
Element[] elements = new Element[3];
for (int i = 0; i < 3; i++) {
when(uidl.getStringAttribute("da" + String.valueOf(i))).thenReturn("itemId" + String.valueOf(i));
elements[i] = Mockito.mock(Element.class);
when(document.getElementById("itemId" + String.valueOf(i))).thenReturn(elements[i]);
}
// act
cut.showDropTargetHints(uidl);
// assure invocation
for (int i = 0; i < 3; i++) {
verify(document).getElementById("itemId" + String.valueOf(i));
verify(elements[i]).addClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
}
// cross-check
verify(document, Mockito.times(0)).getElementById("itemId3");
}
@Test
@Description("Exception occures when processing serialized data structure for preparing the drop targets to show.")
public void exceptionWhenProcessingDropTargetHintsDataStructure() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare configuration:
Document document = Document.get();
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getIntAttribute("cda")).thenReturn(2);
when(uidl.getStringAttribute("da0")).thenReturn("no-problem");
when(uidl.getStringAttribute("da1")).thenReturn("problem-bear");
doThrow(new RuntimeException()).when(uidl).getStringAttribute("da1");
// act
try {
cut.showDropTargetHints(uidl);
} catch (RuntimeException re) {
fail("Exception is not re-thrown in order to continue with the loop");
}
// assure that no-problem was invoked anyway
verify(document).getElementById("no-problem");
// cross-check that problem-bear was never invoked
verify(document, Mockito.times(0)).getElementById("problem-bear");
}
@Test
@Description("Verifies that drag source is valid for the configured prefix")
public void checkDragSourceWithValidId() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
String prefix = "this";
String id = "thisId";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
boolean result = cut.isValidDragSource(dragEvent, uidl);
// assure that drag source is valid: [thisId startsWith this]
assertThat(result).as("Expected: [" + id + " startsWith " + prefix + "].").isTrue();
}
@Test
@Description("Verifies that drag source is not valid for the configured prefix")
public void checkDragSourceWithInvalidId() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
String prefix = "this";
String id = "notThis";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
boolean result = cut.isValidDragSource(dragEvent, uidl);
// assure that drag source is valid: [thisId !startsWith this]
assertThat(result).as("Expected: [" + id + " !startsWith " + prefix + "].").isFalse();
}
@Test
@Description("An exception occures while the drag source is validated against the configured prefix")
public void exceptionWhenCheckingDragSource() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
String prefix = "this";
String id = "notThis";
VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
doThrow(new RuntimeException()).when(dragEvent).getTransferable();
// prepare configuration:
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
Boolean result = null;
try {
result = cut.isValidDragSource(dragEvent, uidl);
} catch (Exception ex) {
fail("Exception is not re-thrown");
}
// assure that in case of exception the drag source is declared invalid
assertThat(result).as("Expected: Invalid drag if exception occures.").isFalse();
}
@Test
@Description("Successfully checks if the current drop location is in the list of valid drop targets")
public void successfulCheckValidDropTarget() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag and drop manager:
String dtargetid = "dropTarget1Id";
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
// prepare configuration:
UIDL uidl = createUidlWithThreeDropTargets();
// act
boolean result = cut.isValidDropTarget(uidl);
// assure drop target is valid: [dropTarget1Id startsWith dropTarget1]
assertThat(result).as("Expected: [" + dtargetid + " startsWith dropTarget1].").isTrue();
}
@Test
@Description("Failed check if the current drop location is in the list of valid drop targets")
public void failedCheckValidDropTarget() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag and drop manager:
String dtargetid = "no-hit";
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
// prepare configuration:
UIDL uidl = createUidlWithThreeDropTargets();
// act
boolean result = cut.isValidDropTarget(uidl);
// assure "no-hit" does not match [dropTarget0,dropTarget1,dropTarget2]
assertThat(result).as("Expected: [" + dtargetid + " does not match one of the list entries].")
.isFalse();
}
@Test
@Description("An exception occures while the current drop location is validated against the list of valid drop target prefixes")
public void exceptionWhenCheckingValidDropTarget() {
ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag and drop manager:
String dtargetid = "no-hit";
VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
doThrow(new RuntimeException()).when(dropHandler).getConnector();
// prepare configuration:
UIDL uidl = createUidlWithThreeDropTargets();
// act
Boolean result = null;
try {
result = cut.isValidDropTarget(uidl);
} catch (Exception ex) {
fail("Exception is not re-thrown");
}
// assure that in case of exception the drop target is declared invalid
assertThat(result).as("Expected: Invalid drop if exception occures.").isFalse();
}
private UIDL createUidlWithThreeDropTargets() {
UIDL uidl = GWT.create(UIDL.class);
when(uidl.getIntAttribute("cdt")).thenReturn(3);
for (int i = 0; i < 3; i++) {
when(uidl.getStringAttribute("dt" + String.valueOf(i))).thenReturn("dropTarget" + String.valueOf(i));
}
return uidl;
}
}

View File

@@ -137,6 +137,7 @@
<allure.version>1.4.22</allure.version>
<eclipselink.version>2.6.4</eclipselink.version>
<org.powermock.version>1.6.5</org.powermock.version>
<gwtmockito.version>1.1.6</gwtmockito.version>
<pl.pragmatists.version>1.0.2</pl.pragmatists.version>
<guava.version>19.0</guava.version>
<mariadb-java-client.version>1.5.3</mariadb-java-client.version>
@@ -707,6 +708,12 @@
<version>${org.powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.gwtmockito</groupId>
<artifactId>gwtmockito</artifactId>
<version>${gwtmockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>