Remove swagger and minor feature extensions and bug fixes

- Various Bug fixes and improvements
- Management API extended
- Swagger removed
- Guava Upgraded to 19
This commit is contained in:
Kai Zimmermann
2016-01-21 13:42:38 +01:00
parent fb9dfd204c
commit 64deaeea3c
813 changed files with 9787 additions and 4929 deletions

0
hawkbit-ui/src/main/.gitignore vendored Executable file → Normal file
View File

View File

View File

View File

View File

View File

@@ -34,6 +34,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -96,6 +97,9 @@ public class ArtifactDetailsLayout extends VerticalLayout {
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private transient UINotification uINotification;
private Label titleOfArtifactDetails;
private SPUIButton maxMinButton;
@@ -121,8 +125,10 @@ public class ArtifactDetailsLayout extends VerticalLayout {
ui = UI.getCurrent();
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
populateArtifactDetails(selectedSoftwareModule.getId(), HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()));
populateArtifactDetails(
selectedSoftwareModule.getId(),
HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.getName(),
selectedSoftwareModule.getVersion()));
}
if (isMaximized()) {
maximizedArtifactDetailsView();
@@ -258,10 +264,10 @@ public class ArtifactDetailsLayout extends VerticalLayout {
public Button generateCell(final Table source, final Object itemId, final Object columnId) {
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
.getItemProperty(PROVIDED_FILE_NAME).getValue();
final Button deleteIcon = SPUIComponentProvider.getButton(
fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "",
SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true,
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
final Button deleteIcon = SPUIComponentProvider.getButton(fileName + "-"
+ SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O,
SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId);
deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
return deleteIcon;
@@ -273,17 +279,22 @@ public class ArtifactDetailsLayout extends VerticalLayout {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.delete.artifact.confirmbox"),
i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"),
i18n.get("button.cancel"), ok -> {
i18n.get("button.cancel"),
ok -> {
if (ok) {
final ArtifactManagement artifactManagement = SpringContextHelper
.getBean(ArtifactManagement.class);
artifactManagement.deleteLocalArtifact(id);
populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(),
HawkbitCommonUtil.getFormattedNameVersion(
artifactUploadState.getSelectedBaseSoftwareModule().get().getName(),
artifactUploadState.getSelectedBaseSoftwareModule().get().getVersion()));
uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName));
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
populateArtifactDetails(
artifactUploadState.getSelectedBaseSwModuleId().get(),
HawkbitCommonUtil.getFormattedNameVersion(artifactUploadState
.getSelectedBaseSoftwareModule().get().getName(), artifactUploadState
.getSelectedBaseSoftwareModule().get().getVersion()));
} else {
populateArtifactDetails(null, null);
}
}
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
@@ -458,8 +469,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) {
ui.access(() -> {
if (softwareModuleEvent.getSoftwareModule() != null) {
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil
.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
softwareModuleEvent.getSoftwareModule().getVersion()));
} else {
populateArtifactDetails(null, null);
@@ -469,8 +480,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
ui.access(() -> {
if (softwareModuleEvent.getSoftwareModule() != null) {
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil
.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
softwareModuleEvent.getSoftwareModule().getVersion()));
} else {
populateArtifactDetails(null, null);

View File

@@ -40,8 +40,6 @@ import com.vaadin.ui.UI;
/**
* Upload view footer layout implementation.
*
*
*
*/
@SpringComponent
@ViewScope
@@ -72,7 +70,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
*/
@@ -135,7 +133,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* hasDeletePermission()
*/
@@ -146,7 +144,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* hasUpdatePermission()
*/
@@ -157,7 +155,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* getDeleteAreaLabel()
*/
@@ -173,7 +171,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* getDeleteLayoutAcceptCriteria()
*/
@@ -184,7 +182,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* processDroppedComponent(com.vaadin .event.dd.DragAndDropEvent)
*/
@@ -198,13 +196,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
final String swModuleTypeName = sourceComponent.getId()
.replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
final String swModuleTypeName = sourceComponent.getId().replace(
SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) {
notification.displayValidationError(
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
notification.displayValidationError(i18n.get("message.swmodule.type.check.delete",
new Object[] { swModuleTypeName }));
} else {
deleteSWModuleType(swModuleTypeName);
updateSWActionCount();
@@ -238,7 +236,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* getNoActionsButtonLabel()
*/
@@ -249,7 +247,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#
* getActionsButtonLabel()
*/
@@ -259,13 +257,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
@Override
protected void reloadActionCount() {
protected void restoreActionCount() {
updateSWActionCount();
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowCaption ()
@@ -277,7 +275,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* unsavedActionsWindowClosed()
@@ -292,7 +290,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowContent ()
@@ -305,7 +303,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUnsavedActions()
@@ -326,4 +324,52 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* isBulkUploadAllowed()
*/
@Override
protected boolean hasBulkUploadPermission() {
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* showBulkUploadWindow()
*/
@Override
protected void showBulkUploadWindow() {
/**
* Bulk upload not supported .No implementation required.
*/
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* restoreBulkUploadStatusCount()
*/
@Override
protected void restoreBulkUploadStatusCount() {
/**
* Bulk upload not supported .No implementation required.
*/
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* hasReadPermission()
*/
@Override
protected boolean hasReadPermission() {
return permChecker.hasReadDistributionPermission();
}
}

View File

@@ -100,19 +100,20 @@ public class SoftwareModuleTable extends AbstractTable {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> {
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();
}
});
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
refreshFilter();
}
});
}
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableId()
*/
@Override
@@ -122,7 +123,7 @@ public class SoftwareModuleTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.table.SPTable#createContainer()
*/
@Override
@@ -138,8 +139,8 @@ public class SoftwareModuleTable extends AbstractTable {
BaseSwModuleBeanQuery.class);
swQF.setQueryConfiguration(queryConfiguration);
final LazyQueryContainer container = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true,
SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
return container;
}
@@ -170,7 +171,7 @@ public class SoftwareModuleTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.SPTable#getItemIdToSelect()
*/
@@ -181,7 +182,7 @@ public class SoftwareModuleTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.table.SPTable#isMaximized()
*/
@Override
@@ -206,8 +207,8 @@ public class SoftwareModuleTable extends AbstractTable {
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule);
artifactUploadState.setSelectedSoftwareModules(values);
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule));
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE,
baseSoftwareModule));
}
} else {
artifactUploadState.setSelectedBaseSwModuleId(null);
@@ -255,15 +256,19 @@ public class SoftwareModuleTable extends AbstractTable {
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue(
SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue(
SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
artifactUploadState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
}
select(swModule.getId());
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableVisibleColumns
* ()
@@ -272,20 +277,20 @@ public class SoftwareModuleTable extends AbstractTable {
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<TableColumn>();
if (isMaximized()) {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f));
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"),
0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE,
i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
} else {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F));
}
return columnList;
}

View File

@@ -368,4 +368,15 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
return Boolean.FALSE;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader#
* isBulkUploadInProgress()
*/
@Override
protected boolean isBulkUploadInProgress() {
return false;
}
}

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.ui.common;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -99,7 +100,12 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
*/
protected void showRowCount(final DragAndDropEvent dragEvent, final Table compsource) {
/* Show the number of rows that are dragging in the drag image */
final Set<String> targetSelectedList = (Set<String>) compsource.getValue();
final Set<String> targetSelectedList = new HashSet<>((Set<String>) compsource.getValue());
/**
* Remove null value if any .
*/
targetSelectedList.remove(null);
if (previousRowCount != targetSelectedList.size()) {
previousRowCount = targetSelectedList.size();
/*

View File

@@ -13,6 +13,8 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.server.Resource;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -25,7 +27,7 @@ import com.vaadin.ui.themes.ValoTheme;
/**
*
* module.
* module.
*
*
*
@@ -55,9 +57,34 @@ public class ConfirmationDialog implements Button.ClickListener {
*/
public ConfirmationDialog(final String caption, final String question, final String okLabel,
final String cancelLabel, final ConfirmationDialogCallback callback) {
this(caption, question, okLabel, cancelLabel, callback, null);
}
/**
* Constructor for configuring confirmation dialog.
*
* @param caption
* the dialog caption.
* @param question
* the question.
* @param okLabel
* the Ok button label.
* @param cancelLabel
* the cancel button label.
* @param callback
* the callback.
* @param icon
* the icon of the dialog
*/
public ConfirmationDialog(final String caption, final String question, final String okLabel,
final String cancelLabel, final ConfirmationDialogCallback callback, final Resource icon) {
window = new Window(caption);
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
if (icon != null) {
window.setIcon(icon);
}
okButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.OK_BUTTON, okLabel, "",
ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
okButton.addClickListener(this);
@@ -73,10 +100,11 @@ public class ConfirmationDialog implements Button.ClickListener {
final VerticalLayout vLayout = new VerticalLayout();
if (question != null) {
final Label questionLbl = new Label();
questionLbl.setValue(question);
final Label questionLbl = new Label(String.format("<p>%s</p>", question.replaceAll("\n", "<br/>")),
ContentMode.HTML);
questionLbl.addStyleName(SPUIStyleDefinitions.CONFIRMBOX_QUESTION_LABEL);
vLayout.addComponent(questionLbl);
}
final HorizontalLayout hButtonLayout = new HorizontalLayout();
@@ -106,6 +134,11 @@ public class ConfirmationDialog implements Button.ClickListener {
callback.response(event.getSource().equals(okButton));
}
/**
* Get the window which holds the confirmation dialog
*
* @return the window which holds the confirmation dialog
*/
public Window getWindow() {
return window;
}

View File

@@ -10,15 +10,32 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
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.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus.SessionEventBus;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.themes.ValoTheme;
@@ -34,21 +51,58 @@ public class SoftwareModuleDetailsTable extends Table {
private static final long serialVersionUID = 2913758200611837718L;
private static final Logger LOG = LoggerFactory.getLogger(SoftwareModuleDetailsTable.class);
private static final String SOFT_TYPE_NAME = "name";
private static final String SOFT_MODULE = "softwareModule";
private static final String SOFT_TYPE_MANDATORY = "mandatory";
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
private boolean isTargetAssigned;
private boolean isUnassignSoftModAllowed;
private SpPermissionChecker permissionChecker;
private transient DistributionSetManagement distributionSetManagement;
private I18N i18n;
private transient SessionEventBus eventBus;
private transient ManageDistUIState manageDistUIState;
private transient UINotification uiNotification;
/**
* Initialize software module table- to be displayed in details layout.
*
* @param i18n
* I18N
* @param isUnassignSoftModAllowed
* boolean flag to check for unassign functionality allowed for
* the view.
* @param distributionSetManagement
* DistributionSetManagement
* @param permissionChecker
* SpPermissionChecker
* @param eventBus
* SessionEventBus
* @param manageDistUIState
* ManageDistUIState
*/
public void init(final I18N i18n) {
public void init(final I18N i18n, final boolean isUnassignSoftModAllowed,
final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement,
final SessionEventBus eventBus, final ManageDistUIState manageDistUIState) {
this.i18n = i18n;
this.isUnassignSoftModAllowed = isUnassignSoftModAllowed;
this.permissionChecker = permissionChecker;
this.distributionSetManagement = distributionSetManagement;
this.manageDistUIState = manageDistUIState;
this.eventBus = eventBus;
this.uiNotification = SpringContextHelper.getBean(UINotification.class);
createSwModuleTable();
}
@@ -69,13 +123,21 @@ public class SoftwareModuleDetailsTable extends Table {
container.addContainerProperty(SOFT_TYPE_MANDATORY, Label.class, "");
container.addContainerProperty(SOFT_TYPE_NAME, Label.class, "");
container.addContainerProperty(SOFT_MODULE, Label.class, "");
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
container.addContainerProperty(UNASSIGN_SOFT_MODULE, Button.class, "");
}
setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1f);
setColumnExpandRatio(SOFT_TYPE_NAME, 0.5f);
setColumnExpandRatio(SOFT_MODULE, 0.4f);
setColumnExpandRatio(SOFT_TYPE_NAME, 0.4f);
setColumnExpandRatio(SOFT_MODULE, 0.3f);
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
setColumnExpandRatio(UNASSIGN_SOFT_MODULE, 0.2F);
}
setColumnAlignment(SOFT_TYPE_MANDATORY, Align.RIGHT);
setColumnAlignment(SOFT_TYPE_NAME, Align.LEFT);
setColumnAlignment(SOFT_MODULE, Align.LEFT);
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
setColumnAlignment(UNASSIGN_SOFT_MODULE, Align.RIGHT);
}
return container;
}
@@ -83,6 +145,10 @@ public class SoftwareModuleDetailsTable extends Table {
setColumnHeader(SOFT_TYPE_MANDATORY, "");
setColumnHeader(SOFT_TYPE_NAME, i18n.get("header.caption.typename"));
setColumnHeader(SOFT_MODULE, i18n.get("header.caption.softwaremodule"));
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
setColumnHeader(UNASSIGN_SOFT_MODULE, i18n.get("header.caption.unassign"));
}
}
/**
@@ -93,29 +159,41 @@ public class SoftwareModuleDetailsTable extends Table {
public void populateModule(final DistributionSet distributionSet) {
removeAllItems();
if (null != distributionSet) {
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) {
try {
distributionSetManagement.checkDistributionSetAlreadyUse(distributionSet);
isTargetAssigned = false;
} catch (final EntityLockedException exception) {
isTargetAssigned = true;
LOG.info("Target already assigned for the distribution set: " + distributionSet.getName(),
exception);
}
}
final Set<SoftwareModuleType> swModuleMandatoryTypes = distributionSet.getType().getMandatoryModuleTypes();
final Set<SoftwareModuleType> swModuleOptionalTypes = distributionSet.getType().getOptionalModuleTypes();
if (null != swModuleMandatoryTypes && !swModuleMandatoryTypes.isEmpty()) {
swModuleMandatoryTypes
.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet.getModules()));
swModuleMandatoryTypes.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet));
}
if (null != swModuleOptionalTypes && !swModuleOptionalTypes.isEmpty()) {
swModuleOptionalTypes
.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet.getModules()));
swModuleOptionalTypes.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet));
}
}
}
private void setSwModuleProperties(final SoftwareModuleType swModType, final Boolean isMandatory,
final Set<SoftwareModule> alreadyAssignedSwModules) {
final DistributionSet distributionSet) {
final Set<SoftwareModule> alreadyAssignedSwModules = distributionSet.getModules();
final Item saveTblitem = getContainerDataSource().addItem(swModType.getName());
final Label mandatoryLabel = createMandatoryLabel(isMandatory);
final Label typeName = HawkbitCommonUtil.getFormatedLabel(swModType.getName());
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY);
final Button reassignSoftModule = SPUIComponentProvider.getButton(swModType.getName(), "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
reassignSoftModule.addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules));
if (null != alreadyAssignedSwModules && !alreadyAssignedSwModules.isEmpty()) {
final String swModuleName = getSwModuleName(alreadyAssignedSwModules, swModType);
softwareModule.setValue(swModuleName);
@@ -124,11 +202,57 @@ public class SoftwareModuleDetailsTable extends Table {
saveTblitem.getItemProperty(SOFT_TYPE_MANDATORY).setValue(mandatoryLabel);
saveTblitem.getItemProperty(SOFT_TYPE_NAME).setValue(typeName);
saveTblitem.getItemProperty(SOFT_MODULE).setValue(softwareModule);
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission() && !isTargetAssigned
&& (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) {
saveTblitem.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule);
}
}
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet,
final Set<SoftwareModule> alreadyAssignedSwModules) {
final SoftwareModule unAssignedSw = getSoftwareModule(
(Label) getContainerDataSource().getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE)
.getValue(), alreadyAssignedSwModules);
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
unAssignedSw);
manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName());
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE,
newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));
}
private static boolean isSoftModAvaiableForSoftType(final Set<SoftwareModule> swModulesSet,
final SoftwareModuleType swModType) {
for (final SoftwareModule sw : swModulesSet) {
if (swModType.getName().equals(sw.getType().getName())) {
return true;
}
}
return false;
}
/**
* @param value
* @param alreadyAssignedSwModules
* @return
*/
protected SoftwareModule getSoftwareModule(final Label softwareModule,
final Set<SoftwareModule> alreadyAssignedSwModules) {
for (final SoftwareModule sw : alreadyAssignedSwModules) {
if (softwareModule.getValue().contains(sw.getName())) {
return sw;
}
}
return null;
}
private Label createMandatoryLabel(final boolean mandatory) {
final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ")
: HawkbitCommonUtil.getFormatedLabel(" ");
final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") : HawkbitCommonUtil
.getFormatedLabel(" ");
if (mandatory) {
mandatoryLable.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
}

View File

@@ -48,11 +48,13 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
private Window unsavedActionsWindow;
private Button bulkUploadStatusButton;
/**
* Initialize.
*/
protected void init() {
if (hasDeletePermission() || hasUpdatePermission()) {
if (hasReadPermission() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) {
createComponents();
buildLayout();
reload();
@@ -60,16 +62,20 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
private void reload() {
reloadActionCount();
restoreActionCount();
restoreBulkUploadStatusCount();
}
private void createComponents() {
if (hasDeletePermission()) {
deleteWrapper = createDeleteWrapperLayout();
}
if (hasUpdatePermission()) {
if (hasDeletePermission() || hasUpdatePermission()) {
noActionBtn = createActionsButton();
}
if (hasBulkUploadPermission()) {
bulkUploadStatusButton = createBulkUploadStatusButton();
}
}
private void buildLayout() {
@@ -80,14 +86,18 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
final HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setSpacing(true);
hLayout.setSizeUndefined();
if (hasDeletePermission()) {
if (null != deleteWrapper) {
hLayout.addComponent(deleteWrapper);
hLayout.setComponentAlignment(deleteWrapper, Alignment.BOTTOM_LEFT);
}
if (hasUpdatePermission()) {
if (null != noActionBtn) {
hLayout.addComponent(noActionBtn);
hLayout.setComponentAlignment(noActionBtn, Alignment.BOTTOM_LEFT);
}
if (null != bulkUploadStatusButton) {
hLayout.addComponent(bulkUploadStatusButton);
hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT);
}
addComponent(dropHintLayout);
addComponent(hLayout);
setComponentAlignment(dropHintLayout, Alignment.BOTTOM_CENTER);
@@ -103,7 +113,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
dropToDelete.setIcon(FontAwesome.TRASH_O);
dropToDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS);
dropToDelete.addStyleName("drop-to-delete-button");
dropToDelete.addStyleName("action-button");
dropToDelete.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
dropToDelete.addStyleName("del-action-button");
dropToDelete.addStyleName("delete-icon");
@@ -118,9 +128,8 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
private Button createActionsButton() {
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.PENDING_ACTION_BUTTON,
getNoActionsButtonLabel(), "", "", false, null, SPUIButtonStyleSmall.class);
button.setIcon(FontAwesome.BELL);
button.setStyleName("action-button");
getNoActionsButtonLabel(), "", "", false, FontAwesome.BELL, SPUIButtonStyleSmall.class);
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
button.addStyleName("del-action-button");
button.addClickListener(event -> actionButtonClicked());
@@ -128,6 +137,41 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
return button;
}
private Button createBulkUploadStatusButton() {
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "",
"", false, null, SPUIButtonStyleSmall.class);
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
button.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
button.setWidth("100px");
button.setHtmlContentAllowed(true);
button.addClickListener(event -> onClickBulkUploadNotificationButton());
button.setVisible(false);
return button;
}
private void onClickBulkUploadNotificationButton() {
hideBulkUploadStatusButton();
showBulkUploadWindow();
}
protected void setUploadStatusButtonCaption(final Long count) {
bulkUploadStatusButton.setCaption("<div class='unread'>" + count + "</div>");
}
protected void enableBulkUploadStatusButton() {
bulkUploadStatusButton.setVisible(true);
}
protected void updateUploadBtnIconToComplete() {
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
}
protected void updateUploadBtnIconToProgressIndicator() {
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(null);
}
protected void actionButtonClicked() {
if (hasUnsavedActions()) {
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
@@ -198,6 +242,11 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
}
protected void hideBulkUploadStatusButton() {
bulkUploadStatusButton.setCaption(null);
bulkUploadStatusButton.setVisible(false);
}
/**
* Check user has delete permission.
*
@@ -258,7 +307,12 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
/**
* reload the count value.
*/
protected abstract void reloadActionCount();
protected abstract void restoreActionCount();
/**
* restore the upload status count.
*/
protected abstract void restoreBulkUploadStatusCount();
/**
* Get caption of unsaved actions window.
@@ -296,4 +350,14 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
protected abstract Label getCountMessageLabel();
/**
* @return true if bulk upload is allowed and has required create
* permissions.
*/
protected abstract boolean hasBulkUploadPermission();
protected abstract void showBulkUploadWindow();
protected abstract boolean hasReadPermission();
}

View File

@@ -103,7 +103,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
* If table is maximized display the minimize icon.
*/
showMinIcon();
hideAddIcon();
hideAddAndUploadIcon();
}
if (onLoadIsShowFilterButtonDisplayed()) {
@@ -113,15 +113,20 @@ public abstract class AbstractTableHeader extends VerticalLayout {
*/
setFilterButtonsIconVisible(true);
}
if (isBulkUploadInProgress()) {
disableBulkUpload();
}
}
private void hideAddIcon() {
private void hideAddAndUploadIcon() {
addIcon.setVisible(false);
bulkUploadIcon.setVisible(false);
}
private void showAddIcon() {
private void showAddAndUploadIcon() {
addIcon.setVisible(true);
bulkUploadIcon.setVisible(true);
}
private void buildLayout() {
@@ -278,13 +283,13 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private void maximizedTableView() {
showMinIcon();
hideAddIcon();
hideAddAndUploadIcon();
maximizeTable();
}
private void minimizeTableView() {
showMaxIcon();
showAddIcon();
showAddAndUploadIcon();
minimizeTable();
}
@@ -322,6 +327,14 @@ public abstract class AbstractTableHeader extends VerticalLayout {
return filterDroppedInfo;
}
protected void enableBulkUpload() {
bulkUploadIcon.setEnabled(true);
}
protected void disableBulkUpload() {
bulkUploadIcon.setEnabled(false);
}
/**
* Resets search text and closed search field when complex filters are
* applied.
@@ -484,6 +497,8 @@ public abstract class AbstractTableHeader extends VerticalLayout {
*/
public abstract Boolean onLoadIsShowFilterButtonDisplayed();
protected abstract boolean isBulkUploadInProgress();
protected abstract void searchBy(String newSearchText);
protected abstract void addNewItem(final Button.ClickEvent event);

View File

@@ -13,8 +13,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.tokenfield.TokenField;
import org.vaadin.tokenfield.TokenField.InsertPosition;
@@ -51,6 +53,9 @@ public abstract class AbstractTagToken implements Serializable {
protected CssLayout tokenLayout = new CssLayout();
@Autowired
protected ManagementUIState managementUIState;
protected void init() {
createTokenField();
checkIfTagAssignedIsAllowed();
@@ -96,8 +101,12 @@ public abstract class AbstractTagToken implements Serializable {
protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) {
tagDetails.put(tagId, new TagData(tagId, tagName, tagColor));
final Item item = container.addItem(tagId);
item.getItemProperty("name").setValue(tagName);
item.getItemProperty("id").setValue(tagId);
updateItem(tagName, tagColor, item);
}
protected void updateItem(final String tagName, final String tagColor, final Item item) {
item.getItemProperty("name").setValue(tagName);
item.getItemProperty(COLOR_PROPERTY).setValue(tagColor);
}
@@ -224,7 +233,11 @@ public abstract class AbstractTagToken implements Serializable {
return tokenField;
}
static class TagData {
/**
* Tag details.
*
*/
public static class TagData {
private String name;

View File

@@ -0,0 +1,73 @@
/**
* 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.tagdetails;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.ui.UI;
/**
* Abstract class for target tag token layout.
*/
public abstract class AbstractTargetTagToken extends AbstractTagToken {
private static final long serialVersionUID = 7772876588903171201L;
protected UI ui;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected I18N i18n;
@Autowired
protected transient TagManagement tagManagement;
@Autowired
protected SpPermissionChecker checker;
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
for (final TargetTag tag : event.getEntities()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetDeletedEvent(final TargetTagDeletedEvent event) {
final Long deletedTagId = getTagIdByTagName(event.getEntity().getName());
removeTagFromCombo(deletedTagId);
}
}

View File

@@ -12,19 +12,23 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -34,6 +38,7 @@ import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.UI;
@@ -126,8 +131,8 @@ public class DistributionTagToken extends AbstractTagToken {
private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) {
final Set<Long> distributionList = new HashSet<Long>();
distributionList.add(selectedDS.getId());
final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
tagNameSelected);
final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(
distributionList, tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
return result;
}
@@ -194,7 +199,7 @@ public class DistributionTagToken extends AbstractTagToken {
@Override
protected void populateContainer() {
container.removeAllItems();
for (final DistributionSetTag tag : tagManagement.findDistributionSetTagsAll()) {
for (final DistributionSetTag tag : tagManagement.findAllDistributionSetTags()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
}
}
@@ -216,30 +221,64 @@ public class DistributionTagToken extends AbstractTagToken {
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTagEvent event) {
ui.access(() -> {
if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.ADD_DIST_TAG) {
setContainerPropertValues(event.getDistributionTag().getId(), event.getDistributionTag().getName(),
event.getDistributionTag().getColour());
} else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.DELETE_DIST_TAG) {
final Long deletedTagId = getTagIdByTagName(event.getDistributionTagName());
removeTagFromCombo(deletedTagId);
} else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.ASSIGNED) {
final Long newlyAssignedTagId = getTagIdByTagName(event.getDistributionTagName());
addNewToken(newlyAssignedTagId);
} else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.UNASSIGNED) {
final Long newlyUnAssignedTagId = getTagIdByTagName(event.getDistributionTagName());
removeTokenItem(newlyUnAssignedTagId, event.getDistributionTagName());
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
for (final DistributionSetTag distributionSetTag : event.getEntities()) {
setContainerPropertValues(distributionSetTag.getId(), distributionSetTag.getName(),
distributionSetTag.getColour());
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetTagDeletedEventBulkEvent(final DistributionSetTagDeletedEvent event) {
final Long deletedTagId = getTagIdByTagName(event.getEntity().getName());
removeTagFromCombo(deletedTagId);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
final DistributionSetTag entity = event.getEntity();
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagAssigmentResultEvent(final DistributionSetTagAssigmentResultEvent event) {
final DistributionSetTagAssigmentResult assignmentResult = event.getAssigmentResult();
final DistributionSetTag tag = assignmentResult.getDistributionSetTag();
if (isAssign(assignmentResult)) {
addNewToken(tag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(tag.getId(), tag.getName());
}
}
protected boolean isAssign(final DistributionSetTagAssigmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;
}
});
}
return false;
}
protected boolean isUnassign(final DistributionSetTagAssigmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;
}
}
return false;
}
@PreDestroy
void destroy() {
/*
* It's good to do this, even though vaadin-spring will automatically
* unsubscribe .
*/
eventBus.unsubscribe(this);
}

View File

@@ -12,31 +12,26 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TargetTagAssigmentResult;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTagEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.UI;
/**
* Implementation of Target tag token.
@@ -45,41 +40,21 @@ import com.vaadin.ui.UI;
*/
@SpringComponent
@ViewScope
public class TargetTagToken extends AbstractTagToken {
public class TargetTagToken extends AbstractTargetTagToken {
private static final long serialVersionUID = 7124887018280196721L;
// To Be Done : have to set this value based on view???
private static final Boolean NOTAGS_SELECTED = Boolean.FALSE;
@Autowired
private SpPermissionChecker spChecker;
@Autowired
private I18N i18n;
@Autowired
private UINotification uinotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient TagManagement tagManagement;
@Autowired
private transient TargetManagement targetManagement;
private Target selectedTarget;
private UI ui;
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@Override
protected String getTagStyleName() {
return "target-tag-";
@@ -132,7 +107,7 @@ public class TargetTagToken extends AbstractTagToken {
@Override
protected Boolean isToggleTagAssignmentAllowed() {
return spChecker.hasUpdateTargetPermission();
return checker.hasUpdateTargetPermission();
}
@Override
@@ -153,6 +128,49 @@ public class TargetTagToken extends AbstractTagToken {
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
final TargetTag entity = event.getEntity();
final Item item = container.getItem(entity.getId());
if (item != null) {
updateItem(entity.getName(), entity.getColour(), item);
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEvent event) {
final TargetTagAssigmentResult assignmentResult = event.getAssigmentResult();
final TargetTag targetTag = assignmentResult.getTargetTag();
if (isAssign(assignmentResult)) {
addNewToken(targetTag.getId());
} else if (isUnassign(assignmentResult)) {
removeTokenItem(targetTag.getId(), targetTag.getName());
}
}
protected boolean isAssign(final TargetTagAssigmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<String> assignedTargetNames = assignmentResult.getAssignedTargets().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
}
}
return false;
}
protected boolean isUnassign(final TargetTagAssigmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
}
}
return false;
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent targetTableEvent) {
if (targetTableEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET
@@ -167,28 +185,4 @@ public class TargetTagToken extends AbstractTagToken {
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTagEvent event) {
ui.access(() -> {
if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ADD_TARGETTAG) {
setContainerPropertValues(event.getTargetTag().getId(), event.getTargetTag().getName(),
event.getTargetTag().getColour());
} else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.DELETE_TARGETTAG) {
final Long deletedTagId = getTagIdByTagName(event.getTargetTagName());
removeTagFromCombo(deletedTagId);
} else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ASSIGNED) {
final Long newlyAssignedTagId = getTagIdByTagName(event.getTargetTagName());
addNewToken(newlyAssignedTagId);
} else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.UNASSIGNED) {
final Long newlyUnAssignedTagId = getTagIdByTagName(event.getTargetTagName());
removeTokenItem(newlyUnAssignedTagId, event.getTargetTagName());
}
});
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -9,13 +9,9 @@
package org.eclipse.hawkbit.ui.components;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
/**
* Proxy for {@link Target}.
*
*
*
* Proxy for {@link DistributionSet}.
*
*
*/
@@ -35,6 +31,23 @@ public class ProxyDistribution extends DistributionSet {
private Boolean isComplete;
private String nameVersion;
/**
* @return the nameVersion
*/
public String getNameVersion() {
return nameVersion;
}
/**
* @param nameVersion
* the nameVersion to set
*/
public void setNameVersion(final String nameVersion) {
this.nameVersion = nameVersion;
}
public Boolean getIsComplete() {
return isComplete;
}

View File

@@ -45,11 +45,13 @@ public class SPNotificationMessage extends Notification {
* message description
* @param autoClose
* flag to indicate enable close option
* @param page
* current {@link Page}
*/
public void showNotification(final String styleName, final String caption, final String description,
final Boolean autoClose) {
final Boolean autoClose, final Page page) {
decorate(styleName, caption, description, autoClose);
this.show(Page.getCurrent());
this.show(page);
}
/**

View File

@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import com.vaadin.server.DefaultErrorHandler;
import com.vaadin.server.ErrorEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.themes.ValoTheme;
/**
@@ -39,7 +40,7 @@ public class SPUIErrorHandler extends DefaultErrorHandler {
private static final Logger LOG = LoggerFactory.getLogger(SPUIErrorHandler.class);
@Override
public void error(ErrorEvent event) {
public void error(final ErrorEvent event) {
final SPNotificationMessage notification = new SPNotificationMessage();
// Build error style
final StringBuilder style = new StringBuilder(ValoTheme.NOTIFICATION_FAILURE);
@@ -47,14 +48,18 @@ public class SPUIErrorHandler extends DefaultErrorHandler {
style.append(ValoTheme.NOTIFICATION_SMALL);
style.append(' ');
style.append(ValoTheme.NOTIFICATION_CLOSABLE);
final I18N i18n = (I18N) SpringContextHelper.getBean(I18N.class);
final I18N i18n = SpringContextHelper.getBean(I18N.class);
String exceptionName = null;
// From the exception trace we get the expected exception class name
for (Throwable error = event.getThrowable(); error != null; error = error.getCause()) {
exceptionName = HawkbitCommonUtil.getLastSequenceBySplitByDot(error.getClass().getName());
LOG.error("Error in SP-UI:", error);
}
notification.showNotification(style.toString(), i18n.get("caption.error"),
i18n.get("message.error.temp", new Object[] { exceptionName }), false);
final Component errorOrgin = findAbstractComponent(event);
if (null != errorOrgin && errorOrgin.getUI() != null) {
notification
.showNotification(style.toString(), i18n.get("caption.error"), i18n.get("message.error.temp",
new Object[] { exceptionName }), false, errorOrgin.getUI().getPage());
}
}
}

View File

@@ -1,61 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.components;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import com.vaadin.server.FontAwesome;
/**
* Common Util for Notifcation Message.
*
*
*
*
*
*/
public final class SPUINotifcation {
/**
* private constructor.
*/
private SPUINotifcation() {
}
/**
* Display success type of notification message.
*
* @param notificationMessage
* as reference
* @param message
* is the message to displayed as success.
*/
public static void displaySuccess(final SPNotificationMessage notificationMessage, final String message) {
notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_SUCCESS_MESSAGE_STYLE, null, message,
true);
}
/**
* Display error type of notification message.
*
* @param notificationMessage
* as reference
* @param message
* as message.
*/
public static void displayValidationError(final SPNotificationMessage notificationMessage, final String message) {
final StringBuilder updatedMsg = new StringBuilder(FontAwesome.EXCLAMATION_TRIANGLE.getHtml());
updatedMsg.append(' ');
updatedMsg.append(message);
notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, null,
updatedMsg.toString(), true);
}
}

Some files were not shown because too many files have changed in this diff Show More