Merge remote-tracking branch 'eclipse/master' into
Feature_Improve_Code_Quality Conflicts: hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -30,10 +30,7 @@ import com.vaadin.ui.VerticalLayout;
|
||||
* View class that is instantiated when no other view matches the navigation
|
||||
* state.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @see Navigator#setErrorView(Class)
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@SpringComponent
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Set;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import org.eclipse.hawkbit.ui.components.SPUIErrorHandler;
|
||||
import org.eclipse.hawkbit.ui.components.HawkbitUIErrorHandler;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardMenu;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardMenuItem;
|
||||
@@ -180,7 +180,10 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
||||
final String locale = getLocaleId(SPUIDefinitions.getAvailableLocales());
|
||||
setLocale(new Locale(locale));
|
||||
|
||||
UI.getCurrent().setErrorHandler(new SPUIErrorHandler());
|
||||
if (UI.getCurrent().getErrorHandler() == null) {
|
||||
UI.getCurrent().setErrorHandler(new HawkbitUIErrorHandler());
|
||||
}
|
||||
|
||||
LOG.info("Current locale of the application is : {}", i18n.getLocale());
|
||||
}
|
||||
|
||||
|
||||
@@ -115,10 +115,10 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
protected void populateDetailsWidget() {
|
||||
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
|
||||
if (getSelectedBaseEntity() != null) {
|
||||
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||
maxAssign = getI18n().get("label.multiAssign.type");
|
||||
} else {
|
||||
if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) {
|
||||
maxAssign = getI18n().get("label.singleAssign.type");
|
||||
} else {
|
||||
maxAssign = getI18n().get("label.multiAssign.type");
|
||||
}
|
||||
updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
|
||||
getSelectedBaseEntity().getVendor(), maxAssign);
|
||||
|
||||
@@ -185,6 +185,7 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout {
|
||||
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||
assignOptiongroup.addStyleName("custom-option-group");
|
||||
assignOptiongroup.setNullSelectionAllowed(false);
|
||||
assignOptiongroup.setId(SPUIDefinitions.ASSIGN_OPTION_GROUP_SOFTWARE_MODULE_TYPE_ID);
|
||||
assignOptiongroup.select(tagOptions.get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,10 @@ 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.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
@@ -60,8 +62,6 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
|
||||
private static final String SOFT_TYPE_MANDATORY = "mandatory";
|
||||
|
||||
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
|
||||
|
||||
private boolean isTargetAssigned;
|
||||
|
||||
private boolean isUnassignSoftModAllowed;
|
||||
@@ -109,7 +109,6 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
|
||||
private void createSwModuleTable() {
|
||||
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_NO_STRIPES);
|
||||
setSelectable(false);
|
||||
setImmediate(true);
|
||||
setContainerDataSource(getSwModuleContainer());
|
||||
@@ -123,22 +122,13 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
final IndexedContainer container = new IndexedContainer();
|
||||
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, "");
|
||||
}
|
||||
container.addContainerProperty(SOFT_MODULE, VerticalLayout.class, "");
|
||||
setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1f);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -146,10 +136,6 @@ 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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,31 +174,18 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
final Item saveTblitem = getContainerDataSource().addItem(swModType.getName());
|
||||
final Label mandatoryLabel = createMandatoryLabel(isMandatory);
|
||||
final Label typeName = HawkbitCommonUtil.getFormatedLabel(swModType.getName());
|
||||
final VerticalLayout verticalLayout = createSoftModuleLayout(swModType, distributionSet,
|
||||
alreadyAssignedSwModules);
|
||||
|
||||
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);
|
||||
softwareModule.setDescription(swModuleName);
|
||||
}
|
||||
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);
|
||||
}
|
||||
saveTblitem.getItemProperty(SOFT_MODULE).setValue(verticalLayout);
|
||||
|
||||
}
|
||||
|
||||
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 SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules);
|
||||
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
|
||||
unAssignedSw);
|
||||
manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet));
|
||||
@@ -233,15 +206,46 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
|
||||
}
|
||||
|
||||
private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType,
|
||||
final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) {
|
||||
final VerticalLayout verticalLayout = new VerticalLayout();
|
||||
for (final SoftwareModule sw : alreadyAssignedSwModules) {
|
||||
if (swModType.getKey().equals(sw.getType().getKey())) {
|
||||
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
||||
horizontalLayout.setSizeFull();
|
||||
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||
final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true,
|
||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
reassignSoftModule
|
||||
.addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules));
|
||||
final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(),
|
||||
sw.getVersion());
|
||||
softwareModule.setValue(softwareModNameVersion);
|
||||
softwareModule.setDescription(softwareModNameVersion);
|
||||
softwareModule.setId(sw.getName() + "-label");
|
||||
horizontalLayout.addComponent(softwareModule);
|
||||
horizontalLayout.setExpandRatio(softwareModule, 1F);
|
||||
if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission() && !isTargetAssigned
|
||||
&& (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) {
|
||||
horizontalLayout.addComponent(reassignSoftModule);
|
||||
}
|
||||
verticalLayout.addComponent(horizontalLayout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return verticalLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @param alreadyAssignedSwModules
|
||||
* @return
|
||||
*/
|
||||
protected SoftwareModule getSoftwareModule(final Label softwareModule,
|
||||
protected SoftwareModule getSoftwareModule(final String softwareModule,
|
||||
final Set<SoftwareModule> alreadyAssignedSwModules) {
|
||||
for (final SoftwareModule sw : alreadyAssignedSwModules) {
|
||||
if (softwareModule.getValue().contains(sw.getName())) {
|
||||
if (softwareModule.equals(sw.getName())) {
|
||||
return sw;
|
||||
}
|
||||
}
|
||||
@@ -256,15 +260,4 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
}
|
||||
return mandatoryLable;
|
||||
}
|
||||
|
||||
private String getSwModuleName(final Set<SoftwareModule> swModulesSet, final SoftwareModuleType swModType) {
|
||||
final StringBuilder assignedSWModules = new StringBuilder();
|
||||
for (final SoftwareModule sw : swModulesSet) {
|
||||
if (swModType.getKey().equals(sw.getType().getKey())) {
|
||||
assignedSWModules.append(HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()))
|
||||
.append("</br>");
|
||||
}
|
||||
}
|
||||
return assignedSWModules.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.shared.Position;
|
||||
import com.vaadin.ui.Notification;
|
||||
|
||||
/**
|
||||
* Notification message component for displaying errors in the UI.
|
||||
*/
|
||||
public class HawkbitErrorNotificationMessage extends Notification {
|
||||
|
||||
private static final long serialVersionUID = -6512576924243195753L;
|
||||
|
||||
/**
|
||||
* Constructor of HawkbitErrorNotificationMessage
|
||||
*
|
||||
* @param style
|
||||
* style of the notification message
|
||||
* @param caption
|
||||
* caption of the notification message
|
||||
* @param description
|
||||
* text which is displayed in the notification
|
||||
* @param autoClose
|
||||
* boolean if notification is closed after random click (true) or
|
||||
* closed by clicking on the notification (false)
|
||||
*/
|
||||
public HawkbitErrorNotificationMessage(final String style, final String caption, final String description,
|
||||
final boolean autoClose) {
|
||||
super(caption);
|
||||
setStyleName(style);
|
||||
if (autoClose) {
|
||||
setDelayMsec(SPUILabelDefinitions.SP_DELAY);
|
||||
} else {
|
||||
setDelayMsec(-1);
|
||||
}
|
||||
setHtmlContentAllowed(true);
|
||||
setPosition(Position.BOTTOM_RIGHT);
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.components;
|
||||
|
||||
import static com.vaadin.ui.themes.ValoTheme.NOTIFICATION_CLOSABLE;
|
||||
import static com.vaadin.ui.themes.ValoTheme.NOTIFICATION_FAILURE;
|
||||
import static com.vaadin.ui.themes.ValoTheme.NOTIFICATION_SMALL;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.vaadin.server.DefaultErrorHandler;
|
||||
import com.vaadin.server.ErrorEvent;
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.ui.Component;
|
||||
|
||||
/**
|
||||
* Default handler for SP UI.
|
||||
*/
|
||||
public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HawkbitUIErrorHandler.class);
|
||||
|
||||
private static final String STYLE = NOTIFICATION_FAILURE + " " + NOTIFICATION_SMALL + " " + NOTIFICATION_CLOSABLE;
|
||||
|
||||
@Override
|
||||
public void error(final ErrorEvent event) {
|
||||
|
||||
LOG.error("Error in UI: ", event.getThrowable());
|
||||
|
||||
final Optional<Page> originError = getPageOriginError(event);
|
||||
|
||||
if (originError.isPresent()) {
|
||||
final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
|
||||
message.show(originError.get());
|
||||
}
|
||||
}
|
||||
|
||||
private static Throwable getRootExceptionFrom(final ErrorEvent event) {
|
||||
|
||||
return getRootCauseOf(event.getThrowable());
|
||||
}
|
||||
|
||||
private static Throwable getRootCauseOf(final Throwable exception) {
|
||||
|
||||
if (exception.getCause() != null) {
|
||||
return getRootCauseOf(exception.getCause());
|
||||
}
|
||||
|
||||
return exception;
|
||||
}
|
||||
|
||||
private static Optional<Page> getPageOriginError(final ErrorEvent event) {
|
||||
|
||||
final Component errorOrigin = findAbstractComponent(event);
|
||||
|
||||
if (errorOrigin != null && errorOrigin.getUI() != null) {
|
||||
return Optional.fromNullable(errorOrigin.getUI().getPage());
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
|
||||
|
||||
final I18N i18n = SpringContextHelper.getBean(I18N.class);
|
||||
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
||||
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,83 +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.Page;
|
||||
import com.vaadin.shared.Position;
|
||||
import com.vaadin.ui.Notification;
|
||||
|
||||
/**
|
||||
* Notification message component.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SPNotificationMessage extends Notification {
|
||||
|
||||
/**
|
||||
* ID.
|
||||
*/
|
||||
private static final long serialVersionUID = -6512576924243195753L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public SPNotificationMessage() {
|
||||
super("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification message component.
|
||||
*
|
||||
* @param styleName
|
||||
* style name of message
|
||||
* @param caption
|
||||
* message caption
|
||||
* @param description
|
||||
* 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 Page page) {
|
||||
decorate(styleName, caption, description, autoClose);
|
||||
this.show(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate.
|
||||
*
|
||||
* @param styleName
|
||||
* style name of message
|
||||
* @param caption
|
||||
* message caption
|
||||
* @param description
|
||||
* message description
|
||||
* @param autoClose
|
||||
* flag to indicate enable close option
|
||||
*/
|
||||
private void decorate(final String styleName, final String caption, final String description,
|
||||
final Boolean autoClose) {
|
||||
setCaption(caption);
|
||||
setDescription(description);
|
||||
setStyleName(styleName);
|
||||
setHtmlContentAllowed(true);
|
||||
setPosition(Position.BOTTOM_RIGHT);
|
||||
if (autoClose) {
|
||||
setDelayMsec(SPUILabelDefinitions.SP_DELAY);
|
||||
} else {
|
||||
setDelayMsec(-1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +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.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.slf4j.Logger;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Default handler for SP UI.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SPUIErrorHandler extends DefaultErrorHandler {
|
||||
|
||||
/**
|
||||
* Comment for <code>serialVersionUID</code>.
|
||||
*/
|
||||
private static final long serialVersionUID = 1877326479308824191L;
|
||||
/**
|
||||
* logger.
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SPUIErrorHandler.class);
|
||||
|
||||
@Override
|
||||
public void error(final ErrorEvent event) {
|
||||
final SPNotificationMessage notification = new SPNotificationMessage();
|
||||
// Build error style
|
||||
final StringBuilder style = new StringBuilder(ValoTheme.NOTIFICATION_FAILURE);
|
||||
style.append(' ');
|
||||
style.append(ValoTheme.NOTIFICATION_SMALL);
|
||||
style.append(' ');
|
||||
style.append(ValoTheme.NOTIFICATION_CLOSABLE);
|
||||
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);
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.TabSheet;
|
||||
import com.vaadin.ui.UI;
|
||||
@@ -67,8 +68,6 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
private static final String SOFT_MODULE = "softwareModule";
|
||||
|
||||
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
|
||||
|
||||
@Autowired
|
||||
private ManageDistUIState manageDistUIState;
|
||||
|
||||
@@ -180,27 +179,25 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
||||
item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
||||
if (item != null) {
|
||||
item.getItemProperty(SOFT_MODULE)
|
||||
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
||||
assignSoftModuleButton(item, entry);
|
||||
|
||||
item.getItemProperty(SOFT_MODULE).setValue(createSoftModuleLayout(entry.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
|
||||
private Button assignSoftModuleButton(final String softwareModuleName) {
|
||||
if (getPermissionChecker().hasUpdateDistributionPermission() && distributionSetManagement
|
||||
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
|
||||
.getAssignedTargets().isEmpty()) {
|
||||
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
|
||||
final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true,
|
||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
reassignSoftModule.setEnabled(false);
|
||||
item.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule);
|
||||
return reassignSoftModule;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getUnsavedAssigedSwModule(final String name, final String version) {
|
||||
private static String getUnsavedAssigedSwModule(final String name, final String version) {
|
||||
return HawkbitCommonUtil.getFormattedNameVersion(name, version);
|
||||
}
|
||||
|
||||
@@ -215,7 +212,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
* type is drroped, then add to the list.
|
||||
*/
|
||||
|
||||
if (module.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||
if (module.getType().getMaxAssignments() > 1) {
|
||||
assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>")
|
||||
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>");
|
||||
}
|
||||
@@ -238,14 +235,27 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
||||
final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
||||
if (item != null) {
|
||||
item.getItemProperty(SOFT_MODULE)
|
||||
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
||||
assignSoftModuleButton(item, entry);
|
||||
|
||||
item.getItemProperty(SOFT_MODULE).setValue(createSoftModuleLayout(entry.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VerticalLayout createSoftModuleLayout(final String softwareModuleName) {
|
||||
final VerticalLayout verticalLayout = new VerticalLayout();
|
||||
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
||||
horizontalLayout.setSizeFull();
|
||||
final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||
final Button reassignSoftModule = assignSoftModuleButton(softwareModuleName);
|
||||
softwareModule.setValue(softwareModuleName);
|
||||
softwareModule.setDescription(softwareModuleName);
|
||||
softwareModule.setId(softwareModuleName + "-label");
|
||||
horizontalLayout.addComponent(softwareModule);
|
||||
horizontalLayout.setExpandRatio(softwareModule, 1F);
|
||||
horizontalLayout.addComponent(reassignSoftModule);
|
||||
verticalLayout.addComponent(horizontalLayout);
|
||||
return verticalLayout;
|
||||
}
|
||||
|
||||
private VerticalLayout createSoftwareModuleTab() {
|
||||
final VerticalLayout softwareLayout = getTabLayout();
|
||||
softwareLayout.setSizeFull();
|
||||
|
||||
@@ -307,7 +307,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
|
||||
private void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
|
||||
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
|
||||
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||
if (softwareModule.getType().getMaxAssignments() > 1) {
|
||||
if (!map.containsKey(softwareModule.getType().getId())) {
|
||||
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
private void populateDetails() {
|
||||
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
|
||||
if (getSelectedBaseEntity() != null) {
|
||||
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||
maxAssign = getI18n().get("label.multiAssign.type");
|
||||
} else {
|
||||
if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) {
|
||||
maxAssign = getI18n().get("label.singleAssign.type");
|
||||
} else {
|
||||
maxAssign = getI18n().get("label.multiAssign.type");
|
||||
}
|
||||
updateSwModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
|
||||
getSelectedBaseEntity().getVendor(), maxAssign);
|
||||
|
||||
@@ -210,18 +210,18 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isDistributionSetSelected(final DistributionSet ds) {
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent()
|
||||
? managementUIState.getLastSelectedDistribution().get() : null;
|
||||
return ds != null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
&& lastselectedManageDS.getVersion().endsWith(ds.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken.TagData;
|
||||
import org.eclipse.hawkbit.ui.components.HawkbitErrorNotificationMessage;
|
||||
import org.eclipse.hawkbit.ui.management.event.BulkUploadValidationMessageEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
|
||||
@@ -40,12 +41,14 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
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;
|
||||
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
@@ -445,7 +448,9 @@ public class BulkUploadHandler extends CustomComponent
|
||||
@Override
|
||||
public void uploadStarted(final StartedEvent event) {
|
||||
if (!event.getFilename().endsWith(".csv")) {
|
||||
uINotification.displayError(i18n.get("bulk.targets.upload"), null, true);
|
||||
|
||||
new HawkbitErrorNotificationMessage(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, null,
|
||||
i18n.get("bulk.targets.upload"), true).show(Page.getCurrent());
|
||||
LOG.error("Wrong file format for file {}", event.getFilename());
|
||||
upload.interruptUpload();
|
||||
} else {
|
||||
|
||||
@@ -590,24 +590,6 @@ public final class HawkbitCommonUtil {
|
||||
return requiredExtraWidth + minTableWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Last sequence of string which is after last dot in String.
|
||||
*
|
||||
* @param name
|
||||
* dotted String name
|
||||
* @return String name
|
||||
*/
|
||||
public static String getLastSequenceBySplitByDot(final String name) {
|
||||
String lastSequence = null;
|
||||
if (null != name) {
|
||||
final String[] strArray = name.split("\\.");
|
||||
if (strArray.length > 0) {
|
||||
lastSequence = strArray[strArray.length - 1];
|
||||
}
|
||||
}
|
||||
return lastSequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the prefix from text.
|
||||
*
|
||||
|
||||
@@ -16,8 +16,6 @@ import com.vaadin.ui.Notification;
|
||||
|
||||
/**
|
||||
* Show notification messages.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@UIScope
|
||||
@SpringComponent
|
||||
@@ -27,8 +25,6 @@ public class NotificationMessage extends Notification {
|
||||
|
||||
/**
|
||||
* Default constructor of notification message.
|
||||
*
|
||||
* @param caption
|
||||
*/
|
||||
public NotificationMessage() {
|
||||
super("");
|
||||
|
||||
@@ -309,6 +309,11 @@ public final class SPUIDefinitions {
|
||||
* New Create Update option group id.
|
||||
*/
|
||||
public static final String CREATE_OPTION_GROUP_DISTRIBUTION_SET_TYPE_ID = "create.option.group.dist.set.type.id";
|
||||
|
||||
/**
|
||||
* Assign option group id(Firmware/Software).
|
||||
*/
|
||||
public static final String ASSIGN_OPTION_GROUP_SOFTWARE_MODULE_TYPE_ID = "assign.option.group.soft.module.type.id";
|
||||
/**
|
||||
* SW Module Source Table ID.
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,7 @@ public final class SPUILabelDefinitions {
|
||||
*/
|
||||
public static final String SP_NOTIFICATION_ERROR_MESSAGE_STYLE = ValoTheme.NOTIFICATION_ERROR + " "
|
||||
+ ValoTheme.NOTIFICATION_TRAY;
|
||||
|
||||
/**
|
||||
* Style - Warning.
|
||||
*/
|
||||
@@ -539,13 +540,12 @@ public final class SPUILabelDefinitions {
|
||||
* Total target coulmn property name.
|
||||
*/
|
||||
public static final String VAR_TOTAL_TARGETS = "totalTargetsCount";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Total target count status coulmn property name.
|
||||
*/
|
||||
public static final String VAR_TOTAL_TARGETS_COUNT_STATUS = "totalTargetCountStatus";
|
||||
|
||||
|
||||
/**
|
||||
* Rollout group started date column property.
|
||||
*/
|
||||
@@ -560,7 +560,7 @@ public final class SPUILabelDefinitions {
|
||||
* Rollout group installed percentage column property.
|
||||
*/
|
||||
public static final String ROLLOUT_GROUP_INSTALLED_PERCENTAGE = "finishedPercentage";
|
||||
|
||||
|
||||
/**
|
||||
* Add metadata icon.
|
||||
*/
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.vaadin.spring.annotation.ViewScope;
|
||||
|
||||
/**
|
||||
* Show success and error messages.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ViewScope
|
||||
@SpringComponent
|
||||
@@ -33,8 +31,6 @@ public class UINotification implements Serializable {
|
||||
/**
|
||||
* Display success type of notification message.
|
||||
*
|
||||
* @param notificationMessage
|
||||
* as reference
|
||||
* @param message
|
||||
* is the message to displayed as success.
|
||||
*/
|
||||
@@ -46,8 +42,6 @@ public class UINotification implements Serializable {
|
||||
/**
|
||||
* Display error type of notification message.
|
||||
*
|
||||
* @param notificationMessage
|
||||
* as reference
|
||||
* @param message
|
||||
* as message.
|
||||
*/
|
||||
@@ -59,18 +53,4 @@ public class UINotification implements Serializable {
|
||||
updatedMsg.toString(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display error type of notification message.
|
||||
*
|
||||
* @param message.
|
||||
* @param caption.
|
||||
* @param autoClose.
|
||||
*/
|
||||
public void displayError(final String message, final String caption, final Boolean autoClose) {
|
||||
final StringBuilder updatedMsg = new StringBuilder(FontAwesome.EXCLAMATION_TRIANGLE.getHtml());
|
||||
updatedMsg.append(' ');
|
||||
updatedMsg.append(message);
|
||||
notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, caption,
|
||||
updatedMsg.toString(), autoClose);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user