Entity details are updated after view change, delete and filtering (#486)

* Distribution Set Details are shown correctly.

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix Distribution Set details shows the right data

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Show the right Details when deleting target, ds and sm

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Software Module details are shown correctly on view change

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Caption Artifact Details of is updated correctly after software module
deletion

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Artifact Details are shown correctly, small css improvements

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Code refactor

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix search of softwareModule and DistributionSet in UI

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix typos, insert ids for components

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Code Refactor

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Redo add access

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Correct caption Id of new dist. set, remove unnecessary event

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix selected entity in SwModuleTable, Code refactor

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix error in Upload View concerning selected softwareModule

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Remove Optional, Remove StringUtils, refactor code

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Refactor events when filtering distribution set or software module

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix Sonar issues

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Save softwareMmoduleId in ArtifactUploadState, not whole entity

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Refactor event handling for filtering sw and ds; refactor optional
handling

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Make selectedSoftwareModule transient

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Remove mysql properties

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Refactor ArtifactDetailsLayout

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix comment

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix some comments

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Generalize common behavior in selecting entity in a table

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Optional is not set in the getter but in the setter in the UIState
classes

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix sonar issue

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Change getter visibility to protected

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Refactor publishSelectedEntity

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Refactor Java Docs

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix pull request comments

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix comments

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Change lastSelectedEntities/selectedEntities to type Long,remove Generic

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Show details captions even when table is empty

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
Melanie Retter
2017-05-06 08:33:01 +02:00
committed by Kai Zimmermann
parent 3da33dd486
commit 7b2e93a727
90 changed files with 1133 additions and 1193 deletions

View File

@@ -730,12 +730,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
Specification<JpaDistributionSet> spec;
if (null != distributionSetFilter.getIsComplete()) {
if (distributionSetFilter.getIsComplete() != null) {
spec = DistributionSetSpecification.isCompleted(distributionSetFilter.getIsComplete());
specList.add(spec);
}
if (null != distributionSetFilter.getIsDeleted()) {
if (distributionSetFilter.getIsDeleted() != null) {
spec = DistributionSetSpecification.isDeleted(distributionSetFilter.getIsDeleted());
specList.add(spec);
}

View File

@@ -266,7 +266,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
if (srcGroup.getTargetFilterQuery() != null) {
group.setTargetFilterQuery(srcGroup.getTargetFilterQuery());
} else {
group.setTargetFilterQuery(StringUtils.EMPTY);
group.setTargetFilterQuery("");
}
group.setSuccessCondition(srcGroup.getSuccessCondition());

View File

@@ -28,9 +28,9 @@ 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.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -57,8 +57,9 @@ import com.vaadin.ui.VerticalLayout;
@SpringView(name = UploadArtifactView.VIEW_NAME, ui = HawkbitUI.class)
public class UploadArtifactView extends VerticalLayout implements View, BrowserWindowResizeListener {
private static final long serialVersionUID = 1L;
public static final String VIEW_NAME = "spUpload";
private static final long serialVersionUID = 8754632011301553682L;
private final transient EventBus.UIEventBus eventBus;
@@ -85,6 +86,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private HorizontalLayout uplaodButtonsLayout;
private GridLayout mainLayout;
private DragAndDropWrapper dadw;
@Autowired
@@ -103,9 +105,9 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
this.smTableLayout = new SoftwareModuleTableLayout(i18n, permChecker, artifactUploadState, uiNotification,
eventBus, softwareManagement, entityFactory, uploadViewClientCriterion);
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
artifactManagement, softwareManagement);
this.uploadLayout = new UploadLayout(i18n, uiNotification, eventBus, artifactUploadState,
multipartConfigElement, artifactManagement);
multipartConfigElement, artifactManagement, softwareManagement);
this.deleteActionsLayout = new SMDeleteActionsLayout(i18n, permChecker, eventBus, uiNotification,
artifactUploadState, softwareManagement, uploadViewClientCriterion);
}
@@ -163,7 +165,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private VerticalLayout createDetailsAndUploadLayout() {
detailAndUploadLayout = new VerticalLayout();
detailAndUploadLayout.addComponent(artifactDetailsLayout);
detailAndUploadLayout.setComponentAlignment(artifactDetailsLayout, Alignment.MIDDLE_CENTER);
@@ -178,7 +179,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
detailAndUploadLayout.addStyleName("group");
detailAndUploadLayout.setSpacing(true);
return detailAndUploadLayout;
}
private GridLayout createMainLayout() {
@@ -205,7 +205,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
if (permChecker.hasCreateDistributionPermission()) {
uplaodButtonsLayout = uploadLayout.getFileUploadLayout();
}
}
private void minimizeSwTable() {
@@ -250,12 +249,10 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private void removeOtherComponents() {
mainLayout.removeComponent(deleteActionsLayout);
mainLayout.removeComponent(uplaodButtonsLayout);
}
private void checkNoDataAvaialble() {
if (artifactUploadState.isNoDataAvilableSoftwareModule()) {
uiNotification.displayValidationError(i18n.getMessage("message.no.data"));
}
}
@@ -267,7 +264,6 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private void showOrHideFilterButtons(final int browserWidth) {
if (browserWidth < SPUIDefinitions.REQ_MIN_BROWSER_WIDTH) {
filterByTypeLayout.setVisible(false);
smTableLayout.setShowFilterButtonVisible(true);
} else if (!artifactUploadState.isSwTypeFilterClosed()) {
@@ -278,7 +274,8 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
@Override
public void enter(final ViewChangeEvent event) {
// This view is constructed in the init() method()
smTableLayout.getSoftwareModuleTable()
.selectEntity(artifactUploadState.getSelectedBaseSwModuleId().orElse(null));
}
}

View File

@@ -13,8 +13,11 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
@@ -26,12 +29,12 @@ import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -61,7 +64,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public class ArtifactDetailsLayout extends VerticalLayout {
private static final long serialVersionUID = -5189069028037133891L;
private static final long serialVersionUID = 1L;
private static final String PROVIDED_FILE_NAME = "filename";
@@ -101,35 +104,65 @@ public class ArtifactDetailsLayout extends VerticalLayout {
private final transient ArtifactManagement artifactManagement;
private final transient SoftwareManagement softwareManagement;
/**
* Constructor for ArtifactDetailsLayout
*
* @param i18n
* VaadinMessageSource
* @param eventBus
* UIEventBus
* @param artifactUploadState
* ArtifactUploadState
* @param uINotification
* UINotification
* @param artifactManagement
* ArtifactManagement
* @param softwareManagement
* SoftwareManagement
*/
public ArtifactDetailsLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
final ArtifactUploadState artifactUploadState, final UINotification uINotification,
final ArtifactManagement artifactManagement) {
final ArtifactManagement artifactManagement, final SoftwareManagement softwareManagement) {
this.i18n = i18n;
this.eventBus = eventBus;
this.artifactUploadState = artifactUploadState;
this.uINotification = uINotification;
this.artifactManagement = artifactManagement;
this.softwareManagement = softwareManagement;
createComponents();
final Optional<SoftwareModule> selectedSoftwareModule = findSelectedSoftwareModule();
String labelSoftwareModule = "";
if (selectedSoftwareModule.isPresent()) {
labelSoftwareModule = HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.get().getName(),
selectedSoftwareModule.get().getVersion());
}
createComponents(labelSoftwareModule);
buildLayout();
eventBus.subscribe(this);
artifactUploadState.getSelectedBaseSoftwareModule()
.ifPresent(selectedSoftwareModule -> populateArtifactDetails(selectedSoftwareModule.getId(),
HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.getName(),
selectedSoftwareModule.getVersion())));
if (selectedSoftwareModule.isPresent()) {
populateArtifactDetails(selectedSoftwareModule.get().getId(), labelSoftwareModule);
}
if (isMaximized()) {
maximizedArtifactDetailsView();
}
}
private void createComponents() {
final String labelStr = artifactUploadState.getSelectedBaseSoftwareModule()
.map(softwareModule -> HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(),
softwareModule.getVersion()))
.orElse("");
titleOfArtifactDetails = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr))
.buildCaptionLabel();
private Optional<SoftwareModule> findSelectedSoftwareModule() {
final Optional<Long> selectedBaseSwModuleId = artifactUploadState.getSelectedBaseSwModuleId();
if (selectedBaseSwModuleId.isPresent()) {
return softwareManagement.findSoftwareModuleById(selectedBaseSwModuleId.get());
}
return Optional.empty();
}
private void createComponents(final String labelSoftwareModule) {
titleOfArtifactDetails = new LabelBuilder().id(UIComponentIdProvider.ARTIFACT_DETAILS_HEADER_LABEL_ID)
.name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelSoftwareModule)).buildCaptionLabel();
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
titleOfArtifactDetails.setSizeFull();
titleOfArtifactDetails.setImmediate(true);
@@ -143,21 +176,17 @@ public class ArtifactDetailsLayout extends VerticalLayout {
addGeneratedColumnButton(artifactDetailsTable);
}
setTableColumnDetails(artifactDetailsTable);
}
/**
* @return
*/
private SPUIButton createMaxMinButton() {
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton(SPUIDefinitions.EXPAND_ACTION_HISTORY,
"", "", null, true, FontAwesome.EXPAND, SPUIButtonStyleSmallNoBorder.class);
button.addClickListener(event -> maxArtifactDetails());
return button;
}
private void buildLayout() {
final HorizontalLayout header = new HorizontalLayout();
header.addStyleName("artifact-details-header");
header.addStyleName("bordered-layout");
@@ -181,7 +210,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
addComponent(artifactDetailsTable);
setComponentAlignment(artifactDetailsTable, Alignment.MIDDLE_CENTER);
setExpandRatio(artifactDetailsTable, 1.0F);
}
private Container createArtifactLazyQueryContainer() {
@@ -210,9 +238,9 @@ public class ArtifactDetailsLayout extends VerticalLayout {
}
}
private void addGeneratedColumn(final Table table) {
private static void addGeneratedColumn(final Table table) {
table.addGeneratedColumn(CREATE_MODIFIED_DATE_UPLOAD, new ColumnGenerator() {
private static final long serialVersionUID = -866800417175863258L;
private static final long serialVersionUID = 1L;
@Override
public String generateCell(final Table source, final Object itemId, final Object columnId) {
@@ -226,12 +254,11 @@ public class ArtifactDetailsLayout extends VerticalLayout {
return SPDateTimeUtil.getFormattedDate(createdDate);
}
});
}
private void addGeneratedColumnButton(final Table table) {
table.addGeneratedColumn(ACTION, new ColumnGenerator() {
private static final long serialVersionUID = -866800417175863258L;
private static final long serialVersionUID = 1L;
@Override
public Button generateCell(final Table source, final Object itemId, final Object columnId) {
@@ -246,21 +273,22 @@ public class ArtifactDetailsLayout extends VerticalLayout {
return deleteIcon;
}
});
}
private void confirmAndDeleteArtifact(final Long id, final String fileName) {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.delete.artifact.confirmbox"),
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
i18n.getMessage("caption.delete.artifact.confirmbox"),
i18n.getMessage("message.delete.artifact", new Object[] { fileName }), i18n.getMessage("button.ok"),
i18n.getMessage("button.cancel"), ok -> {
if (ok) {
artifactManagement.deleteArtifact(id);
uINotification.displaySuccess(i18n.getMessage("message.artifact.deleted", fileName));
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(),
HawkbitCommonUtil.getFormattedNameVersion(
artifactUploadState.getSelectedBaseSoftwareModule().get().getName(),
artifactUploadState.getSelectedBaseSoftwareModule().get().getVersion()));
final Optional<SoftwareModule> softwareModule = findSelectedSoftwareModule();
if (softwareModule.isPresent()) {
populateArtifactDetails(softwareModule.get().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.get().getName(),
softwareModule.get().getVersion()));
} else {
populateArtifactDetails(null, null);
}
@@ -268,7 +296,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
confirmDialog.getWindow().bringToFront();
}
private void setTableColumnDetails(final Table table) {
@@ -285,7 +312,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
}
table.setColumnExpandRatio(PROVIDED_FILE_NAME, 3.5F);
table.setColumnExpandRatio(SIZE, 2f);
table.setColumnExpandRatio(SIZE, 2F);
if (fullWindowMode) {
table.setColumnExpandRatio(SHA1HASH, 2.8F);
table.setColumnExpandRatio(MD5HASH, 2.4F);
@@ -313,7 +340,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
return visibileColumn;
}
private Table createArtifactDetailsTable() {
private static Table createArtifactDetailsTable() {
final Table detailsTable = new Table();
detailsTable.addStyleName("sp-table");
@@ -417,7 +444,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
maxArtifactDetailsTable.setContainerDataSource(artifactContainer);
}
setTableColumnDetails(artifactDetailsTable);
}
/**
@@ -430,18 +456,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (BaseEntityEventType.SELECTED_ENTITY == softwareModuleEvent.getEventType()) {
UI.getCurrent().access(() -> {
if (softwareModuleEvent.getEntity() != null) {
populateArtifactDetails(softwareModuleEvent.getEntity().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getEntity().getName(),
softwareModuleEvent.getEntity().getVersion()));
} else {
populateArtifactDetails(null, null);
}
});
}
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
if (softwareModuleEvent.getEventType() == BaseEntityEventType.SELECTED_ENTITY
|| softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
UI.getCurrent().access(() -> {
if (softwareModuleEvent.getEntity() != null) {
populateArtifactDetails(softwareModuleEvent.getEntity().getId(),

View File

@@ -8,19 +8,13 @@
*/
package org.eclipse.hawkbit.ui.artifacts.event;
import org.eclipse.hawkbit.ui.common.table.BaseUIEvent;
/**
* Software module filter events.
*
*
*
* Software module filter event. Is thrown when there is a filter action on a
* software module table on the Distribution or Upload View. It is possible to
* filter by text or type.
*/
public enum SMFilterEvent {
public class RefreshSoftwareModuleByFilterEvent extends BaseUIEvent {
FILTER_BY_TYPE,
FILTER_BY_TEXT,
REMOVER_FILTER_BY_TYPE,
REMOVER_FILTER_BY_TEXT
}

View File

@@ -17,10 +17,10 @@ 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.dd.criteria.UploadViewClientCriterion;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -45,8 +45,8 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
private final UploadViewClientCriterion uploadViewClientCriterion;
public SMDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final ArtifactUploadState artifactUploadState,
public SMDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final UIEventBus eventBus, final UINotification notification, final ArtifactUploadState artifactUploadState,
final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion) {
super(i18n, permChecker, eventBus, notification);
this.artifactUploadState = artifactUploadState;
@@ -146,8 +146,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> swTable = (AbstractTable<?, Long>) sourceTable;
final AbstractTable<?> swTable = (AbstractTable<?>) sourceTable;
final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable);
swModuleIdNameSet.forEach(id -> {

View File

@@ -15,16 +15,18 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps;
@@ -37,11 +39,11 @@ import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
/**
* Abstract layout of confirm actions window.
* Layout of confirm actions window on the Upload View.
*/
public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWindowLayout {
private static final long serialVersionUID = 1804036019105286988L;
private static final long serialVersionUID = 1L;
private static final String SW_MODULE_NAME_MSG = "SW MOdule Name";
@@ -63,13 +65,14 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
}
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
protected Map<String, ConfirmationTab> getConfirmationTabs() {
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(2);
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
tabs.put(i18n.getMessage("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
}
if (!artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"),
createSMtypeDeleteConfirmationTab());
}
return tabs;
}
@@ -144,6 +147,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private void deleteSMAll(final ConfirmationTab tab) {
final Set<Long> swmoduleIds = artifactUploadState.getDeleteSofwareModules().keySet();
softwareManagement.deleteSoftwareModules(swmoduleIds);
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.REMOVE_ENTITY, swmoduleIds));
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.getMessage("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size()));
/*

View File

@@ -24,18 +24,20 @@ import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
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.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Sets;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout;
@@ -49,7 +51,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private static final long serialVersionUID = -5217675246477211483L;
private static final long serialVersionUID = 1L;
private final VaadinMessageSource i18n;
@@ -77,6 +79,8 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
private FormLayout formLayout;
private final AbstractTable<SoftwareModule> softwareModuleTable;
/**
* Constructor for SoftwareModuleAddUpdateWindow
*
@@ -91,13 +95,15 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
* @param entityFactory
* EntityFactory
*/
public SoftwareModuleAddUpdateWindow(final VaadinMessageSource i18n, final UINotification uiNotifcation, final UIEventBus eventBus,
final SoftwareManagement softwareManagement, final EntityFactory entityFactory) {
public SoftwareModuleAddUpdateWindow(final VaadinMessageSource i18n, final UINotification uiNotifcation,
final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final AbstractTable<SoftwareModule> softwareModuleTable) {
this.i18n = i18n;
this.uiNotifcation = uiNotifcation;
this.eventBus = eventBus;
this.softwareManagement = softwareManagement;
this.entityFactory = entityFactory;
this.softwareModuleTable = softwareModuleTable;
createRequiredComponents();
}
@@ -133,12 +139,10 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
.type(softwareModuleTypeByName).name(name).version(version).description(description).vendor(vendor);
final SoftwareModule newSoftwareModule = softwareManagement.createSoftwareModule(softwareModule);
if (newSoftwareModule != null) {
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule));
uiNotifcation.displaySuccess(i18n.getMessage("message.save.success",
new Object[] { newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion() }));
}
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule));
uiNotifcation.displaySuccess(i18n.getMessage("message.save.success",
new Object[] { newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion() }));
softwareModuleTable.setValue(Sets.newHashSet(newSoftwareModule.getId()));
}
private boolean isDuplicate() {
@@ -173,7 +177,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
}
/**
* Create window for new software module.
* Creates window for new software module.
*
* @return reference of {@link com.vaadin.ui.Window} to add new software
* module.
@@ -183,10 +187,10 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
}
/**
* Create window for update software module.
* Creates window for update software module.
*
* @param baseSwModuleId
* is id of the software module to edit.
* id of the software module to edit.
* @return reference of {@link com.vaadin.ui.Window} to update software
* module.
*/
@@ -206,17 +210,18 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
vendorTextField = createTextField("textfield.vendor", UIComponentIdProvider.SOFT_MODULE_VENDOR);
vendorTextField.setRequired(false);
vendorTextField.setNullRepresentation(StringUtils.EMPTY);
vendorTextField.setNullRepresentation("");
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION)
.buildTextComponent();
descTextArea.setNullRepresentation(StringUtils.EMPTY);
descTextArea.setNullRepresentation("");
typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("upload.swmodule.type"), "", null, null, true, null,
i18n.getMessage("upload.swmodule.type"));
typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("upload.swmodule.type"), "", null, null, true,
null, i18n.getMessage("upload.swmodule.type"));
typeComboBox.setId(UIComponentIdProvider.SW_MODULE_TYPE);
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
typeComboBox
.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + StringUtils.SPACE + ValoTheme.COMBOBOX_TINY);
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
typeComboBox.setImmediate(Boolean.TRUE);
}
@@ -233,7 +238,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
}
private void resetComponents() {
vendorTextField.clear();
nameTextField.clear();
versionTextField.clear();
@@ -265,7 +269,6 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
nameTextField.setEnabled(!editSwModule);
versionTextField.setEnabled(!editSwModule);
typeComboBox.setEnabled(!editSwModule);
typeComboBox.focus();
return window;

View File

@@ -38,11 +38,6 @@ public class SoftwareModuleDetails extends AbstractSoftwareModuleDetails {
restoreState();
}
@Override
protected boolean onLoadIsTableRowSelected() {
return artifactUploadState.getSelectedBaseSoftwareModule().isPresent();
}
@Override
protected boolean onLoadIsTableMaximized() {
return artifactUploadState.isSwModuleTableMaximized();

View File

@@ -14,7 +14,7 @@ import java.util.Optional;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
@@ -26,13 +26,14 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout;
import org.eclipse.hawkbit.ui.push.SoftwareModuleUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.view.filter.OnlyEventsFromUploadArtifactViewFilter;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -53,9 +54,9 @@ import com.vaadin.ui.UI;
/**
* The Software module table.
*/
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule> {
private static final long serialVersionUID = 6469417305487144809L;
private static final long serialVersionUID = 1L;
private final ArtifactUploadState artifactUploadState;
@@ -80,16 +81,9 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
setDataAvailable(getContainerDataSource().size() != 0);
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> {
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
refreshFilter();
}
});
@EventBusListenerMethod(scope = EventScope.UI, filter = OnlyEventsFromUploadArtifactViewFilter.class)
void onEvent(final RefreshSoftwareModuleByFilterEvent filterEvent) {
UI.getCurrent().access(this::refreshFilter);
}
@Override
@@ -140,7 +134,8 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Override
protected Object getItemIdToSelect() {
return artifactUploadState.getSelectedSoftwareModules();
return artifactUploadState.getSelectedSoftwareModules().isEmpty() ? null
: artifactUploadState.getSelectedSoftwareModules();
}
@Override
@@ -154,13 +149,12 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
}
@Override
protected ArtifactUploadState getManagmentEntityState() {
protected ArtifactUploadState getManagementEntityState() {
return artifactUploadState;
}
@Override
protected void publishEntityAfterValueChange(final SoftwareModule lastSoftwareModule) {
artifactUploadState.setSelectedBaseSoftwareModule(lastSoftwareModule);
protected void publishSelectedEntityEvent(final SoftwareModule lastSoftwareModule) {
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule));
}
@@ -178,12 +172,10 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@EventBusListenerMethod(scope = EventScope.UI)
void onSoftwareModuleUpdateEvents(final SoftwareModuleUpdatedEventContainer eventContainer) {
@SuppressWarnings("unchecked")
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
eventContainer.getEvents().stream().filter(event -> visibleItemIds.contains(event.getEntityId()))
.forEach(event -> updateSoftwareModuleInTable(event.getEntity()));
}
private void updateSoftwareModuleInTable(final SoftwareModule editedSm) {
@@ -205,7 +197,8 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.METADATA_ICON, new ColumnGenerator() {
private static final long serialVersionUID = 117186282275044399L;
private static final long serialVersionUID = 1L;
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {

View File

@@ -9,8 +9,8 @@
package org.eclipse.hawkbit.ui.artifacts.smtable;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractSoftwareModuleTableHeader;
@@ -42,51 +42,50 @@ public class SoftwareModuleTableHeader extends AbstractSoftwareModuleTableHeader
@Override
protected String onLoadSearchBoxValue() {
return artifactUploadState.getSoftwareModuleFilters().getSearchText().orElse(null);
return getArtifactUploadState().getSoftwareModuleFilters().getSearchText().orElse(null);
}
@Override
protected void showFilterButtonsLayout() {
artifactUploadState.setSwTypeFilterClosed(false);
getArtifactUploadState().setSwTypeFilterClosed(false);
eventbus.publish(this, UploadArtifactUIEvent.SHOW_FILTER_BY_TYPE);
}
@Override
protected void resetSearchText() {
if (artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()) {
artifactUploadState.getSoftwareModuleFilters().setSearchText(null);
eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT);
if (getArtifactUploadState().getSoftwareModuleFilters().getSearchText().isPresent()) {
getArtifactUploadState().getSoftwareModuleFilters().setSearchText(null);
eventbus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
}
@Override
public void maximizeTable() {
artifactUploadState.setSwModuleTableMaximized(Boolean.TRUE);
getArtifactUploadState().setSwModuleTableMaximized(Boolean.TRUE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED));
}
@Override
public void minimizeTable() {
artifactUploadState.setSwModuleTableMaximized(Boolean.FALSE);
getArtifactUploadState().setSwModuleTableMaximized(Boolean.FALSE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED));
}
@Override
public Boolean onLoadIsTableMaximized() {
return artifactUploadState.isSwModuleTableMaximized();
return getArtifactUploadState().isSwModuleTableMaximized();
}
@Override
public Boolean onLoadIsShowFilterButtonDisplayed() {
return artifactUploadState.isSwTypeFilterClosed();
return getArtifactUploadState().isSwTypeFilterClosed();
}
@Override
protected void searchBy(final String newSearchText) {
artifactUploadState.getSoftwareModuleFilters().setSearchText(newSearchText);
eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT);
getArtifactUploadState().getSoftwareModuleFilters().setSearchText(newSearchText);
eventbus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
@Override

View File

@@ -15,8 +15,8 @@ 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.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
/**
@@ -24,26 +24,33 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
*/
public class SoftwareModuleTableLayout extends AbstractTableLayout<SoftwareModuleTable> {
private static final long serialVersionUID = 6464291374980641235L;
private static final long serialVersionUID = 1L;
private final SoftwareModuleTable softwareModuleTable;
public SoftwareModuleTableLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final ArtifactUploadState artifactUploadState, final UINotification uiNotification,
final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final UploadViewClientCriterion uploadViewClientCriterion) {
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
uiNotification, eventBus, softwareManagement, entityFactory);
final SwMetadataPopupLayout swMetadataPopupLayout = new SwMetadataPopupLayout(i18n, uiNotification, eventBus,
softwareManagement, entityFactory, permChecker);
this.softwareModuleTable = new SoftwareModuleTable(eventBus, i18n, uiNotification, artifactUploadState,
softwareManagement, uploadViewClientCriterion, swMetadataPopupLayout);
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
uiNotification, eventBus, softwareManagement, entityFactory, softwareModuleTable);
super.init(
new SoftwareModuleTableHeader(i18n, permChecker, eventBus, artifactUploadState,
softwareModuleAddUpdateWindow),
new SoftwareModuleTable(eventBus, i18n, uiNotification, artifactUploadState, softwareManagement,
uploadViewClientCriterion, swMetadataPopupLayout),
softwareModuleTable,
new SoftwareModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow,
artifactUploadState, softwareManagement, swMetadataPopupLayout, entityFactory));
}
public SoftwareModuleTable getSoftwareModuleTable() {
return softwareModuleTable;
}
}

View File

@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.TagManagement;
@@ -28,10 +27,10 @@ import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -110,9 +109,9 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC)
.buildTextComponent();
tagDesc.setNullRepresentation(StringUtils.EMPTY);
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC).buildTextComponent();
tagDesc.setNullRepresentation("");
singleMultiOptionGroup();
}
@@ -131,8 +130,9 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
}
private TextField createTextField(final String in18Key, final String styleName, final String id) {
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
.required(true).prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent();
return new TextFieldBuilder().caption(i18n.getMessage(in18Key))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true).prompt(i18n.getMessage(in18Key))
.immediate(true).id(id).buildTextComponent();
}
@Override
@@ -267,7 +267,8 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
final SoftwareModuleType newSWType = swTypeManagementService.createSoftwareModuleType(
entityFactory.softwareModuleType().create().key(typeKeyValue).name(typeNameValue)
.description(typeDescValue).colour(colorPicked).maxAssignments(assignNumber));
uiNotification.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSWType.getName() }));
uiNotification
.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSWType.getName() }));
eventBus.publish(this,
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE, newSWType));
} else {
@@ -279,7 +280,8 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
swTypeManagementService.updateSoftwareModuleType(
entityFactory.softwareModuleType().update(existingType.getId()).description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview())));
uiNotification.displaySuccess(i18n.getMessage("message.update.success", new Object[] { existingType.getName() }));
uiNotification
.displaySuccess(i18n.getMessage("message.update.success", new Object[] { existingType.getName() }));
eventBus.publish(this,
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType));
}

View File

@@ -8,10 +8,8 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtype;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.vaadin.spring.events.EventBus;
@@ -20,11 +18,12 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.ui.Button;
/**
* Single button click behaviour of filter buttons layout.
* Single button click behavior of filter buttons layout for software module
* table on the Upload view.
*/
public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick {
private static final long serialVersionUID = 3707945900524967887L;
private static final long serialVersionUID = 1L;
private final transient EventBus.UIEventBus eventBus;
@@ -42,7 +41,7 @@ public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick imp
@Override
protected void filterUnClicked(final Button clickedButton) {
artifactUploadState.getSoftwareModuleFilters().setSoftwareModuleType(null);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
eventBus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
@Override
@@ -50,7 +49,7 @@ public class SMTypeFilterButtonClick extends AbstractFilterSingleButtonClick imp
softwareManagement.findSoftwareModuleTypeByName(clickedButton.getData().toString())
.ifPresent(softwareModuleType -> {
artifactUploadState.getSoftwareModuleFilters().setSoftwareModuleType(softwareModuleType);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
eventBus.publish(this, new RefreshSoftwareModuleByFilterEvent());
});
}

View File

@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.upload.UploadStatusObject;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -29,14 +29,12 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
/**
* User status of Artifact upload.
*
*
*/
@VaadinSessionScope
@SpringComponent
public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializable {
public class ArtifactUploadState implements ManagementEntityState, Serializable {
private static final long serialVersionUID = 8273440375917450859L;
private static final long serialVersionUID = 1L;
private final SoftwareModuleFilters softwareModuleFilters;
@@ -44,9 +42,7 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
private final Set<CustomFile> fileSelected = new HashSet<>();
private Long selectedBaseSwModuleId;
private SoftwareModule selectedBaseSoftwareModule;
private transient Optional<Long> selectedBaseSwModuleId = Optional.empty();
private final Map<String, SoftwareModule> baseSwModuleList = new HashMap<>();
@@ -115,54 +111,33 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
return statusPopupMinimized;
}
/**
* Set software.
*
* @return
*/
public SoftwareModuleFilters getSoftwareModuleFilters() {
return softwareModuleFilters;
}
/**
* @return the selectedSofwareModules
*/
public Map<Long, String> getDeleteSofwareModules() {
return deleteSofwareModules;
}
/**
* @return the fileSelected
*/
public Set<CustomFile> getFileSelected() {
return fileSelected;
}
/**
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return Optional.ofNullable(selectedBaseSwModuleId);
return selectedBaseSwModuleId;
}
/**
* @return the baseSwModuleList
*/
public Map<String, SoftwareModule> getBaseSwModuleList() {
return baseSwModuleList;
}
/**
* @return the selectedSoftwareModules
*/
public Set<Long> getSelectedSoftwareModules() {
return selectedSoftwareModules;
}
@Override
public void setLastSelectedEntity(final Long value) {
this.selectedBaseSwModuleId = value;
public void setLastSelectedEntityId(final Long value) {
this.selectedBaseSwModuleId = Optional.ofNullable(value);
}
@Override
@@ -170,32 +145,18 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
this.selectedSoftwareModules = values;
}
/**
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return swTypeFilterClosed;
}
/**
* @param swTypeFilterClosed
* the swTypeFilterClosed to set
*/
public void setSwTypeFilterClosed(final boolean swTypeFilterClosed) {
this.swTypeFilterClosed = swTypeFilterClosed;
}
/**
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return swModuleTableMaximized;
}
/**
* @param isSwModuleTableMaximized
* the isSwModuleTableMaximized to set
*/
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
this.swModuleTableMaximized = swModuleTableMaximized;
}
@@ -204,41 +165,19 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
return selectedDeleteSWModuleTypes;
}
/**
* @return the isArtifactDetailsMaximized
*/
public boolean isArtifactDetailsMaximized() {
return artifactDetailsMaximized;
}
/**
* @param isArtifactDetailsMaximized
* the isArtifactDetailsMaximized to set
*/
public void setArtifactDetailsMaximized(final boolean artifactDetailsMaximized) {
this.artifactDetailsMaximized = artifactDetailsMaximized;
}
/**
* @return the noDataAvilableSoftwareModule
*/
public boolean isNoDataAvilableSoftwareModule() {
return noDataAvilableSoftwareModule;
}
/**
* @param noDataAvilableSoftwareModule
* the noDataAvilableSoftwareModule to set
*/
public void setNoDataAvilableSoftwareModule(final boolean noDataAvilableSoftwareModule) {
this.noDataAvilableSoftwareModule = noDataAvilableSoftwareModule;
}
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
return Optional.ofNullable(selectedBaseSoftwareModule);
}
public void setSelectedBaseSoftwareModule(final SoftwareModule selectedBaseSoftwareModule) {
this.selectedBaseSoftwareModule = selectedBaseSoftwareModule;
}
}

View File

@@ -62,7 +62,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public class UploadConfirmationWindow implements Button.ClickListener {
private static final long serialVersionUID = -1679035890140031740L;
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(UploadConfirmationWindow.class);
@@ -138,8 +138,8 @@ public class UploadConfirmationWindow implements Button.ClickListener {
}
private boolean checkIfArtifactDetailsDisplayed(final Long bSoftwareModuleId) {
return artifactUploadState.getSelectedBaseSoftwareModule()
.map(module -> module.getId().equals(bSoftwareModuleId)).orElse(false);
return artifactUploadState.getSelectedBaseSwModuleId().map(moduleId -> moduleId.equals(bSoftwareModuleId))
.orElse(false);
}
private Boolean preUploadValidation(final List<String> itemIds) {
@@ -178,7 +178,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
/**
* Warning icon is displayed, if an artifact exists with same provided file
* name. Error icon is displayed ,if file name entered is duplicate.
* name. Error icon is displayed, if file name entered is duplicate.
*
* @param warningIconLabel
* warning/error label
@@ -344,7 +344,6 @@ public class UploadConfirmationWindow implements Button.ClickListener {
}
}
}
}
/**
@@ -354,7 +353,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
* label
* @return Boolean
*/
private static Boolean isWarningIcon(final Label icon) {
private static boolean isWarningIcon(final Label icon) {
return !isErrorIcon(icon);
}
@@ -365,7 +364,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
* label
* @return Boolean
*/
private static Boolean isErrorIcon(final Label icon) {
private static boolean isErrorIcon(final Label icon) {
return icon.isVisible() && icon.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL);
}
@@ -532,7 +531,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
return footer;
}
public Window getUploadConfrimationWindow() {
public Window getUploadConfirmationWindow() {
return window;
}
@@ -568,9 +567,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
window.close();
uploadLayout.clearUploadedFileDetails();
}
}
}
// Exception squid:S3655 - Optional access is checked in
@@ -598,7 +595,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
}
if (refreshArtifactDetailsLayout) {
uploadLayout.refreshArtifactDetailsLayout(artifactUploadState.getSelectedBaseSoftwareModule().get());
uploadLayout.refreshArtifactDetailsLayout(artifactUploadState.getSelectedBaseSwModuleId().get());
}
uploadLayout.clearFileList();
window.close();
@@ -612,7 +609,6 @@ public class UploadConfirmationWindow implements Button.ClickListener {
uploadLayout.getUINotification()
.displayValidationError(uploadLayout.getI18n().getMessage("message.error.noProvidedName"));
}
}
private void onResultDetailsPopupClose() {
@@ -661,7 +657,6 @@ public class UploadConfirmationWindow implements Button.ClickListener {
result.setUploadResult(status);
result.setReason(message);
uploadResultList.add(result);
}
public Table getUploadDetailsTable() {

View File

@@ -10,7 +10,9 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Optional;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus;
@@ -71,8 +73,11 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
private SoftwareModule selectedSwForUpload;
private final ArtifactUploadState artifactUploadState;
private final transient SoftwareManagement softwareManagement;
UploadHandler(final String fileName, final long fileSize, final UploadLayout view, final long maxSize,
final Upload upload, final String mimeType, final SoftwareModule selectedSw) {
final Upload upload, final String mimeType, final SoftwareModule selectedSw,
final SoftwareManagement softwareManagement) {
super();
this.aborted = false;
this.fileName = fileName;
@@ -85,6 +90,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
this.i18n = SpringContextHelper.getBean(VaadinMessageSource.class);
this.eventBus = SpringContextHelper.getBean(EventBus.UIEventBus.class);
this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class);
this.softwareManagement = softwareManagement;
eventBus.subscribe(this);
}
@@ -207,7 +213,12 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
@Override
public void uploadStarted(final StartedEvent event) {
uploadInterrupted = false;
selectedSwForUpload = artifactUploadState.getSelectedBaseSoftwareModule().orElse(null);
selectedSwForUpload = null;
final Optional<Long> selectedBaseSwModuleId = artifactUploadState.getSelectedBaseSwModuleId();
if (selectedBaseSwModuleId.isPresent()) {
selectedSwForUpload = softwareManagement.findSoftwareModuleById(selectedBaseSwModuleId.get()).orElse(null);
}
if (selectedSwForUpload != null && view.checkIfSoftwareModuleIsSelected()
&& !view.checkIfFileIsDuplicate(event.getFilename(), selectedSwForUpload)) {

View File

@@ -21,6 +21,7 @@ import javax.servlet.MultipartConfigElement;
import org.apache.commons.io.FileUtils;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -74,9 +75,10 @@ import com.vaadin.ui.VerticalLayout;
* Upload files layout.
*/
public class UploadLayout extends VerticalLayout {
private static final String HTML_DIV = "</div>";
private static final long serialVersionUID = -566164756606779220L;
private static final long serialVersionUID = 1L;
private static final String HTML_DIV = "</div>";
private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class);
@@ -110,6 +112,8 @@ public class UploadLayout extends VerticalLayout {
private Button uploadStatusButton;
private final transient SoftwareManagement softwareManagement;
private static AcceptCriterion acceptAllExceptBlacklisted = new Not(new ServerItemIdClientCriterion(Mode.PREFIX,
UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
@@ -117,7 +121,7 @@ public class UploadLayout extends VerticalLayout {
public UploadLayout(final VaadinMessageSource i18n, final UINotification uiNotification, final UIEventBus eventBus,
final ArtifactUploadState artifactUploadState, final MultipartConfigElement multipartConfigElement,
final ArtifactManagement artifactManagement) {
final ArtifactManagement artifactManagement, final SoftwareManagement softwareManagement) {
this.uploadInfoWindow = new UploadStatusInfoWindow(eventBus, artifactUploadState, i18n);
this.i18n = i18n;
this.uiNotification = uiNotification;
@@ -125,6 +129,7 @@ public class UploadLayout extends VerticalLayout {
this.artifactUploadState = artifactUploadState;
this.multipartConfigElement = multipartConfigElement;
this.artifactManagement = artifactManagement;
this.softwareManagement = softwareManagement;
createComponents();
buildLayout();
@@ -173,7 +178,7 @@ public class UploadLayout extends VerticalLayout {
final Upload upload = new Upload();
final UploadHandler uploadHandler = new UploadHandler(null, 0, this, multipartConfigElement.getMaxFileSize(),
upload, null, null);
upload, null, null, softwareManagement);
upload.setButtonCaption(i18n.getMessage("upload.file"));
upload.setImmediate(true);
upload.setReceiver(uploadHandler);
@@ -183,6 +188,7 @@ public class UploadLayout extends VerticalLayout {
upload.addProgressListener(uploadHandler);
upload.addStartedListener(uploadHandler);
upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
upload.addStyleName("no-border");
fileUploadLayout = new HorizontalLayout();
fileUploadLayout.setSpacing(true);
@@ -243,11 +249,13 @@ public class UploadLayout extends VerticalLayout {
// selected software module at the time of file drop is
// considered for upload
artifactUploadState.getSelectedBaseSoftwareModule().ifPresent(selectedSw -> {
artifactUploadState.getSelectedBaseSwModuleId().ifPresent(selectedSwId -> {
// reset the flag
hasDirectory = false;
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(selectedSwId)
.orElse(null);
for (final Html5File file : files) {
processFile(file, selectedSw);
processFile(file, softwareModule);
}
if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) {
processBtn.setEnabled(false);
@@ -296,7 +304,7 @@ public class UploadLayout extends VerticalLayout {
private StreamVariable createStreamVariable(final Html5File file, final SoftwareModule selectedSw) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this,
multipartConfigElement.getMaxFileSize(), null, file.getType(), selectedSw);
multipartConfigElement.getMaxFileSize(), null, file.getType(), selectedSw, softwareManagement);
}
private boolean isDirectory(final Html5File file) {
@@ -321,7 +329,7 @@ public class UploadLayout extends VerticalLayout {
}
}
private VerticalLayout createDropAreaLayout() {
private static VerticalLayout createDropAreaLayout() {
final VerticalLayout dropAreaLayout = new VerticalLayout();
final Label dropHereLabel = new Label("Drop files to upload");
dropHereLabel.setWidth(null);
@@ -413,7 +421,6 @@ public class UploadLayout extends VerticalLayout {
LOG.error("Upload failed {}", e);
throw new ArtifactUploadFailedException(i18n.getMessage("message.upload.failed"));
}
}
boolean checkIfSoftwareModuleIsSelected() {
@@ -425,13 +432,13 @@ public class UploadLayout extends VerticalLayout {
}
/**
* Check if file selected is duplicate.i,e already selected for upload for
* same software module.
* Check if the selected file is duplicate. i.e. already selected for upload
* for same software module.
*
* @param name
* file name
* @param selectedSoftwareModule
* the current selected sm module
* the current selected software module
* @return Boolean
*/
Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
@@ -615,16 +622,13 @@ public class UploadLayout extends VerticalLayout {
} else {
currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState, eventBus,
artifactManagement);
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfirmationWindow());
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
Page.getCurrent().getBrowserWindowHeight());
}
}
}
/**
* @return
*/
VaadinMessageSource getI18n() {
return i18n;
}
@@ -654,7 +658,7 @@ public class UploadLayout extends VerticalLayout {
private void onUploadStreamingFailure(final UploadStatusEvent event) {
/**
* If upload interrupted because of duplicate file,do not remove the
* If upload interrupted because of duplicate file, do not remove the
* file already in upload list
**/
if (getDuplicateFileNamesList().isEmpty()
@@ -707,7 +711,7 @@ public class UploadLayout extends VerticalLayout {
private void onUploadFailure(final UploadStatusEvent event) {
/**
* If upload interrupted because of duplicate file,do not remove the
* If upload interrupted because of duplicate file, do not remove the
* file already in upload list
**/
if (getDuplicateFileNamesList().isEmpty()
@@ -726,17 +730,12 @@ public class UploadLayout extends VerticalLayout {
}
}
/**
* @param selectedBaseSoftwareModule
*/
void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule));
void refreshArtifactDetailsLayout(final Long selectedBaseSoftwareModuleId) {
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(selectedBaseSoftwareModuleId)
.orElse(null);
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, softwareModule));
}
/**
* @return the fileUploadLayout
*/
public HorizontalLayout getFileUploadLayout() {
return fileUploadLayout;
}

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.common;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
@@ -24,11 +23,11 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -231,8 +230,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
private TextField createKeyTextField() {
final TextField keyField = new TextFieldBuilder().caption(i18n.getMessage("textfield.key")).required(true)
.prompt(i18n.getMessage("textfield.key")).immediate(true).id(UIComponentIdProvider.METADATA_KEY_FIELD_ID)
.maxLengthAllowed(128).buildTextComponent();
.prompt(i18n.getMessage("textfield.key")).immediate(true)
.id(UIComponentIdProvider.METADATA_KEY_FIELD_ID).maxLengthAllowed(128).buildTextComponent();
keyField.addTextChangeListener(this::onKeyChange);
keyField.setTextChangeEventMode(TextChangeEventMode.EAGER);
keyField.setWidth("100%");
@@ -243,7 +242,7 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
valueTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.value")).required(true)
.prompt(i18n.getMessage("textfield.value")).immediate(true).id(UIComponentIdProvider.METADATA_VALUE_ID)
.maxLengthAllowed(4000).buildTextComponent();
valueTextArea.setNullRepresentation(StringUtils.EMPTY);
valueTextArea.setNullRepresentation("");
valueTextArea.setSizeFull();
valueTextArea.setHeight(100, Unit.PERCENTAGE);
valueTextArea.addTextChangeListener(this::onValueChange);
@@ -278,8 +277,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
final String value = (String) item.getItemProperty(VALUE).getValue();
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
i18n.getMessage("caption.metadata.delete.action.confirmbox"), i18n.getMessage("message.confirm.delete.metadata", key),
i18n.getMessage("button.ok"), i18n.getMessage("button.cancel"), ok -> {
i18n.getMessage("caption.metadata.delete.action.confirmbox"),
i18n.getMessage("message.confirm.delete.metadata", key), i18n.getMessage("button.ok"),
i18n.getMessage("button.cancel"), ok -> {
if (ok) {
handleOkDeleteMetadata(event, key, value);
}
@@ -320,8 +320,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
}
private Button createAddIcon() {
addIcon = SPUIComponentProvider.getButton(UIComponentIdProvider.METADTA_ADD_ICON_ID, i18n.getMessage("button.save"),
null, null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class);
addIcon = SPUIComponentProvider.getButton(UIComponentIdProvider.METADTA_ADD_ICON_ID,
i18n.getMessage("button.save"), null, null, false, FontAwesome.PLUS,
SPUIButtonStyleSmallNoBorder.class);
addIcon.addClickListener(event -> onAdd());
return addIcon;
}
@@ -425,7 +426,8 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
return false;
}
uiNotification.displayValidationError(i18n.getMessage("message.metadata.duplicate.check", keyTextField.getValue()));
uiNotification
.displayValidationError(i18n.getMessage("message.metadata.duplicate.check", keyTextField.getValue()));
return true;
}

View File

@@ -13,7 +13,7 @@ import java.util.Set;
/**
* Interface for all entity states UI to show the details to a entity.
*/
public interface ManagmentEntityState<T> {
public interface ManagementEntityState {
/**
* The selected entities for the detail.
@@ -22,7 +22,7 @@ public interface ManagmentEntityState<T> {
* the selected entities.
*
*/
void setSelectedEnitities(Set<T> values);
void setSelectedEnitities(Set<Long> values);
/**
* The last selected value.
@@ -30,6 +30,6 @@ public interface ManagmentEntityState<T> {
* @param value
* the value
*/
void setLastSelectedEntity(T value);
void setLastSelectedEntityId(Long value);
}

View File

@@ -60,7 +60,7 @@ public final class UserDetailsFormatter {
*/
public static String loadAndFormatCreatedBy(final BaseEntity baseEntity) {
if (baseEntity == null || baseEntity.getCreatedBy() == null) {
return StringUtils.EMPTY;
return "";
}
return loadAndFormatUsername(baseEntity.getCreatedBy());
@@ -78,7 +78,7 @@ public final class UserDetailsFormatter {
*/
public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
if (baseEntity == null || baseEntity.getLastModifiedBy() == null) {
return StringUtils.EMPTY;
return "";
}
return loadAndFormatUsername(baseEntity.getLastModifiedBy());
@@ -123,14 +123,13 @@ public final class UserDetailsFormatter {
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
String firstname = StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), StringUtils.EMPTY);
String firstname = StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), "");
if (!StringUtils.isEmpty(firstname)) {
firstname += DETAIL_SEPERATOR;
}
final String firstAndLastname = firstname
+ StringUtils.defaultIfEmpty(userPrincipal.getLastname(), StringUtils.EMPTY);
final String firstAndLastname = firstname + StringUtils.defaultIfEmpty(userPrincipal.getLastname(), "");
final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength);
@@ -177,7 +176,7 @@ public final class UserDetailsFormatter {
}
private static String trimAndFormatDetail(final String formatString, final int expectedDetailLength) {
final String detail = StringUtils.defaultIfEmpty(formatString, StringUtils.EMPTY);
final String detail = StringUtils.defaultIfEmpty(formatString, "");
final String trimmedDetail = StringUtils.substring(detail, 0, expectedDetailLength);
if (StringUtils.length(detail) > expectedDetailLength) {
return trimmedDetail + TRIM_APPENDIX;

View File

@@ -14,10 +14,10 @@ import java.util.Map.Entry;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -36,7 +36,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
private static final long serialVersionUID = -4042317361561298155L;
private static final long serialVersionUID = 1L;
private Label actionMessage;
@@ -53,6 +53,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
this.eventBus = eventBus;
}
/**
* Initialize the confirmation window layout
*/
public void initialize() {
removeAllComponents();
consolidatedMessage = "";
@@ -76,7 +79,7 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
}
private void buildLayout() {
final Map<String, ConfirmationTab> confimrationTabs = getConfimrationTabs();
final Map<String, ConfirmationTab> confimrationTabs = getConfirmationTabs();
for (final Entry<String, ConfirmationTab> captionConfirmationTab : confimrationTabs.entrySet()) {
accordion.addTab(captionConfirmationTab.getValue(), captionConfirmationTab.getKey(), null);
}
@@ -129,7 +132,7 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
*
* @return map of caption and content for each tab.
*/
protected abstract Map<String, ConfirmationTab> getConfimrationTabs();
protected abstract Map<String, ConfirmationTab> getConfirmationTabs();
/**
* @return the consolidatedMessage

View File

@@ -172,18 +172,22 @@ public abstract class AbstractDistributionSetDetails
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider
.createNameValueLabel(getI18n().getMessage("label.dist.details.type"), type);
typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label typeLabel = SPUIComponentProvider
.createNameValueLabel(getI18n().getMessage("label.dist.details.type"), type);
typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
if (isMigrationRequired != null) {
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
getI18n().getMessage("checkbox.dist.migration.required"), isMigrationRequired.equals(Boolean.TRUE)
? getI18n().getMessage("label.yes") : getI18n().getMessage("label.no")));
detailsTabLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("checkbox.dist.migration.required"),
getMigrationRequiredValue(isMigrationRequired)));
}
private String getMigrationRequiredValue(final Boolean isMigrationRequired) {
if (isMigrationRequired == null) {
return null;
}
return isMigrationRequired.equals(Boolean.TRUE) ? getI18n().getMessage("label.yes")
: getI18n().getMessage("label.no");
}
protected SoftwareModuleDetailsTable getSoftwareModuleTable() {

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.ui.common.detailslayout;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.MetaData;
@@ -130,7 +129,7 @@ public abstract class AbstractSoftwareModuleDetails
@Override
protected String getDetailsHeaderCaptionId() {
return UIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
return UIComponentIdProvider.SOFTWARE_MODULE_DETAILS_HEADER_LABEL_ID;
}
@Override
@@ -197,7 +196,7 @@ public abstract class AbstractSoftwareModuleDetails
updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().getVendor(), maxAssign);
} else {
updateSoftwareModuleDetailsLayout(StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY);
updateSoftwareModuleDetailsLayout("", "", "");
}
}

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
@@ -40,10 +39,11 @@ import com.vaadin.ui.VerticalLayout;
/**
* Abstract Layout to show the entity details.
*
* @param <T>
*/
public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends VerticalLayout {
private static final long serialVersionUID = 4862529368471627190L;
private static final long serialVersionUID = 1L;
private final VaadinMessageSource i18n;
@@ -116,7 +116,8 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
*/
protected void onBaseEntityEvent(final BaseUIEntityEvent<T> baseEntityEvent) {
final BaseEntityEventType eventType = baseEntityEvent.getEventType();
if (BaseEntityEventType.SELECTED_ENTITY == eventType || BaseEntityEventType.UPDATED_ENTITY == eventType) {
if (BaseEntityEventType.SELECTED_ENTITY == eventType || BaseEntityEventType.UPDATED_ENTITY == eventType
|| BaseEntityEventType.REMOVE_ENTITY == eventType) {
UI.getCurrent().access(() -> populateData(baseEntityEvent.getEntity()));
} else if (BaseEntityEventType.MINIMIZED == eventType) {
UI.getCurrent().access(() -> setVisible(true));
@@ -129,11 +130,12 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
caption.setValue(HawkbitCommonUtil.getSoftwareModuleName(headerCaption, value));
}
/**
* Restores the tables and tabs displayed on the view based on the selected
* entity.
*/
protected void restoreState() {
if (onLoadIsTableRowSelected()) {
populateData(null);
editButton.setEnabled(true);
}
populateData(getSelectedBaseEntity());
if (onLoadIsTableMaximized()) {
setVisible(false);
}
@@ -149,28 +151,21 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
protected void populateLog() {
logLayout.removeAllComponents();
logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.getMessage("label.created.at"),
SPDateTimeUtil.formatCreatedAt(selectedBaseEntity)));
logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity));
if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) {
return;
}
logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.getMessage("label.modified.date"),
SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity)));
logLayout.addComponent(SPUIComponentProvider.createLastModifiedByLabel(i18n, selectedBaseEntity));
}
protected void updateDescriptionLayout(final String descriptionLabel, final String description) {
protected void updateDescriptionLayout(final String description) {
descriptionLayout.removeAllComponents();
final Label descLabel = SPUIComponentProvider.createNameValueLabel(descriptionLabel,
final Label descLabel = SPUIComponentProvider.createNameValueLabel("",
HawkbitCommonUtil.trimAndNullIfEmpty(description) == null ? "" : description);
/**
* By default text will be truncated based on layout width .so removing
* By default text will be truncated based on layout width. So removing
* it as we need full description.
*/
descLabel.removeStyleName("label-style");
@@ -191,7 +186,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
conAttributeLabel.setDescription(entry.getKey().concat(" : ") + entry.getValue());
conAttributeLabel.addStyleName("label-style");
attributesLayout.addComponent(conAttributeLabel);
}
}
}
@@ -282,15 +276,15 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
}
/**
* If no data in table (i,e no row selected),then disable the edit button.
* If row is selected ,enable edit button.
* If there is no data in table (i.e. no row selected), then disable the
* edit button. If row is selected, enable edit button.
*/
private void populateData(final T selectedBaseEntity) {
this.selectedBaseEntity = selectedBaseEntity;
editButton.setEnabled(selectedBaseEntity != null);
manageMetadataBtn.setEnabled(selectedBaseEntity != null);
if (selectedBaseEntity == null) {
setName(getDefaultCaption(), StringUtils.EMPTY);
setName(getDefaultCaption(), "");
} else {
setName(getDefaultCaption(), getName());
}
@@ -301,9 +295,9 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private void populateDescription() {
if (selectedBaseEntity != null) {
updateDescriptionLayout(i18n.getMessage("label.description"), selectedBaseEntity.getDescription());
updateDescriptionLayout(selectedBaseEntity.getDescription());
} else {
updateDescriptionLayout(i18n.getMessage("label.description"), null);
updateDescriptionLayout(null);
}
}
@@ -332,8 +326,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
protected abstract String getEditButtonId();
protected abstract boolean onLoadIsTableRowSelected();
protected abstract boolean onLoadIsTableMaximized();
protected abstract String getTabSheetId();

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -24,9 +23,9 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus;
@@ -191,12 +190,11 @@ public class SoftwareModuleDetailsTable extends Table {
} else {
final DistributionSet newDistributionSet = distributionSetManagement
.unassignSoftwareModule(distributionSet.getId(), unAssignedSw.getId());
manageDistUIState.setLastSelectedEntity(newDistributionSet.getId());
manageDistUIState.setLastSelectedEntityId(newDistributionSet.getId());
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
uiNotification.displaySuccess(i18n.getMessage("message.sw.unassigned", unAssignedSw.getName()));
}
}
private static boolean isSoftModAvaiableForSoftType(final Set<SoftwareModule> swModulesSet,
@@ -218,7 +216,7 @@ public class SoftwareModuleDetailsTable extends Table {
if (swModType.getKey().equals(sw.getType().getKey())) {
final HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSizeFull();
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(StringUtils.EMPTY);
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel("");
final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule

View File

@@ -17,8 +17,8 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
/**
*
*
* Abstract class for button click behavior. It is possible to click multiple
* buttons.
*/
public abstract class AbstractFilterMultiButtonClick extends AbstractFilterButtonClickBehaviour {

View File

@@ -12,11 +12,11 @@ import org.eclipse.hawkbit.ui.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.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -37,11 +37,10 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Parent class for footer layout.
*
*/
public abstract class AbstractDeleteActionsLayout extends VerticalLayout implements DropHandler {
private static final long serialVersionUID = -6047975388519155509L;
private static final long serialVersionUID = 1L;
protected VaadinMessageSource i18n;
@@ -100,17 +99,18 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
dropHintLayout.addComponent(getCountMessageLabel());
}
final HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setId(UIComponentIdProvider.ACTION_BUTTON_LAYOUT);
hLayout.setSpacing(true);
hLayout.setSizeUndefined();
if (null != deleteWrapper) {
if (deleteWrapper != null) {
hLayout.addComponent(deleteWrapper);
hLayout.setComponentAlignment(deleteWrapper, Alignment.BOTTOM_LEFT);
}
if (null != noActionBtn) {
if (noActionBtn != null) {
hLayout.addComponent(noActionBtn);
hLayout.setComponentAlignment(noActionBtn, Alignment.BOTTOM_LEFT);
}
if (null != bulkUploadStatusButton) {
if (bulkUploadStatusButton != null) {
hLayout.addComponent(bulkUploadStatusButton);
hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT);
}
@@ -127,13 +127,13 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
private DragAndDropWrapper createDeleteWrapperLayout() {
final Button dropToDelete = new Button("Drop here to delete");
final Button dropToDelete = new Button(i18n.getMessage("label.components.drop.area"));
dropToDelete.setCaptionAsHtml(true);
dropToDelete.setIcon(FontAwesome.TRASH_O);
dropToDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS);
dropToDelete.addStyleName("drop-to-delete-button");
dropToDelete.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
dropToDelete.addStyleName("del-action-button");
dropToDelete.addStyleName(SPUIStyleDefinitions.DEL_ACTION_BUTTON);
dropToDelete.addStyleName("delete-icon");
final DragAndDropWrapper wrapper = new DragAndDropWrapper(dropToDelete);
@@ -148,7 +148,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
final Button button = SPUIComponentProvider.getButton(UIComponentIdProvider.PENDING_ACTION_BUTTON,
getNoActionsButtonLabel(), "", "", false, FontAwesome.BELL, SPUIButtonStyleSmall.class);
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
button.addStyleName("del-action-button");
button.addStyleName(SPUIStyleDefinitions.DEL_ACTION_BUTTON);
button.addClickListener(event -> actionButtonClicked());
button.setHtmlContentAllowed(true);
@@ -255,7 +255,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
/**
*
* @return true if the count label is displayed false is not displayed
* @return true if the count label is displayed; false is not displayed
*/
protected boolean hasCountMessage() {
return false;
@@ -290,7 +290,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
/**
* Check user has delete permission.
* Check if user has delete permission.
*
* @return true if user has permission, otherwise return false.
*/
@@ -379,7 +379,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
/**
* Check if any unsaved actions done by the user.
*
* @return 'true' if any unsaved actions available, otherwise retrun
* @return 'true' if any unsaved actions available, otherwise return
* 'false'.
*/
protected abstract boolean hasUnsavedActions();

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.ui.common.grid;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -42,7 +41,7 @@ public class DefaultGridHeader extends VerticalLayout {
* @param managementUIState
*/
public DefaultGridHeader(final ManagementUIState managementUIState) {
this(managementUIState, StringUtils.EMPTY);
this(managementUIState, "");
}
/**

View File

@@ -0,0 +1,34 @@
/**
* 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.table;
import org.vaadin.spring.events.EventBusListenerMethodFilter;
/**
* Abstract class for filter classes which contains information about the origin
* view.
*
*/
public abstract class AbstractBaseViewFilter implements EventBusListenerMethodFilter {
@Override
public boolean filter(final Object payload) {
if (!(payload instanceof BaseUIEvent)) {
return false;
}
final BaseUIEvent event = (BaseUIEvent) payload;
return getOriginView().equals(event.getSource());
}
protected abstract Class<?> getOriginView();
}

View File

@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.ui.common.table;
import java.util.List;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.data.Item;
@@ -26,14 +26,13 @@ import com.vaadin.ui.DragAndDropWrapper;
*
* @param <E>
* e is the entity class
* @param <I>
* i is the id of the table
*/
public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity, I> extends AbstractTable<E, I> {
public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity> extends AbstractTable<E> {
private static final long serialVersionUID = 780050712209750719L;
protected AbstractNamedVersionTable(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification notification) {
protected AbstractNamedVersionTable(final UIEventBus eventBus, final VaadinMessageSource i18n,
final UINotification notification) {
super(eventBus, i18n, notification);
setMultiSelect(true);
setSelectable(true);
@@ -43,8 +42,8 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = super.getTableVisibleColumns();
final float versionColumnSize = isMaximized() ? 0.1F : 0.2F;
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.getMessage("header.version"), versionColumnSize));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.getMessage("header.version"),
versionColumnSize));
return columnList;
}

View File

@@ -19,15 +19,15 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.RefreshableContainer;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -51,15 +51,13 @@ import com.vaadin.ui.themes.ValoTheme;
*
* @param <E>
* e is the entity class
* @param <I>
* i is the id of the table
*/
public abstract class AbstractTable<E extends NamedEntity, I> extends Table implements RefreshableContainer {
public abstract class AbstractTable<E extends NamedEntity> extends Table implements RefreshableContainer {
private static final long serialVersionUID = 1L;
private static final float DEFAULT_COLUMN_NAME_MIN_SIZE = 0.8F;
private static final long serialVersionUID = 4856562746502217630L;
protected static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
protected transient EventBus.UIEventBus eventBus;
@@ -68,7 +66,8 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
protected UINotification notification;
protected AbstractTable(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification notification) {
protected AbstractTable(final UIEventBus eventBus, final VaadinMessageSource i18n,
final UINotification notification) {
this.eventBus = eventBus;
this.i18n = i18n;
this.notification = notification;
@@ -84,7 +83,6 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
setDefault();
addValueChangeListener(event -> onValueChange());
setPageLength(SPUIDefinitions.PAGE_SIZE);
eventBus.subscribe(this);
}
@@ -107,26 +105,24 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
private void onValueChange() {
eventBus.publish(this, UploadArtifactUIEvent.HIDE_DROP_HINTS);
final Set<I> values = getTableValue(this);
final Set<Long> values = getTableValue(this);
I lastId = null;
Long lastId = null;
if (!values.isEmpty()) {
lastId = Iterables.getLast(values);
}
setManagementEntitiyStateValues(values, lastId);
if (lastId != null) {
findEntityByTableValue(lastId).ifPresent(this::publishEntityAfterValueChange);
}
setManagementEntityStateValues(values, lastId);
selectEntity(lastId);
afterEntityIsSelected();
}
protected void setManagementEntitiyStateValues(final Set<I> values, final I lastId) {
final ManagmentEntityState<I> managmentEntityState = getManagmentEntityState();
if (managmentEntityState == null) {
protected void setManagementEntityStateValues(final Set<Long> values, final Long lastId) {
final ManagementEntityState managementEntityState = getManagementEntityState();
if (managementEntityState == null) {
return;
}
managmentEntityState.setLastSelectedEntity(lastId);
managmentEntityState.setSelectedEnitities(values);
managementEntityState.setLastSelectedEntityId(lastId);
managementEntityState.setSelectedEnitities(values);
}
private void setDefault() {
@@ -241,28 +237,53 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
* the table transferable
* @return set of entities id which will deleted
*/
@SuppressWarnings("unchecked")
public Set<I> getDeletedEntityByTransferable(final TableTransferable transferable) {
final Set<I> selectedEntities = (Set<I>) getTableValue(this);
final Set<I> ids = new HashSet<>();
final Object tranferableData = transferable.getData(SPUIDefinitions.ITEMID);
public Set<Long> getDeletedEntityByTransferable(final TableTransferable transferable) {
final Set<Long> selectedEntities = getTableValue(this);
final Set<Long> ids = new HashSet<>();
final Long tranferableData = (Long) transferable.getData(SPUIDefinitions.ITEMID);
if (tranferableData == null) {
return ids;
}
if (!selectedEntities.contains(tranferableData)) {
ids.add((I) tranferableData);
ids.add(tranferableData);
} else {
ids.addAll(selectedEntities);
}
return ids;
}
protected abstract Optional<E> findEntityByTableValue(I lastSelectedId);
/**
* Finds the entity object of the given entity ID by performing a database
* search
*
* @param lastSelectedId
* ID of the entity
* @return entity object as Optional
*/
protected abstract Optional<E> findEntityByTableValue(Long lastSelectedId);
protected abstract void publishEntityAfterValueChange(E selectedLastEntity);
/**
* This method is performed after selecting the current entity in the table.
*/
protected void afterEntityIsSelected() {
// can be overridden by subclass
}
protected abstract ManagmentEntityState<I> getManagmentEntityState();
/**
* Publish the BaseEntityEventType.SELECTED_ENTITY Event with the given
* entity.
*
* @param selectedLastEntity
* entity that was selected in the table
*/
protected abstract void publishSelectedEntityEvent(final E selectedLastEntity);
protected void setLastSelectedEntityId(final Long selectedLastEntityId) {
getManagementEntityState().setLastSelectedEntityId(selectedLastEntityId);
}
protected abstract ManagementEntityState getManagementEntityState();
/**
* Get Id of the table.
@@ -292,14 +313,16 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
}
/**
* Check if first row should be selected by default on load.
* Check if the first row should be selected by default on load. (if there
* is no other item selected)
*
* @return true if it should be selected otherwise return false.
* @return true if it should be selected otherwise return false, if there is
* a different item already selected.
*/
protected abstract boolean isFirstRowSelectedOnLoad();
/**
* Get Item Id should be displayed as selected.
* Get Item Id which should be displayed as selected.
*
* @return reference of Item Id of the Row.
*/
@@ -326,10 +349,12 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
}
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.getMessage("header.name"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.getMessage("header.createdBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.getMessage("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.getMessage("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.getMessage("header.modifiedDate"), 0.1F));
new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.getMessage("header.createdDate"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.getMessage("header.modifiedBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE,
i18n.getMessage("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.getMessage("header.description"), 0.2F));
setItemDescriptionGenerator((source, itemId, propertyId) -> {
@@ -372,24 +397,24 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
};
}
protected Set<I> getDraggedTargetList(final DragAndDropEvent event) {
protected Set<Long> getDraggedTargetList(final DragAndDropEvent event) {
final com.vaadin.event.dd.TargetDetails targetDet = event.getTargetDetails();
final Table targetTable = (Table) targetDet.getTarget();
final Set<I> targetSelected = getTableValue(targetTable);
final Set<Long> targetSelected = getTableValue(targetTable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object targetItemId = dropData.getItemIdOver();
final Long targetItemId = (Long) dropData.getItemIdOver();
if (!targetSelected.contains(targetItemId)) {
return Sets.newHashSet((I) targetItemId);
return Sets.newHashSet(targetItemId);
}
return targetSelected;
}
private Set<Object> getDraggedTargetList(final TableTransferable transferable, final Table source) {
private Set<Long> getDraggedTargetList(final TableTransferable transferable, final Table source) {
@SuppressWarnings("unchecked")
final AbstractTable<NamedEntity, Object> table = (AbstractTable<NamedEntity, Object>) source;
final AbstractTable<NamedEntity> table = (AbstractTable<NamedEntity>) source;
return table.getDeletedEntityByTransferable(transferable);
}
@@ -432,9 +457,6 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
return true;
}
/**
* Refresh the container.
*/
@Override
public void refreshContainer() {
final Container container = getContainerDataSource();
@@ -448,6 +470,23 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
return notification;
}
/**
* Finds the entity object of the given entity ID and performs the
* publishing of the BaseEntityEventType.SELECTED_ENTITY event
*
* @param entityId
* ID of the current entity
*/
public void selectEntity(final Long entityId) {
E entity = null;
if (entityId != null) {
entity = findEntityByTableValue(entityId).orElse(null);
}
setLastSelectedEntityId(entityId);
publishSelectedEntityEvent(entity);
}
protected abstract boolean hasDropPermission();
protected abstract boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource);

View File

@@ -18,9 +18,9 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -40,7 +40,7 @@ import com.vaadin.ui.VerticalLayout;
*/
public abstract class AbstractTableHeader extends VerticalLayout {
private static final long serialVersionUID = 4881626370291837175L;
private static final long serialVersionUID = 1L;
protected VaadinMessageSource i18n;
@@ -64,13 +64,15 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private Button bulkUploadIcon;
protected final ManagementUIState managementUIState;
protected final ManageDistUIState manageDistUIstate;
protected final ArtifactUploadState artifactUploadState;
private final ManagementUIState managementUIState;
protected AbstractTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
final ManagementUIState managementUIState, final ManageDistUIState manageDistUIstate,
final ArtifactUploadState artifactUploadState) {
private final ManageDistUIState manageDistUIstate;
private final ArtifactUploadState artifactUploadState;
protected AbstractTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final UIEventBus eventbus, final ManagementUIState managementUIState,
final ManageDistUIState manageDistUIstate, final ArtifactUploadState artifactUploadState) {
this.i18n = i18n;
this.permChecker = permChecker;
this.eventbus = eventbus;
@@ -535,4 +537,16 @@ public abstract class AbstractTableHeader extends VerticalLayout {
protected abstract void addNewItem(final Button.ClickEvent event);
protected ManagementUIState getManagementUIState() {
return managementUIState;
}
protected ManageDistUIState getManageDistUIstate() {
return manageDistUIstate;
}
protected ArtifactUploadState getArtifactUploadState() {
return artifactUploadState;
}
}

View File

@@ -27,7 +27,7 @@ import com.vaadin.ui.themes.ValoTheme;
* @param <T>
* type of the concrete table
*/
public abstract class AbstractTableLayout<T extends AbstractTable<?, ?>> extends VerticalLayout {
public abstract class AbstractTableLayout<T extends AbstractTable<?>> extends VerticalLayout {
private static final long serialVersionUID = 1L;

View File

@@ -0,0 +1,33 @@
/**
* 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.table;
import com.vaadin.ui.UI;
/**
* Base class which every UI event should inherit from. The class provides
* information about the view the event was published from.
*
*/
public class BaseUIEvent {
private final Class<?> source;
/**
* Constructor for BaseUIEvent
*/
public BaseUIEvent() {
this.source = UI.getCurrent().getNavigator().getCurrentView().getClass();
}
public Class<?> getSource() {
return source;
}
}

View File

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.ui.common.tagdetails;
import java.util.Optional;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target;
@@ -18,8 +20,8 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
@@ -43,9 +45,9 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
private final transient TargetManagement targetManagement;
public TargetTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification,
final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement,
final TargetManagement targetManagement) {
public TargetTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n,
final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState,
final TagManagement tagManagement, final TargetManagement targetManagement) {
super(checker, i18n, uinotification, eventBus, managementUIState, tagManagement);
this.targetManagement = targetManagement;
}
@@ -123,17 +125,19 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
}
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0 && managementUIState.getLastSelectedTargetId() != null) {
final Optional<Long> targetId = managementUIState.getLastSelectedTargetId();
if (assignmentResult.getAssigned() > 0 && targetId.isPresent()) {
return assignmentResult.getAssignedEntity().stream().map(Target::getId)
.anyMatch(controllerId -> controllerId.equals(managementUIState.getLastSelectedTargetId()));
.anyMatch(controllerId -> controllerId.equals(targetId.get()));
}
return false;
}
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0 && managementUIState.getLastSelectedTargetId() != null) {
final Optional<Long> targetId = managementUIState.getLastSelectedTargetId();
if (assignmentResult.getUnassigned() > 0 && targetId.isPresent()) {
return assignmentResult.getUnassignedEntity().stream().map(Target::getId)
.anyMatch(controllerId -> controllerId.equals(managementUIState.getLastSelectedTargetId()));
.anyMatch(controllerId -> controllerId.equals(targetId.get()));
}
return false;
}

View File

@@ -37,6 +37,7 @@ import com.vaadin.ui.VerticalLayout;
public abstract class AbstractNotificationView extends VerticalLayout implements View {
private static final long serialVersionUID = 1L;
private final transient Cache<BaseUIEntityEvent<?>, Object> skipUiEventsCache;
private final transient EventBus.UIEventBus eventBus;
@@ -116,8 +117,6 @@ public abstract class AbstractNotificationView extends VerticalLayout implements
/**
* Refresh the view by event container changes.
*
*
*/
public void refreshView() {
if (viewUnreadNotifcations.get() <= 0) {
@@ -163,7 +162,6 @@ public abstract class AbstractNotificationView extends VerticalLayout implements
protected abstract Map<Class<?>, RefreshableContainer> getSupportedPushEvents();
/**
*
* @return the related dashboard menu item for this view.
*/
protected abstract DashboardMenuItem getDashboardMenuItem();

View File

@@ -17,8 +17,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -208,7 +208,7 @@ public final class SPUIComponentProvider {
}
private static Label createUsernameLabel(final String label, final String username) {
String loadAndFormatUsername = StringUtils.EMPTY;
String loadAndFormatUsername = "";
if (!StringUtils.isEmpty(username)) {
loadAndFormatUsername = UserDetailsFormatter.loadAndFormatUsername(username);
}
@@ -233,7 +233,7 @@ public final class SPUIComponentProvider {
*/
public static Label createCreatedByLabel(final VaadinMessageSource i18n, final BaseEntity baseEntity) {
return createUsernameLabel(i18n.getMessage("label.created.by"),
baseEntity == null ? StringUtils.EMPTY : baseEntity.getCreatedBy());
baseEntity == null ? "" : baseEntity.getCreatedBy());
}
/**
@@ -248,7 +248,7 @@ public final class SPUIComponentProvider {
*/
public static Label createLastModifiedByLabel(final VaadinMessageSource i18n, final BaseEntity baseEntity) {
return createUsernameLabel(i18n.getMessage("label.modified.by"),
baseEntity == null ? StringUtils.EMPTY : baseEntity.getLastModifiedBy());
baseEntity == null ? "" : baseEntity.getLastModifiedBy());
}
/**

View File

@@ -40,15 +40,16 @@ import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.SoftwareModuleCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.SoftwareModuleDeletedEventContainer;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Maps;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener;
@@ -64,8 +65,9 @@ import com.vaadin.ui.GridLayout;
@SpringView(name = DistributionsView.VIEW_NAME, ui = HawkbitUI.class)
public class DistributionsView extends AbstractNotificationView implements BrowserWindowResizeListener {
private static final long serialVersionUID = 1L;
public static final String VIEW_NAME = "distributions";
private static final long serialVersionUID = 3887435076372276300L;
private final SpPermissionChecker permChecker;
@@ -122,7 +124,6 @@ public class DistributionsView extends AbstractNotificationView implements Brows
@PostConstruct
void init() {
// Build the Distributions view layout with all the required components.
buildLayout();
restoreState();
checkNoDataAvaialble();
@@ -130,6 +131,15 @@ public class DistributionsView extends AbstractNotificationView implements Brows
showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth());
}
@Override
public void enter(final ViewChangeEvent event) {
softwareModuleTableLayout.getSwModuleTable()
.selectEntity(manageDistUIState.getLastSelectedSoftwareModule().orElse(null));
distributionTableLayout.getDistributionSetTable()
.selectEntity(manageDistUIState.getLastSelectedDistribution().orElse(null));
}
@Override
protected DashboardMenuItem getDashboardMenuItem() {
return distributionsViewMenuItem;
@@ -145,15 +155,19 @@ public class DistributionsView extends AbstractNotificationView implements Brows
}
private void buildLayout() {
// Check if user has permissions
if (permChecker.hasUpdateDistributionPermission() || permChecker.hasCreateDistributionPermission()
|| permChecker.hasReadDistributionPermission()) {
setSizeFull();
setStyleName("rootLayout");
createMainLayout();
addComponents(mainLayout);
setExpandRatio(mainLayout, 1);
if (!hasUserPermission()) {
return;
}
setSizeFull();
setStyleName("rootLayout");
createMainLayout();
addComponents(mainLayout);
setExpandRatio(mainLayout, 1);
}
private boolean hasUserPermission() {
return permChecker.hasUpdateDistributionPermission() || permChecker.hasCreateDistributionPermission()
|| permChecker.hasReadDistributionPermission();
}
private void createMainLayout() {
@@ -227,7 +241,6 @@ public class DistributionsView extends AbstractNotificationView implements Brows
private void checkNoDataAvaialble() {
if (manageDistUIState.isNoDataAvilableSwModule() && manageDistUIState.isNoDataAvailableDist()) {
uiNotification.displayValidationError(i18n.getMessage("message.no.data"));
}
}
@@ -239,7 +252,6 @@ public class DistributionsView extends AbstractNotificationView implements Brows
private void showOrHideFilterButtons(final int browserWidth) {
if (browserWidth < SPUIDefinitions.REQ_MIN_BROWSER_WIDTH) {
filterByDSTypeLayout.setVisible(false);
distributionTableLayout.setShowFilterButtonVisible(true);
filterBySMTypeLayout.setVisible(false);
@@ -248,7 +260,6 @@ public class DistributionsView extends AbstractNotificationView implements Brows
if (!manageDistUIState.isDistTypeFilterClosed()) {
filterByDSTypeLayout.setVisible(true);
distributionTableLayout.setShowFilterButtonVisible(false);
}
if (!manageDistUIState.isSwTypeFilterClosed()) {
filterBySMTypeLayout.setVisible(true);

View File

@@ -13,7 +13,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
@@ -33,11 +32,11 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -127,12 +126,13 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC).buildTextComponent();
tagDesc.setNullRepresentation(StringUtils.EMPTY);
tagDesc.setNullRepresentation("");
}
private TextField createTextField(final String in18Key, final String styleName, final String id) {
return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
.required(true).prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent();
return new TextFieldBuilder().caption(i18n.getMessage(in18Key))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName).required(true).prompt(i18n.getMessage(in18Key))
.immediate(true).id(id).buildTextComponent();
}
@Override
@@ -400,7 +400,8 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final DistributionSetType newDistType = distributionSetManagement.createDistributionSetType(
entityFactory.distributionSetType().create().key(typeKeyValue).name(typeNameValue)
.description(typeDescValue).colour(colorPicked).mandatory(mandatory).optional(optional));
uiNotification.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newDistType.getName() }));
uiNotification
.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newDistType.getName() }));
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType));
} else {
@@ -439,7 +440,8 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final DistributionSetType updateDistSetType = distributionSetManagement.updateDistributionSetType(update);
uiNotification.displaySuccess(i18n.getMessage("message.update.success", new Object[] { updateDistSetType.getName() }));
uiNotification.displaySuccess(
i18n.getMessage("message.update.success", new Object[] { updateDistSetType.getName() }));
eventBus.publish(this,
new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));

View File

@@ -13,7 +13,7 @@ import java.io.Serializable;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.RefreshDistributionTableByFilterEvent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -24,7 +24,7 @@ import com.vaadin.ui.Button;
*/
public class DSTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
private static final long serialVersionUID = -584783755917528648L;
private static final long serialVersionUID = 1L;
private final transient EventBus.UIEventBus eventBus;
@@ -42,16 +42,14 @@ public class DSTypeFilterButtonClick extends AbstractFilterSingleButtonClick imp
@Override
protected void filterUnClicked(final Button clickedButton) {
manageDistUIState.getManageDistFilters().setClickedDistSetType(null);
eventBus.publish(this, DistributionTableFilterEvent.FILTER_BY_TAG);
eventBus.publish(this, new RefreshDistributionTableByFilterEvent());
}
@Override
protected void filterClicked(final Button clickedButton) {
distributionSetManagement.findDistributionSetTypeByName(clickedButton.getData().toString())
.ifPresent(manageDistUIState.getManageDistFilters()::setClickedDistSetType);
eventBus.publish(this, DistributionTableFilterEvent.FILTER_BY_TAG);
eventBus.publish(this, new RefreshDistributionTableByFilterEvent());
}
}

View File

@@ -12,7 +12,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
@@ -218,7 +217,7 @@ public class DistributionSetDetails extends AbstractDistributionSetDetails {
final VerticalLayout verticalLayout = new VerticalLayout();
final HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSizeFull();
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(StringUtils.EMPTY);
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel("");
final Button reassignSoftModule = assignSoftModuleButton(softwareModuleName);
softwareModule.setValue(softwareModuleName);
softwareModule.setDescription(softwareModuleName);
@@ -234,11 +233,6 @@ public class DistributionSetDetails extends AbstractDistributionSetDetails {
tfqDetailsTable.populateTableByDistributionSet(getSelectedBaseEntity());
}
@Override
protected boolean onLoadIsTableRowSelected() {
return manageDistUIState.getSelectedDistributions().map(selected -> !selected.isEmpty()).orElse(false);
}
@Override
protected boolean onLoadIsTableMaximized() {
return manageDistUIState.isDsTableMaximized();

View File

@@ -37,16 +37,17 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.RefreshDistributionTableByFilterEvent;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.view.filter.OnlyEventsFromDistributionsViewFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
@@ -70,9 +71,9 @@ import com.vaadin.ui.UI;
/**
* Distribution set table.
*/
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, Long> {
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet> {
private static final long serialVersionUID = -7731776093470487988L;
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(DistributionSetTable.class);
@@ -104,7 +105,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
this.targetManagement = targetManagement;
this.dsMetadataPopupLayout = dsMetadataPopupLayout;
addTableStyleGenerator();
addNewContainerDS();
setColumnProperties();
setDataAvailable(getContainerDataSource().size() != 0);
@@ -112,11 +112,10 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@EventBusListenerMethod(scope = EventScope.UI)
void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {
@SuppressWarnings("unchecked")
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
handleSelectedAndUpdatedDs(eventContainer.getEvents());
}
private void handleSelectedAndUpdatedDs(final List<DistributionSetUpdateEvent> events) {
@@ -141,7 +140,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
protected Container createContainer() {
final Map<String, Object> queryConfiguration = prepareQueryConfigFilters();
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<>(ManageDistBeanQuery.class);
@@ -155,7 +153,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
manageDistUIState.getManageDistFilters().getSearchText()
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
if (manageDistUIState.getManageDistFilters().getClickedDistSetType() != null) {
queryConfig.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE,
manageDistUIState.getManageDistFilters().getClickedDistSetType());
}
@@ -172,12 +170,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
protected boolean isFirstRowSelectedOnLoad() {
return manageDistUIState.getSelectedDistributions().map(Set::isEmpty).orElse(true);
return manageDistUIState.getSelectedDistributions().isEmpty();
}
@Override
protected Object getItemIdToSelect() {
return manageDistUIState.getSelectedDistributions().orElse(null);
return isFirstRowSelectedOnLoad() ? null : manageDistUIState.getSelectedDistributions();
}
@Override
@@ -186,17 +184,18 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
}
@Override
protected ManageDistUIState getManagmentEntityState() {
protected ManageDistUIState getManagementEntityState() {
return manageDistUIState;
}
@Override
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
protected void afterEntityIsSelected() {
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
if (distributionSet != null) {
manageDistUIState.setLastSelectedEntity(distributionSet.getId());
}
}
@Override
protected void publishSelectedEntityEvent(final DistributionSet distributionSet) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
}
@Override
@@ -212,15 +211,13 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
protected void onDropEventFromTable(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final AbstractTable<?> source = (AbstractTable<?>) transferable.getSourceComponent();
final Set<Long> softwareModulesIdList = source.getDeletedEntityByTransferable(transferable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object distItemId = dropData.getItemIdOver();
handleDropEvent(source, softwareModulesIdList, distItemId);
}
@Override
@@ -284,26 +281,23 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
if (manageDistUIState.getLastSelectedDistribution().map(distId::equals).orElse(false)) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule));
}
}
private void handleFirmwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
private static void handleFirmwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() == 1) {
if (!map.containsKey(softwareModule.getType().getId())) {
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
}
map.get(softwareModule.getType().getId()).clear();
map.get(softwareModule.getType().getId()).add(softwareModuleIdName);
}
}
private void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
private static void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() > 1) {
if (!map.containsKey(softwareModule.getType().getId())) {
@@ -317,7 +311,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
final HashSet<SoftwareModuleIdName> softwareModules) {
LOG.debug("Adding a log to check if distributionSetIdName is null : {} ", distributionSetIdName);
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
}
@@ -378,7 +371,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
return false;
}
}
}
return true;
}
@@ -429,16 +421,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
/**
* DistributionTableFilterEvent.
*
* @param event
* as instance of {@link DistributionTableFilterEvent}
* @param filterEvent
* as instance of {@link RefreshDistributionTableByFilterEvent}
*/
@EventBusListenerMethod(scope = EventScope.UI)
public void onEvent(final DistributionTableFilterEvent event) {
if (event == DistributionTableFilterEvent.FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.FILTER_BY_TAG) {
UI.getCurrent().access(this::refreshFilter);
}
@EventBusListenerMethod(scope = EventScope.UI, filter = OnlyEventsFromDistributionsViewFilter.class)
public void onEvent(final RefreshDistributionTableByFilterEvent filterEvent) {
UI.getCurrent().access(this::refreshFilter);
}
@Override
@@ -452,13 +440,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
@Override
protected void setDataAvailable(final boolean available) {
manageDistUIState.setNoDataAvailableDist(!available);
}
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.METADATA_ICON, new ColumnGenerator() {
private static final long serialVersionUID = 117186282275065399L;
private static final long serialVersionUID = 1L;
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {

View File

@@ -15,9 +15,9 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.management.event.RefreshDistributionTableByFilterEvent;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -35,8 +35,9 @@ public class DistributionSetTableHeader extends AbstractDistributionSetTableHead
private final DistributionAddUpdateWindowLayout addUpdateWindowLayout;
DistributionSetTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus,
final ManageDistUIState manageDistUIstate, final DistributionAddUpdateWindowLayout addUpdateWindowLayout) {
DistributionSetTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final UIEventBus eventbus, final ManageDistUIState manageDistUIstate,
final DistributionAddUpdateWindowLayout addUpdateWindowLayout) {
super(i18n, permChecker, eventbus, null, manageDistUIstate, null);
this.addUpdateWindowLayout = addUpdateWindowLayout;
}
@@ -50,49 +51,49 @@ public class DistributionSetTableHeader extends AbstractDistributionSetTableHead
@Override
protected String onLoadSearchBoxValue() {
return manageDistUIstate.getManageDistFilters().getSearchText().orElse(null);
return getManageDistUIstate().getManageDistFilters().getSearchText().orElse(null);
}
@Override
protected void showFilterButtonsLayout() {
manageDistUIstate.setDistTypeFilterClosed(false);
getManageDistUIstate().setDistTypeFilterClosed(false);
eventbus.publish(this, DistributionsUIEvent.SHOW_DIST_FILTER_BY_TYPE);
}
@Override
protected void resetSearchText() {
if (manageDistUIstate.getManageDistFilters().getSearchText().isPresent()) {
manageDistUIstate.getManageDistFilters().setSearchText(null);
eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT);
if (getManageDistUIstate().getManageDistFilters().getSearchText().isPresent()) {
getManageDistUIstate().getManageDistFilters().setSearchText(null);
eventbus.publish(this, new RefreshDistributionTableByFilterEvent());
}
}
@Override
public void maximizeTable() {
manageDistUIstate.setDsTableMaximized(Boolean.TRUE);
getManageDistUIstate().setDsTableMaximized(Boolean.TRUE);
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED));
}
@Override
public void minimizeTable() {
manageDistUIstate.setDsTableMaximized(Boolean.FALSE);
getManageDistUIstate().setDsTableMaximized(Boolean.FALSE);
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED));
}
@Override
public Boolean onLoadIsTableMaximized() {
return manageDistUIstate.isDsTableMaximized();
return getManageDistUIstate().isDsTableMaximized();
}
@Override
public Boolean onLoadIsShowFilterButtonDisplayed() {
return manageDistUIstate.isDistTypeFilterClosed();
return getManageDistUIstate().isDistTypeFilterClosed();
}
@Override
protected void searchBy(final String newSearchText) {
manageDistUIstate.getManageDistFilters().setSearchText(newSearchText);
eventbus.publish(this, DistributionTableFilterEvent.FILTER_BY_TEXT);
getManageDistUIstate().getManageDistFilters().setSearchText(newSearchText);
eventbus.publish(this, new RefreshDistributionTableByFilterEvent());
}
@Override

View File

@@ -19,16 +19,18 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
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.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
/**
* DistributionSet table layout
* DistributionSet table layout.
*/
public class DistributionSetTableLayout extends AbstractTableLayout<DistributionSetTable> {
private static final long serialVersionUID = 6464291374980641235L;
private static final long serialVersionUID = 1L;
private final DistributionSetTable distributionSetTable;
public DistributionSetTableLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManageDistUIState manageDistUIState,
@@ -41,9 +43,9 @@ public class DistributionSetTableLayout extends AbstractTableLayout<Distribution
final DsMetadataPopupLayout popupLayout = new DsMetadataPopupLayout(i18n, uiNotification, eventBus,
distributionSetManagement, entityFactory, permissionChecker);
final DistributionSetTable distributionSetTable = new DistributionSetTable(eventBus, i18n, uiNotification,
permissionChecker, manageDistUIState, distributionSetManagement, softwareManagement,
distributionsViewClientCriterion, targetManagement, popupLayout);
this.distributionSetTable = new DistributionSetTable(eventBus, i18n, uiNotification, permissionChecker,
manageDistUIState, distributionSetManagement, softwareManagement, distributionsViewClientCriterion,
targetManagement, popupLayout);
final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout = new DistributionAddUpdateWindowLayout(
i18n, uiNotification, eventBus, distributionSetManagement, systemManagement, entityFactory,
@@ -58,4 +60,8 @@ public class DistributionSetTableLayout extends AbstractTableLayout<Distribution
targetManagement, entityFactory, uiNotification, tagManagement, popupLayout));
}
public DistributionSetTable getDistributionSetTable() {
return distributionSetTable;
}
}

View File

@@ -29,11 +29,11 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -61,8 +61,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
private final DistributionsViewClientCriterion distributionsViewClientCriterion;
public DSDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final SystemManagement systemManagement,
public DSDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final UIEventBus eventBus, final UINotification notification, final SystemManagement systemManagement,
final ManageDistUIState manageDistUIState,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final DistributionSetManagement dsManagement, final SoftwareManagement softwareManagement) {
@@ -145,8 +145,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
if (isDsTypeSelected(distTypeName)) {
notification
.displayValidationError(i18n.getMessage("message.dist.type.check.delete", new Object[] { distTypeName }));
notification.displayValidationError(
i18n.getMessage("message.dist.type.check.delete", new Object[] { distTypeName }));
} else if (isDefaultDsType(distTypeName)) {
notification.displayValidationError(i18n.getMessage("message.cannot.delete.default.dstype"));
} else {
@@ -182,7 +182,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
final AbstractTable<?, Long> table = (AbstractTable<?, Long>) sourceTable;
final AbstractTable<?> table = (AbstractTable<?>) sourceTable;
final Set<Long> ids = table.getDeletedEntityByTransferable(transferable);
final List<DistributionSet> findDistributionSetAllById = distributionSetManagement
.findDistributionSetAllById(ids);
@@ -207,8 +207,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addToSWDeleteList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> swTable = (AbstractTable<?, Long>) sourceTable;
final AbstractTable<?> swTable = (AbstractTable<?>) sourceTable;
final Set<Long> swModuleIdNameSet = swTable.getDeletedEntityByTransferable(transferable);
swModuleIdNameSet.forEach(id -> {

View File

@@ -28,12 +28,13 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -93,7 +94,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
protected Map<String, ConfirmationTab> getConfirmationTabs() {
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(5);
/* Create tab for SW Modules delete */
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
@@ -102,7 +103,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Create tab for SW Module Type delete */
if (!manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"),
createSMtypeDeleteConfirmationTab());
}
/* Create tab for Distributions delete */
@@ -112,7 +114,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Create tab for Distribution Set Types delete */
if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(i18n.getMessage("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab());
tabs.put(i18n.getMessage("caption.delete.dist.set.type.accordion.tab"),
createDistSetTypeDeleteConfirmationTab());
}
/* Create tab for Assign Software Module */
@@ -361,18 +364,17 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void deleteDistAll(final ConfirmationTab tab) {
final Long[] deletedIds = manageDistUIState.getDeletedDistributionList().stream().map(idName -> idName.getId())
.toArray(Long[]::new);
if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
if (manageDistUIState.getAssignedList() != null && !manageDistUIState.getAssignedList().isEmpty()) {
manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (manageDistUIState.getAssignedList().containsKey(distSetName)) {
manageDistUIState.getAssignedList().remove(distSetName);
}
});
}
dsManagement.deleteDistributionSet(Lists.newArrayList(deletedIds));
eventBus.publish(this,
new DistributionTableEvent(BaseEntityEventType.REMOVE_ENTITY, Lists.newArrayList(deletedIds)));
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.getMessage("message.dist.deleted", deletedIds.length));
@@ -543,7 +545,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
assignmnetTab.getTable().setVisibleColumns(DIST_NAME, SOFTWARE_MODULE_NAME, DISCARD);
assignmnetTab.getTable().setColumnHeaders(i18n.getMessage("header.dist.first.assignment.table"),
i18n.getMessage("header.dist.second.assignment.table"), i18n.getMessage("header.third.assignment.table"));
i18n.getMessage("header.dist.second.assignment.table"),
i18n.getMessage("header.third.assignment.table"));
assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);

View File

@@ -40,11 +40,6 @@ public class SwModuleDetails extends AbstractSoftwareModuleDetails {
restoreState();
}
@Override
protected boolean onLoadIsTableRowSelected() {
return !manageDistUIState.getSelectedSoftwareModules().isEmpty();
}
@Override
protected boolean onLoadIsTableMaximized() {
return manageDistUIState.isSwModuleTableMaximized();
@@ -57,7 +52,8 @@ public class SwModuleDetails extends AbstractSoftwareModuleDetails {
@Override
protected boolean isSoftwareModuleSelected(final SoftwareModule softwareModule) {
return compareSoftwareModulesById(softwareModule, manageDistUIState.getSelectedBaseSwModuleId().orElse(null));
return compareSoftwareModulesById(softwareModule,
manageDistUIState.getLastSelectedSoftwareModule().orElse(null));
}
}

View File

@@ -18,10 +18,10 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -32,13 +32,14 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.push.SoftwareModuleUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.view.filter.OnlyEventsFromDistributionsViewFilter;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -63,11 +64,10 @@ import com.vaadin.ui.Window;
/**
* Implementation of software module table using generic abstract table styles .
*
*/
public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule> {
private static final long serialVersionUID = 6785314784507424750L;
private static final long serialVersionUID = 1L;
private final ManageDistUIState manageDistUIState;
@@ -89,7 +89,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
this.softwareManagement = softwareManagement;
this.distributionsViewClientCriterion = distributionsViewClientCriterion;
this.artifactDetailsLayout = new ArtifactDetailsLayout(i18n, eventBus, artifactUploadState, uiNotification,
artifactManagement);
artifactManagement, softwareManagement);
this.swMetadataPopupLayout = swMetadataPopupLayout;
addNewContainerDS();
@@ -98,16 +98,11 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
styleTableOnDistSelection();
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SMFilterEvent filterEvent) {
@EventBusListenerMethod(scope = EventScope.UI, filter = OnlyEventsFromDistributionsViewFilter.class)
void onEvent(final RefreshSoftwareModuleByFilterEvent filterEvent) {
UI.getCurrent().access(() -> {
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
refreshFilter();
styleTableOnDistSelection();
}
refreshFilter();
styleTableOnDistSelection();
});
}
@@ -135,19 +130,15 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
@EventBusListenerMethod(scope = EventScope.UI)
void onSoftwareModuleUpdateEvents(final SoftwareModuleUpdatedEventContainer eventContainer) {
@SuppressWarnings("unchecked")
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
handleSelectedAndUpdatedSoftwareModules(eventContainer.getEvents());
eventContainer.getEvents().stream().filter(event -> visibleItemIds.contains(event.getEntityId()))
.forEach(event -> updateSoftwareModuleInTable(event.getEntity()));
}
private void handleSelectedAndUpdatedSoftwareModules(final List<SoftwareModuleUpdatedEvent> events) {
manageDistUIState.getSelectedBaseSwModuleId()
manageDistUIState.getLastSelectedSoftwareModule()
.ifPresent(lastSelectedModuleId -> events.stream()
.filter(event -> lastSelectedModuleId.equals(event.getEntityId())).findAny()
.ifPresent(lastEvent -> eventBus.publish(this,
@@ -178,14 +169,12 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(3);
manageDistUIState.getSoftwareModuleFilters().getSearchText()
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType()
.ifPresent(type -> queryConfig.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type));
manageDistUIState.getLastSelectedDistribution()
.ifPresent(id -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, id));
return queryConfig;
}
@Override
@@ -208,9 +197,9 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.ARTIFACT_ICON, new ColumnGenerator() {
private static final long serialVersionUID = -5982361782989980277L;
private static final long serialVersionUID = 1L;
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
@@ -226,6 +215,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
return iconLayout;
}
});
}
@Override
@@ -235,7 +225,8 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
@Override
protected Object getItemIdToSelect() {
return manageDistUIState.getSelectedSoftwareModules();
return manageDistUIState.getSelectedSoftwareModules().isEmpty() ? null
: manageDistUIState.getSelectedSoftwareModules();
}
@Override
@@ -244,16 +235,18 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}
@Override
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
protected void publishSelectedEntityEvent(final SoftwareModule selectedLastEntity) {
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
if (selectedLastEntity != null) {
manageDistUIState.setSelectedBaseSwModuleId(selectedLastEntity.getId());
}
}
@Override
protected void setManagementEntitiyStateValues(final Set<Long> values, final Long lastId) {
manageDistUIState.setSelectedBaseSwModuleId(lastId);
protected void setLastSelectedEntityId(final Long selectedLastEntityId) {
manageDistUIState.setLastSelectedSoftwareModule(selectedLastEntityId);
}
@Override
protected void setManagementEntityStateValues(final Set<Long> values, final Long lastId) {
manageDistUIState.setLastSelectedSoftwareModule(lastId);
manageDistUIState.setSelectedSoftwareModules(values);
}
@@ -263,7 +256,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}
@Override
protected ManagmentEntityState<Long> getManagmentEntityState() {
protected ManagementEntityState getManagementEntityState() {
return null;
}
@@ -293,8 +286,6 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
return false;
}
/* All Private Methods */
private void styleTableOnDistSelection() {
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getScriptSMHighlightReset());
setCellStyleGenerator(new Table.CellStyleGenerator() {
@@ -305,7 +296,6 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
return createTableStyle(itemId, propertyId);
}
});
}
private static String getTableStyle(final Long typeId, final boolean isAssigned, final String color) {
@@ -379,39 +369,42 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
}
private void showArtifactDetailsWindow(final Long itemId, final String nameVersionStr) {
final Window atrifactDtlsWindow = new Window();
atrifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr));
atrifactDtlsWindow.setCaptionAsHtml(true);
atrifactDtlsWindow.setClosable(true);
atrifactDtlsWindow.setResizable(true);
atrifactDtlsWindow.setImmediate(true);
atrifactDtlsWindow.setWindowMode(WindowMode.NORMAL);
atrifactDtlsWindow.setModal(true);
atrifactDtlsWindow.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
final Window artifactDtlsWindow = new Window();
artifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr));
artifactDtlsWindow.setCaptionAsHtml(true);
artifactDtlsWindow.setClosable(true);
artifactDtlsWindow.setResizable(true);
artifactDtlsWindow.setImmediate(true);
artifactDtlsWindow.setWindowMode(WindowMode.NORMAL);
artifactDtlsWindow.setModal(true);
artifactDtlsWindow.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
artifactDetailsLayout.setFullWindowMode(false);
artifactDetailsLayout.populateArtifactDetails(itemId, nameVersionStr);
/* Now add table to the window */
artifactDetailsLayout.getArtifactDetailsTable().setWidth(700, Unit.PIXELS);
artifactDetailsLayout.getArtifactDetailsTable().setHeight(500, Unit.PIXELS);
atrifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());
artifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());
/* Create maximized view of the table */
atrifactDtlsWindow.addWindowModeChangeListener(event -> {
if (event.getWindowMode() == WindowMode.MAXIMIZED) {
atrifactDtlsWindow.setSizeFull();
artifactDetailsLayout.setFullWindowMode(true);
artifactDetailsLayout.createMaxArtifactDetailsTable();
artifactDetailsLayout.getMaxArtifactDetailsTable().setWidth(100, Unit.PERCENTAGE);
artifactDetailsLayout.getMaxArtifactDetailsTable().setHeight(100, Unit.PERCENTAGE);
atrifactDtlsWindow.setContent(artifactDetailsLayout.getMaxArtifactDetailsTable());
} else {
atrifactDtlsWindow.setSizeUndefined();
atrifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());
}
});
artifactDtlsWindow.addWindowModeChangeListener(
event -> {
if (event.getWindowMode() == WindowMode.MAXIMIZED) {
artifactDtlsWindow.setSizeFull();
artifactDetailsLayout.setFullWindowMode(true);
artifactDetailsLayout.createMaxArtifactDetailsTable();
artifactDetailsLayout.getMaxArtifactDetailsTable().setWidth(100, Unit.PERCENTAGE);
artifactDetailsLayout.getMaxArtifactDetailsTable().setHeight(100, Unit.PERCENTAGE);
artifactDtlsWindow.setContent(artifactDetailsLayout.getMaxArtifactDetailsTable());
} else {
artifactDtlsWindow.setSizeUndefined();
artifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());
}
});
/* display the window */
UI.getCurrent().addWindow(atrifactDtlsWindow);
UI.getCurrent().addWindow(artifactDtlsWindow);
}
@Override

View File

@@ -9,8 +9,8 @@
package org.eclipse.hawkbit.ui.distributions.smtable;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.common.table.AbstractSoftwareModuleTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
@@ -44,50 +44,50 @@ public class SwModuleTableHeader extends AbstractSoftwareModuleTableHeader {
@Override
protected String onLoadSearchBoxValue() {
return manageDistUIstate.getSoftwareModuleFilters().getSearchText().orElse(null);
return getManageDistUIstate().getSoftwareModuleFilters().getSearchText().orElse(null);
}
@Override
protected void showFilterButtonsLayout() {
manageDistUIstate.setSwTypeFilterClosed(false);
getManageDistUIstate().setSwTypeFilterClosed(false);
eventbus.publish(this, DistributionsUIEvent.SHOW_SM_FILTER_BY_TYPE);
}
@Override
protected void resetSearchText() {
if (manageDistUIstate.getSoftwareModuleFilters().getSearchText().isPresent()) {
manageDistUIstate.getSoftwareModuleFilters().setSearchText(null);
eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT);
if (getManageDistUIstate().getSoftwareModuleFilters().getSearchText().isPresent()) {
getManageDistUIstate().getSoftwareModuleFilters().setSearchText(null);
eventbus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
}
@Override
public void maximizeTable() {
manageDistUIstate.setSwModuleTableMaximized(Boolean.TRUE);
getManageDistUIstate().setSwModuleTableMaximized(Boolean.TRUE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED));
}
@Override
public void minimizeTable() {
manageDistUIstate.setSwModuleTableMaximized(Boolean.FALSE);
getManageDistUIstate().setSwModuleTableMaximized(Boolean.FALSE);
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED));
}
@Override
public Boolean onLoadIsTableMaximized() {
return manageDistUIstate.isSwModuleTableMaximized();
return getManageDistUIstate().isSwModuleTableMaximized();
}
@Override
public Boolean onLoadIsShowFilterButtonDisplayed() {
return manageDistUIstate.isSwTypeFilterClosed();
return getManageDistUIstate().isSwTypeFilterClosed();
}
@Override
protected void searchBy(final String newSearchText) {
manageDistUIstate.getSoftwareModuleFilters().setSearchText(newSearchText);
eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT);
getManageDistUIstate().getSoftwareModuleFilters().setSearchText(newSearchText);
eventbus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
}

View File

@@ -17,35 +17,41 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout;
import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
/**
* Implementation of software module Layout
* Implementation of software module Layout on the Distribution View
*/
public class SwModuleTableLayout extends AbstractTableLayout<SwModuleTable> {
private static final long serialVersionUID = 6464291374980641235L;
private static final long serialVersionUID = 1L;
public SwModuleTableLayout(final VaadinMessageSource i18n, final UINotification uiNotification, final UIEventBus eventBus,
final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
private final SwModuleTable swModuleTable;
public SwModuleTableLayout(final VaadinMessageSource i18n, final UINotification uiNotification,
final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory,
final ManageDistUIState manageDistUIState, final SpPermissionChecker permChecker,
final DistributionsViewClientCriterion distributionsViewClientCriterion,
final ArtifactUploadState artifactUploadState, final ArtifactManagement artifactManagement) {
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
uiNotification, eventBus, softwareManagement, entityFactory);
final SwMetadataPopupLayout swMetadataPopupLayout = new SwMetadataPopupLayout(i18n, uiNotification, eventBus,
softwareManagement, entityFactory, permChecker);
this.swModuleTable = new SwModuleTable(eventBus, i18n, uiNotification, manageDistUIState, softwareManagement,
distributionsViewClientCriterion, artifactManagement, swMetadataPopupLayout, artifactUploadState);
final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow = new SoftwareModuleAddUpdateWindow(i18n,
uiNotification, eventBus, softwareManagement, entityFactory, swModuleTable);
super.init(
new SwModuleTableHeader(i18n, permChecker, eventBus, manageDistUIState, softwareModuleAddUpdateWindow),
new SwModuleTable(eventBus, i18n, uiNotification, manageDistUIState, softwareManagement,
distributionsViewClientCriterion, artifactManagement, swMetadataPopupLayout,
artifactUploadState),
new SwModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow, manageDistUIState,
softwareManagement, swMetadataPopupLayout, entityFactory));
swModuleTable, new SwModuleDetails(i18n, eventBus, permChecker, softwareModuleAddUpdateWindow,
manageDistUIState, softwareManagement, swMetadataPopupLayout, entityFactory));
}
public SwModuleTable getSwModuleTable() {
return swModuleTable;
}
}

View File

@@ -8,10 +8,8 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtype;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.RefreshSoftwareModuleByFilterEvent;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.vaadin.spring.events.EventBus;
@@ -22,7 +20,7 @@ import com.vaadin.ui.Button;
/**
* Single button click behaviour of filter buttons layout.
*/
public class DistSMTypeFilterButtonClick extends AbstractFilterSingleButtonClick implements Serializable {
public class DistSMTypeFilterButtonClick extends AbstractFilterSingleButtonClick {
private static final long serialVersionUID = -4166632002904286983L;
@@ -42,14 +40,14 @@ public class DistSMTypeFilterButtonClick extends AbstractFilterSingleButtonClick
@Override
protected void filterUnClicked(final Button clickedButton) {
manageDistUIState.getSoftwareModuleFilters().setSoftwareModuleType(null);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
eventBus.publish(this, new RefreshSoftwareModuleByFilterEvent());
}
@Override
protected void filterClicked(final Button clickedButton) {
softwareManagement.findSoftwareModuleTypeByName(clickedButton.getData().toString()).ifPresent(smType -> {
manageDistUIState.getSoftwareModuleFilters().setSoftwareModuleType(smType);
eventBus.publish(this, SMFilterEvent.FILTER_BY_TYPE);
eventBus.publish(this, new RefreshSoftwareModuleByFilterEvent());
});
}

View File

@@ -8,16 +8,15 @@
*/
package org.eclipse.hawkbit.ui.distributions.state;
import static java.util.Collections.emptySet;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.SoftwareModuleIdName;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,14 +26,12 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
/**
* Manage Distributions user state.
*
*
*/
@SpringComponent
@VaadinSessionScope
public class ManageDistUIState implements ManagmentEntityState<Long>, Serializable {
public class ManageDistUIState implements ManagementEntityState, Serializable {
private static final long serialVersionUID = -7569047247017742928L;
private static final long serialVersionUID = 1L;
private final ManageDistFilters manageDistFilters;
@@ -46,16 +43,16 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
private Set<Long> selectedDistributions = new HashSet<>();
private Long lastSelectedDistribution;
private transient Optional<Long> lastSelectedDistribution = Optional.empty();
private Set<Long> selectedSoftwareModules = emptySet();
private transient Optional<Long> lastSelectedSoftwareModule = Optional.empty();
private Set<Long> selectedSoftwareModules = Collections.emptySet();
private final Set<String> selectedDeleteDistSetTypes = new HashSet<>();
private Set<String> selectedDeleteSWModuleTypes = new HashSet<>();
private Long selectedBaseSwModuleId;
private boolean distTypeFilterClosed;
private boolean swTypeFilterClosed;
@@ -81,16 +78,10 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
this.softwareModuleFilters = softwareModuleFilters;
}
/**
* @return the manageDistFilters
*/
public ManageDistFilters getManageDistFilters() {
return manageDistFilters;
}
/**
* @return the deletedDistributionList
*/
public Set<DistributionSetIdName> getDeletedDistributionList() {
return deletedDistributionList;
}
@@ -104,23 +95,17 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
return assignedList;
}
/**
* @return the slectedDistributions
*/
public Optional<Set<Long>> getSelectedDistributions() {
return Optional.ofNullable(selectedDistributions);
public Set<Long> getSelectedDistributions() {
return selectedDistributions;
}
/**
* @return the lastSelectedDistribution
*/
public Optional<Long> getLastSelectedDistribution() {
return Optional.ofNullable(lastSelectedDistribution);
return lastSelectedDistribution;
}
@Override
public void setLastSelectedEntity(final Long value) {
this.lastSelectedDistribution = value;
public void setLastSelectedEntityId(final Long value) {
this.lastSelectedDistribution = Optional.ofNullable(value);
}
@Override
@@ -128,76 +113,42 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
selectedDistributions = values;
}
/**
* @return the softwareModuleFilters
*/
public ManageSoftwareModuleFilters getSoftwareModuleFilters() {
return softwareModuleFilters;
}
/**
* @return the selectedSoftwareModules
*/
public Optional<Long> getLastSelectedSoftwareModule() {
return lastSelectedSoftwareModule;
}
public void setLastSelectedSoftwareModule(final Long value) {
this.lastSelectedSoftwareModule = Optional.ofNullable(value);
}
public Set<Long> getSelectedSoftwareModules() {
return selectedSoftwareModules;
}
/**
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return Optional.ofNullable(selectedBaseSwModuleId);
}
/**
* @param selectedBaseSwModuleId
* the selectedBaseSwModuleId to set
*/
public void setSelectedBaseSwModuleId(final Long selectedBaseSwModuleId) {
this.selectedBaseSwModuleId = selectedBaseSwModuleId;
}
/**
* @param selectedSoftwareModules
* the selectedSoftwareModules to set
*/
public void setSelectedSoftwareModules(final Set<Long> selectedSoftwareModules) {
this.selectedSoftwareModules = selectedSoftwareModules;
}
/**
* @return the distTypeFilterClosed
*/
public boolean isDistTypeFilterClosed() {
return distTypeFilterClosed;
}
/**
* @param distTypeFilterClosed
* the distTypeFilterClosed to set
*/
public void setDistTypeFilterClosed(final boolean distTypeFilterClosed) {
this.distTypeFilterClosed = distTypeFilterClosed;
}
/**
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return swTypeFilterClosed;
}
/**
* @param swTypeFilterClosed
* the swTypeFilterClosed to set
*/
public void setSwTypeFilterClosed(final boolean swTypeFilterClosed) {
this.swTypeFilterClosed = swTypeFilterClosed;
}
/**
* @return the deleteSofwareModulesList
*/
public Map<Long, String> getDeleteSofwareModulesList() {
return deleteSofwareModulesList;
}
@@ -214,20 +165,10 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
this.selectedDeleteSWModuleTypes = selectedDeleteSWModuleTypes;
}
/**
* Get isSwModuleTableMaximized.
*
* @return boolean
*/
public boolean isDsTableMaximized() {
return dsTableMaximized;
}
/***
* Set isDsModuleTableMaximized.
*
* @param dsModuleTableMaximized
*/
public void setDsTableMaximized(final boolean dsModuleTableMaximized) {
dsTableMaximized = dsModuleTableMaximized;
}
@@ -236,56 +177,30 @@ public class ManageDistUIState implements ManagmentEntityState<Long>, Serializab
return assignedSoftwareModuleDetails;
}
/**
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return swModuleTableMaximized;
}
/**
* @param swModuleTableMaximized
* the isSwModuleTableMaximized to set
*/
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
this.swModuleTableMaximized = swModuleTableMaximized;
}
/**
* @return the noDataAvilableSwModule
*/
public boolean isNoDataAvilableSwModule() {
return noDataAvilableSwModule;
}
/**
* @param noDataAvilableSwModule
* the noDataAvilableSwModule to set
*/
public void setNoDataAvilableSwModule(final boolean noDataAvilableSwModule) {
this.noDataAvilableSwModule = noDataAvilableSwModule;
}
/**
* @return the noDataAvailableDist
*/
public boolean isNoDataAvailableDist() {
return noDataAvailableDist;
}
/**
* @param noDataAvailableDist
* the isNoDataAvailableDist to set
*/
public void setNoDataAvailableDist(final boolean noDataAvailableDist) {
this.noDataAvailableDist = noDataAvailableDist;
}
/**
* Need HashSet because the Set have to be serializable
*
* @return map
*/
public Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
return consolidatedDistSoftwarewList;
}

View File

@@ -17,11 +17,11 @@ import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.ui.distributions.dstable.ManageDistBeanQuery;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -46,7 +46,8 @@ public class DistributionSetSelectTable extends Table {
private Container container;
DistributionSetSelectTable(final VaadinMessageSource i18n, final UIEventBus eventBus, final ManageDistUIState manageDistUIState) {
DistributionSetSelectTable(final VaadinMessageSource i18n, final UIEventBus eventBus,
final ManageDistUIState manageDistUIState) {
this.i18n = i18n;
this.manageDistUIState = manageDistUIState;
setStyleName("sp-table");
@@ -139,7 +140,8 @@ public class DistributionSetSelectTable extends Table {
}
private Object getItemIdToSelect() {
return manageDistUIState.getSelectedDistributions().orElse(null);
return manageDistUIState.getSelectedDistributions().isEmpty() ? null
: manageDistUIState.getSelectedDistributions();
}
private void selectRow() {

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.layouts;
import java.util.Objects;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.builder.TagUpdate;
@@ -34,10 +33,10 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.DistributionSetTagTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -209,10 +208,10 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC)
.prompt(i18n.getMessage("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_DESC)
.buildTextComponent();
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_TARGET_TAG_DESC).buildTextComponent();
tagDesc.setNullRepresentation(StringUtils.EMPTY);
tagDesc.setNullRepresentation("");
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", null, null, false, "",
i18n.getMessage("label.combobox.tag"));
@@ -609,8 +608,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
private boolean isDuplicateByName() {
final Optional<E> existingType = findEntityByName();
existingType.ifPresent(type -> uiNotification
.displayValidationError(i18n.getMessage("message.tag.duplicate.check", new Object[] { type.getName() })));
existingType.ifPresent(type -> uiNotification.displayValidationError(
i18n.getMessage("message.tag.duplicate.check", new Object[] { type.getName() })));
return existingType.isPresent();
}

View File

@@ -56,9 +56,9 @@ import org.eclipse.hawkbit.ui.push.TargetDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer;
import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -66,6 +66,7 @@ import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Maps;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener;
@@ -82,8 +83,9 @@ import com.vaadin.ui.UI;
@SpringView(name = DeploymentView.VIEW_NAME, ui = HawkbitUI.class)
public class DeploymentView extends AbstractNotificationView implements BrowserWindowResizeListener {
private static final long serialVersionUID = 1L;
public static final String VIEW_NAME = "deployment";
private static final long serialVersionUID = 1847434723456644998L;
private final SpPermissionChecker permChecker;
@@ -172,6 +174,11 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW
getEventBus().publish(this, ManagementUIEvent.SHOW_COUNT_MESSAGE);
}
@Override
public void enter(final ViewChangeEvent event) {
distributionTableLayout.getDistributionTable().selectEntity(managementUIState.getLastSelectedDsIdName());
}
@Override
protected DashboardMenuItem getDashboardMenuItem() {
return deploymentViewMenuItem;

View File

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.ui.management.actionhistory;
import java.util.Optional;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
@@ -71,11 +73,12 @@ public class ActionHistoryLayout extends AbstractGridComponentLayout {
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final TargetTableEvent targetUIEvent) {
final Optional<Long> targetId = managementUIState.getLastSelectedTargetId();
if (BaseEntityEventType.SELECTED_ENTITY == targetUIEvent.getEventType()) {
setData(SPUIDefinitions.DATA_AVAILABLE);
UI.getCurrent().access(() -> populateActionHistoryDetails(targetUIEvent.getEntity()));
} else if (BaseEntityEventType.REMOVE_ENTITY == targetUIEvent.getEventType()
&& targetUIEvent.getEntityIds().contains(managementUIState.getLastSelectedTargetId())) {
} else if (BaseEntityEventType.REMOVE_ENTITY == targetUIEvent.getEventType() && targetId.isPresent()
&& targetUIEvent.getEntityIds().contains(targetId.get())) {
setData(SPUIDefinitions.NO_DATA);
UI.getCurrent().access(this::populateActionHistoryDetails);
}

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstable;
import java.util.Collections;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SystemManagement;
@@ -30,12 +29,12 @@ 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.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -169,10 +168,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
.description(desc).type(distributionSetType).requiredMigrationStep(isMigStepReq));
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.ADD_ENTITY, newDist));
notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success",
new Object[] { newDist.getName(), newDist.getVersion() }));
distributionSetTable.setValue(Sets.newHashSet(newDist.getId()));
}
@@ -226,16 +223,16 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME);
distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null, "",
false, "", i18n.getMessage("label.combobox.type"));
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null,
"", false, "", i18n.getMessage("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC)
.buildTextComponent();
descTextArea.setNullRepresentation(StringUtils.EMPTY);
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent();
descTextArea.setNullRepresentation("");
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"),
"dist-checkbox-style", null, false, "");
@@ -246,7 +243,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
private TextField createTextField(final String in18Key, final String id) {
final TextField buildTextField = new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true)
.prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent();
buildTextField.setNullRepresentation(StringUtils.EMPTY);
buildTextField.setNullRepresentation("");
return buildTextField;
}
@@ -323,8 +320,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
populateDistSetTypeNameCombo();
populateValuesOfDistribution(editDistId);
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.getMessage(UIComponentIdProvider.DIST_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n)
.saveDialogCloseListener(new SaveOnCloseDialogListener()).buildCommonDialogWindow();
.caption(i18n.getMessage(UIComponentIdProvider.DIST_ADD_CAPTION)).content(this).layout(formLayout)
.i18n(i18n).saveDialogCloseListener(new SaveOnCloseDialogListener()).buildCommonDialogWindow();
}
/**

View File

@@ -8,8 +8,6 @@
*/
package org.eclipse.hawkbit.ui.management.dstable;
import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
@@ -46,11 +44,6 @@ public class DistributionDetails extends AbstractDistributionSetDetails {
return new SoftwareModuleDetailsTable(i18n, false, permissionChecker, null, null, null, uiNotification);
}
@Override
protected boolean onLoadIsTableRowSelected() {
return getManagementUIState().getSelectedDsIdName().map(Set::isEmpty).orElse(true);
}
@Override
protected boolean onLoadIsTableMaximized() {
return getManagementUIState().isDsTableMaximized();

View File

@@ -17,7 +17,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
@@ -35,10 +34,9 @@ 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.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.event.RefreshDistributionTableByFilterEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer;
@@ -50,6 +48,7 @@ import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.view.filter.OnlyEventsFromDeploymentViewFilter;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -71,23 +70,31 @@ import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
/**
* Distribution set table.
* Distribution set table which is shown on the Deployment View.
*/
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet, Long> {
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet> {
private static final long serialVersionUID = -1928335256399519494L;
private static final long serialVersionUID = 1L;
private final SpPermissionChecker permissionChecker;
private final ManagementUIState managementUIState;
private final ManagementViewClientCriterion managementViewClientCriterion;
private final transient TargetManagement targetManagement;
private final DsMetadataPopupLayout dsMetadataPopupLayout;
private final transient DistributionSetManagement distributionSetManagement;
private final transient DeploymentManagement deploymentManagement;
private final String notAllowedMsg;
private boolean isDistPinned;
private Button distributinPinnedBtn;
private boolean distPinned;
private Button distributionPinnedBtn;
DistributionTable(final UIEventBus eventBus, final VaadinMessageSource i18n,
final SpPermissionChecker permissionChecker, final UINotification notification,
@@ -153,7 +160,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
refreshContainer();
if (setsThatAreVisibleButNotCompleteAnymore.stream()
.anyMatch(id -> id.equals(managementUIState.getLastSelectedDsIdName()))) {
managementUIState.setLastSelectedEntity(null);
managementUIState.setLastSelectedEntityId(null);
}
return true;
@@ -165,16 +172,12 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
/**
* DistributionTableFilterEvent.
*
* @param event
* as instance of {@link DistributionTableFilterEvent}
* @param filterEvent
* as instance of {@link RefreshDistributionTableByFilterEvent}
*/
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final DistributionTableFilterEvent event) {
if (event == DistributionTableFilterEvent.FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT
|| event == DistributionTableFilterEvent.FILTER_BY_TAG) {
UI.getCurrent().access(this::refreshFilter);
}
@EventBusListenerMethod(scope = EventScope.UI, filter = OnlyEventsFromDeploymentViewFilter.class)
void onEvent(final RefreshDistributionTableByFilterEvent filterEvent) {
UI.getCurrent().access(this::refreshFilter);
}
@EventBusListenerMethod(scope = EventScope.UI)
@@ -184,7 +187,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
return;
}
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
}
@EventBusListenerMethod(scope = EventScope.UI)
@@ -194,8 +196,8 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
refreshFilter();
styleDistributionTableOnPinning();
// unstyleDistPin
if (distributinPinnedBtn != null) {
distributinPinnedBtn.setStyleName(getPinStyle());
if (distributionPinnedBtn != null) {
distributionPinnedBtn.setStyleName(getPinStyle());
}
} else if (pinUnpinEvent == PinUnpinEvent.UNPIN_TARGET) {
refreshFilter();
@@ -204,13 +206,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
});
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.DELETED_DISTRIBUTIONS) {
refreshFilter();
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final ManagementUIEvent managementUIEvent) {
UI.getCurrent().access(() -> {
@@ -273,7 +268,6 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
iconLayout.addComponent(manageMetaDataBtn);
return iconLayout;
}
});
}
@@ -296,12 +290,12 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
@Override
protected boolean isFirstRowSelectedOnLoad() {
return managementUIState.getSelectedDsIdName().map(Set::isEmpty).orElse(true);
return managementUIState.getSelectedDsIdName().isEmpty();
}
@Override
protected Object getItemIdToSelect() {
return managementUIState.getSelectedDsIdName().orElse(null);
return managementUIState.getSelectedDsIdName().isEmpty() ? null : managementUIState.getSelectedDsIdName();
}
@Override
@@ -310,15 +304,12 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
}
@Override
protected void publishEntityAfterValueChange(final DistributionSet selectedLastEntity) {
protected void publishSelectedEntityEvent(final DistributionSet selectedLastEntity) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
if (selectedLastEntity != null) {
managementUIState.setLastSelectedEntity(selectedLastEntity.getId());
}
}
@Override
protected ManagementUIState getManagmentEntityState() {
protected ManagementUIState getManagementEntityState() {
return managementUIState;
}
@@ -333,7 +324,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
if (isMaximized()) {
return columnList;
}
columnList.add(new TableColumn(SPUILabelDefinitions.PIN_COLUMN, StringUtils.EMPTY, 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.PIN_COLUMN, "", 0.2F));
return columnList;
}
@@ -460,7 +451,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
return false;
}
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
private boolean isNoTagButton(final String tagData, final String targetNoTagData) {
if (tagData.equals(targetNoTagData)) {
notification.displayValidationError(i18n.getMessage("message.tag.cannot.be.assigned",
new Object[] { i18n.getMessage("label.no.tag.assigned") }));
@@ -530,12 +521,10 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
managementUIState.getDistributionTableFilters().getPinnedTarget().map(TargetIdName::getControllerId)
.ifPresent(controllerId -> {
final Long installedDistId = deploymentManagement.getInstalledDistributionSet(controllerId)
.map(DistributionSet::getId).orElse(null);
final Long assignedDistId = deploymentManagement.getAssignedDistributionSet(controllerId)
.map(DistributionSet::getId).orElse(null);
styleDistributionSetTable(installedDistId, assignedDistId);
});
}
@@ -574,13 +563,13 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
final Long pinnedId = ((DistributionSetIdName) pinBtn.getData()).getId();
if (managementUIState.getTargetTableFilters().getPinnedDistId().map(pinnedId::equals).orElse(false)) {
setDistributinPinnedBtn(pinBtn);
setDistributionPinnedBtn(pinBtn);
}
}
private void addPinClickListener(final ClickEvent event) {
checkifAlreadyPinned(event.getButton());
if (isDistPinned) {
if (distPinned) {
pinDitribution(event.getButton());
} else {
unPinDistribution(event.getButton());
@@ -593,17 +582,17 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
final Long pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().orElse(null);
if (pinnedDistId == null) {
isDistPinned = !isDistPinned;
distPinned = !distPinned;
managementUIState.getTargetTableFilters().setPinnedDistId(newPinnedDistItemId);
} else if (newPinnedDistItemId.equals(pinnedDistId)) {
isDistPinned = false;
distPinned = false;
} else {
isDistPinned = true;
distPinned = true;
managementUIState.getTargetTableFilters().setPinnedDistId(newPinnedDistItemId);
distributinPinnedBtn.setStyleName(getPinStyle());
distributionPinnedBtn.setStyleName(getPinStyle());
}
distributinPinnedBtn = eventBtn;
distributionPinnedBtn = eventBtn;
}
private void unPinDistribution(final Button eventBtn) {
@@ -624,14 +613,14 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
eventBus.publish(this, PinUnpinEvent.PIN_DISTRIBUTION);
applyPinStyle(eventBtn);
styleDistributionSetTable();
isDistPinned = Boolean.FALSE;
distPinned = false;
}
private void rePinDistribution(final Button pinBtn, final Long distID) {
if (managementUIState.getTargetTableFilters().getPinnedDistId().map(distID::equals).orElse(false)) {
applyPinStyle(pinBtn);
isDistPinned = Boolean.TRUE;
distributinPinnedBtn = pinBtn;
distPinned = true;
distributionPinnedBtn = pinBtn;
eventBus.publish(this, PinUnpinEvent.PIN_DISTRIBUTION);
}
}
@@ -703,8 +692,8 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
assignedDistTableItemId, itemId));
}
public void setDistributinPinnedBtn(final Button distributinPinnedBtn) {
this.distributinPinnedBtn = distributinPinnedBtn;
public void setDistributionPinnedBtn(final Button distributionPinnedBtn) {
this.distributionPinnedBtn = distributionPinnedBtn;
}
@Override

View File

@@ -12,7 +12,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractDistributionSetTableHeader;
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.RefreshDistributionTableByFilterEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -46,49 +46,49 @@ public class DistributionTableHeader extends AbstractDistributionSetTableHeader
@Override
protected String onLoadSearchBoxValue() {
return managementUIState.getDistributionTableFilters().getSearchText().orElse(null);
return getManagementUIState().getDistributionTableFilters().getSearchText().orElse(null);
}
@Override
protected void showFilterButtonsLayout() {
managementUIState.setDistTagFilterClosed(false);
getManagementUIState().setDistTagFilterClosed(false);
eventbus.publish(this, ManagementUIEvent.SHOW_DISTRIBUTION_TAG_LAYOUT);
}
@Override
protected void resetSearchText() {
if (managementUIState.getDistributionTableFilters().getSearchText().isPresent()) {
managementUIState.getDistributionTableFilters().setSearchText(null);
eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT);
if (getManagementUIState().getDistributionTableFilters().getSearchText().isPresent()) {
getManagementUIState().getDistributionTableFilters().setSearchText(null);
eventbus.publish(this, new RefreshDistributionTableByFilterEvent());
}
}
@Override
public void maximizeTable() {
managementUIState.setDsTableMaximized(Boolean.TRUE);
getManagementUIState().setDsTableMaximized(Boolean.TRUE);
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED));
}
@Override
public void minimizeTable() {
managementUIState.setDsTableMaximized(Boolean.FALSE);
getManagementUIState().setDsTableMaximized(Boolean.FALSE);
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED));
}
@Override
public Boolean onLoadIsTableMaximized() {
return managementUIState.isDsTableMaximized();
return getManagementUIState().isDsTableMaximized();
}
@Override
public Boolean onLoadIsShowFilterButtonDisplayed() {
return managementUIState.isDistTagFilterClosed();
return getManagementUIState().isDistTagFilterClosed();
}
@Override
protected void searchBy(final String newSearchText) {
managementUIState.getDistributionTableFilters().setSearchText(newSearchText);
eventbus.publish(this, DistributionTableFilterEvent.FILTER_BY_TEXT);
getManagementUIState().getDistributionTableFilters().setSearchText(newSearchText);
eventbus.publish(this, new RefreshDistributionTableByFilterEvent());
}
@Override

View File

@@ -19,16 +19,18 @@ 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.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
/**
* Software module table layout.
* Distribution Set table layout which is shown on the Distribution View
*/
public class DistributionTableLayout extends AbstractTableLayout<DistributionTable> {
private static final long serialVersionUID = 6464291374980641235L;
private static final long serialVersionUID = 1L;
private final DistributionTable distributionTable;
public DistributionTableLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState,
@@ -44,8 +46,8 @@ public class DistributionTableLayout extends AbstractTableLayout<DistributionTab
final DsMetadataPopupLayout dsMetadataPopupLayout = new DsMetadataPopupLayout(i18n, notification, eventBus,
distributionSetManagement, entityFactory, permissionChecker);
final DistributionTable distributionTable = new DistributionTable(eventBus, i18n, permissionChecker,
notification, managementUIState, managementViewClientCriterion, targetManagement, dsMetadataPopupLayout,
this.distributionTable = new DistributionTable(eventBus, i18n, permissionChecker, notification,
managementUIState, managementViewClientCriterion, targetManagement, dsMetadataPopupLayout,
distributionSetManagement, deploymentManagement);
super.init(new DistributionTableHeader(i18n, permissionChecker, eventBus, managementUIState), distributionTable,
@@ -54,4 +56,8 @@ public class DistributionTableLayout extends AbstractTableLayout<DistributionTab
distributionAddUpdateWindowLayout));
}
public DistributionTable getDistributionTable() {
return distributionTable;
}
}

View File

@@ -9,7 +9,7 @@
package org.eclipse.hawkbit.ui.management.dstag;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterMultiButtonClick;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.RefreshDistributionTableByFilterEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.vaadin.spring.events.EventBus;
@@ -18,13 +18,15 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.ui.Button;
/**
*
*
* Abstract class for button click behavior of the distribution set's tag
* buttons. Filters the distribution sets according to the active tags.
*/
public class DistributionTagButtonClick extends AbstractFilterMultiButtonClick {
private static final long serialVersionUID = 4120296456125178019L;
private static final long serialVersionUID = 1L;
private final transient EventBus.UIEventBus eventBus;
private final ManagementUIState managementUIState;
DistributionTagButtonClick(final UIEventBus eventBus, final ManagementUIState managementUIState) {
@@ -39,7 +41,7 @@ public class DistributionTagButtonClick extends AbstractFilterMultiButtonClick {
} else {
managementUIState.getDistributionTableFilters().getDistSetTags().remove(clickedButton.getId());
}
eventBus.publish(this, DistributionTableFilterEvent.FILTER_BY_TAG);
eventBus.publish(this, new RefreshDistributionTableByFilterEvent());
}
@Override
@@ -49,8 +51,7 @@ public class DistributionTagButtonClick extends AbstractFilterMultiButtonClick {
} else {
managementUIState.getDistributionTableFilters().getDistSetTags().add(clickedButton.getId());
}
eventBus.publish(this, DistributionTableFilterEvent.FILTER_BY_TAG);
eventBus.publish(this, new RefreshDistributionTableByFilterEvent());
}
}

View File

@@ -22,11 +22,11 @@ import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -35,16 +35,19 @@ import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler;
/**
*
*
* Class for defining the tag buttons of the distribution sets on the Deployment
* View.
*/
public class DistributionTagButtons extends AbstractFilterButtons implements RefreshableContainer {
private static final String NO_TAG = "NO TAG";
private static final long serialVersionUID = 1L;
private static final String NO_TAG = "NO TAG";
private final DistributionTagDropEvent spDistTagDropEvent;
private final ManagementUIState managementUIState;
private final transient EntityFactory entityFactory;
DistributionTagButtons(final UIEventBus eventBus, final ManagementUIState managementUIState,
@@ -71,7 +74,6 @@ public class DistributionTagButtons extends AbstractFilterButtons implements Ref
final BeanQueryFactory<DistributionTagBeanQuery> tagQF = new BeanQueryFactory<>(DistributionTagBeanQuery.class);
tagQF.setQueryConfiguration(Collections.emptyMap());
return HawkbitCommonUtil.createDSLazyQueryContainer(new BeanQueryFactory<>(DistributionTagBeanQuery.class));
}
@Override

View File

@@ -18,11 +18,11 @@ 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.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -85,8 +85,8 @@ public class DistributionTagDropEvent implements DropHandler {
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString();
if (tagName.equals(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON)) {
notification.displayValidationError(
i18n.getMessage("message.tag.cannot.be.assigned", new Object[] { i18n.getMessage("label.no.tag.assigned") }));
notification.displayValidationError(i18n.getMessage("message.tag.cannot.be.assigned",
new Object[] { i18n.getMessage("label.no.tag.assigned") }));
return false;
}
return true;
@@ -131,8 +131,7 @@ public class DistributionTagDropEvent implements DropHandler {
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final AbstractTable<?> source = (AbstractTable<?>) transferable.getSourceComponent();
final Set<Long> distSelected = source.getDeletedEntityByTransferable(transferable);

View File

@@ -8,10 +8,13 @@
*/
package org.eclipse.hawkbit.ui.management.event;
import org.eclipse.hawkbit.ui.common.table.BaseUIEvent;
/**
*
*
* Distribution Set Filter Event. Is published when there is a filter action on
* a distribution set table on the Deployment or Distribution View. It is
* possible to filter by text or tag.
*/
public enum DistributionTableFilterEvent {
FILTER_BY_TEXT, FILTER_BY_TAG, REMOVE_FILTER_BY_TEXT, REMOVE_FILTER_BY_TAG
public class RefreshDistributionTableByFilterEvent extends BaseUIEvent {
}

View File

@@ -9,12 +9,11 @@
package org.eclipse.hawkbit.ui.management.event;
/**
*
*
*
* Enum for events of type SaveAction which are thrown when pending actions are
* performed
*/
public enum SaveActionWindowEvent {
SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DELETED_DISTRIBUTIONS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS
SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS
}

View File

@@ -38,10 +38,10 @@ import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -56,12 +56,11 @@ import com.vaadin.ui.Table.TableTransferable;
import com.vaadin.ui.UI;
/**
*
*
* Layout for the action button footer on the Deployment View.
*/
public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -8112907467821886253L;
private static final long serialVersionUID = 1L;
private final transient TagManagement tagManagementService;
@@ -77,8 +76,8 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private final transient DistributionSetManagement distributionSetManagement;
public DeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus,
final UINotification notification, final TagManagement tagManagementService,
public DeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker,
final UIEventBus eventBus, final UINotification notification, final TagManagement tagManagementService,
final ManagementViewClientCriterion managementViewClientCriterion,
final ManagementUIState managementUIState, final TargetManagement targetManagement,
final TargetTable targetTable, final DeploymentManagement deploymentManagement,
@@ -122,9 +121,9 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final BulkUploadPopupEvent event) {
if (BulkUploadPopupEvent.MINIMIZED == event) {
UI.getCurrent().access(() -> enableBulkUploadStatusButton());
UI.getCurrent().access(this::enableBulkUploadStatusButton);
} else if (BulkUploadPopupEvent.CLOSED == event) {
UI.getCurrent().access(() -> hideBulkUploadStatusButton());
UI.getCurrent().access(this::hideBulkUploadStatusButton);
}
}
@@ -137,9 +136,9 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
.getBulkUpload().getFailedUploadCount()
+ managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount()));
} else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) {
this.getUI().access(() -> updateUploadBtnIconToComplete());
this.getUI().access(this::updateUploadBtnIconToComplete);
} else if (TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED == event.getTargetComponentEvent()) {
this.getUI().access(() -> updateUploadBtnIconToProgressIndicator());
this.getUI().access(this::updateUploadBtnIconToProgressIndicator);
}
}
}
@@ -274,8 +273,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> distTable = (AbstractTable<?, Long>) sourceTable;
final AbstractTable<?> distTable = (AbstractTable<?>) sourceTable;
final Set<Long> ids = distTable.getDeletedEntityByTransferable(transferable);
final Long dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload().getDsNameAndVersion();
@@ -345,7 +343,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final TargetTable targetTable = (TargetTable) sourceTable;
final Set<Long> targetIdSet = targetTable.getDeletedEntityByTransferable(transferable);
final Collection<Target> findTargetAllById = targetManagement.findTargetAllById(targetIdSet);

View File

@@ -37,10 +37,10 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Maps;
@@ -51,13 +51,12 @@ import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
/**
* Confirmation window for target/ds delete and assignment.
*
*
* Confirmation window for target/distributionSet delete and assignment
* operations on the Deployment View.
*/
public class ManangementConfirmationWindowLayout extends AbstractConfirmationWindowLayout {
private static final long serialVersionUID = 2114943830055679554L;
private static final long serialVersionUID = 1L;
private static final String DISCARD_CHANGES = "DiscardChanges";
@@ -79,7 +78,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
private final ActionTypeOptionGroupLayout actionTypeOptionGroupLayout;
private ConfirmationTab assignmnetTab;
private ConfirmationTab assignmentTab;
public ManangementConfirmationWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus,
final ManagementUIState managementUIState, final TargetManagement targetManagement,
@@ -94,7 +93,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
protected Map<String, ConfirmationTab> getConfirmationTabs() {
final Map<String, ConfirmationTab> tabs = Maps.newHashMapWithExpectedSize(3);
if (!managementUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(i18n.getMessage("caption.delete.dist.accordion.tab"), createDeletedDistributionTab());
@@ -105,42 +104,41 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
if (!managementUIState.getAssignedList().isEmpty()) {
tabs.put(i18n.getMessage("caption.assign.dist.accordion.tab"), createAssignmentTab());
}
return tabs;
}
private ConfirmationTab createAssignmentTab() {
assignmnetTab = new ConfirmationTab();
assignmnetTab.getConfirmAll().setId(UIComponentIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.getMessage("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
assignmentTab = new ConfirmationTab();
assignmentTab.getConfirmAll().setId(UIComponentIdProvider.SAVE_ASSIGNMENT);
assignmentTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmentTab.getConfirmAll().setCaption(i18n.getMessage("button.assign.all"));
assignmentTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmentTab));
assignmnetTab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllAssignments(assignmnetTab));
assignmentTab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmentTab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_ASSIGNMENT);
assignmentTab.getDiscardAll().addClickListener(event -> discardAllAssignments(assignmentTab));
// Add items container to the table.
assignmnetTab.getTable().setContainerDataSource(getAssignmentsTableContainer());
assignmentTab.getTable().setContainerDataSource(getAssignmentsTableContainer());
// Add the discard action column
assignmnetTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final ClickListener clickListener = event -> discardAssignment((TargetIdName) itemId, assignmnetTab);
assignmentTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final ClickListener clickListener = event -> discardAssignment((TargetIdName) itemId, assignmentTab);
return createDiscardButton(itemId, clickListener);
});
assignmnetTab.getTable().setColumnExpandRatio(TARGET_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISCARD_CHANGES, 1);
assignmnetTab.getTable().setVisibleColumns(TARGET_NAME, DISTRIBUTION_NAME, DISCARD_CHANGES);
assignmnetTab.getTable().setColumnHeaders(i18n.getMessage("header.first.assignment.table"),
assignmentTab.getTable().setColumnExpandRatio(TARGET_NAME, 2);
assignmentTab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, 2);
assignmentTab.getTable().setColumnExpandRatio(DISCARD_CHANGES, 1);
assignmentTab.getTable().setVisibleColumns(TARGET_NAME, DISTRIBUTION_NAME, DISCARD_CHANGES);
assignmentTab.getTable().setColumnHeaders(i18n.getMessage("header.first.assignment.table"),
i18n.getMessage("header.second.assignment.table"), i18n.getMessage("header.third.assignment.table"));
assignmnetTab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER);
assignmentTab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER);
actionTypeOptionGroupLayout.selectDefaultOption();
assignmnetTab.addComponent(actionTypeOptionGroupLayout, 1);
return assignmnetTab;
assignmentTab.addComponent(actionTypeOptionGroupLayout, 1);
return assignmentTab;
}
@@ -372,7 +370,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
private void deleteAllDistributions(final ConfirmationTab tab) {
final Collection<Long> deletedIds = managementUIState.getDeletedDistributionList().stream()
.map(DistributionSetIdName::getId).collect(Collectors.toList());
@@ -388,9 +385,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
managementUIState.getTargetTableFilters().getPinnedDistId()
.ifPresent(distId -> unPinDeletedDS(deletedIds, distId));
managementUIState.getDeletedDistributionList().clear();
}
private void unPinDeletedTarget(final TargetIdName pinnedTarget) {
@@ -426,7 +421,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
private void removeFromAssignmentTab(final Entry<TargetIdName, DistributionSetIdName> entry,
final DistributionSetIdName value) {
if (Objects.equals(entry.getValue(), value)) {
assignmnetTab.getTable().removeItem(entry.getKey().getTargetId());
assignmentTab.getTable().removeItem(entry.getKey().getTargetId());
}
}
@@ -454,7 +449,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_TARGET);
}
}
private void discardAllTargets(final ConfirmationTab tab) {
@@ -482,14 +476,13 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
managementUIState.getDistributionTableFilters().getPinnedTarget().ifPresent(this::unPinDeletedTarget);
eventBus.publish(this, SaveActionWindowEvent.SHOW_HIDE_TAB);
managementUIState.getDeletedTargetList().clear();
}
private void removeDeletedTargetsFromAssignmentTab() {
for (final TargetIdName targetNameId : managementUIState.getDeletedTargetList()) {
if (managementUIState.getAssignedList().containsKey(targetNameId)) {
managementUIState.getAssignedList().remove(targetNameId);
assignmnetTab.getTable().removeItem(targetNameId.getTargetId());
assignmentTab.getTable().removeItem(targetNameId.getTargetId());
}
}
}

View File

@@ -17,7 +17,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,14 +27,12 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
/**
* User action on management UI.
*
*
*/
@VaadinSessionScope
@SpringComponent
public class ManagementUIState implements ManagmentEntityState<Long>, Serializable {
public class ManagementUIState implements ManagementEntityState, Serializable {
private static final long serialVersionUID = 7301409196969723794L;
private static final long serialVersionUID = 1L;
private final transient Set<Object> expandParentActionRowId = new HashSet<>();
@@ -52,7 +50,8 @@ public class ManagementUIState implements ManagmentEntityState<Long>, Serializab
private Boolean distTagLayoutVisible = Boolean.FALSE;
private Long lastSelectedTargetId;
private transient Optional<Long> lastSelectedTargetId = Optional.empty();
private Set<Long> selectedTargetId = Collections.emptySet();
private boolean targetTagFilterClosed;
@@ -90,32 +89,18 @@ public class ManagementUIState implements ManagmentEntityState<Long>, Serializab
this.targetTableFilters = targetTableFilters;
}
/**
* @return the bulkUploadWindowMinimised
*/
public boolean isBulkUploadWindowMinimised() {
return bulkUploadWindowMinimised;
}
/**
* @param bulkUploadWindowMinimised
* the bulkUploadWindowMinimised to set
*/
public void setBulkUploadWindowMinimised(final boolean bulkUploadWindowMinimised) {
this.bulkUploadWindowMinimised = bulkUploadWindowMinimised;
}
/**
* @return the isCustomFilterSelected
*/
public boolean isCustomFilterSelected() {
return customFilterSelected;
}
/**
* @param isCustomFilterSelected
* the isCustomFilterSelected to set
*/
public void setCustomFilterSelected(final boolean isCustomFilterSelected) {
customFilterSelected = isCustomFilterSelected;
}
@@ -164,78 +149,50 @@ public class ManagementUIState implements ManagmentEntityState<Long>, Serializab
return deletedTargetList;
}
public Long getLastSelectedTargetId() {
public Optional<Long> getLastSelectedTargetId() {
return lastSelectedTargetId;
}
public void setLastSelectedTargetId(final Long lastSelectedTargetId) {
this.lastSelectedTargetId = lastSelectedTargetId;
this.lastSelectedTargetId = Optional.ofNullable(lastSelectedTargetId);
}
public Optional<Set<Long>> getSelectedTargetId() {
return Optional.ofNullable(selectedTargetId);
public Set<Long> getSelectedTargetId() {
return selectedTargetId;
}
public void setSelectedTargetId(final Set<Long> selectedTargetId) {
this.selectedTargetId = selectedTargetId;
}
/**
* @return the targetTagFilterClosed
*/
public boolean isTargetTagFilterClosed() {
return targetTagFilterClosed;
}
/**
* @param targetTagFilterClosed
* the targetTagFilterClosed to set
*/
public void setTargetTagFilterClosed(final boolean targetTagFilterClosed) {
this.targetTagFilterClosed = targetTagFilterClosed;
}
/**
* @return the distTagFilterClosed
*/
public boolean isDistTagFilterClosed() {
return distTagFilterClosed;
}
/**
* @param distTagFilterClosed
* the distTagFilterClosed to set
*/
public void setDistTagFilterClosed(final boolean distTagFilterClosed) {
this.distTagFilterClosed = distTagFilterClosed;
}
/**
* @return the targetsTruncated
*/
public Long getTargetsTruncated() {
return targetsTruncated;
}
/**
* @param targetsTruncated
* the targetsTruncated to set
*/
public void setTargetsTruncated(final Long targetsTruncated) {
this.targetsTruncated = targetsTruncated;
}
/**
* @return the targetsCountAll
*/
public long getTargetsCountAll() {
return targetsCountAll.get();
}
/**
* @param targetsCountAll
* the targetsCountAll to set
*/
public void setTargetsCountAll(final long targetsCountAll) {
this.targetsCountAll.set(targetsCountAll);
}
@@ -253,76 +210,47 @@ public class ManagementUIState implements ManagmentEntityState<Long>, Serializab
}
@Override
public void setLastSelectedEntity(final Long value) {
public void setLastSelectedEntityId(final Long value) {
this.lastSelectedDsIdName = value;
}
@Override
public void setSelectedEnitities(final Set<Long> values) {
this.selectedDsIdName = values;
}
public Optional<Set<Long>> getSelectedDsIdName() {
return Optional.ofNullable(selectedDsIdName);
public Set<Long> getSelectedDsIdName() {
return selectedDsIdName;
}
/**
* @return the isTargetTableMaximized
*/
public boolean isTargetTableMaximized() {
return targetTableMaximized;
}
/**
* @param isTargetTableMaximized
* the isTargetTableMaximized to set
*/
public void setTargetTableMaximized(final boolean isTargetTableMaximized) {
this.targetTableMaximized = isTargetTableMaximized;
}
/**
* @return the isActionHistoryMaximized
*/
public boolean isActionHistoryMaximized() {
return actionHistoryMaximized;
}
/**
* @param isActionHistoryMaximized
* the isActionHistoryMaximized to set
*/
public void setActionHistoryMaximized(final boolean isActionHistoryMaximized) {
this.actionHistoryMaximized = isActionHistoryMaximized;
}
/**
* @return the noDataAvilableTarget
*/
public boolean isNoDataAvilableTarget() {
return noDataAvilableTarget;
}
/**
* @param noDataAvilableTarget
* the noDataAvilableTarget to set
*/
public void setNoDataAvilableTarget(final boolean noDataAvilableTarget) {
this.noDataAvilableTarget = noDataAvilableTarget;
}
/**
* @return the noDataAvailableDistribution
*/
public boolean isNoDataAvailableDistribution() {
return noDataAvailableDistribution;
}
/**
* @param noDataAvailableDistribution
* the noDataAvailableDistribution to set
*/
public void setNoDataAvailableDistribution(final boolean noDataAvailableDistribution) {
this.noDataAvailableDistribution = noDataAvailableDistribution;
}

View File

@@ -14,11 +14,10 @@ import java.util.List;
/**
* Hold details for target bulk upload window.
*
*/
public class TargetBulkUpload implements Serializable {
private static final long serialVersionUID = -7697723122460382323L;
private static final long serialVersionUID = 1L;
private Long dsNameAndVersion;
@@ -34,91 +33,50 @@ public class TargetBulkUpload implements Serializable {
private final List<String> targetsCreated = new ArrayList<>();
/**
* @return the targetsCreated
*/
public List<String> getTargetsCreated() {
return targetsCreated;
}
/**
* @return the assignedTagIds
*/
public List<String> getAssignedTagNames() {
return assignedTagNames;
}
/**
* @return the dsNameAndVersion
*/
public Long getDsNameAndVersion() {
return dsNameAndVersion;
}
/**
* @return the progressBarCurrentValue
*/
public float getProgressBarCurrentValue() {
return progressBarCurrentValue;
}
/**
* @param progressBarCurrentValue
* the progressBarCurrentValue to set
*/
public void setProgressBarCurrentValue(final float progressBarCurrentValue) {
this.progressBarCurrentValue = progressBarCurrentValue;
}
/**
* @param dsNameAndVersion
* the dsNameAndVersion to set
*/
public void setDsNameAndVersion(final Long dsNameAndVersion) {
this.dsNameAndVersion = dsNameAndVersion;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description
* the description to set
*/
public void setDescription(final String description) {
this.description = description;
}
/**
* @return the sucessfulUploadCount
*/
public int getSucessfulUploadCount() {
return sucessfulUploadCount;
}
/**
* @param sucessfulUploadCount
* the sucessfulUploadCount to set
*/
public void setSucessfulUploadCount(final int sucessfulUploadCount) {
this.sucessfulUploadCount = sucessfulUploadCount;
}
/**
* @return the failedUploadCount
*/
public int getFailedUploadCount() {
return failedUploadCount;
}
/**
* @param failedUploadCount
* the failedUploadCount to set
*/
public void setFailedUploadCount(final int failedUploadCount) {
this.failedUploadCount = failedUploadCount;
}

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target;
@@ -22,14 +21,15 @@ import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.google.common.collect.Sets;
import com.vaadin.data.validator.RegexpValidator;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout;
@@ -62,13 +62,17 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
private FormLayout formLayout;
private CommonDialogWindow window;
TargetAddUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement, final UIEventBus eventBus,
final UINotification uINotification, final EntityFactory entityFactory) {
private final TargetTable targetTable;
TargetAddUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement,
final UIEventBus eventBus, final UINotification uINotification, final EntityFactory entityFactory,
final TargetTable targetTable) {
this.i18n = i18n;
this.targetManagement = targetManagement;
this.eventBus = eventBus;
this.uINotification = uINotification;
this.entityFactory = entityFactory;
this.targetTable = targetTable;
createRequiredComponents();
buildLayout();
setCompositionRoot(formLayout);
@@ -96,14 +100,15 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
private void createRequiredComponents() {
controllerIDTextField = createTextField("prompt.target.id", UIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
controllerIDTextField.addValidator(new RegexpValidator("[.\\S]*", i18n.getMessage("message.target.whitespace.check")));
controllerIDTextField
.addValidator(new RegexpValidator("[.\\S]*", i18n.getMessage("message.target.whitespace.check")));
nameTextField = createTextField("textfield.name", UIComponentIdProvider.TARGET_ADD_NAME);
nameTextField.setRequired(false);
descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).immediate(true).id(UIComponentIdProvider.TARGET_ADD_DESC)
.buildTextComponent();
descTextArea.setNullRepresentation(StringUtils.EMPTY);
.prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(UIComponentIdProvider.TARGET_ADD_DESC).buildTextComponent();
descTextArea.setNullRepresentation("");
}
private TextField createTextField(final String in18Key, final String id) {
@@ -143,14 +148,14 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
entityFactory.target().create().controllerId(newControllerId).name(newName).description(newDesc));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.ADD_ENTITY, newTarget));
uINotification.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newTarget.getName() }));
targetTable.setValue(Sets.newHashSet(newTarget.getId()));
}
public Window createNewWindow() {
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.getMessage(UIComponentIdProvider.TARGET_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n)
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
.caption(i18n.getMessage(UIComponentIdProvider.TARGET_ADD_CAPTION)).content(this).layout(formLayout)
.i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
return window;
}

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.Map;
import java.util.concurrent.Executor;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
@@ -27,12 +26,12 @@ import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
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.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
@@ -96,11 +95,12 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
private Button minimizeButton;
private Button closeButton;
TargetBulkUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement, final UIEventBus eventBus,
final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement,
final UiProperties uiproperties, final SpPermissionChecker checker, final UINotification uinotification,
final TagManagement tagManagement, final DistributionSetManagement distributionSetManagement,
final EntityFactory entityFactory, final Executor uiExecutor) {
TargetBulkUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement,
final UIEventBus eventBus, final ManagementUIState managementUIState,
final DeploymentManagement deploymentManagement, final UiProperties uiproperties,
final SpPermissionChecker checker, final UINotification uinotification, final TagManagement tagManagement,
final DistributionSetManagement distributionSetManagement, final EntityFactory entityFactory,
final Executor uiExecutor) {
this.i18n = i18n;
this.targetManagement = targetManagement;
this.eventBus = eventBus;
@@ -197,15 +197,15 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
final TextArea description = new TextAreaBuilder().caption(i18n.getMessage("textfield.description"))
.style("text-area-style").prompt(i18n.getMessage("textfield.description")).immediate(true)
.id(UIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent();
description.setNullRepresentation(StringUtils.EMPTY);
description.setNullRepresentation("");
description.setWidth("100%");
return description;
}
private ComboBox getDsComboField() {
final Container container = createContainer();
final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null, null,
false, "", i18n.getMessage("bulkupload.ds.name"));
final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null,
null, false, "", i18n.getMessage("bulkupload.ds.name"));
dsComboBox.setSizeUndefined();
dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE);
dsComboBox.setImmediate(true);

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.net.URI;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
@@ -39,7 +38,6 @@ import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@@ -47,11 +45,11 @@ import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
/**
* Target details layout.
* Target details layout which is shown on the Deployment View.
*/
public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private static final long serialVersionUID = 4571732743399605843L;
private static final long serialVersionUID = 1L;
private final TargetTagToken targetTagToken;
@@ -62,18 +60,19 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private final transient DeploymentManagement deploymentManagement;
private VerticalLayout assignedDistLayout;
private VerticalLayout installedDistLayout;
TargetDetails(final VaadinMessageSource i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState,
final UINotification uiNotification, final TagManagement tagManagement,
final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
final EntityFactory entityFactory) {
final EntityFactory entityFactory, final TargetTable targetTable) {
super(i18n, eventBus, permissionChecker, managementUIState);
this.targetTagToken = new TargetTagToken(permissionChecker, i18n, uiNotification, eventBus, managementUIState,
tagManagement, targetManagement);
targetAddUpdateWindowLayout = new TargetAddUpdateWindowLayout(i18n, targetManagement, eventBus, uiNotification,
entityFactory);
entityFactory, targetTable);
this.targetManagement = targetManagement;
this.deploymentManagement = deploymentManagement;
addDetailsTab();
@@ -128,11 +127,6 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
return UIComponentIdProvider.TARGET_EDIT_ICON;
}
@Override
protected boolean onLoadIsTableRowSelected() {
return getManagementUIState().getLastSelectedTargetId() != null;
}
@Override
protected boolean onLoadIsTableMaximized() {
return getManagementUIState().isTargetTableMaximized();
@@ -182,15 +176,13 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
detailsTabLayout.addComponent(lastPollDtLabel);
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.ip"),
address == null ? StringUtils.EMPTY : address.toString());
address == null ? "" : address.toString());
typeLabel.setId(UIComponentIdProvider.TARGET_IP_ADDRESS);
detailsTabLayout.addComponent(typeLabel);
if (securityToken != null) {
final HorizontalLayout securityTokenLayout = getSecurityTokenLayout(securityToken);
controllerLabel.setId(UIComponentIdProvider.TARGET_SECURITY_TOKEN);
detailsTabLayout.addComponent(securityTokenLayout);
}
final HorizontalLayout securityTokenLayout = getSecurityTokenLayout(securityToken);
controllerLabel.setId(UIComponentIdProvider.TARGET_SECURITY_TOKEN);
detailsTabLayout.addComponent(securityTokenLayout);
}
private HorizontalLayout getSecurityTokenLayout(final String securityToken) {
@@ -208,6 +200,7 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
securityTokentxt.addStyleName("targetDtls-securityToken");
securityTokentxt.addStyleName(SPUIDefinitions.TEXT_STYLE);
securityTokentxt.setCaption(null);
securityTokentxt.setNullRepresentation("");
securityTokentxt.setValue(securityToken);
securityTokentxt.setReadOnly(true);
@@ -218,15 +211,16 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private void populateDistributionDtls(final VerticalLayout layout, final DistributionSet distributionSet) {
layout.removeAllComponents();
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.name"),
distributionSet == null ? "" : distributionSet.getName()));
layout.addComponent(
SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.version"),
distributionSet == null ? "" : distributionSet.getVersion()));
if (distributionSet == null) {
return;
}
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.name"),
distributionSet.getName()));
layout.addComponent(SPUIComponentProvider.createNameValueLabel(
getI18n().getMessage("label.dist.details.version"), distributionSet.getVersion()));
distributionSet.getModules()
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
}

View File

@@ -31,7 +31,7 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.ManagementEntityState;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.common.entity.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.entity.TargetIdName;
@@ -51,7 +51,6 @@ import org.eclipse.hawkbit.ui.push.CancelTargetAssignmentEventContainer;
import org.eclipse.hawkbit.ui.push.TargetUpdatedEventContainer;
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -59,6 +58,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
@@ -87,17 +87,23 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
* Concrete implementation of Target table.
* Concrete implementation of Target table which is displayed on the Deployment
* View.
*/
public class TargetTable extends AbstractTable<Target, Long> {
public class TargetTable extends AbstractTable<Target> {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class);
private static final String TARGET_PINNED = "targetPinned";
private static final long serialVersionUID = -2300392868806614568L;
private static final int PROPERTY_DEPT = 3;
private final transient TargetManagement targetManagement;
private final transient DistributionSetManagement distributionSetManagement;
private final transient TagManagement tagManagement;
private final SpPermissionChecker permChecker;
@@ -107,7 +113,8 @@ public class TargetTable extends AbstractTable<Target, Long> {
private final ManagementUIState managementUIState;
private Button targetPinnedBtn;
private boolean isTargetPinned;
private boolean targetPinned;
public TargetTable(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification notification,
final TargetManagement targetManagement, final ManagementUIState managementUIState,
@@ -122,7 +129,6 @@ public class TargetTable extends AbstractTable<Target, Long> {
this.tagManagement = tagManagement;
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
addNewContainerDS();
setColumnProperties();
setDataAvailable(getContainerDataSource().size() != 0);
@@ -139,7 +145,8 @@ public class TargetTable extends AbstractTable<Target, Long> {
@EventBusListenerMethod(scope = EventScope.UI)
void onTargetUpdatedEvents(final TargetUpdatedEventContainer eventContainer) {
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
@SuppressWarnings("unchecked")
final List<Long> visibleItemIds = (List<Long>) getVisibleItemIds();
if (isFilterEnabled()) {
refreshTargets();
@@ -256,7 +263,6 @@ public class TargetTable extends AbstractTable<Target, Long> {
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGN_DIST_SET, DistributionSet.class, null,
false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALL_DIST_SET, DistributionSet.class, null,
@@ -273,32 +279,37 @@ public class TargetTable extends AbstractTable<Target, Long> {
@Override
protected boolean isFirstRowSelectedOnLoad() {
return managementUIState.getSelectedTargetId().map(Set::isEmpty).orElse(true);
return managementUIState.getSelectedTargetId().isEmpty();
}
@Override
protected Object getItemIdToSelect() {
return managementUIState.getSelectedTargetId().orElse(null);
return managementUIState.getSelectedTargetId().isEmpty() ? null : managementUIState.getSelectedTargetId();
}
@Override
protected void publishEntityAfterValueChange(final Target selectedLastEntity) {
protected void publishSelectedEntityEvent(final Target selectedLastEntity) {
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
}
@Override
protected void setLastSelectedEntityId(final Long selectedLastEntityId) {
managementUIState.setLastSelectedTargetId(selectedLastEntityId);
}
@Override
protected Optional<Target> findEntityByTableValue(final Long lastSelectedId) {
return targetManagement.findTargetById(lastSelectedId);
}
@Override
protected void setManagementEntitiyStateValues(final Set<Long> values, final Long lastId) {
protected void setManagementEntityStateValues(final Set<Long> values, final Long lastId) {
managementUIState.setSelectedTargetId(values);
managementUIState.setLastSelectedTargetId(lastId);
}
@Override
protected ManagmentEntityState<Long> getManagmentEntityState() {
protected ManagementEntityState getManagementEntityState() {
return null;
}
@@ -383,7 +394,7 @@ public class TargetTable extends AbstractTable<Target, Long> {
pinBtn.addClickListener(this::addPinClickListener);
if (isPinned(pinnedTarget)) {
pinBtn.addStyleName(TARGET_PINNED);
isTargetPinned = Boolean.TRUE;
targetPinned = Boolean.TRUE;
targetPinnedBtn = pinBtn;
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
@@ -397,38 +408,26 @@ public class TargetTable extends AbstractTable<Target, Long> {
.map(pinnedTarget -> pinnedTarget.equals(target)).orElse(false);
}
/**
* Add listener to pin.
*
* @param event
* as event
*/
private void addPinClickListener(final ClickEvent event) {
checkifAlreadyPinned(event.getButton());
if (isTargetPinned) {
if (targetPinned) {
pinTarget(event.getButton());
} else {
unPinTarget(event.getButton());
}
}
/**
* Check already pinned.
*
* @param eventBtn
* as button
*/
private void checkifAlreadyPinned(final Button eventBtn) {
final TargetIdName newPinnedTargetItemId = (TargetIdName) eventBtn.getData();
final TargetIdName targetId = managementUIState.getDistributionTableFilters().getPinnedTarget().orElse(null);
if (targetId == null) {
isTargetPinned = !isTargetPinned;
targetPinned = !targetPinned;
managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
} else if (targetId.equals(newPinnedTargetItemId)) {
isTargetPinned = Boolean.FALSE;
targetPinned = Boolean.FALSE;
} else {
isTargetPinned = true;
targetPinned = true;
managementUIState.getDistributionTableFilters().setPinnedTarget(newPinnedTargetItemId);
if (null != targetPinnedBtn) {
resetPinStyle(targetPinnedBtn);
@@ -445,7 +444,7 @@ public class TargetTable extends AbstractTable<Target, Long> {
/* change target table styling */
styleTargetTable();
eventBtn.addStyleName(TARGET_PINNED);
isTargetPinned = Boolean.FALSE;
targetPinned = Boolean.FALSE;
}
private void unPinTarget(final Button eventBtn) {
@@ -458,13 +457,9 @@ public class TargetTable extends AbstractTable<Target, Long> {
pinBtn.removeStyleName(TARGET_PINNED);
pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE);
final TargetIdName targetIdname = (TargetIdName) pinBtn.getData();
HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, targetIdname.getTargetId());
}
/**
* Set style of target table.
*/
private void styleTargetTable() {
setCellStyleGenerator((source, itemId, propertyId) -> null);
}
@@ -485,8 +480,8 @@ public class TargetTable extends AbstractTable<Target, Long> {
final String tagName = ((DragAndDropWrapper) (event.getTransferable().getSourceComponent())).getData()
.toString();
if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) {
notification.displayValidationError(
i18n.getMessage("message.tag.cannot.be.assigned", new Object[] { i18n.getMessage("label.no.tag.assigned") }));
notification.displayValidationError(i18n.getMessage("message.tag.cannot.be.assigned",
new Object[] { i18n.getMessage("label.no.tag.assigned") }));
return false;
}
return true;
@@ -575,8 +570,7 @@ public class TargetTable extends AbstractTable<Target, Long> {
private void dsToTargetAssignment(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> source = (AbstractTable<?, Long>) transferable.getSourceComponent();
final AbstractTable<?> source = (AbstractTable<?>) transferable.getSourceComponent();
final Set<Long> ids = source.getDeletedEntityByTransferable(transferable);
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object targetItemId = dropData.getItemIdOver();
@@ -794,8 +788,8 @@ public class TargetTable extends AbstractTable<Target, Long> {
}
private boolean isLastSelectedTarget(final Long targetId) {
return managementUIState.getLastSelectedTargetId() != null
&& managementUIState.getLastSelectedTargetId().equals(targetId);
final Optional<Long> currentTargetId = managementUIState.getLastSelectedTargetId();
return currentTargetId.isPresent() && currentTargetId.get().equals(targetId);
}
private boolean isFilterEnabled() {

View File

@@ -35,10 +35,10 @@ 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;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUITargetDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
@@ -82,12 +82,13 @@ public class TargetTableHeader extends AbstractTableHeader {
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 DistributionSetManagement distributionSetManagement, final Executor uiExecutor) {
final DistributionSetManagement distributionSetManagement, final Executor uiExecutor,
final TargetTable targetTable) {
super(i18n, permChecker, eventbus, managementUIState, null, null);
this.notification = notification;
this.managementViewClientCriterion = managementViewClientCriterion;
this.targetAddUpdateWindow = new TargetAddUpdateWindowLayout(i18n, targetManagement, eventBus, uinotification,
entityFactory);
entityFactory, targetTable);
this.targetBulkUpdateWindow = new TargetBulkUpdateWindowLayout(i18n, targetManagement, eventBus,
managementUIState, deploymentManagement, uiproperties, permChecker, uinotification, tagManagement,
distributionSetManagement, entityFactory, uiExecutor);
@@ -114,7 +115,7 @@ public class TargetTableHeader extends AbstractTableHeader {
targetBulkUpdateWindow.restoreComponentsValue();
openBulkUploadWindow();
} else if (BulkUploadPopupEvent.CLOSED == event) {
UI.getCurrent().access(() -> enableBulkUpload());
UI.getCurrent().access(this::enableBulkUpload);
}
}
@@ -127,11 +128,11 @@ public class TargetTableHeader extends AbstractTableHeader {
void onEvent(final TargetTableEvent event) {
if (TargetComponentEvent.BULK_TARGET_CREATED == event.getTargetComponentEvent()) {
this.getUI().access(() -> targetBulkUpdateWindow.setProgressBarValue(
managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue()));
getManagementUIState().getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue()));
} else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) {
this.getUI().access(() -> targetBulkUpdateWindow.onUploadCompletion());
this.getUI().access(targetBulkUpdateWindow::onUploadCompletion);
} else if (TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED == event.getTargetComponentEvent()) {
this.getUI().access(() -> onStartOfBulkUpload());
this.getUI().access(this::onStartOfBulkUpload);
} else if (TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED == event.getTargetComponentEvent()) {
this.getUI().access(() -> targetBulkUpdateWindow.getBulkUploader().getUpload().setEnabled(false));
}
@@ -148,7 +149,7 @@ public class TargetTableHeader extends AbstractTableHeader {
}
private void onLoadRestoreState() {
if (managementUIState.isCustomFilterSelected()) {
if (getManagementUIState().isCustomFilterSelected()) {
onSimpleFilterReset();
}
}
@@ -159,7 +160,7 @@ public class TargetTableHeader extends AbstractTableHeader {
if (isSearchFieldOpen()) {
resetSearch();
}
if (managementUIState.getTargetTableFilters().getDistributionSet().isPresent()) {
if (getManagementUIState().getTargetTableFilters().getDistributionSet().isPresent()) {
closeFilterByDistribution();
}
}
@@ -226,20 +227,20 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
protected void showFilterButtonsLayout() {
managementUIState.setTargetTagFilterClosed(false);
getManagementUIState().setTargetTagFilterClosed(false);
eventbus.publish(this, ManagementUIEvent.SHOW_TARGET_TAG_LAYOUT);
}
@Override
protected void resetSearchText() {
if (managementUIState.getTargetTableFilters().getSearchText().isPresent()) {
managementUIState.getTargetTableFilters().setSearchText(null);
if (getManagementUIState().getTargetTableFilters().getSearchText().isPresent()) {
getManagementUIState().getTargetTableFilters().setSearchText(null);
eventbus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TEXT);
}
}
private String getSearchText() {
return managementUIState.getTargetTableFilters().getSearchText().orElse(null);
return getManagementUIState().getTargetTableFilters().getSearchText().orElse(null);
}
@Override
@@ -249,29 +250,29 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
managementUIState.setTargetTableMaximized(Boolean.TRUE);
getManagementUIState().setTargetTableMaximized(Boolean.TRUE);
eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MAXIMIZED));
}
@Override
public void minimizeTable() {
managementUIState.setTargetTableMaximized(Boolean.FALSE);
getManagementUIState().setTargetTableMaximized(Boolean.FALSE);
eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MINIMIZED));
}
@Override
public Boolean onLoadIsTableMaximized() {
return managementUIState.isTargetTableMaximized();
return getManagementUIState().isTargetTableMaximized();
}
@Override
public Boolean onLoadIsShowFilterButtonDisplayed() {
return managementUIState.isTargetTagFilterClosed();
return getManagementUIState().isTargetTagFilterClosed();
}
@Override
protected void searchBy(final String newSearchText) {
managementUIState.getTargetTableFilters().setSearchText(newSearchText);
getManagementUIState().getTargetTableFilters().setSearchText(newSearchText);
eventbus.publish(this, TargetFilterEvent.FILTER_BY_TEXT);
}
@@ -341,7 +342,7 @@ public class TargetTableHeader extends AbstractTableHeader {
return;
}
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet.get());
managementUIState.getTargetTableFilters().setDistributionSet(distributionSetIdName);
getManagementUIState().getTargetTableFilters().setDistributionSet(distributionSetIdName);
addFilterTextField(distributionSetIdName);
}
}
@@ -376,8 +377,7 @@ public class TargetTableHeader extends AbstractTableHeader {
}
private static Set<Long> getDropppedDistributionDetails(final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final AbstractTable<?, Long> distTable = (AbstractTable<?, Long>) transferable.getSourceComponent();
final AbstractTable<?> distTable = (AbstractTable<?>) transferable.getSourceComponent();
return distTable.getDeletedEntityByTransferable(transferable);
}
@@ -409,7 +409,7 @@ public class TargetTableHeader extends AbstractTableHeader {
getFilterDroppedInfo().removeAllComponents();
getFilterDroppedInfo().setSizeUndefined();
/* Remove distribution Id from target filter parameters */
managementUIState.getTargetTableFilters().setDistributionSet(null);
getManagementUIState().getTargetTableFilters().setDistributionSet(null);
/* Reload the table */
eventbus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION);
@@ -417,13 +417,13 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
protected void displayFilterDropedInfoOnLoad() {
managementUIState.getTargetTableFilters().getDistributionSet().ifPresent(this::addFilterTextField);
getManagementUIState().getTargetTableFilters().getDistributionSet().ifPresent(this::addFilterTextField);
}
@Override
protected boolean isBulkUploadInProgress() {
return managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount() != 0
|| managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount() != 0;
return getManagementUIState().getTargetTableFilters().getBulkUpload().getSucessfulUploadCount() != 0
|| getManagementUIState().getTargetTableFilters().getBulkUpload().getFailedUploadCount() != 0;
}
@Override

View File

@@ -22,8 +22,8 @@ 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;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -50,10 +50,11 @@ public class TargetTableLayout extends AbstractTableLayout<TargetTable> {
final Executor uiExecutor) {
this.eventBus = eventBus;
this.targetDetails = new TargetDetails(i18n, eventbus, permissionChecker, managementUIState, uinotification,
tagManagement, targetManagement, deploymentManagement, entityFactory);
tagManagement, targetManagement, deploymentManagement, entityFactory, targetTable);
this.targetTableHeader = new TargetTableHeader(i18n, permissionChecker, eventBus, notification,
managementUIState, managementViewClientCriterion, targetManagement, deploymentManagement, uiproperties,
eventbus, entityFactory, uinotification, tagManagement, distributionSetManagement, uiExecutor);
eventbus, entityFactory, uinotification, tagManagement, distributionSetManagement, uiExecutor,
targetTable);
super.init(targetTableHeader, targetTable, targetDetails);
}

View File

@@ -24,11 +24,11 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.tag.TagIdName;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -135,8 +135,8 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString();
if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) {
notification.displayValidationError(
i18n.getMessage("message.tag.cannot.be.assigned", new Object[] { i18n.getMessage("label.no.tag.assigned") }));
notification.displayValidationError(i18n.getMessage("message.tag.cannot.be.assigned",
new Object[] { i18n.getMessage("label.no.tag.assigned") }));
return false;
}
return true;
@@ -159,13 +159,13 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref
final TableTransferable tabletransferable = (TableTransferable) transferable;
final AbstractTable<?, ?> source = (AbstractTable<?, ?>) tabletransferable.getSourceComponent();
final AbstractTable<?> source = (AbstractTable<?>) tabletransferable.getSourceComponent();
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
return false;
}
final Set<?> deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable);
final Set<Long> deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable);
if (deletedEntityByTransferable.isEmpty()) {
final String actionDidNotWork = i18n.getMessage("message.action.did.not.work", new Object[] {});
notification.displayValidationError(actionDidNotWork);

View File

@@ -16,7 +16,6 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
@@ -471,7 +470,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private TextField createIntegerTextField(final String in18Key, final String id) {
final TextField textField = createTextField(in18Key, id);
textField.setNullRepresentation(StringUtils.EMPTY);
textField.setNullRepresentation("");
textField.setConverter(new StringToIntegerConverter());
textField.setConversionError(i18n.getMessage(MESSAGE_ENTER_NUMBER));
textField.setSizeUndefined();
@@ -599,7 +598,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
filterField.setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
filterField.setNullRepresentation(StringUtils.EMPTY);
filterField.setNullRepresentation("");
filterField.setEnabled(false);
filterField.setSizeUndefined();
return filterField;
@@ -760,7 +759,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
final TextArea descriptionField = new TextAreaBuilder().style("text-area-style")
.prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID)
.buildTextComponent();
descriptionField.setNullRepresentation(StringUtils.EMPTY);
descriptionField.setNullRepresentation("");
descriptionField.setSizeUndefined();
return descriptionField;
}

View File

@@ -97,8 +97,8 @@ public class DefineGroupsLayout extends GridLayout {
private final AtomicInteger runningValidationsCounter;
DefineGroupsLayout(VaadinMessageSource i18n, EntityFactory entityFactory, RolloutManagement rolloutManagement,
TargetFilterQueryManagement targetFilterQueryManagement) {
DefineGroupsLayout(final VaadinMessageSource i18n, final EntityFactory entityFactory,
final RolloutManagement rolloutManagement, final TargetFilterQueryManagement targetFilterQueryManagement) {
this.i18n = i18n;
this.entityFactory = entityFactory;
this.rolloutManagement = rolloutManagement;
@@ -467,7 +467,7 @@ public class DefineGroupsLayout extends GridLayout {
.id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD)
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
filterField.setNullRepresentation(StringUtils.EMPTY);
filterField.setNullRepresentation("");
filterField.setEnabled(false);
filterField.setSizeUndefined();
return filterField;
@@ -547,7 +547,7 @@ public class DefineGroupsLayout extends GridLayout {
* @param rowIndex
* the row of the grid layout
*/
public void addToGridRow(GridLayout layout, int rowIndex) {
public void addToGridRow(final GridLayout layout, final int rowIndex) {
layout.addComponent(groupName, 0, rowIndex);
if (populated) {
layout.addComponent(targetFilterQuery, 1, rowIndex);

View File

@@ -18,7 +18,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
@@ -519,7 +518,7 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
scheduledActions = 0L;
}
final Long runningActions = statusTotalCount.get(Status.RUNNING);
String rolloutDetailsMessage = StringUtils.EMPTY;
String rolloutDetailsMessage = "";
if ((scheduledActions > 0) || (runningActions > 0)) {
rolloutDetailsMessage = i18n.getMessage("message.delete.rollout.details", runningActions, scheduledActions);
}

View File

@@ -13,7 +13,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.PollStatus;
@@ -108,7 +107,7 @@ public final class HawkbitCommonUtil {
* null.
*/
public static String concatStrings(final String delimiter, final String... texts) {
final String delim = delimiter == null ? StringUtils.EMPTY : delimiter;
final String delim = delimiter == null ? "" : delimiter;
final StringBuilder conCatStrBldr = new StringBuilder();
if (null != texts) {
for (final String text : texts) {

View File

@@ -14,7 +14,6 @@ import java.util.Date;
import java.util.Map;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.eclipse.hawkbit.repository.model.BaseEntity;
@@ -102,9 +101,9 @@ public final class SPDateTimeUtil {
*/
public static String formatCreatedAt(final BaseEntity baseEntity) {
if (baseEntity == null) {
return StringUtils.EMPTY;
return "";
}
return formatDate(baseEntity.getCreatedAt(), StringUtils.EMPTY);
return formatDate(baseEntity.getCreatedAt(), "");
}
/**
@@ -116,9 +115,9 @@ public final class SPDateTimeUtil {
*/
public static String formatLastModifiedAt(final BaseEntity baseEntity) {
if (baseEntity == null) {
return StringUtils.EMPTY;
return "";
}
return formatDate(baseEntity.getLastModifiedAt(), StringUtils.EMPTY);
return formatDate(baseEntity.getLastModifiedAt(), "");
}
/**
@@ -132,9 +131,9 @@ public final class SPDateTimeUtil {
*/
public static String formatLastModifiedAt(final BaseEntity baseEntity, final String datePattern) {
if (baseEntity == null) {
return StringUtils.EMPTY;
return "";
}
return formatDate(baseEntity.getLastModifiedAt(), StringUtils.EMPTY, datePattern);
return formatDate(baseEntity.getLastModifiedAt(), "", datePattern);
}
private static String formatDate(final Long lastQueryDate, final String defaultString, final String datePattern) {

View File

@@ -108,6 +108,11 @@ public final class SPUIStyleDefinitions {
*/
public static final String ACTION_BUTTON = "action-button";
/**
* Width of 'drop to delete' layout and 'no actions' button
*/
public static final String DEL_ACTION_BUTTON = "del-action-button";
/**
* Confirmation window caption stle.
*/

View File

@@ -67,7 +67,7 @@ public final class UIComponentIdProvider {
public static final String TARGET_FILTER_ADD_ICON_ID = "target.filter.add.id";
/**
* ID-Dist.
* ID-Dist. on deployment and distribution view
*/
public static final String DIST_TABLE_ID = "dist.tableId";
@@ -278,6 +278,11 @@ public final class UIComponentIdProvider {
*/
public static final String TARGET_FILTER_WRAPPER_ID = "target-drop-filter";
/**
* ID for HorizontalLayout containing Action Buttons (delete, action)
*/
public static final String ACTION_BUTTON_LAYOUT = "ActionButtonLayout";
/**
* Delete button wrapper id.
*/
@@ -501,7 +506,7 @@ public final class UIComponentIdProvider {
public static final String SM_TYPE_FILTER_BTN_ID = "sm.type.filter.btn.";
/**
* Software module table details header caption id.
* Target table details header caption id.
*/
public static final String TARGET_DETAILS_HEADER_LABEL_ID = "target.details.header.caption";
@@ -510,6 +515,11 @@ public final class UIComponentIdProvider {
*/
public static final String DISTRIBUTION_DETAILS_HEADER_LABEL_ID = "distribution.details.header.caption";
/**
* Software Module table details header caption id.
*/
public static final String SOFTWARE_MODULE_DETAILS_HEADER_LABEL_ID = "software.module.details.header.caption";
/**
* Software module table details vendor label id.
*/
@@ -1015,6 +1025,11 @@ public final class UIComponentIdProvider {
*/
public static final String ROLLOUT_DELETE_CONFIRMATION_DIALOG = "rollout.delete.confirmation.window";
/**
* Details header caption id of the Artifacts Table
*/
public static final String ARTIFACT_DETAILS_HEADER_LABEL_ID = "artifact.details.header.caption";
/**
* /* Private Constructor.
*/

View File

@@ -0,0 +1,24 @@
/**
* 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.view.filter;
import org.eclipse.hawkbit.ui.common.table.AbstractBaseViewFilter;
import org.eclipse.hawkbit.ui.management.DeploymentView;
/**
* View Filter class which holds the information about the Deployment View
*
*/
public class OnlyEventsFromDeploymentViewFilter extends AbstractBaseViewFilter {
@Override
protected Class<?> getOriginView() {
return DeploymentView.class;
}
}

View File

@@ -0,0 +1,24 @@
/**
* 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.view.filter;
import org.eclipse.hawkbit.ui.common.table.AbstractBaseViewFilter;
import org.eclipse.hawkbit.ui.distributions.DistributionsView;
/**
* View Filter class which holds the information about the Distributions View
*
*/
public class OnlyEventsFromDistributionsViewFilter extends AbstractBaseViewFilter {
@Override
protected Class<?> getOriginView() {
return DistributionsView.class;
}
}

View File

@@ -0,0 +1,24 @@
/**
* 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.view.filter;
import org.eclipse.hawkbit.ui.artifacts.UploadArtifactView;
import org.eclipse.hawkbit.ui.common.table.AbstractBaseViewFilter;
/**
* View Filter class which holds the information about the Upload View
*
*/
public class OnlyEventsFromUploadArtifactViewFilter extends AbstractBaseViewFilter {
@Override
protected Class<?> getOriginView() {
return UploadArtifactView.class;
}
}

View File

@@ -17,6 +17,10 @@
}
}
.no-border {
border: 0px !important;
}
//Style applied on all buttons of footer layout.Width and height of buttons can be configured
.action-button {
@include valo-gradient($color: $footer-button-background-color);

View File

@@ -89,8 +89,7 @@ caption.filter.custom = Custom Filter
caption.metadata = Metadata
caption.select.auto.assign.dist = Select auto assignment distribution set
caption.add.softwaremodule = Configure Software Module
caption.add.new.dist = Configure New Distribution
caption.add.dist = Configure New Distribution
caption.update.dist = Configure Update Distribution
caption.add.tag = Configure Tag
caption.add.type = Configure Type