Merge branch 'master' into Feature_Improve_Code_Quality
Conflicts: hawkbit-core/src/main/java/org/eclipse/hawkbit/api/ArtifactUrlHandlerProperties.java hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListener.java hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -11,18 +11,18 @@ package org.eclipse.hawkbit.ui;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||
|
||||
/**
|
||||
* The default hawkbit event provider.
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
@@ -27,18 +28,14 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
/**
|
||||
* Simple implementation of generics bean query which dynamically loads artifact
|
||||
* beans.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
private static final long serialVersionUID = -333786310371208962L;
|
||||
private Sort sort = new Sort(Direction.DESC, "filename");
|
||||
private transient ArtifactManagement artifactManagement;
|
||||
private transient Page<LocalArtifact> firstPagetArtifacts;
|
||||
private Long baseSwModuleId;
|
||||
private transient ArtifactManagement artifactManagement = null;
|
||||
private transient EntityFactory entityFactory;
|
||||
private transient Page<LocalArtifact> firstPagetArtifacts = null;
|
||||
private Long baseSwModuleId = null;
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
@@ -72,7 +69,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
|
||||
@Override
|
||||
protected LocalArtifact constructBean() {
|
||||
return new LocalArtifact();
|
||||
return entityFactory.generateLocalArtifact();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,4 +112,11 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
}
|
||||
return artifactManagement;
|
||||
}
|
||||
|
||||
private EntityFactory getEntityFactory() {
|
||||
if (entityFactory == null) {
|
||||
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
|
||||
}
|
||||
return entityFactory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
@@ -260,7 +260,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
|
||||
.getItemProperty(PROVIDED_FILE_NAME).getValue();
|
||||
final Button deleteIcon = SPUIComponentProvider.getButton(
|
||||
fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "",
|
||||
fileName + "-" + SPUIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
|
||||
SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true,
|
||||
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
|
||||
deleteIcon.setData(itemId);
|
||||
@@ -344,7 +344,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
detailsTable.setImmediate(true);
|
||||
detailsTable.setSizeFull();
|
||||
|
||||
detailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
|
||||
detailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
|
||||
detailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
detailsTable.addStyleName(ValoTheme.TABLE_SMALL);
|
||||
return detailsTable;
|
||||
@@ -385,7 +385,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
*/
|
||||
public void createMaxArtifactDetailsTable() {
|
||||
maxArtifactDetailsTable = createArtifactDetailsTable();
|
||||
maxArtifactDetailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
|
||||
maxArtifactDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
|
||||
maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource());
|
||||
addGeneratedColumn(maxArtifactDetailsTable);
|
||||
if (!readOnly) {
|
||||
|
||||
@@ -12,17 +12,11 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
* Event to represent software module type add, update or delete.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleTypeEvent {
|
||||
|
||||
/**
|
||||
* Software module type events in the Upload UI.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum SoftwareModuleTypeEnum {
|
||||
ADD_SOFTWARE_MODULE_TYPE, DELETE_SOFTWARE_MODULE_TYPE, UPDATE_SOFTWARE_MODULE_TYPE
|
||||
|
||||
@@ -15,6 +15,5 @@ package org.eclipse.hawkbit.ui.artifacts.event;
|
||||
*
|
||||
*/
|
||||
public enum UploadArtifactUIEvent {
|
||||
|
||||
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, ENABLE_PROCESS_BUTTON, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISABLE_PROCESS_BUTTON, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE
|
||||
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE, MINIMIZED_STATUS_POPUP, MAXIMIZED_STATUS_POPUP, UPLOAD_IN_PROGESS, ARTIFACT_RESULT_POPUP_CLOSED
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds file and upload status details.Meta data sent with upload events.
|
||||
*
|
||||
*/
|
||||
public class UploadFileStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3599629192216760811L;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private long contentLength;
|
||||
|
||||
private long bytesRead;
|
||||
|
||||
private String failureReason;
|
||||
|
||||
private SoftwareModule softwareModule;
|
||||
|
||||
public UploadFileStatus(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public UploadFileStatus(String fileName, long bytesRead, long contentLength,SoftwareModule softwareModule) {
|
||||
this.fileName = fileName;
|
||||
this.contentLength = contentLength;
|
||||
this.bytesRead = bytesRead;
|
||||
this.softwareModule = softwareModule;
|
||||
}
|
||||
|
||||
public UploadFileStatus(String fileName, String failureReason,SoftwareModule selectedSw) {
|
||||
this.failureReason = failureReason;
|
||||
this.fileName = fileName;
|
||||
this.softwareModule = selectedSw;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public long getContentLength() {
|
||||
return contentLength;
|
||||
}
|
||||
|
||||
public long getBytesRead() {
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
public String getFailureReason() {
|
||||
return failureReason;
|
||||
}
|
||||
|
||||
public SoftwareModule getSoftwareModule() {
|
||||
return softwareModule;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.event;
|
||||
/**
|
||||
*
|
||||
* Holds the upload file status.
|
||||
*
|
||||
*/
|
||||
public class UploadStatusEvent {
|
||||
|
||||
public enum UploadStatusEventType {
|
||||
UPLOAD_FAILED, UPLOAD_IN_PROGRESS, UPLOAD_STARTED, UPLOAD_FINISHED, UPLOAD_SUCCESSFUL, UPLOAD_STREAMING_FAILED, UPLOAD_STREAMING_FINISHED, ABORT_UPLOAD
|
||||
}
|
||||
|
||||
private UploadStatusEventType uploadProgressEventType;
|
||||
|
||||
private UploadFileStatus uploadStatus;
|
||||
|
||||
public UploadStatusEvent(UploadStatusEventType eventType, UploadFileStatus entity) {
|
||||
this.uploadProgressEventType = eventType;
|
||||
this.uploadStatus = entity;
|
||||
}
|
||||
|
||||
public UploadFileStatus getUploadStatus() {
|
||||
return uploadStatus;
|
||||
}
|
||||
|
||||
public void setUploadStatus(UploadFileStatus uploadStatus) {
|
||||
this.uploadStatus = uploadStatus;
|
||||
}
|
||||
|
||||
public UploadStatusEventType getUploadProgressEventType() {
|
||||
return uploadProgressEventType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
@@ -37,8 +37,8 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
@Override
|
||||
protected String getComponentId(final Component component) {
|
||||
String id = component.getId();
|
||||
if (id != null && id.startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||
id = SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
|
||||
if (id != null && id.startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||
id = SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@@ -56,16 +56,16 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
private static Map<String, List<String>> createDropConfigurations() {
|
||||
final Map<String, List<String>> config = new HashMap<>();
|
||||
// Delete drop area droppable components
|
||||
config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
|
||||
SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList(
|
||||
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX));
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Map<String, Object> createDropHintConfigurations() {
|
||||
final Map<String, Object> config = new HashMap<>();
|
||||
config.put(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
|
||||
config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
@@ -114,7 +114,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
|
||||
@Override
|
||||
protected String getDeleteAreaId() {
|
||||
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
|
||||
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,10 +130,10 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
addToDeleteList(sourceTable, (TableTransferable) event.getTransferable());
|
||||
updateSWActionCount();
|
||||
}
|
||||
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||
if (sourceComponent.getId().startsWith(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||
|
||||
final String swModuleTypeName = sourceComponent.getId()
|
||||
.replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
|
||||
.replace(SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
|
||||
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
||||
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
|
||||
.equalsIgnoreCase(swModuleTypeName)) {
|
||||
|
||||
@@ -21,7 +21,7 @@ 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.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -77,7 +77,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
||||
private ConfirmationTab createSMDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.SW_DELETE_ALL);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
|
||||
@@ -181,7 +181,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
||||
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
|
||||
|
||||
@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
*
|
||||
* Proxy for software module to display details in Software modules table.
|
||||
@@ -19,7 +17,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
|
||||
public class ProxyBaseSoftwareModuleItem {
|
||||
|
||||
private static final long serialVersionUID = -1555306616599140635L;
|
||||
|
||||
@@ -39,6 +37,11 @@ public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
|
||||
|
||||
private String modifiedByUser;
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private String vendor;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -47,6 +50,38 @@ public class ProxyBaseSoftwareModuleItem extends SoftwareModule {
|
||||
swId = RANDOM_OBJ.nextLong();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(final String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCreatedByUser() {
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
@@ -10,47 +10,43 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
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.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.FormLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Generates window for Software module add or update.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
public class SoftwareModuleAddUpdateWindow extends CustomComponent implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5217675246477211483L;
|
||||
|
||||
@@ -66,7 +62,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
@Autowired
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
private Label madatoryLabel;
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private TextField nameTextField;
|
||||
|
||||
@@ -74,35 +71,34 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
|
||||
private TextField vendorTextField;
|
||||
|
||||
private Button saveSoftware;
|
||||
|
||||
private Button closeWindow;
|
||||
|
||||
private ComboBox typeComboBox;
|
||||
|
||||
private TextArea descTextArea;
|
||||
|
||||
private Window window;
|
||||
|
||||
private String oldDescriptionValue;
|
||||
|
||||
private String oldVendorValue;
|
||||
private CommonDialogWindow window;
|
||||
|
||||
private Boolean editSwModule = Boolean.FALSE;
|
||||
|
||||
private Long baseSwModuleId;
|
||||
|
||||
private FormLayout formLayout;
|
||||
|
||||
/**
|
||||
* Initialize Distribution Add and Edit Window.
|
||||
*/
|
||||
@PostConstruct
|
||||
void init() {
|
||||
createRequiredComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create window for new software module.
|
||||
*
|
||||
* @return reference of {@link com.vaadin.ui.Window} to add new software
|
||||
* module.
|
||||
*/
|
||||
public Window createAddSoftwareModuleWindow() {
|
||||
editSwModule = Boolean.FALSE;
|
||||
createRequiredComponents();
|
||||
createWindow();
|
||||
return window;
|
||||
public CommonDialogWindow createAddSoftwareModuleWindow() {
|
||||
return createUpdateSoftwareModuleWindow(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,185 +109,114 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
* @return reference of {@link com.vaadin.ui.Window} to update software
|
||||
* module.
|
||||
*/
|
||||
public Window createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
||||
editSwModule = Boolean.TRUE;
|
||||
public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
||||
this.baseSwModuleId = baseSwModuleId;
|
||||
createRequiredComponents();
|
||||
createWindow();
|
||||
/* populate selected target values to edit. */
|
||||
resetComponents();
|
||||
populateValuesOfSwModule();
|
||||
nameTextField.setEnabled(false);
|
||||
versionTextField.setEnabled(false);
|
||||
typeComboBox.setEnabled(false);
|
||||
createWindow();
|
||||
return window;
|
||||
}
|
||||
|
||||
private void createRequiredComponents() {
|
||||
/* name textfield */
|
||||
nameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
nameTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_NAME);
|
||||
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
||||
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
|
||||
|
||||
/* version text field */
|
||||
versionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
||||
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
versionTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_VERSION);
|
||||
versionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
||||
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
|
||||
|
||||
/* Vendor text field */
|
||||
vendorTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
vendorTextField.setId(SPUIComponetIdProvider.SOFT_MODULE_VENDOR);
|
||||
vendorTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.vendor"), "", ValoTheme.TEXTFIELD_TINY,
|
||||
false, null, i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
|
||||
|
||||
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
|
||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
descTextArea.setId(SPUIComponetIdProvider.ADD_SW_MODULE_DESCRIPTION);
|
||||
addDescriptionTextChangeListener();
|
||||
addVendorTextChangeListener();
|
||||
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
||||
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
|
||||
|
||||
/* Label for mandatory symbol */
|
||||
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
||||
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||
madatoryLabel.addStyleName(ValoTheme.LABEL_SMALL);
|
||||
|
||||
typeComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, null,
|
||||
i18n.get("upload.swmodule.type"));
|
||||
typeComboBox.setId(SPUIComponetIdProvider.SW_MODULE_TYPE);
|
||||
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", "", null, null, true,
|
||||
null, i18n.get("upload.swmodule.type"));
|
||||
typeComboBox.setId(SPUIComponentIdProvider.SW_MODULE_TYPE);
|
||||
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
|
||||
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
|
||||
typeComboBox.setImmediate(Boolean.TRUE);
|
||||
|
||||
populateTypeNameCombo();
|
||||
|
||||
/* save or update button */
|
||||
saveSoftware = SPUIComponentProvider.getButton(SPUIComponetIdProvider.SOFT_MODULE_SAVE, "", "", "", true,
|
||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
||||
saveSoftware.addClickListener(event -> {
|
||||
if (editSwModule) {
|
||||
updateSwModule();
|
||||
} else {
|
||||
/* add new or update software module */
|
||||
addNewBaseSoftware();
|
||||
}
|
||||
});
|
||||
|
||||
/* close button */
|
||||
closeWindow = SPUIComponentProvider.getButton(SPUIComponetIdProvider.SOFT_MODULE_DISCARD, "", "", "", true,
|
||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
/* Just close this window when this button is clicked */
|
||||
closeWindow.addClickListener(event -> closeThisWindow());
|
||||
|
||||
resetOldValues();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void populateTypeNameCombo() {
|
||||
typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
||||
typeComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||
|
||||
}
|
||||
|
||||
private void resetOldValues() {
|
||||
oldDescriptionValue = null;
|
||||
oldVendorValue = null;
|
||||
private void resetComponents() {
|
||||
|
||||
vendorTextField.clear();
|
||||
nameTextField.clear();
|
||||
versionTextField.clear();
|
||||
descTextArea.clear();
|
||||
typeComboBox.clear();
|
||||
editSwModule = Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep UI components on Layout.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void createWindow() {
|
||||
/* action button layout (save & dicard) */
|
||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
||||
buttonsLayout.setSizeFull();
|
||||
buttonsLayout.addComponents(saveSoftware, closeWindow);
|
||||
buttonsLayout.setComponentAlignment(saveSoftware, Alignment.BOTTOM_LEFT);
|
||||
buttonsLayout.setComponentAlignment(closeWindow, Alignment.BOTTOM_RIGHT);
|
||||
buttonsLayout.addStyleName("window-style");
|
||||
|
||||
final Label madatoryStarLabel = new Label("*");
|
||||
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
|
||||
madatoryStarLabel.setWidth(null);
|
||||
final HorizontalLayout hLayout = new HorizontalLayout();
|
||||
hLayout.setSizeFull();
|
||||
hLayout.addComponents(typeComboBox, madatoryStarLabel);
|
||||
hLayout.setComponentAlignment(typeComboBox, Alignment.TOP_LEFT);
|
||||
hLayout.setComponentAlignment(madatoryStarLabel, Alignment.TOP_RIGHT);
|
||||
hLayout.setExpandRatio(typeComboBox, 0.8f);
|
||||
addStyleName("lay-color");
|
||||
setSizeUndefined();
|
||||
|
||||
/*
|
||||
* The main layout of the window contains mandatory info, textboxes
|
||||
* (controller Id, name & description) and action buttons layout
|
||||
*/
|
||||
final VerticalLayout mainLayout = new VerticalLayout();
|
||||
mainLayout.setSpacing(Boolean.TRUE);
|
||||
mainLayout.addStyleName("lay-color");
|
||||
mainLayout.addComponent(madatoryLabel);
|
||||
mainLayout.setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
|
||||
mainLayout.addComponent(hLayout);
|
||||
mainLayout.setComponentAlignment(hLayout, Alignment.MIDDLE_LEFT);
|
||||
mainLayout.addComponents(nameTextField, versionTextField, vendorTextField, descTextArea, buttonsLayout);
|
||||
|
||||
/* add main layout to the window */
|
||||
window = SPUIComponentProvider.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
|
||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
||||
window.setContent(mainLayout);
|
||||
window.setModal(true);
|
||||
nameTextField.focus();
|
||||
formLayout = new FormLayout();
|
||||
formLayout.setCaption(null);
|
||||
formLayout.addComponent(typeComboBox);
|
||||
formLayout.addComponent(nameTextField);
|
||||
formLayout.addComponent(versionTextField);
|
||||
formLayout.addComponent(vendorTextField);
|
||||
formLayout.addComponent(descTextArea);
|
||||
|
||||
setCompositionRoot(formLayout);
|
||||
|
||||
window = SPUIWindowDecorator.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
|
||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> saveOrUpdate(), null, null, formLayout, i18n);
|
||||
window.getButtonsLayout().removeStyleName("actionButtonsMargin");
|
||||
|
||||
nameTextField.setEnabled(!editSwModule);
|
||||
versionTextField.setEnabled(!editSwModule);
|
||||
typeComboBox.setEnabled(!editSwModule);
|
||||
|
||||
typeComboBox.focus();
|
||||
}
|
||||
|
||||
private void addDescriptionTextChangeListener() {
|
||||
descTextArea.addTextChangeListener(event -> {
|
||||
if (event.getText().equals(oldDescriptionValue) && vendorTextField.getValue().equals(oldVendorValue)) {
|
||||
saveSoftware.setEnabled(false);
|
||||
} else {
|
||||
saveSoftware.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addVendorTextChangeListener() {
|
||||
vendorTextField.addTextChangeListener(event -> {
|
||||
if (event.getText().equals(oldVendorValue) && descTextArea.getValue().equals(oldDescriptionValue)) {
|
||||
saveSoftware.setEnabled(false);
|
||||
} else {
|
||||
saveSoftware.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new SW module.
|
||||
*/
|
||||
private void addNewBaseSoftware() {
|
||||
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(nameTextField.getValue());
|
||||
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(versionTextField.getValue());
|
||||
final String vendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
||||
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
||||
if (mandatoryCheck(name, version, type)) {
|
||||
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
||||
uiNotifcation.displayValidationError(
|
||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||
} else {
|
||||
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(name, version, vendor,
|
||||
softwareManagement.findSoftwareModuleTypeByName(type), description);
|
||||
if (newBaseSoftwareModule != null) {
|
||||
/* display success message */
|
||||
uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] {
|
||||
newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() }));
|
||||
eventBus.publish(this,
|
||||
new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule));
|
||||
}
|
||||
// close the window
|
||||
closeThisWindow();
|
||||
|
||||
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
||||
uiNotifcation.displayValidationError(
|
||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||
} else {
|
||||
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
|
||||
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
|
||||
if (newBaseSoftwareModule != null) {
|
||||
/* display success message */
|
||||
uiNotifcation.displaySuccess(i18n.get("message.save.success",
|
||||
new Object[] { newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() }));
|
||||
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updates a softwareModule
|
||||
*/
|
||||
private void updateSwModule() {
|
||||
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
final String newVendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
||||
@@ -305,10 +230,16 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
|
||||
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.UPDATED_ENTITY, newSWModule));
|
||||
}
|
||||
closeThisWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* fill the data of a softwareModule in the content of the window
|
||||
*/
|
||||
private void populateValuesOfSwModule() {
|
||||
if (baseSwModuleId == null) {
|
||||
return;
|
||||
}
|
||||
editSwModule = Boolean.TRUE;
|
||||
final SoftwareModule swModle = softwareManagement.findSoftwareModuleById(baseSwModuleId);
|
||||
nameTextField.setValue(swModle.getName());
|
||||
versionTextField.setValue(swModle.getVersion());
|
||||
@@ -316,48 +247,22 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
||||
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getVendor()));
|
||||
descTextArea.setValue(swModle.getDescription() == null ? HawkbitCommonUtil.SP_STRING_EMPTY
|
||||
: HawkbitCommonUtil.trimAndNullIfEmpty(swModle.getDescription()));
|
||||
oldDescriptionValue = descTextArea.getValue();
|
||||
oldVendorValue = vendorTextField.getValue();
|
||||
if (swModle.getType().isDeleted()) {
|
||||
typeComboBox.addItem(swModle.getType().getName());
|
||||
}
|
||||
typeComboBox.setValue(swModle.getType().getName());
|
||||
saveSoftware.setEnabled(Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to close window.
|
||||
*/
|
||||
private void closeThisWindow() {
|
||||
window.close();
|
||||
UI.getCurrent().removeWindow(window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation check - Mandatory.
|
||||
*
|
||||
* @param name
|
||||
* as String
|
||||
* @param version
|
||||
* as version
|
||||
* @return boolena as flag
|
||||
*/
|
||||
private boolean mandatoryCheck(final String name, final String version, final String type) {
|
||||
boolean isValid = true;
|
||||
if (name == null || version == null || type == null) {
|
||||
if (name == null) {
|
||||
nameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||
}
|
||||
if (version == null) {
|
||||
versionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||
}
|
||||
if (type == null) {
|
||||
typeComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
|
||||
}
|
||||
|
||||
uiNotifcation.displayValidationError(i18n.get("message.mandatory.check"));
|
||||
isValid = false;
|
||||
private void saveOrUpdate() {
|
||||
if (editSwModule) {
|
||||
updateSwModule();
|
||||
} else {
|
||||
addNewBaseSoftware();
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public FormLayout getFormLayout() {
|
||||
return formLayout;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -47,7 +47,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
|
||||
@Override
|
||||
protected String getEditButtonId() {
|
||||
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
|
||||
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,19 +90,19 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
|
||||
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
|
||||
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
|
||||
vendorLabel.setId(SPUIComponentIdProvider.DETAILS_VENDOR_LABEL_ID);
|
||||
detailsTabLayout.addComponent(vendorLabel);
|
||||
|
||||
if (type != null) {
|
||||
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
|
||||
type);
|
||||
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
detailsTabLayout.addComponent(typeLabel);
|
||||
}
|
||||
|
||||
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
|
||||
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
|
||||
assignLabel.setId(SPUIComponentIdProvider.SWM_DTLS_MAX_ASSIGN);
|
||||
detailsTabLayout.addComponent(assignLabel);
|
||||
|
||||
}
|
||||
@@ -139,6 +139,6 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
|
||||
|
||||
@Override
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponetIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||
@@ -44,7 +44,6 @@ import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Header of Software module table.
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
@@ -75,7 +74,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,4 +210,5 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
||||
protected void setDataAvailable(final boolean available) {
|
||||
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -58,17 +58,17 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getSearchBoxId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
|
||||
return SPUIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSearchRestIconId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON;
|
||||
return SPUIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAddIconId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON;
|
||||
return SPUIComponentIdProvider.SW_MODULE_ADD_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getMaxMinIconId() {
|
||||
return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON;
|
||||
return SPUIComponentIdProvider.SW_MAX_MIN_TABLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,10 +17,7 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
|
||||
/**
|
||||
* Software module table layout.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Software module table layout. (Upload Management)
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
@@ -44,4 +41,5 @@ public class SoftwareModuleTableLayout extends AbstractTableLayout {
|
||||
void init() {
|
||||
super.init(smTableHeader, smTable, softwareModuleDetails);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,275 +9,106 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
|
||||
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
||||
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
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.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.vaadin.data.Property.ValueChangeEvent;
|
||||
import com.vaadin.data.Property.ValueChangeListener;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.OptionGroup;
|
||||
import com.vaadin.ui.Slider;
|
||||
import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||
import com.vaadin.ui.components.colorpicker.ColorPickerGradient;
|
||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
* Layout for the create or update software module type.
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
|
||||
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout {
|
||||
|
||||
private static final long serialVersionUID = -5169398523815919367L;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class);
|
||||
|
||||
@Autowired
|
||||
private SpPermissionChecker permChecker;
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
/**
|
||||
* Instance of ColorPickerPreview.
|
||||
*/
|
||||
private SpColorPickerPreview selPreview;
|
||||
|
||||
@Autowired
|
||||
private transient UINotification uiNotification;
|
||||
|
||||
@Autowired
|
||||
private transient SoftwareManagement swTypeManagementService;
|
||||
|
||||
@Autowired
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private String createTypeStr;
|
||||
private String updateTypeStr;
|
||||
private String singleAssignStr;
|
||||
private String multiAssignStr;
|
||||
private Label createType;
|
||||
private Label updateType;
|
||||
private Label singleAssign;
|
||||
private Label multiAssign;
|
||||
private Label comboLabel;
|
||||
private Label colorLabel;
|
||||
private Label madatoryLabel;
|
||||
private TextField typeName;
|
||||
private TextField typeKey;
|
||||
private TextArea typeDesc;
|
||||
private Button saveTag;
|
||||
private Button discardTag;
|
||||
private Button tagColorPreviewBtn;
|
||||
private OptionGroup createOptiongroup;
|
||||
private OptionGroup assignOptiongroup;
|
||||
private ComboBox typeNameComboBox;
|
||||
protected static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
||||
private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||
private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
||||
private Set<ColorSelector> selectors;
|
||||
private Color selectedColor;
|
||||
private ColorPickerGradient colorSelect;
|
||||
private Slider redSlider;
|
||||
private Slider greenSlider;
|
||||
private Slider blueSlider;
|
||||
private Window swTypeWindow;
|
||||
protected boolean tagPreviewBtnClicked = false;
|
||||
private VerticalLayout comboLayout;
|
||||
private VerticalLayout sliders;
|
||||
private VerticalLayout colorPickerLayout;
|
||||
private HorizontalLayout mainLayout;
|
||||
private VerticalLayout fieldLayout;
|
||||
|
||||
/** RGB color converter. */
|
||||
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
||||
|
||||
/**
|
||||
* Initialize the artifact details layout.
|
||||
*/
|
||||
public void init() {
|
||||
createComponents();
|
||||
buildLayout();
|
||||
addListeners();
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
super.addListeners();
|
||||
optiongroup.addValueChangeListener(this::optionValueChanged);
|
||||
}
|
||||
|
||||
private void createComponents() {
|
||||
createTypeStr = i18n.get("label.create.type");
|
||||
updateTypeStr = i18n.get("label.update.type");
|
||||
@Override
|
||||
protected void createRequiredComponents() {
|
||||
|
||||
super.createRequiredComponents();
|
||||
|
||||
singleAssignStr = i18n.get("label.singleAssign.type");
|
||||
multiAssignStr = i18n.get("label.multiAssign.type");
|
||||
createType = SPUIComponentProvider.getLabel(createTypeStr, null);
|
||||
updateType = SPUIComponentProvider.getLabel(updateTypeStr, null);
|
||||
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
||||
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||
madatoryLabel = getMandatoryLabel();
|
||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||
|
||||
typeName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME,
|
||||
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
typeName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
||||
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME, true, "", i18n.get("textfield.name"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
tagName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
||||
|
||||
typeKey = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY,
|
||||
true, "", i18n.get("textfield.key"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
|
||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY, true, "", i18n.get("textfield.key"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
typeKey.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
|
||||
|
||||
typeDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC,
|
||||
false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
|
||||
typeDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
|
||||
typeDesc.setImmediate(true);
|
||||
typeDesc.setNullRepresentation("");
|
||||
|
||||
typeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
|
||||
i18n.get("label.combobox.type"));
|
||||
typeNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
||||
typeNameComboBox.setImmediate(true);
|
||||
|
||||
saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_SW_TYPE_SAVE, "", "", "", true, FontAwesome.SAVE,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||
|
||||
discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
|
||||
"discard-button-style", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||
|
||||
tagColorPreviewBtn = new Button();
|
||||
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||
getPreviewButtonColor(DEFAULT_COLOR);
|
||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||
|
||||
selectors = new HashSet<>();
|
||||
selectedColor = new Color(44, 151, 32);
|
||||
selPreview = new SpColorPickerPreview(selectedColor);
|
||||
|
||||
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
|
||||
colorSelect.setColor(selectedColor);
|
||||
colorSelect.setWidth("220px");
|
||||
|
||||
redSlider = createRGBSlider("", "red");
|
||||
greenSlider = createRGBSlider("", "green");
|
||||
blueSlider = createRGBSlider("", "blue");
|
||||
setRgbSliderValues(selectedColor);
|
||||
|
||||
createUpdateOptionGroup();
|
||||
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC, false, "",
|
||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
tagDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
|
||||
tagDesc.setImmediate(true);
|
||||
tagDesc.setNullRepresentation("");
|
||||
|
||||
singleMultiOptionGroup();
|
||||
|
||||
}
|
||||
|
||||
private void buildLayout() {
|
||||
comboLayout = new VerticalLayout();
|
||||
@Override
|
||||
protected void buildLayout() {
|
||||
|
||||
sliders = new VerticalLayout();
|
||||
sliders.addComponents(redSlider, greenSlider, blueSlider);
|
||||
|
||||
selectors.add(colorSelect);
|
||||
|
||||
colorPickerLayout = new VerticalLayout();
|
||||
colorPickerLayout.setStyleName("rgb-vertical-layout");
|
||||
colorPickerLayout.addComponent(selPreview);
|
||||
colorPickerLayout.addComponent(colorSelect);
|
||||
|
||||
fieldLayout = new VerticalLayout();
|
||||
fieldLayout.setSpacing(true);
|
||||
fieldLayout.setMargin(false);
|
||||
fieldLayout.setWidth("100%");
|
||||
fieldLayout.setHeight(null);
|
||||
fieldLayout.addComponent(createOptiongroup);
|
||||
fieldLayout.addComponent(comboLayout);
|
||||
fieldLayout.addComponent(madatoryLabel);
|
||||
fieldLayout.addComponent(typeName);
|
||||
fieldLayout.addComponent(typeKey);
|
||||
fieldLayout.addComponent(typeDesc);
|
||||
fieldLayout.addComponent(assignOptiongroup);
|
||||
|
||||
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
|
||||
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
||||
fieldLayout.addComponent(colorLabelLayout);
|
||||
|
||||
final HorizontalLayout buttonLayout = new HorizontalLayout();
|
||||
buttonLayout.addComponent(saveTag);
|
||||
buttonLayout.addComponent(discardTag);
|
||||
buttonLayout.setComponentAlignment(discardTag, Alignment.BOTTOM_RIGHT);
|
||||
buttonLayout.setComponentAlignment(saveTag, Alignment.BOTTOM_LEFT);
|
||||
buttonLayout.addStyleName("window-style");
|
||||
buttonLayout.setWidth("152px");
|
||||
|
||||
final VerticalLayout fieldButtonLayout = new VerticalLayout();
|
||||
fieldButtonLayout.addComponent(fieldLayout);
|
||||
fieldButtonLayout.addComponent(buttonLayout);
|
||||
|
||||
mainLayout = new HorizontalLayout();
|
||||
mainLayout.addComponent(fieldButtonLayout);
|
||||
setCompositionRoot(mainLayout);
|
||||
typeName.focus();
|
||||
super.buildLayout();
|
||||
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||
getFormLayout().addComponent(typeKey, 4);
|
||||
getFormLayout().addComponent(assignOptiongroup);
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
saveTag.addClickListener(event -> save());
|
||||
discardTag.addClickListener(event -> discard());
|
||||
colorSelect.addColorChangeListener(this);
|
||||
selPreview.addColorChangeListener(this);
|
||||
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
|
||||
createOptiongroup.addValueChangeListener(event -> createOptionValueChanged(event));
|
||||
typeNameComboBox.addValueChangeListener(event -> typeNameChosen(event));
|
||||
slidersValueChangeListeners();
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
reset();
|
||||
swTypeWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.type"), null,
|
||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
||||
swTypeWindow.setContent(this);
|
||||
return swTypeWindow;
|
||||
|
||||
@Override
|
||||
protected String getWindowCaption() {
|
||||
return i18n.get("caption.add.type");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,100 +117,36 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
* @param event
|
||||
* ValueChangeEvent
|
||||
*/
|
||||
private void createOptionValueChanged(final ValueChangeEvent event) {
|
||||
if ("Update Type".equals(event.getProperty().getValue())) {
|
||||
typeName.clear();
|
||||
typeDesc.clear();
|
||||
typeKey.clear();
|
||||
typeKey.setEnabled(false);
|
||||
typeName.setEnabled(false);
|
||||
@Override
|
||||
protected void optionValueChanged(final ValueChangeEvent event) {
|
||||
|
||||
super.optionValueChanged(event);
|
||||
|
||||
if (updateTypeStr.equals(event.getProperty().getValue())) {
|
||||
assignOptiongroup.setEnabled(false);
|
||||
|
||||
populateTypeNameCombo();
|
||||
// show target name combo
|
||||
comboLayout.addComponent(comboLabel);
|
||||
comboLayout.addComponent(typeNameComboBox);
|
||||
} else {
|
||||
typeKey.setEnabled(true);
|
||||
typeName.setEnabled(true);
|
||||
typeName.clear();
|
||||
typeDesc.clear();
|
||||
typeKey.clear();
|
||||
assignOptiongroup.setEnabled(true);
|
||||
// hide target name combo
|
||||
comboLayout.removeComponent(comboLabel);
|
||||
comboLayout.removeComponent(typeNameComboBox);
|
||||
}
|
||||
// close the color picker layout
|
||||
tagPreviewBtnClicked = false;
|
||||
// reset the selected color - Set defualt color
|
||||
restoreComponentStyles();
|
||||
getPreviewButtonColor(DEFAULT_COLOR);
|
||||
selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
|
||||
// remove the sliders and color picker layout
|
||||
fieldLayout.removeComponent(sliders);
|
||||
mainLayout.removeComponent(colorPickerLayout);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate Software Module Type name combo.
|
||||
*/
|
||||
public void populateTypeNameCombo() {
|
||||
typeNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
||||
typeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||
assignOptiongroup.select(singleAssignStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the components.
|
||||
*/
|
||||
private void reset() {
|
||||
typeName.setEnabled(true);
|
||||
typeName.clear();
|
||||
typeKey.clear();
|
||||
typeDesc.clear();
|
||||
restoreComponentStyles();
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
// hide target name combo
|
||||
comboLayout.removeComponent(comboLabel);
|
||||
comboLayout.removeComponent(typeNameComboBox);
|
||||
fieldLayout.removeComponent(sliders);
|
||||
mainLayout.removeComponent(colorPickerLayout);
|
||||
|
||||
createOptiongroup.select(createTypeStr);
|
||||
super.reset();
|
||||
assignOptiongroup.select(singleAssignStr);
|
||||
// Default green color
|
||||
selectedColor = new Color(44, 151, 32);
|
||||
selPreview.setColor(selectedColor);
|
||||
tagPreviewBtnClicked = false;
|
||||
}
|
||||
|
||||
private void typeNameChosen(final ValueChangeEvent event) {
|
||||
final String tagSelected = (String) event.getProperty().getValue();
|
||||
if (null != tagSelected) {
|
||||
setTypeTagCombo(tagSelected);
|
||||
} else {
|
||||
resetTagNameField();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetTagNameField() {
|
||||
typeName.setEnabled(false);
|
||||
typeName.clear();
|
||||
@Override
|
||||
protected void resetTagNameField() {
|
||||
|
||||
super.resetTagNameField();
|
||||
typeKey.clear();
|
||||
typeDesc.clear();
|
||||
restoreComponentStyles();
|
||||
fieldLayout.removeComponent(sliders);
|
||||
mainLayout.removeComponent(colorPickerLayout);
|
||||
|
||||
tagDesc.clear();
|
||||
assignOptiongroup.select(singleAssignStr);
|
||||
// Default green color
|
||||
selectedColor = new Color(44, 151, 32);
|
||||
selPreview.setColor(selectedColor);
|
||||
tagPreviewBtnClicked = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,59 +156,23 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
* @param targetTagSelected
|
||||
* as the selected tag from combo
|
||||
*/
|
||||
private void setTypeTagCombo(final String targetTagSelected) {
|
||||
typeName.setValue(targetTagSelected);
|
||||
@Override
|
||||
protected void setTagDetails(final String targetTagSelected) {
|
||||
tagName.setValue(targetTagSelected);
|
||||
final SoftwareModuleType selectedTypeTag = swTypeManagementService
|
||||
.findSoftwareModuleTypeByName(targetTagSelected);
|
||||
if (null != selectedTypeTag) {
|
||||
typeDesc.setValue(selectedTypeTag.getDescription());
|
||||
tagDesc.setValue(selectedTypeTag.getDescription());
|
||||
typeKey.setValue(selectedTypeTag.getKey());
|
||||
if (selectedTypeTag.getMaxAssignments() == Integer.MAX_VALUE) {
|
||||
assignOptiongroup.setValue(multiAssignStr);
|
||||
} else {
|
||||
if (selectedTypeTag.getMaxAssignments() == 1) {
|
||||
assignOptiongroup.setValue(singleAssignStr);
|
||||
}
|
||||
|
||||
if (null == selectedTypeTag.getColour()) {
|
||||
selectedColor = new Color(44, 151, 32);
|
||||
selPreview.setColor(selectedColor);
|
||||
colorSelect.setColor(selectedColor);
|
||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, DEFAULT_COLOR);
|
||||
getPreviewButtonColor(DEFAULT_COLOR);
|
||||
} else {
|
||||
selectedColor = rgbToColorConverter(selectedTypeTag.getColour());
|
||||
selPreview.setColor(selectedColor);
|
||||
colorSelect.setColor(selectedColor);
|
||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, selectedTypeTag.getColour());
|
||||
getPreviewButtonColor(selectedTypeTag.getColour());
|
||||
assignOptiongroup.setValue(multiAssignStr);
|
||||
}
|
||||
|
||||
setColorPickerComponentsColor(selectedTypeTag.getColour());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic styles for window.
|
||||
*
|
||||
* @param top
|
||||
* int value
|
||||
* @param marginLeft
|
||||
* int value
|
||||
*/
|
||||
private void getPreviewButtonColor(final String color) {
|
||||
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
|
||||
}
|
||||
|
||||
private void createUpdateOptionGroup() {
|
||||
final List<String> optionValues = new ArrayList<>();
|
||||
if (permChecker.hasCreateDistributionPermission()) {
|
||||
optionValues.add(createType.getValue());
|
||||
}
|
||||
if (permChecker.hasUpdateDistributionPermission()) {
|
||||
optionValues.add(updateType.getValue());
|
||||
}
|
||||
createOptionGroupByValues(optionValues);
|
||||
}
|
||||
|
||||
private void singleMultiOptionGroup() {
|
||||
final List<String> optionValues = new ArrayList<>();
|
||||
optionValues.add(singleAssign.getValue());
|
||||
@@ -449,16 +180,6 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
assignOptionGroupByValues(optionValues);
|
||||
}
|
||||
|
||||
private void createOptionGroupByValues(final List<String> tagOptions) {
|
||||
createOptiongroup = new OptionGroup("", tagOptions);
|
||||
createOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||
createOptiongroup.addStyleName("custom-option-group");
|
||||
createOptiongroup.setNullSelectionAllowed(false);
|
||||
if (!tagOptions.isEmpty()) {
|
||||
createOptiongroup.select(tagOptions.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
private void assignOptionGroupByValues(final List<String> tagOptions) {
|
||||
assignOptiongroup = new OptionGroup("", tagOptions);
|
||||
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||
@@ -467,156 +188,27 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
assignOptiongroup.select(tagOptions.get(0));
|
||||
}
|
||||
|
||||
private Label getMandatoryLabel() {
|
||||
final Label label = new Label(i18n.get("label.mandatory.field"));
|
||||
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
||||
return label;
|
||||
}
|
||||
|
||||
private Slider createRGBSlider(final String caption, final String styleName) {
|
||||
final Slider slider = new Slider(caption, 0, 255);
|
||||
slider.setImmediate(true);
|
||||
slider.setWidth("150px");
|
||||
slider.addStyleName(styleName);
|
||||
return slider;
|
||||
}
|
||||
|
||||
private void setRgbSliderValues(final Color color) {
|
||||
try {
|
||||
final double redColorValue = color.getRed();
|
||||
redSlider.setValue(new Double(redColorValue));
|
||||
final double blueColorValue = color.getBlue();
|
||||
blueSlider.setValue(new Double(blueColorValue));
|
||||
final double greenColorValue = color.getGreen();
|
||||
greenSlider.setValue(new Double(greenColorValue));
|
||||
} catch (final ValueOutOfBoundsException e) {
|
||||
LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
|
||||
+ color.getBlue(), e);
|
||||
@Override
|
||||
protected void save(final ClickEvent event) {
|
||||
final SoftwareModuleType existingSMTypeByKey = swTypeManagementService
|
||||
.findSoftwareModuleTypeByKey(typeKey.getValue());
|
||||
final SoftwareModuleType existingSMTypeByName = swTypeManagementService
|
||||
.findSoftwareModuleTypeByName(tagName.getValue());
|
||||
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||
if (!checkIsDuplicateByKey(existingSMTypeByKey) && !checkIsDuplicate(existingSMTypeByName)) {
|
||||
createNewSWModuleType();
|
||||
}
|
||||
} else {
|
||||
updateSWModuleType(existingSMTypeByName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Value change listeners implementations of sliders.
|
||||
*/
|
||||
private void slidersValueChangeListeners() {
|
||||
redSlider.addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = -8336732888800920839L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double red = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue());
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
greenSlider.addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = 1236358037766775663L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double green = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color(selectedColor.getRed(), (int) green, selectedColor.getBlue());
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
blueSlider.addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = 8466370763686043947L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double blue = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color(selectedColor.getRed(), selectedColor.getGreen(), (int) blue);
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setColorToComponents(final Color newColor) {
|
||||
setColor(newColor);
|
||||
colorSelect.setColor(newColor);
|
||||
getPreviewButtonColor(newColor.getCSS());
|
||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, newColor.getCSS());
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the tag name and tag description component border color.
|
||||
*/
|
||||
private void restoreComponentStyles() {
|
||||
typeName.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeDesc.removeStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
||||
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
getPreviewButtonColor(DEFAULT_COLOR);
|
||||
}
|
||||
|
||||
private void save() {
|
||||
if (mandatoryValuesPresent()) {
|
||||
final SoftwareModuleType existingType = swTypeManagementService
|
||||
.findSoftwareModuleTypeByName(typeName.getValue());
|
||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
||||
if (!checkIsKeyDuplicate(typeKey.getValue()) && !checkIsDuplicate(existingType)) {
|
||||
createNewSWModuleType();
|
||||
}
|
||||
} else {
|
||||
|
||||
updateSWModuleType(existingType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIsKeyDuplicate(final String key) {
|
||||
final SoftwareModuleType existingKeyType = swTypeManagementService.findSoftwareModuleTypeByKey(key);
|
||||
if (existingKeyType != null) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.get("message.type.key.swmodule.duplicate.check", new Object[] { existingKeyType.getKey() }));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
private Boolean mandatoryValuesPresent() {
|
||||
if (Strings.isNullOrEmpty(typeName.getValue()) && Strings.isNullOrEmpty(typeKey.getValue())) {
|
||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
||||
}
|
||||
if (createOptiongroup.getValue().equals(updateTypeStr)) {
|
||||
if (null == typeNameComboBox.getValue()) {
|
||||
uiNotification.displayValidationError(i18n.get("message.error.missing.typename"));
|
||||
} else {
|
||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
private Boolean checkIsDuplicate(final SoftwareModuleType existingType) {
|
||||
if (existingType != null) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
private void closeWindow() {
|
||||
swTypeWindow.close();
|
||||
UI.getCurrent().removeWindow(swTypeWindow);
|
||||
}
|
||||
|
||||
private void discard() {
|
||||
UI.getCurrent().removeWindow(swTypeWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new tag.
|
||||
*/
|
||||
private void createNewSWModuleType() {
|
||||
int assignNumber = 0;
|
||||
final String colorPicked = getColorPickedString();
|
||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeName.getValue());
|
||||
final String colorPicked = ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview());
|
||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
|
||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||
final String assignValue = (String) assignOptiongroup.getValue();
|
||||
if (null != assignValue && assignValue.equalsIgnoreCase(singleAssignStr)) {
|
||||
assignNumber = 1;
|
||||
@@ -625,121 +217,35 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
}
|
||||
|
||||
if (null != typeNameValue && null != typeKeyValue) {
|
||||
SoftwareModuleType newSWType = new SoftwareModuleType(typeKeyValue, typeNameValue, typeDescValue,
|
||||
assignNumber, colorPicked);
|
||||
if (null != typeDescValue) {
|
||||
newSWType.setDescription(typeDescValue);
|
||||
}
|
||||
|
||||
SoftwareModuleType newSWType = entityFactory.generateSoftwareModuleType(typeKeyValue, typeNameValue,
|
||||
typeDescValue, assignNumber);
|
||||
newSWType.setColour(colorPicked);
|
||||
newSWType.setDescription(typeDescValue);
|
||||
newSWType.setColour(colorPicked);
|
||||
|
||||
newSWType = swTypeManagementService.createSoftwareModuleType(newSWType);
|
||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newSWType.getName() }));
|
||||
closeWindow();
|
||||
eventBus.publish(this,
|
||||
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE, newSWType));
|
||||
|
||||
} else {
|
||||
uiNotification.displayValidationError(i18n.get("message.error.missing.typenameorkey"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color picked value in string.
|
||||
*
|
||||
* @return String of color picked value.
|
||||
*/
|
||||
private String getColorPickedString() {
|
||||
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
|
||||
+ getSelPreview().getColor().getBlue() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Color view.
|
||||
*
|
||||
* @return ColorPickerPreview as UI
|
||||
*/
|
||||
public SpColorPickerPreview getSelPreview() {
|
||||
return selPreview;
|
||||
}
|
||||
|
||||
/**
|
||||
* update tag.
|
||||
*/
|
||||
private void updateSWModuleType(final SoftwareModuleType existingType) {
|
||||
|
||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeName.getValue());
|
||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
|
||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||
if (null != typeNameValue) {
|
||||
existingType.setName(typeNameValue);
|
||||
|
||||
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
|
||||
|
||||
existingType.setColour(getColorPickedString());
|
||||
existingType.setDescription(typeDescValue);
|
||||
existingType.setColour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
|
||||
swTypeManagementService.updateSoftwareModuleType(existingType);
|
||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
|
||||
closeWindow();
|
||||
eventBus.publish(this,
|
||||
new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType));
|
||||
|
||||
} else {
|
||||
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Open color picker on click of preview button. Auto select the color based
|
||||
* on target tag if already selected.
|
||||
*/
|
||||
private void previewButtonClicked() {
|
||||
if (!tagPreviewBtnClicked) {
|
||||
final String selectedOption = (String) createOptiongroup.getValue();
|
||||
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTypeStr)) {
|
||||
if (null != typeNameComboBox.getValue()) {
|
||||
|
||||
final SoftwareModuleType typeSelected = swTypeManagementService
|
||||
.findSoftwareModuleTypeByName(typeNameComboBox.getValue().toString());
|
||||
if (null != typeSelected) {
|
||||
selectedColor = typeSelected.getColour() != null ? rgbToColorConverter(typeSelected.getColour())
|
||||
: rgbToColorConverter(DEFAULT_COLOR);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
||||
}
|
||||
}
|
||||
selPreview.setColor(selectedColor);
|
||||
fieldLayout.addComponent(sliders);
|
||||
mainLayout.addComponent(colorPickerLayout);
|
||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
|
||||
}
|
||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Covert RGB code to {@Color}.
|
||||
*
|
||||
* @param value
|
||||
* RGB vale
|
||||
* @return Color
|
||||
*/
|
||||
protected Color rgbToColorConverter(final String value) {
|
||||
if (value.startsWith("rgb")) {
|
||||
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
||||
final int red = Integer.parseInt(colors[0]);
|
||||
final int green = Integer.parseInt(colors[1]);
|
||||
final int blue = Integer.parseInt(colors[2]);
|
||||
if (colors.length > 3) {
|
||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
||||
return new Color(red, green, blue, alpha);
|
||||
} else {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -753,63 +259,16 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(final Color color) {
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
selectedColor = color;
|
||||
selPreview.setColor(selectedColor);
|
||||
final String colorPickedPreview = selPreview.getColor().getCSS();
|
||||
if (typeName.isEnabled() && null != colorSelect) {
|
||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, colorPickedPreview);
|
||||
colorSelect.setColor(selPreview.getColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void colorChanged(final ColorChangeEvent event) {
|
||||
setColor(event.getColor());
|
||||
for (final ColorSelector select : selectors) {
|
||||
if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(selectedColor)) {
|
||||
select.setColor(selectedColor);
|
||||
}
|
||||
}
|
||||
setRgbSliderValues(selectedColor);
|
||||
getPreviewButtonColor(event.getColor().getCSS());
|
||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, event.getColor().getCSS());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tag name and desc field border color based on chosen color.
|
||||
*
|
||||
* @param tagName
|
||||
* @param tagDesc
|
||||
* @param taregtTagColor
|
||||
*/
|
||||
private void createDynamicStyleForComponents(final TextField typeName, final TextField typeKey,
|
||||
final TextArea typeDesc, final String typeTagColor) {
|
||||
getTargetDynamicStyles(typeTagColor);
|
||||
typeName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target style - Dynamically as per the color picked, cannot be done
|
||||
* from the static css.
|
||||
*
|
||||
* @param colorPickedPreview
|
||||
*/
|
||||
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
||||
Page.getCurrent().getJavaScript()
|
||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
||||
protected void populateTagNameCombo() {
|
||||
tagNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
||||
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||
@@ -63,7 +63,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected String getButtonsTableId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +80,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected String createButtonId(final String name) {
|
||||
return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name;
|
||||
return SPUIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,7 +102,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected String getButttonWrapperIdPrefix() {
|
||||
return SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
|
||||
return SPUIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ import javax.annotation.PostConstruct;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -86,7 +86,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
|
||||
|
||||
@Override
|
||||
protected String getHideButtonId() {
|
||||
return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID;
|
||||
return SPUIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,14 +9,18 @@
|
||||
package org.eclipse.hawkbit.ui.artifacts.state;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -49,15 +53,63 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
|
||||
|
||||
private Set<Long> selectedSoftwareModules = Collections.emptySet();
|
||||
|
||||
private boolean swTypeFilterClosed = Boolean.FALSE;
|
||||
private boolean swTypeFilterClosed;
|
||||
|
||||
private boolean swModuleTableMaximized = Boolean.FALSE;
|
||||
private boolean swModuleTableMaximized;
|
||||
|
||||
private boolean artifactDetailsMaximized = Boolean.FALSE;
|
||||
private boolean artifactDetailsMaximized;
|
||||
|
||||
private final Set<String> selectedDeleteSWModuleTypes = new HashSet<>();
|
||||
|
||||
private boolean noDataAvilableSoftwareModule = Boolean.FALSE;
|
||||
private boolean noDataAvilableSoftwareModule;
|
||||
|
||||
private boolean statusPopupMinimized;
|
||||
|
||||
private boolean uploadCompleted;
|
||||
|
||||
private List<UploadStatusObject> uploadedFileStatusList = new ArrayList<>();
|
||||
|
||||
private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger();
|
||||
|
||||
private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger();
|
||||
|
||||
private final AtomicInteger numberOfFileUploadsFailed = new AtomicInteger();
|
||||
|
||||
public AtomicInteger getNumberOfFileUploadsFailed() {
|
||||
return numberOfFileUploadsFailed;
|
||||
}
|
||||
|
||||
public AtomicInteger getNumberOfFilesActuallyUpload() {
|
||||
return numberOfFilesActuallyUpload;
|
||||
}
|
||||
|
||||
public AtomicInteger getNumberOfFileUploadsExpected() {
|
||||
return numberOfFileUploadsExpected;
|
||||
}
|
||||
|
||||
public List<UploadStatusObject> getUploadedFileStatusList() {
|
||||
return uploadedFileStatusList;
|
||||
}
|
||||
|
||||
public void setUploadedFileStatusList(final List<UploadStatusObject> uploadedFileStatusList) {
|
||||
this.uploadedFileStatusList = uploadedFileStatusList;
|
||||
}
|
||||
|
||||
public boolean isUploadCompleted() {
|
||||
return uploadCompleted;
|
||||
}
|
||||
|
||||
public void setUploadCompleted(final boolean uploadCompleted) {
|
||||
this.uploadCompleted = uploadCompleted;
|
||||
}
|
||||
|
||||
public void setStatusPopupMinimized(final boolean statusPopupMinimized) {
|
||||
this.statusPopupMinimized = statusPopupMinimized;
|
||||
}
|
||||
|
||||
public boolean isStatusPopupMinimized() {
|
||||
return statusPopupMinimized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set software.
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -151,10 +151,10 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
}
|
||||
|
||||
private void createRequiredComponents() {
|
||||
uploadBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT,
|
||||
uploadBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_BUTTON, SPUILabelDefinitions.SUBMIT,
|
||||
SPUILabelDefinitions.SUBMIT, ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
|
||||
uploadBtn.addClickListener(this);
|
||||
cancelBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON,
|
||||
cancelBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON,
|
||||
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
|
||||
SPUIButtonStyleTiny.class);
|
||||
cancelBtn.addClickListener(this);
|
||||
@@ -162,7 +162,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
uploadDetailsTable = new Table();
|
||||
uploadDetailsTable.addStyleName("artifact-table");
|
||||
uploadDetailsTable.setSizeFull();
|
||||
uploadDetailsTable.setId(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
|
||||
uploadDetailsTable.setId(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE);
|
||||
uploadDetailsTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
|
||||
uploadDetailsTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
uploadDetailsTable.addStyleName(ValoTheme.TABLE_SMALL);
|
||||
@@ -238,23 +238,23 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
newItem.getItemProperty(SW_MODULE_NAME).setValue(HawkbitCommonUtil.getFormatedLabel(swNameVersion));
|
||||
newItem.getItemProperty(SIZE).setValue(customFile.getFileSize());
|
||||
final Button deleteIcon = SPUIComponentProvider.getButton(
|
||||
SPUIComponetIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
|
||||
SPUIComponentIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
|
||||
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
deleteIcon.addClickListener(this);
|
||||
deleteIcon.setData(itemId);
|
||||
newItem.getItemProperty(ACTION).setValue(deleteIcon);
|
||||
|
||||
final TextField sha1 = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, null,
|
||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
final TextField sha1 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
sha1.setId(swNameVersion + "/" + customFile.getFileName() + "/sha1");
|
||||
|
||||
final TextField md5 = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, null,
|
||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
final TextField md5 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
md5.setId(swNameVersion + "/" + customFile.getFileName() + "/md5");
|
||||
|
||||
final TextField customFileName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false,
|
||||
null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
final TextField customFileName = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
||||
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
customFileName.setId(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
|
||||
newItem.getItemProperty(SHA1_CHECKSUM).setValue(sha1);
|
||||
newItem.getItemProperty(MD5_CHECKSUM).setValue(md5);
|
||||
@@ -265,8 +265,8 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
|
||||
final String customFileName, final String itemId) {
|
||||
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
||||
final TextField fileNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false,
|
||||
null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
final TextField fileNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
||||
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
fileNameTextField.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
|
||||
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
|
||||
fileNameTextField.setValue(customFileName);
|
||||
@@ -541,16 +541,16 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
|
||||
@Override
|
||||
public void buttonClick(final ClickEvent event) {
|
||||
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) {
|
||||
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_CLOSE)) {
|
||||
uploadConfrimationWindow.close();
|
||||
} else if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) {
|
||||
uploadLayout.clearFileList();
|
||||
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_DISCARD_DETAILS_BUTTON)) {
|
||||
uploadLayout.clearUploadedFileDetails();
|
||||
uploadConfrimationWindow.close();
|
||||
} else if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_BUTTON)) {
|
||||
} else if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_BUTTON)) {
|
||||
processArtifactUpload();
|
||||
}
|
||||
|
||||
else if (event.getComponent().getId().startsWith(SPUIComponetIdProvider.UPLOAD_DELETE_ICON)) {
|
||||
else if (event.getComponent().getId().startsWith(SPUIComponentIdProvider.UPLOAD_DELETE_ICON)) {
|
||||
final String itemId = ((Button) event.getComponent()).getData().toString();
|
||||
final Item item = uploadDetailsTable.getItem(((Button) event.getComponent()).getData());
|
||||
final Long swId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
|
||||
@@ -568,10 +568,10 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
||||
|
||||
uploadDetailsTable.removeItem(((Button) event.getComponent()).getData());
|
||||
uploadLayout.getFileSelected().remove(customFile);
|
||||
uploadLayout.updateActionCount();
|
||||
uploadLayout.updateUploadCounts();
|
||||
if (uploadDetailsTable.getItemIds().isEmpty()) {
|
||||
uploadLayout.clearFileList();
|
||||
uploadConfrimationWindow.close();
|
||||
uploadLayout.clearUploadedFileDetails();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,21 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.vaadin.server.StreamVariable;
|
||||
import com.vaadin.ui.Upload;
|
||||
@@ -49,28 +57,53 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
|
||||
private final long fileSize;
|
||||
private final UploadLayout view;
|
||||
private final UploadStatusInfoWindow infoWindow;
|
||||
private final long maxSize;
|
||||
private final Upload upload;
|
||||
|
||||
private volatile String fileName = null;
|
||||
private volatile String mimeType = null;
|
||||
private volatile boolean interrupted = false;
|
||||
private volatile boolean streamingInterrupted = false;
|
||||
private volatile boolean uploadInterrupted = false;
|
||||
private volatile boolean aborted = false;
|
||||
|
||||
private String failureReason;
|
||||
private final I18N i18n;
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
private final SoftwareModule selectedSw;
|
||||
private SoftwareModule selectedSwForUpload;
|
||||
private ArtifactUploadState artifactUploadState;
|
||||
|
||||
UploadHandler(final String fileName, final long fileSize, final UploadLayout view,
|
||||
final UploadStatusInfoWindow infoWindow, final long maxSize, final Upload upload, final String mimeType) {
|
||||
UploadHandler(final String fileName, final long fileSize, final UploadLayout view, final long maxSize,
|
||||
final Upload upload, final String mimeType, SoftwareModule selectedSw) {
|
||||
super();
|
||||
this.aborted = false;
|
||||
this.fileName = fileName;
|
||||
this.fileSize = fileSize;
|
||||
this.view = view;
|
||||
this.infoWindow = infoWindow;
|
||||
this.maxSize = maxSize;
|
||||
this.upload = upload;
|
||||
this.mimeType = mimeType;
|
||||
this.selectedSw = selectedSw;
|
||||
this.i18n = SpringContextHelper.getBean(I18N.class);
|
||||
this.eventBus = SpringContextHelper.getBean(EventBus.SessionEventBus.class);
|
||||
this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class);
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
/*
|
||||
* It's good manners to do this, even though vaadin-spring will
|
||||
* automatically unsubscribe when this UI is garbage collected.
|
||||
*/
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final UploadStatusEventType event) {
|
||||
if (event == UploadStatusEventType.ABORT_UPLOAD) {
|
||||
aborted = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,11 +114,13 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
@Override
|
||||
public final OutputStream getOutputStream() {
|
||||
try {
|
||||
return view.saveUploadedFileDetails(fileName, fileSize, mimeType);
|
||||
streamingInterrupted = false;
|
||||
failureReason = null;
|
||||
return view.saveUploadedFileDetails(fileName, fileSize, mimeType, selectedSw);
|
||||
} catch (final ArtifactUploadFailedException e) {
|
||||
LOG.error("Atifact upload failed {} ", e);
|
||||
failureReason = e.getMessage();
|
||||
interrupted = true;
|
||||
streamingInterrupted = true;
|
||||
return new NullOutputStream();
|
||||
}
|
||||
}
|
||||
@@ -98,23 +133,22 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public OutputStream receiveUpload(final String fileName, final String mimeType) {
|
||||
aborted = false;
|
||||
failureReason = null;
|
||||
this.fileName = fileName;
|
||||
this.mimeType = mimeType;
|
||||
// reset has directory flag before upload
|
||||
view.setHasDirectory(false);
|
||||
try {
|
||||
if (view.checkIfSoftwareModuleIsSelected()) {
|
||||
if (view.checkForDuplicate(fileName)) {
|
||||
view.showDuplicateMessage();
|
||||
} else {
|
||||
view.increaseNumberOfFileUploadsExpected();
|
||||
return view.saveUploadedFileDetails(fileName, 0, mimeType);
|
||||
}
|
||||
if (view.checkIfSoftwareModuleIsSelected() && !view.checkForDuplicate(fileName, selectedSwForUpload)) {
|
||||
view.increaseNumberOfFileUploadsExpected();
|
||||
return view.saveUploadedFileDetails(fileName, 0, mimeType, selectedSwForUpload);
|
||||
}
|
||||
} catch (final ArtifactUploadFailedException e) {
|
||||
LOG.error("Atifact upload failed {} ", e);
|
||||
failureReason = e.getMessage();
|
||||
upload.interruptUpload();
|
||||
uploadInterrupted = true;
|
||||
}
|
||||
// if final validation fails ,final no upload ,return NullOutputStream
|
||||
return new NullOutputStream();
|
||||
@@ -129,13 +163,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
@Override
|
||||
public void uploadSucceeded(final SucceededEvent event) {
|
||||
LOG.debug("Streaming finished for file :{}", event.getFilename());
|
||||
view.updateFileSize(event.getFilename(), event.getLength());
|
||||
|
||||
// recorded that we now one more uploaded
|
||||
view.increaseNumberOfFilesActuallyUpload();
|
||||
|
||||
// inform upload status window
|
||||
infoWindow.uploadSucceeded(event.getFilename());
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_SUCCESSFUL, new UploadFileStatus(
|
||||
event.getFilename(), 0, event.getLength(), selectedSwForUpload)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,20 +177,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
@Override
|
||||
public void streamingFinished(final StreamingEndEvent event) {
|
||||
LOG.debug("Streaming finished for file :{}", event.getFileName());
|
||||
// record that we now one more uploaded
|
||||
view.increaseNumberOfFilesActuallyUpload();
|
||||
|
||||
// inform upload status window
|
||||
infoWindow.uploadSucceeded(event.getFileName());
|
||||
|
||||
// check if we are finished
|
||||
if (view.enableProcessBtn()) {
|
||||
infoWindow.uploadSessionFinished();
|
||||
}
|
||||
view.updateActionCount();
|
||||
|
||||
// display the duplicate message after streaming all files
|
||||
view.displayDuplicateValidationMessage();
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STREAMING_FINISHED,
|
||||
new UploadFileStatus(event.getFileName(), 0, event.getContentLength(), selectedSw)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,12 +190,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
@Override
|
||||
public void uploadFinished(final FinishedEvent event) {
|
||||
LOG.debug("Upload finished for file :{}", event.getFilename());
|
||||
// check if we are finished
|
||||
if (view.enableProcessBtn()) {
|
||||
infoWindow.uploadSessionFinished();
|
||||
}
|
||||
view.updateActionCount();
|
||||
|
||||
eventBus.publish(this,
|
||||
new UploadStatusEvent(UploadStatusEventType.UPLOAD_FINISHED, new UploadFileStatus(event.getFilename())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +202,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
@Override
|
||||
public void streamingStarted(final StreamingStartEvent event) {
|
||||
LOG.debug("Streaming started for file :{}", fileName);
|
||||
infoWindow.uploadStarted(fileName);
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STARTED, new UploadFileStatus(
|
||||
fileName, 0, 0, selectedSw)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,14 +213,24 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public void uploadStarted(final StartedEvent event) {
|
||||
// single file session
|
||||
if (view.isSoftwareModuleSelected() && !view.checkIfFileIsDuplicate(event.getFilename())) {
|
||||
infoWindow.uploadSessionStarted();
|
||||
LOG.debug("Upload started for file :{}", event.getFilename());
|
||||
infoWindow.uploadStarted(event.getFilename());
|
||||
} else {
|
||||
uploadInterrupted = false;
|
||||
selectedSwForUpload = artifactUploadState.getSelectedBaseSoftwareModule().isPresent() ? artifactUploadState
|
||||
.getSelectedBaseSoftwareModule().get() : null;
|
||||
|
||||
if (view.isSoftwareModuleSelected()) {
|
||||
// single file session
|
||||
if (!view.checkIfFileIsDuplicate(event.getFilename(), selectedSwForUpload)) {
|
||||
LOG.debug("Upload started for file :{}", event.getFilename());
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STARTED,
|
||||
new UploadFileStatus(event.getFilename(), 0, 0, selectedSwForUpload)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
failureReason = i18n.get("message.upload.failed");
|
||||
upload.interruptUpload();
|
||||
// actual interrupt will happen a bit late so setting the below
|
||||
// flag
|
||||
uploadInterrupted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,21 +251,25 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public void updateProgress(final long readBytes, final long contentLength) {
|
||||
if (readBytes > maxSize || contentLength > maxSize) {
|
||||
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
|
||||
view.decreaseNumberOfFileUploadsExpected();
|
||||
final SoftwareModule sw = view.getSoftwareModuleSelected();
|
||||
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
|
||||
view.updateActionCount();
|
||||
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
|
||||
infoWindow.uploadFailed(fileName, failureReason);
|
||||
upload.interruptUpload();
|
||||
interrupted = true;
|
||||
return;
|
||||
// Update progress is called event after upload interrupted in
|
||||
// uploadStarted method
|
||||
if (!uploadInterrupted) {
|
||||
if (aborted) {
|
||||
LOG.info("User aborted file upload for file : {}", fileName);
|
||||
failureReason = i18n.get("message.uploadedfile.aborted");
|
||||
interruptFileUpload();
|
||||
return;
|
||||
}
|
||||
if (readBytes > maxSize || contentLength > maxSize) {
|
||||
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
|
||||
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
|
||||
interruptFileUpload();
|
||||
return;
|
||||
}
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_IN_PROGRESS,
|
||||
new UploadFileStatus(fileName, readBytes, contentLength, selectedSwForUpload)));
|
||||
LOG.info("Update progress - {} : {}", fileName, (double) readBytes / (double) contentLength);
|
||||
}
|
||||
|
||||
infoWindow.updateProgress(fileName, readBytes, contentLength);
|
||||
LOG.info("Update progress - {} : {}", fileName, (double) readBytes / (double) contentLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,19 +279,20 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public void onProgress(final StreamingProgressEvent event) {
|
||||
if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) {
|
||||
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
|
||||
view.decreaseNumberOfFileUploadsExpected();
|
||||
final SoftwareModule sw = view.getSoftwareModuleSelected();
|
||||
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
|
||||
view.updateActionCount();
|
||||
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
|
||||
infoWindow.uploadFailed(event.getFileName(), failureReason);
|
||||
interrupted = true;
|
||||
if (aborted) {
|
||||
LOG.info("User aborted the upload for file : {}", event.getFileName());
|
||||
failureReason = i18n.get("message.uploadedfile.aborted");
|
||||
interruptFileStreaming();
|
||||
return;
|
||||
}
|
||||
|
||||
infoWindow.updateProgress(event.getFileName(), event.getBytesReceived(), event.getContentLength());
|
||||
if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) {
|
||||
LOG.error("User tried to upload more than was allowed ({}).", maxSize);
|
||||
failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize);
|
||||
interruptFileStreaming();
|
||||
return;
|
||||
}
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_IN_PROGRESS, new UploadFileStatus(
|
||||
fileName, event.getBytesReceived(), event.getContentLength(), selectedSw)));
|
||||
// Logging to solve sonar issue
|
||||
LOG.trace("Streaming in progress for file :{}", event.getFileName());
|
||||
}
|
||||
@@ -276,19 +305,16 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public void streamingFailed(final StreamingErrorEvent event) {
|
||||
LOG.info("Streaming failed for file :{}", event.getFileName());
|
||||
view.decreaseNumberOfFileUploadsExpected();
|
||||
final SoftwareModule sw = view.getSoftwareModuleSelected();
|
||||
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
|
||||
view.updateActionCount();
|
||||
infoWindow.uploadFailed(event.getFileName(), failureReason);
|
||||
// check if we are finished
|
||||
if (view.enableProcessBtn()) {
|
||||
infoWindow.uploadSessionFinished();
|
||||
if (failureReason == null) {
|
||||
failureReason = event.getException().getMessage();
|
||||
}
|
||||
view.displayDuplicateValidationMessage();
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_STREAMING_FAILED,
|
||||
new UploadFileStatus(fileName, failureReason, selectedSw)));
|
||||
|
||||
LOG.info("Streaming failed due to :{}", event.getException());
|
||||
if (!aborted) {
|
||||
LOG.info("Streaming failed for file :{}", event.getFileName());
|
||||
LOG.info("Streaming failed due to :{}", event.getException());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,20 +324,21 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public void uploadFailed(final FailedEvent event) {
|
||||
LOG.info("Upload failed for file :{}", event.getFilename());
|
||||
view.decreaseNumberOfFileUploadsExpected();
|
||||
/**
|
||||
* If upload interrupted because of duplicate file,do not remove the
|
||||
* file already in upload list
|
||||
**/
|
||||
if (!view.getDuplicateFileNamesList().isEmpty()) {
|
||||
final SoftwareModule sw = view.getSoftwareModuleSelected();
|
||||
view.getFileSelected().remove(new CustomFile(fileName, sw.getName(), sw.getVersion()));
|
||||
* If upload failed due to no selected software UPLOAD_FAILED event need
|
||||
* not be published.
|
||||
*/
|
||||
if (selectedSwForUpload != null) {
|
||||
if (failureReason == null) {
|
||||
failureReason = event.getReason().getMessage();
|
||||
}
|
||||
eventBus.publish(this, new UploadStatusEvent(UploadStatusEventType.UPLOAD_FAILED, new UploadFileStatus(
|
||||
fileName, failureReason, selectedSwForUpload)));
|
||||
if (!aborted) {
|
||||
LOG.info("Upload failed for file :{}", event.getFilename());
|
||||
LOG.info("Upload failed for file :{}", event.getReason());
|
||||
}
|
||||
}
|
||||
view.updateActionCount();
|
||||
infoWindow.uploadFailed(event.getFilename(), failureReason);
|
||||
LOG.info("Upload failed for file :{}", event.getReason());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,7 +346,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
*/
|
||||
@Override
|
||||
public boolean isInterrupted() {
|
||||
return interrupted;
|
||||
return streamingInterrupted;
|
||||
}
|
||||
|
||||
private static class NullOutputStream extends OutputStream {
|
||||
@@ -339,7 +366,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (fileName == null ? 0 : fileName.hashCode());
|
||||
result = prime * result + ((fileName == null) ? 0 : fileName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -348,16 +375,30 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof UploadHandler)) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final UploadHandler other = (UploadHandler) obj;
|
||||
if (fileName == null && other.fileName != null) {
|
||||
return false;
|
||||
if (fileName == null) {
|
||||
if (other.fileName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!fileName.equals(other.fileName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void interruptFileStreaming() {
|
||||
streamingInterrupted = true;
|
||||
}
|
||||
|
||||
private void interruptFileUpload() {
|
||||
upload.interruptUpload();
|
||||
uploadInterrupted = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
@@ -26,13 +25,15 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -97,10 +98,6 @@ public class UploadLayout extends VerticalLayout {
|
||||
@Autowired
|
||||
private transient SPInfo spInfo;
|
||||
|
||||
private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger();
|
||||
|
||||
private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger();
|
||||
|
||||
private final List<String> duplicateFileNamesList = new ArrayList<>();
|
||||
|
||||
private Button processBtn;
|
||||
@@ -119,6 +116,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
|
||||
private Boolean hasDirectory = Boolean.FALSE;
|
||||
|
||||
private Button uploadStatusButton;
|
||||
|
||||
/**
|
||||
* Initialize the upload layout.
|
||||
*/
|
||||
@@ -126,13 +125,52 @@ public class UploadLayout extends VerticalLayout {
|
||||
void init() {
|
||||
createComponents();
|
||||
buildLayout();
|
||||
updateActionCount();
|
||||
restoreState();
|
||||
eventBus.subscribe(this);
|
||||
ui = UI.getCurrent();
|
||||
}
|
||||
|
||||
private void createComponents() {
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final UploadArtifactUIEvent event) {
|
||||
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
|
||||
ui.access(() -> updateActionCount());
|
||||
} else if (event == UploadArtifactUIEvent.MINIMIZED_STATUS_POPUP) {
|
||||
ui.access(() -> showUploadStatusButton());
|
||||
} else if (event == UploadArtifactUIEvent.MAXIMIZED_STATUS_POPUP) {
|
||||
ui.access(() -> maximizeStatusPopup());
|
||||
} else if (event == UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED) {
|
||||
ui.access(() -> closeUploadStatusPopup());
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final UploadStatusEvent event) {
|
||||
if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) {
|
||||
ui.access(() -> onStartOfUpload());
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FAILED) {
|
||||
ui.access(() -> onUploadFailure(event));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_FINISHED) {
|
||||
ui.access(() -> onUploadCompletion());
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) {
|
||||
ui.access(() -> onUploadSuccess(event));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) {
|
||||
ui.access(() -> onUploadStreamingFailure(event));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) {
|
||||
ui.access(() -> onUploadStreamingSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
/*
|
||||
* It's good manners to do this, even though vaadin-spring will
|
||||
* automatically unsubscribe when this UI is garbage collected.
|
||||
*/
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
private void createComponents() {
|
||||
createUploadStatusButton();
|
||||
createProcessButton();
|
||||
createDiscardBtn();
|
||||
}
|
||||
@@ -140,8 +178,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
private void buildLayout() {
|
||||
|
||||
final Upload upload = new Upload();
|
||||
final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow,
|
||||
spInfo.getMaxArtifactFileSize(), upload, null);
|
||||
final UploadHandler uploadHandler = new UploadHandler(null, 0, this, spInfo.getMaxArtifactFileSize(), upload,
|
||||
null, null);
|
||||
upload.setButtonCaption(i18n.get("upload.file"));
|
||||
upload.setImmediate(true);
|
||||
upload.setReceiver(uploadHandler);
|
||||
@@ -154,12 +192,15 @@ public class UploadLayout extends VerticalLayout {
|
||||
|
||||
fileUploadLayout = new HorizontalLayout();
|
||||
fileUploadLayout.setSpacing(true);
|
||||
fileUploadLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
|
||||
fileUploadLayout.addComponent(upload);
|
||||
fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
|
||||
fileUploadLayout.addComponent(processBtn);
|
||||
fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT);
|
||||
fileUploadLayout.addComponent(discardBtn);
|
||||
fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT);
|
||||
fileUploadLayout.addComponent(uploadStatusButton);
|
||||
fileUploadLayout.setComponentAlignment(uploadStatusButton, Alignment.MIDDLE_RIGHT);
|
||||
setMargin(false);
|
||||
|
||||
/* create drag-drop wrapper for drop area */
|
||||
@@ -167,7 +208,25 @@ public class UploadLayout extends VerticalLayout {
|
||||
dropAreaWrapper.setDropHandler(new DropAreahandler());
|
||||
setSizeFull();
|
||||
setSpacing(true);
|
||||
}
|
||||
|
||||
private void restoreState() {
|
||||
updateActionCount();
|
||||
|
||||
if (!artifactUploadState.getFileSelected().isEmpty() && artifactUploadState.isUploadCompleted()) {
|
||||
processBtn.setEnabled(true);
|
||||
}
|
||||
if (artifactUploadState.isStatusPopupMinimized()) {
|
||||
showUploadStatusButton();
|
||||
if (artifactUploadState.isUploadCompleted()) {
|
||||
setUploadStatusButtonIconToFinished();
|
||||
}
|
||||
}
|
||||
if (artifactUploadState.isUploadCompleted()) {
|
||||
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
|
||||
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
|
||||
}
|
||||
}
|
||||
|
||||
public DragAndDropWrapper getDropAreaWrapper() {
|
||||
@@ -187,15 +246,16 @@ public class UploadLayout extends VerticalLayout {
|
||||
public void drop(final DragAndDropEvent event) {
|
||||
if (validate(event)) {
|
||||
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||
// selected software module at the time of file drop is
|
||||
// considered for upload
|
||||
SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
// reset the flag
|
||||
hasDirectory = Boolean.FALSE;
|
||||
for (final Html5File file : files) {
|
||||
processFile(file);
|
||||
processFile(file, selectedSw);
|
||||
}
|
||||
if (numberOfFileUploadsExpected.get() > 0) {
|
||||
if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) {
|
||||
processBtn.setEnabled(false);
|
||||
// reset before we start
|
||||
uploadInfoWindow.uploadSessionStarted();
|
||||
} else {
|
||||
// If the upload is not started, it signifies all
|
||||
// dropped files as either duplicate or directory.So
|
||||
@@ -205,20 +265,20 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void processFile(final Html5File file) {
|
||||
private void processFile(final Html5File file, SoftwareModule selectedSw) {
|
||||
if (!isDirectory(file)) {
|
||||
if (!checkForDuplicate(file.getFileName())) {
|
||||
numberOfFileUploadsExpected.incrementAndGet();
|
||||
file.setStreamVariable(createStreamVariable(file));
|
||||
if (!checkForDuplicate(file.getFileName(), selectedSw)) {
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
|
||||
file.setStreamVariable(createStreamVariable(file, selectedSw));
|
||||
}
|
||||
} else {
|
||||
hasDirectory = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
private StreamVariable createStreamVariable(final Html5File file) {
|
||||
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
|
||||
spInfo.getMaxArtifactFileSize(), null, file.getType());
|
||||
private StreamVariable createStreamVariable(final Html5File file, SoftwareModule selectedSw) {
|
||||
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this,
|
||||
spInfo.getMaxArtifactFileSize(), null, file.getType(), selectedSw);
|
||||
}
|
||||
|
||||
private boolean isDirectory(final Html5File file) {
|
||||
@@ -263,44 +323,33 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
private void createProcessButton() {
|
||||
processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON,
|
||||
processBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON,
|
||||
SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null,
|
||||
SPUIButtonStyleSmall.class);
|
||||
processBtn.setIcon(FontAwesome.BELL);
|
||||
processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||
processBtn.addClickListener(event -> displayConfirmWindow(event));
|
||||
processBtn.addClickListener(this::displayConfirmWindow);
|
||||
processBtn.setHtmlContentAllowed(true);
|
||||
if (artifactUploadState.getFileSelected().isEmpty()) {
|
||||
processBtn.setEnabled(false);
|
||||
}
|
||||
processBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
private void createDiscardBtn() {
|
||||
discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON,
|
||||
discardBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_DISCARD_BUTTON,
|
||||
SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null,
|
||||
SPUIButtonStyleSmall.class);
|
||||
discardBtn.setIcon(FontAwesome.TRASH_O);
|
||||
discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||
discardBtn.addClickListener(event -> discardUploadData(event));
|
||||
discardBtn.addClickListener(this::discardUploadData);
|
||||
}
|
||||
|
||||
boolean checkForDuplicate(final String filename) {
|
||||
final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
|
||||
boolean checkForDuplicate(final String filename, final SoftwareModule selectedSw) {
|
||||
final Boolean isDuplicate = checkIfFileIsDuplicate(filename, selectedSw);
|
||||
if (isDuplicate) {
|
||||
getDuplicateFileNamesList().add(filename);
|
||||
}
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void toggleProcessButton(final UploadArtifactUIEvent event) {
|
||||
if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) {
|
||||
processBtn.setEnabled(true);
|
||||
} else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) {
|
||||
processBtn.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save uploaded file details.
|
||||
*
|
||||
@@ -312,29 +361,29 @@ public class UploadLayout extends VerticalLayout {
|
||||
* file size
|
||||
* @param mimeType
|
||||
* the mimeType of the file
|
||||
* @param selectedSw
|
||||
* @throws IOException
|
||||
* in case of upload errors
|
||||
*/
|
||||
OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) {
|
||||
OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType,
|
||||
SoftwareModule selectedSw) {
|
||||
File tempFile = null;
|
||||
try {
|
||||
tempFile = File.createTempFile("spUiArtifactUpload", null);
|
||||
|
||||
final OutputStream out = new FileOutputStream(tempFile);
|
||||
|
||||
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(selectedSw.getName(),
|
||||
selectedSw.getVersion());
|
||||
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
|
||||
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
|
||||
final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(),
|
||||
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType);
|
||||
final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), selectedSw.getName(),
|
||||
selectedSw.getVersion(), mimeType);
|
||||
|
||||
artifactUploadState.getFileSelected().add(customFile);
|
||||
processBtn.setEnabled(false);
|
||||
|
||||
if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) {
|
||||
artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule);
|
||||
artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSw);
|
||||
}
|
||||
return out;
|
||||
} catch (final FileNotFoundException e) {
|
||||
@@ -344,6 +393,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
LOG.error("Upload failed {}", e);
|
||||
throw new ArtifactUploadFailedException(i18n.get("message.upload.failed"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Boolean validate(final DragAndDropEvent event) {
|
||||
@@ -378,13 +428,6 @@ public class UploadLayout extends VerticalLayout {
|
||||
return true;
|
||||
}
|
||||
|
||||
SoftwareModule getSoftwareModuleSelected() {
|
||||
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
|
||||
return artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Boolean isSoftwareModuleSelected() {
|
||||
if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
|
||||
return false;
|
||||
@@ -400,11 +443,10 @@ public class UploadLayout extends VerticalLayout {
|
||||
* file name
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean checkIfFileIsDuplicate(final String name) {
|
||||
public Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
|
||||
Boolean isDuplicate = false;
|
||||
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
|
||||
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
|
||||
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
||||
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
@@ -418,7 +460,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
void decreaseNumberOfFileUploadsExpected() {
|
||||
numberOfFileUploadsExpected.decrementAndGet();
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().decrementAndGet();
|
||||
}
|
||||
|
||||
List<String> getDuplicateFileNamesList() {
|
||||
@@ -439,8 +481,10 @@ public class UploadLayout extends VerticalLayout {
|
||||
|
||||
void displayDuplicateValidationMessage() {
|
||||
// check if streaming of all dropped files are completed
|
||||
if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) {
|
||||
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == artifactUploadState
|
||||
.getNumberOfFileUploadsExpected().intValue()) {
|
||||
displayCompositeMessage();
|
||||
duplicateFileNamesList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,7 +498,6 @@ public class UploadLayout extends VerticalLayout {
|
||||
} else if (duplicateFileNamesList.size() > 1) {
|
||||
message.append(i18n.get("message.no.duplicateFiles"));
|
||||
}
|
||||
duplicateFileNamesList.clear();
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
@@ -464,13 +507,12 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
void increaseNumberOfFileUploadsExpected() {
|
||||
numberOfFileUploadsExpected.incrementAndGet();
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
|
||||
}
|
||||
|
||||
void updateFileSize(final String name, final long size) {
|
||||
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
|
||||
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
void updateFileSize(final String name, final long size, SoftwareModule selectedSoftwareModule) {
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
|
||||
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
||||
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
@@ -483,17 +525,22 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
void increaseNumberOfFilesActuallyUpload() {
|
||||
numberOfFilesActuallyUpload.incrementAndGet();
|
||||
artifactUploadState.getNumberOfFilesActuallyUpload().incrementAndGet();
|
||||
}
|
||||
|
||||
void increaseNumberOfFileUploadsFailed() {
|
||||
artifactUploadState.getNumberOfFileUploadsFailed().incrementAndGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable process button once upload is completed.
|
||||
*/
|
||||
boolean enableProcessBtn() {
|
||||
if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) {
|
||||
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() >= artifactUploadState
|
||||
.getNumberOfFileUploadsExpected().intValue() && !getFileSelected().isEmpty()) {
|
||||
processBtn.setEnabled(true);
|
||||
numberOfFileUploadsExpected.set(0);
|
||||
numberOfFilesActuallyUpload.set(0);
|
||||
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -507,13 +554,23 @@ public class UploadLayout extends VerticalLayout {
|
||||
if (event.getButton().equals(discardBtn)) {
|
||||
if (artifactUploadState.getFileSelected().isEmpty()) {
|
||||
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
|
||||
|
||||
} else {
|
||||
clearFileList();
|
||||
clearUploadedFileDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearUploadedFileDetails() {
|
||||
clearFileList();
|
||||
closeUploadStatusPopup();
|
||||
}
|
||||
|
||||
private void closeUploadStatusPopup() {
|
||||
uploadInfoWindow.clearWindow();
|
||||
hideUploadStatusButton();
|
||||
artifactUploadState.setStatusPopupMinimized(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear details.
|
||||
*/
|
||||
@@ -529,19 +586,20 @@ public class UploadLayout extends VerticalLayout {
|
||||
processBtn.setCaption(SPUILabelDefinitions.PROCESS);
|
||||
/* disable when there is no files to upload. */
|
||||
processBtn.setEnabled(false);
|
||||
numberOfFileUploadsExpected.set(0);
|
||||
numberOfFilesActuallyUpload.set(0);
|
||||
artifactUploadState.getNumberOfFilesActuallyUpload().set(0);
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().set(0);
|
||||
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
|
||||
duplicateFileNamesList.clear();
|
||||
}
|
||||
|
||||
private void setConfirmationPopupHeightWidth(final float newWidth, final float newHeight) {
|
||||
if (currentUploadConfirmationwindow != null) {
|
||||
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(HawkbitCommonUtil
|
||||
.getArtifactUploadPopupWidth(newWidth, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH),
|
||||
Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(HawkbitCommonUtil
|
||||
.getArtifactUploadPopupHeight(newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT),
|
||||
Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,22 +616,24 @@ public class UploadLayout extends VerticalLayout {
|
||||
&& currentUploadConfirmationwindow.getCurrentUploadResultWindow() != null) {
|
||||
final UploadResultWindow uploadResultWindow = currentUploadConfirmationwindow
|
||||
.getCurrentUploadResultWindow();
|
||||
uploadResultWindow.getUploadResultsWindow().setWidth(HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultTable().setHeight(HawkbitCommonUtil.getArtifactUploadPopupHeight(
|
||||
newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultsWindow().setWidth(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultTable().setHeight(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayConfirmWindow(final Button.ClickEvent event) {
|
||||
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) {
|
||||
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_PROCESS_BUTTON)) {
|
||||
if (artifactUploadState.getFileSelected().isEmpty()) {
|
||||
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
|
||||
} else {
|
||||
currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState);
|
||||
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
|
||||
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
|
||||
Page.getCurrent().getBrowserWindowHeight());
|
||||
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent()
|
||||
.getBrowserWindowHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -599,25 +659,101 @@ public class UploadLayout extends VerticalLayout {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
||||
VerticalLayout getDropAreaLayout() {
|
||||
return dropAreaLayout;
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final UploadArtifactUIEvent event) {
|
||||
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
|
||||
ui.access(() -> updateActionCount());
|
||||
private void onStartOfUpload() {
|
||||
setUploadStatusButtonIconToInProgress();
|
||||
if (artifactUploadState.isStatusPopupMinimized()) {
|
||||
updateStatusButtonCount();
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
/*
|
||||
* It's good manners to do this, even though vaadin-spring will
|
||||
* automatically unsubscribe when this UI is garbage collected.
|
||||
*/
|
||||
eventBus.unsubscribe(this);
|
||||
private void onUploadStreamingSuccess() {
|
||||
increaseNumberOfFilesActuallyUpload();
|
||||
updateUploadCounts();
|
||||
enableProcessBtn();
|
||||
if (isUploadComplete()) {
|
||||
uploadInfoWindow.uploadSessionFinished();
|
||||
setUploadStatusButtonIconToFinished();
|
||||
}
|
||||
// display the duplicate message after streaming all files
|
||||
displayDuplicateValidationMessage();
|
||||
}
|
||||
|
||||
private void onUploadStreamingFailure(UploadStatusEvent event) {
|
||||
/**
|
||||
* If upload interrupted because of duplicate file,do not remove the
|
||||
* file already in upload list
|
||||
**/
|
||||
if (getDuplicateFileNamesList().isEmpty()
|
||||
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
|
||||
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
|
||||
if (sw != null) {
|
||||
getFileSelected().remove(
|
||||
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
}
|
||||
// failed reason to be updated only if there is error other than
|
||||
// duplicate file error
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
increaseNumberOfFileUploadsFailed();
|
||||
}
|
||||
decreaseNumberOfFileUploadsExpected();
|
||||
updateUploadCounts();
|
||||
enableProcessBtn();
|
||||
// check if we are finished
|
||||
if (isUploadComplete()) {
|
||||
uploadInfoWindow.uploadSessionFinished();
|
||||
setUploadStatusButtonIconToFinished();
|
||||
}
|
||||
displayDuplicateValidationMessage();
|
||||
}
|
||||
|
||||
private void onUploadSuccess(UploadStatusEvent event) {
|
||||
updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(), event
|
||||
.getUploadStatus().getSoftwareModule());
|
||||
// recorded that we now one more uploaded
|
||||
increaseNumberOfFilesActuallyUpload();
|
||||
}
|
||||
|
||||
private void onUploadCompletion() {
|
||||
// check if we are finished
|
||||
if (isUploadComplete()) {
|
||||
uploadInfoWindow.uploadSessionFinished();
|
||||
setUploadStatusButtonIconToFinished();
|
||||
displayDuplicateValidationMessage();
|
||||
}
|
||||
updateUploadCounts();
|
||||
enableProcessBtn();
|
||||
}
|
||||
|
||||
private boolean isUploadComplete() {
|
||||
int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue();
|
||||
int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue();
|
||||
return uploadedCount == expectedUploadsCount;
|
||||
}
|
||||
|
||||
private void onUploadFailure(final UploadStatusEvent event) {
|
||||
/**
|
||||
* If upload interrupted because of duplicate file,do not remove the
|
||||
* file already in upload list
|
||||
**/
|
||||
if (getDuplicateFileNamesList().isEmpty()
|
||||
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
|
||||
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
|
||||
if (sw != null) {
|
||||
getFileSelected().remove(
|
||||
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
}
|
||||
// failed reason to be updated only if there is error other than
|
||||
// duplicate file error
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
increaseNumberOfFileUploadsFailed();
|
||||
decreaseNumberOfFileUploadsExpected();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,8 +773,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
* @param selectedBaseSoftwareModule
|
||||
*/
|
||||
public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
|
||||
eventBus.publish(this,
|
||||
new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule));
|
||||
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED,
|
||||
selectedBaseSoftwareModule));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -655,4 +791,79 @@ public class UploadLayout extends VerticalLayout {
|
||||
public void setHasDirectory(final Boolean hasDirectory) {
|
||||
this.hasDirectory = hasDirectory;
|
||||
}
|
||||
|
||||
private void createUploadStatusButton() {
|
||||
uploadStatusButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_STATUS_BUTTON, "", "", "",
|
||||
false, null, SPUIButtonStyleSmall.class);
|
||||
uploadStatusButton.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||
uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
uploadStatusButton.setWidth("100px");
|
||||
uploadStatusButton.setHtmlContentAllowed(true);
|
||||
uploadStatusButton.addClickListener(event -> onClickOfUploadStatusButton());
|
||||
uploadStatusButton.setVisible(false);
|
||||
}
|
||||
|
||||
void updateStatusButtonCount() {
|
||||
int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get()
|
||||
- artifactUploadState.getNumberOfFilesActuallyUpload().get();
|
||||
int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get();
|
||||
StringBuilder builder = new StringBuilder("");
|
||||
if (uploadsFailed != 0) {
|
||||
if (uploadsPending != 0) {
|
||||
builder.append("<div class='error-count error-count-color'>" + uploadsFailed + "</div>");
|
||||
} else {
|
||||
builder.append("<div class='unread error-count-color'>" + uploadsFailed + "</div>");
|
||||
}
|
||||
}
|
||||
if (uploadsPending != 0) {
|
||||
builder.append("<div class='unread'>" + uploadsPending + "</div>");
|
||||
}
|
||||
uploadStatusButton.setCaption(builder.toString());
|
||||
}
|
||||
|
||||
private void onClickOfUploadStatusButton() {
|
||||
artifactUploadState.setStatusPopupMinimized(false);
|
||||
eventBus.publish(this, UploadArtifactUIEvent.MAXIMIZED_STATUS_POPUP);
|
||||
}
|
||||
|
||||
private void showUploadStatusButton() {
|
||||
if (uploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
uploadStatusButton.setVisible(true);
|
||||
updateStatusButtonCount();
|
||||
}
|
||||
|
||||
protected void hideUploadStatusButton() {
|
||||
if (uploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
uploadStatusButton.setVisible(false);
|
||||
}
|
||||
|
||||
private void maximizeStatusPopup() {
|
||||
hideUploadStatusButton();
|
||||
uploadInfoWindow.maximizeStatusPopup();
|
||||
}
|
||||
|
||||
private void setUploadStatusButtonIconToFinished() {
|
||||
if (uploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
uploadStatusButton.removeStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
uploadStatusButton.setIcon(FontAwesome.UPLOAD);
|
||||
}
|
||||
|
||||
private void setUploadStatusButtonIconToInProgress() {
|
||||
if (uploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
uploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
uploadStatusButton.setIcon(null);
|
||||
}
|
||||
|
||||
protected void updateUploadCounts() {
|
||||
updateActionCount();
|
||||
updateStatusButtonCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,17 @@ package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
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.SpringContextHelper;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.IndexedContainer;
|
||||
@@ -63,6 +66,9 @@ public class UploadResultWindow implements Button.ClickListener {
|
||||
private static final String UPLOAD_RESULT = "uploadResult";
|
||||
|
||||
private static final String REASON = "reason";
|
||||
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize upload status popup.
|
||||
@@ -75,12 +81,13 @@ public class UploadResultWindow implements Button.ClickListener {
|
||||
public UploadResultWindow(final List<UploadStatus> uploadResultList, final I18N i18n) {
|
||||
this.uploadResultList = uploadResultList;
|
||||
this.i18n = i18n;
|
||||
eventBus = SpringContextHelper.getBean( EventBus.SessionEventBus.class);
|
||||
createComponents();
|
||||
createLayout();
|
||||
}
|
||||
|
||||
private void createComponents() {
|
||||
closeBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE,
|
||||
closeBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE,
|
||||
SPUILabelDefinitions.CLOSE, SPUILabelDefinitions.CLOSE, ValoTheme.BUTTON_PRIMARY, false, null,
|
||||
SPUIButtonStyleTiny.class);
|
||||
closeBtn.addClickListener(this);
|
||||
@@ -89,7 +96,7 @@ public class UploadResultWindow implements Button.ClickListener {
|
||||
uploadResultTable.addStyleName("artifact-table");
|
||||
uploadResultTable.setSizeFull();
|
||||
uploadResultTable.setImmediate(true);
|
||||
uploadResultTable.setId(SPUIComponetIdProvider.UPLOAD_RESULT_TABLE);
|
||||
uploadResultTable.setId(SPUIComponentIdProvider.UPLOAD_RESULT_TABLE);
|
||||
uploadResultTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
|
||||
uploadResultTable.addStyleName(ValoTheme.TABLE_SMALL);
|
||||
uploadResultTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
@@ -121,7 +128,7 @@ public class UploadResultWindow implements Button.ClickListener {
|
||||
|
||||
reasonLabel = HawkbitCommonUtil.getFormatedLabel(uploadResult.getReason());
|
||||
reasonLabel.setDescription(uploadResult.getReason());
|
||||
final String idStr = SPUIComponetIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/"
|
||||
final String idStr = SPUIComponentIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/"
|
||||
+ uploadResult.getFileName();
|
||||
reasonLabel.setId(idStr);
|
||||
newItem.getItemProperty(REASON).setValue(reasonLabel);
|
||||
@@ -180,9 +187,11 @@ public class UploadResultWindow implements Button.ClickListener {
|
||||
|
||||
@Override
|
||||
public void buttonClick(final ClickEvent event) {
|
||||
if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|
||||
|| event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
|
||||
if (event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_CLOSE)
|
||||
|| event.getComponent().getId().equals(SPUIComponentIdProvider.UPLOAD_ARTIFACT_RESULT_POPUP_CLOSE)) {
|
||||
uploadResultsWindow.close();
|
||||
//close upload status popup if open
|
||||
eventBus.publish(this, UploadArtifactUIEvent.ARTIFACT_RESULT_POPUP_CLOSED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,20 +8,49 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
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.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
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.Container.Indexed;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.IndexedContainer;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.window.WindowMode;
|
||||
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.Grid;
|
||||
import com.vaadin.ui.Grid.SelectionMode;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.renderers.HtmlRenderer;
|
||||
import com.vaadin.ui.renderers.ProgressBarRenderer;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
import elemental.json.JsonValue;
|
||||
|
||||
@@ -34,7 +63,16 @@ import elemental.json.JsonValue;
|
||||
|
||||
@ViewScope
|
||||
@SpringComponent
|
||||
public class UploadStatusInfoWindow extends Window implements Window.CloseListener, Window.WindowModeChangeListener {
|
||||
public class UploadStatusInfoWindow extends Window {
|
||||
|
||||
@Autowired
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@Autowired
|
||||
private ArtifactUploadState artifactUploadState;
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
private static final String PROGRESS = "Progress";
|
||||
|
||||
@@ -46,52 +84,173 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Grid grid;
|
||||
private Grid grid;
|
||||
|
||||
private final IndexedContainer uploads;
|
||||
private IndexedContainer uploads;
|
||||
|
||||
private volatile boolean errorOccured = false;
|
||||
|
||||
private volatile boolean uploadAborted = false;
|
||||
|
||||
private Button minimizeButton;
|
||||
|
||||
private VerticalLayout mainLayout;
|
||||
|
||||
private Label windowCaption;
|
||||
|
||||
private Button closeButton;
|
||||
|
||||
private Button resizeButton;
|
||||
|
||||
private UI ui;
|
||||
|
||||
private ConfirmationDialog confirmDialog;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
UploadStatusInfoWindow() {
|
||||
super("Upload Status");
|
||||
@PostConstruct
|
||||
void init() {
|
||||
|
||||
addStyleName(SPUIStyleDefinitions.UPLOAD_INFO);
|
||||
center();
|
||||
setImmediate(true);
|
||||
setResizable(true);
|
||||
setDraggable(true);
|
||||
setClosable(true);
|
||||
uploads = new IndexedContainer();
|
||||
uploads.addContainerProperty(STATUS, String.class, "Active");
|
||||
uploads.addContainerProperty(FILE_NAME, String.class, null);
|
||||
uploads.addContainerProperty(PROGRESS, Double.class, 0D);
|
||||
uploads.addContainerProperty(REASON, String.class, "");
|
||||
setPopupProperties();
|
||||
createStatusPopupHeaderComponents();
|
||||
|
||||
grid = new Grid(uploads);
|
||||
grid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
|
||||
grid.setSelectionMode(SelectionMode.NONE);
|
||||
grid.getColumn(STATUS).setRenderer(new StatusRenderer());
|
||||
grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
|
||||
setColumnWidth();
|
||||
grid.setFrozenColumnCount(4);
|
||||
grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, REASON);
|
||||
grid.setHeaderVisible(true);
|
||||
grid.setImmediate(true);
|
||||
mainLayout = new VerticalLayout();
|
||||
mainLayout.setSpacing(Boolean.TRUE);
|
||||
mainLayout.setSizeUndefined();
|
||||
setPopupSizeInMinMode();
|
||||
|
||||
setContent(grid);
|
||||
addCloseListener(this);
|
||||
addWindowModeChangeListener(this);
|
||||
uploads = getGridContainer();
|
||||
grid = createGrid();
|
||||
setGridColumnProperties();
|
||||
|
||||
mainLayout.addComponents(getCaptionLayout(), grid);
|
||||
mainLayout.setExpandRatio(grid, 1.0F);
|
||||
setContent(mainLayout);
|
||||
eventBus.subscribe(this);
|
||||
ui = UI.getCurrent();
|
||||
|
||||
createConfirmDialog();
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final UploadStatusEvent event) {
|
||||
if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_IN_PROGRESS) {
|
||||
UI.getCurrent().access(
|
||||
() -> updateProgress(event.getUploadStatus().getFileName(), event.getUploadStatus().getBytesRead(),
|
||||
event.getUploadStatus().getContentLength(), event.getUploadStatus().getSoftwareModule()));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STARTED) {
|
||||
UI.getCurrent().access(() -> onStartOfUpload(event));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FAILED) {
|
||||
ui.access(() -> uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getFailureReason(), event.getUploadStatus().getSoftwareModule()));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_SUCCESSFUL) {
|
||||
UI.getCurrent().access(
|
||||
() -> uploadSucceeded(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getSoftwareModule()));
|
||||
} else if (event.getUploadProgressEventType() == UploadStatusEventType.UPLOAD_STREAMING_FINISHED) {
|
||||
ui.access(() -> uploadSucceeded(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getSoftwareModule()));
|
||||
}
|
||||
}
|
||||
|
||||
private void onStartOfUpload(UploadStatusEvent event) {
|
||||
uploadSessionStarted();
|
||||
uploadStarted(event.getUploadStatus().getFileName(), event.getUploadStatus().getSoftwareModule());
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
/*
|
||||
* It's good manners to do this, even though vaadin-spring will
|
||||
* automatically unsubscribe when this UI is garbage collected.
|
||||
*/
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
private void restoreState() {
|
||||
Indexed container = grid.getContainerDataSource();
|
||||
if (container.getItemIds().isEmpty()) {
|
||||
container.removeAllItems();
|
||||
for (UploadStatusObject statusObject : artifactUploadState.getUploadedFileStatusList()) {
|
||||
Item item = container.addItem(getItemid(statusObject.getFilename(),
|
||||
statusObject.getSelectedSoftwareModule()));
|
||||
item.getItemProperty(REASON).setValue(statusObject.getReason() != null ? statusObject.getReason() : "");
|
||||
item.getItemProperty(STATUS).setValue(statusObject.getStatus());
|
||||
item.getItemProperty(PROGRESS).setValue(statusObject.getProgress());
|
||||
item.getItemProperty(FILE_NAME).setValue(statusObject.getFilename());
|
||||
SoftwareModule sw = statusObject.getSelectedSoftwareModule();
|
||||
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(
|
||||
HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()));
|
||||
}
|
||||
if (artifactUploadState.isUploadCompleted()) {
|
||||
minimizeButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setPopupProperties() {
|
||||
setId(SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_ID);
|
||||
addStyleName(SPUIStyleDefinitions.UPLOAD_INFO);
|
||||
setImmediate(true);
|
||||
setResizable(false);
|
||||
setDraggable(true);
|
||||
setClosable(false);
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
private void setGridColumnProperties() {
|
||||
grid.getColumn(STATUS).setRenderer(new StatusRenderer());
|
||||
grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
|
||||
grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, SPUILabelDefinitions.NAME_VERSION, REASON);
|
||||
setColumnWidth();
|
||||
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setHeaderCaption(i18n.get("upload.swModuleTable.header"));
|
||||
grid.setFrozenColumnCount(5);
|
||||
}
|
||||
|
||||
private Grid createGrid() {
|
||||
Grid statusGrid = new Grid(uploads);
|
||||
statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
|
||||
statusGrid.setSelectionMode(SelectionMode.NONE);
|
||||
statusGrid.setHeaderVisible(true);
|
||||
statusGrid.setImmediate(true);
|
||||
statusGrid.setSizeFull();
|
||||
return statusGrid;
|
||||
}
|
||||
|
||||
private IndexedContainer getGridContainer() {
|
||||
IndexedContainer uploadContainer = new IndexedContainer();
|
||||
uploadContainer.addContainerProperty(STATUS, String.class, "Active");
|
||||
uploadContainer.addContainerProperty(FILE_NAME, String.class, null);
|
||||
uploadContainer.addContainerProperty(PROGRESS, Double.class, 0D);
|
||||
uploadContainer.addContainerProperty(REASON, String.class, "");
|
||||
uploadContainer.addContainerProperty(SPUILabelDefinitions.NAME_VERSION, String.class, "");
|
||||
return uploadContainer;
|
||||
}
|
||||
|
||||
private HorizontalLayout getCaptionLayout() {
|
||||
final HorizontalLayout captionLayout = new HorizontalLayout();
|
||||
captionLayout.setSizeFull();
|
||||
captionLayout.setHeight("36px");
|
||||
captionLayout.addComponents(windowCaption, minimizeButton, resizeButton, closeButton);
|
||||
captionLayout.setExpandRatio(windowCaption, 1.0F);
|
||||
captionLayout.addStyleName("v-window-header");
|
||||
return captionLayout;
|
||||
}
|
||||
|
||||
private void createStatusPopupHeaderComponents() {
|
||||
minimizeButton = getMinimizeButton();
|
||||
windowCaption = new Label("Upload status");
|
||||
closeButton = getCloseButton();
|
||||
resizeButton = getResizeButton();
|
||||
}
|
||||
|
||||
private void setColumnWidth() {
|
||||
grid.getColumn(STATUS).setWidth(70);
|
||||
grid.getColumn(STATUS).setWidth(60);
|
||||
grid.getColumn(PROGRESS).setWidth(150);
|
||||
grid.getColumn(FILE_NAME).setWidth(280);
|
||||
grid.getColumn(REASON).setWidth(300);
|
||||
grid.getColumn(FILE_NAME).setWidth(200);
|
||||
grid.getColumn(REASON).setWidth(290);
|
||||
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidth(200);
|
||||
}
|
||||
|
||||
private void resetColumnWidth() {
|
||||
@@ -99,15 +258,16 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
|
||||
grid.getColumn(PROGRESS).setWidthUndefined();
|
||||
grid.getColumn(FILE_NAME).setWidthUndefined();
|
||||
grid.getColumn(REASON).setWidthUndefined();
|
||||
|
||||
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidthUndefined();
|
||||
}
|
||||
|
||||
private static class StatusRenderer extends HtmlRenderer {
|
||||
|
||||
private static final long serialVersionUID = -5365795450234970943L;
|
||||
|
||||
@Override
|
||||
public JsonValue encode(final String value) {
|
||||
|
||||
String result = "";
|
||||
String result;
|
||||
switch (value) {
|
||||
case "Finished":
|
||||
result = "<div class=\"statusIconGreen\">" + FontAwesome.CHECK_CIRCLE.getHtml() + "</div>";
|
||||
@@ -127,30 +287,66 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
|
||||
* Automatically close if not error has occured.
|
||||
*/
|
||||
void uploadSessionFinished() {
|
||||
if (!errorOccured) {
|
||||
close();
|
||||
uploadAborted = false;
|
||||
if (!errorOccured && !artifactUploadState.isStatusPopupMinimized()) {
|
||||
clearWindow();
|
||||
}
|
||||
|
||||
artifactUploadState.setUploadCompleted(true);
|
||||
minimizeButton.setEnabled(false);
|
||||
closeButton.setEnabled(true);
|
||||
confirmDialog.getWindow().close();
|
||||
UI.getCurrent().removeWindow(confirmDialog.getWindow());
|
||||
}
|
||||
|
||||
void uploadSessionStarted() {
|
||||
close();
|
||||
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == 0
|
||||
&& artifactUploadState.getNumberOfFileUploadsFailed().intValue() == 0
|
||||
&& !artifactUploadState.isStatusPopupMinimized()) {
|
||||
openWindow();
|
||||
}
|
||||
if (!uploadAborted) {
|
||||
minimizeButton.setEnabled(true);
|
||||
closeButton.setEnabled(true);
|
||||
artifactUploadState.setUploadCompleted(false);
|
||||
}
|
||||
}
|
||||
|
||||
void openWindow() {
|
||||
UI.getCurrent().addWindow(this);
|
||||
center();
|
||||
}
|
||||
|
||||
void uploadStarted(final String filename) {
|
||||
final Item item = uploads.addItem(filename);
|
||||
item.getItemProperty(FILE_NAME).setValue(filename);
|
||||
grid.scrollToEnd();
|
||||
|
||||
void maximizeStatusPopup() {
|
||||
openWindow();
|
||||
restoreState();
|
||||
}
|
||||
|
||||
void updateProgress(final String filename, final long readBytes, final long contentLength) {
|
||||
final Item item = uploads.getItem(filename);
|
||||
void uploadStarted(final String filename, final SoftwareModule softwareModule) {
|
||||
final Item item = uploads.addItem(getItemid(filename, softwareModule));
|
||||
if (item != null) {
|
||||
item.getItemProperty(PROGRESS).setValue((double) readBytes / (double) contentLength);
|
||||
item.getItemProperty(FILE_NAME).setValue(filename);
|
||||
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(
|
||||
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()));
|
||||
}
|
||||
grid.scrollToEnd();
|
||||
UploadStatusObject uploadStatus = new UploadStatusObject(filename, softwareModule);
|
||||
uploadStatus.setStatus("Active");
|
||||
artifactUploadState.getUploadedFileStatusList().add(uploadStatus);
|
||||
}
|
||||
|
||||
void updateProgress(final String filename, final long readBytes, final long contentLength,
|
||||
final SoftwareModule softwareModule) {
|
||||
final Item item = uploads.getItem(getItemid(filename, softwareModule));
|
||||
double progress = (double) readBytes / (double) contentLength;
|
||||
if (item != null) {
|
||||
item.getItemProperty(PROGRESS).setValue(progress);
|
||||
}
|
||||
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
|
||||
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
|
||||
.collect(Collectors.toList());
|
||||
if (!uploadStatusObjectList.isEmpty()) {
|
||||
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
|
||||
uploadStatusObject.setProgress(progress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,67 +355,142 @@ public class UploadStatusInfoWindow extends Window implements Window.CloseListen
|
||||
*
|
||||
* @param filename
|
||||
* of the uploaded file.
|
||||
* @param softwareModule
|
||||
* selected software module
|
||||
*/
|
||||
public void uploadSucceeded(final String filename) {
|
||||
final Item item = uploads.getItem(filename);
|
||||
public void uploadSucceeded(final String filename, SoftwareModule softwareModule) {
|
||||
final Item item = uploads.getItem(getItemid(filename, softwareModule));
|
||||
String status = "Finished";
|
||||
if (item != null) {
|
||||
item.getItemProperty(STATUS).setValue("Finished");
|
||||
|
||||
item.getItemProperty(STATUS).setValue(status);
|
||||
}
|
||||
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
|
||||
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
|
||||
.collect(Collectors.toList());
|
||||
if (!uploadStatusObjectList.isEmpty()) {
|
||||
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
|
||||
uploadStatusObject.setStatus(status);
|
||||
uploadStatusObject.setProgress(1d);
|
||||
}
|
||||
}
|
||||
|
||||
void uploadFailed(final String filename, final String errorReason) {
|
||||
final Item item = uploads.getItem(filename);
|
||||
void uploadFailed(final String filename, final String errorReason, SoftwareModule softwareModule) {
|
||||
errorOccured = true;
|
||||
String status = "Failed";
|
||||
final Item item = uploads.getItem(getItemid(filename, softwareModule));
|
||||
if (item != null) {
|
||||
if (!errorOccured) {
|
||||
errorOccured = true;
|
||||
}
|
||||
item.getItemProperty(REASON).setValue(errorReason);
|
||||
item.getItemProperty(STATUS).setValue("Failed");
|
||||
|
||||
item.getItemProperty(STATUS).setValue(status);
|
||||
}
|
||||
List<UploadStatusObject> uploadStatusObjectList = (List<UploadStatusObject>) artifactUploadState
|
||||
.getUploadedFileStatusList().stream().filter(e -> e.getFilename().equals(filename))
|
||||
.collect(Collectors.toList());
|
||||
if (!uploadStatusObjectList.isEmpty()) {
|
||||
UploadStatusObject uploadStatusObject = uploadStatusObjectList.get(0);
|
||||
uploadStatusObject.setStatus(status);
|
||||
uploadStatusObject.setReason(errorReason);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.vaadin.ui.Window.CloseListener#windowClose(com.vaadin.ui.Window.
|
||||
* CloseEvent)
|
||||
*/
|
||||
@Override
|
||||
public void windowClose(final CloseEvent e) {
|
||||
clearWindow();
|
||||
}
|
||||
|
||||
private void clearWindow() {
|
||||
protected void clearWindow() {
|
||||
errorOccured = false;
|
||||
uploads.removeAllItems();
|
||||
setWindowMode(WindowMode.NORMAL);
|
||||
setColumnWidth();
|
||||
setPopupSizeInMinMode();
|
||||
resizeButton.setIcon(FontAwesome.EXPAND);
|
||||
this.close();
|
||||
artifactUploadState.getUploadedFileStatusList().clear();
|
||||
artifactUploadState.getNumberOfFileUploadsFailed().set(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.vaadin.ui.Window.WindowModeChangeListener#windowModeChanged(com.
|
||||
* vaadin.ui.Window. WindowModeChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void windowModeChanged(final WindowModeChangeEvent event) {
|
||||
if (event.getWindow().getWindowMode() == WindowMode.MAXIMIZED) {
|
||||
private void setPopupSizeInMinMode() {
|
||||
mainLayout.setWidth(900, Unit.PIXELS);
|
||||
mainLayout.setHeight(510, Unit.PIXELS);
|
||||
}
|
||||
|
||||
private Button getMinimizeButton() {
|
||||
final Button minimizeBtn = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_MINIMIZE_BUTTON_ID, "", "", "", true, FontAwesome.MINUS,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
minimizeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||
minimizeBtn.addClickListener(event -> minimizeWindow());
|
||||
minimizeBtn.setEnabled(true);
|
||||
return minimizeBtn;
|
||||
}
|
||||
|
||||
private Button getResizeButton() {
|
||||
final Button resizeBtn = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_RESIZE_BUTTON_ID, "", "", "", true, FontAwesome.EXPAND,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
resizeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||
resizeBtn.addClickListener(event -> resizeWindow(event));
|
||||
return resizeBtn;
|
||||
}
|
||||
|
||||
private void resizeWindow(ClickEvent event) {
|
||||
if (event.getButton().getIcon() == FontAwesome.EXPAND) {
|
||||
event.getButton().setIcon(FontAwesome.COMPRESS);
|
||||
setWindowMode(WindowMode.MAXIMIZED);
|
||||
resetColumnWidth();
|
||||
grid.getColumn(STATUS).setExpandRatio(0);
|
||||
grid.getColumn(PROGRESS).setExpandRatio(1);
|
||||
grid.getColumn(FILE_NAME).setExpandRatio(2);
|
||||
grid.getColumn(REASON).setExpandRatio(3);
|
||||
grid.setSizeFull();
|
||||
grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setExpandRatio(4);
|
||||
mainLayout.setSizeFull();
|
||||
} else {
|
||||
event.getButton().setIcon(FontAwesome.EXPAND);
|
||||
setWindowMode(WindowMode.NORMAL);
|
||||
setColumnWidth();
|
||||
setPopupSizeInMinMode();
|
||||
}
|
||||
}
|
||||
|
||||
private void setPopupSizeInMinMode() {
|
||||
grid.setWidth(800, Unit.PIXELS);
|
||||
grid.setHeight(510, Unit.PIXELS);
|
||||
private void minimizeWindow() {
|
||||
this.close();
|
||||
artifactUploadState.setStatusPopupMinimized(true);
|
||||
eventBus.publish(this, UploadArtifactUIEvent.MINIMIZED_STATUS_POPUP);
|
||||
}
|
||||
|
||||
private Button getCloseButton() {
|
||||
final Button closeBtn = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.UPLOAD_STATUS_POPUP_CLOSE_BUTTON_ID, "", "", "", true, FontAwesome.TIMES,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
closeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||
closeBtn.addClickListener(event -> onClose());
|
||||
return closeBtn;
|
||||
}
|
||||
|
||||
private void onClose() {
|
||||
if (!artifactUploadState.isUploadCompleted()) {
|
||||
confirmAbortAction();
|
||||
} else {
|
||||
clearWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void confirmAbortAction() {
|
||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||
confirmDialog.getWindow().bringToFront();
|
||||
}
|
||||
|
||||
private void createConfirmDialog() {
|
||||
confirmDialog = new ConfirmationDialog(i18n.get("caption.confirm.abort.action"),
|
||||
i18n.get("message.abort.upload"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||
if (ok) {
|
||||
eventBus.publish(this, UploadStatusEventType.ABORT_UPLOAD);
|
||||
uploadAborted = true;
|
||||
errorOccured = true;
|
||||
minimizeButton.setEnabled(false);
|
||||
closeButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getItemid(final String filename, final SoftwareModule softwareModule) {
|
||||
return new StringBuilder(filename).append(
|
||||
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds uploaded file status.Used to display the details in upload status
|
||||
* popup.
|
||||
*
|
||||
*/
|
||||
public class UploadStatusObject implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String status;
|
||||
private Double progress;
|
||||
private String filename;
|
||||
private String reason;
|
||||
private final SoftwareModule selectedSoftwareModule;
|
||||
|
||||
public UploadStatusObject(final String status, final Double progress, final String fileName, final String reason,
|
||||
final SoftwareModule selectedSoftwareModule) {
|
||||
this(fileName, selectedSoftwareModule);
|
||||
this.status = status;
|
||||
this.progress = progress;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public UploadStatusObject(final String fileName, final SoftwareModule selectedSoftwareModule) {
|
||||
this.filename = fileName;
|
||||
this.selectedSoftwareModule = selectedSoftwareModule;
|
||||
}
|
||||
|
||||
public SoftwareModule getSelectedSoftwareModule() {
|
||||
return selectedSoftwareModule;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Double getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(final Double progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(final String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(final String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((filename == null) ? 0 : filename.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof UploadStatusObject)) {
|
||||
return false;
|
||||
}
|
||||
final UploadStatusObject other = (UploadStatusObject) obj;
|
||||
if (filename == null) {
|
||||
if (other.filename != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!filename.equals(other.filename)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.colorpicker;
|
||||
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
|
||||
/**
|
||||
* Provides color constants for the ColorPickerLayout
|
||||
*
|
||||
*/
|
||||
public class ColorPickerConstants {
|
||||
|
||||
public static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
||||
public static final Color START_COLOR = new Color(0, 146, 58);
|
||||
|
||||
private ColorPickerConstants() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.colorpicker;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Contains helper methods for the ColorPickerLayout to handle the ColorPicker
|
||||
*
|
||||
*/
|
||||
public class ColorPickerHelper {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ColorPickerHelper.class);
|
||||
|
||||
private ColorPickerHelper() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color picked value as string.
|
||||
*
|
||||
* @return String of color picked value.
|
||||
*/
|
||||
public static String getColorPickedString(final SpColorPickerPreview preview) {
|
||||
|
||||
final Color color = preview.getColor();
|
||||
return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Covert RGB code to {@Color}.
|
||||
*
|
||||
* @param value
|
||||
* RGB vale
|
||||
* @return Color
|
||||
*/
|
||||
public static Color rgbToColorConverter(final String value) {
|
||||
|
||||
if (StringUtils.isEmpty(value) || (StringUtils.isNotEmpty(value) && !value.startsWith("rgb"))) {
|
||||
throw new IllegalArgumentException(
|
||||
"String to convert is empty or of invalid format - value: '" + value + "'");
|
||||
}
|
||||
|
||||
// RGB color format rgb/rgba(255,255,255,0.1)
|
||||
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
||||
final int red = Integer.parseInt(colors[0]);
|
||||
final int green = Integer.parseInt(colors[1]);
|
||||
final int blue = Integer.parseInt(colors[2]);
|
||||
if (colors.length > 3) {
|
||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
||||
return new Color(red, green, blue, alpha);
|
||||
}
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the selectedColor in the ColorPickerLayout and sets the slider
|
||||
* values
|
||||
*
|
||||
* @param colorPickerLayout
|
||||
* colorPickerLayout
|
||||
*/
|
||||
public static void setRgbSliderValues(final ColorPickerLayout colorPickerLayout) {
|
||||
|
||||
try {
|
||||
final double redColorValue = colorPickerLayout.getSelectedColor().getRed();
|
||||
colorPickerLayout.getRedSlider().setValue(Double.valueOf(redColorValue));
|
||||
final double blueColorValue = colorPickerLayout.getSelectedColor().getBlue();
|
||||
colorPickerLayout.getBlueSlider().setValue(Double.valueOf(blueColorValue));
|
||||
final double greenColorValue = colorPickerLayout.getSelectedColor().getGreen();
|
||||
colorPickerLayout.getGreenSlider().setValue(Double.valueOf(greenColorValue));
|
||||
} catch (final ValueOutOfBoundsException e) {
|
||||
LOG.error("Unable to set RGB color value to " + colorPickerLayout.getSelectedColor().getRed() + ","
|
||||
+ colorPickerLayout.getSelectedColor().getGreen() + ","
|
||||
+ colorPickerLayout.getSelectedColor().getBlue(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* 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.colorpicker;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
|
||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
||||
import com.vaadin.ui.GridLayout;
|
||||
import com.vaadin.ui.Slider;
|
||||
import com.vaadin.ui.components.colorpicker.ColorPickerGradient;
|
||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the Layout for the ColorPicker
|
||||
*
|
||||
*/
|
||||
public class ColorPickerLayout extends GridLayout {
|
||||
|
||||
private static final long serialVersionUID = -7025970080613796692L;
|
||||
|
||||
private SpColorPickerPreview selPreview;
|
||||
|
||||
private ColorPickerGradient colorSelect;
|
||||
private Set<ColorSelector> selectors;
|
||||
private Color selectedColor;
|
||||
|
||||
/** RGB color converter. */
|
||||
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
||||
|
||||
private Slider redSlider;
|
||||
private Slider greenSlider;
|
||||
private Slider blueSlider;
|
||||
|
||||
public ColorPickerLayout() {
|
||||
|
||||
setColumns(2);
|
||||
setRows(4);
|
||||
setId(SPUIComponentIdProvider.COLOR_PICKER_LAYOUT);
|
||||
|
||||
init();
|
||||
|
||||
setStyleName("rgb-vertical-layout");
|
||||
|
||||
addComponent(redSlider, 0, 1);
|
||||
addComponent(greenSlider, 0, 2);
|
||||
addComponent(blueSlider, 0, 3);
|
||||
|
||||
addComponent(selPreview, 1, 0);
|
||||
addComponent(colorSelect, 1, 1, 1, 3);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
selectors = new HashSet<>();
|
||||
selectedColor = getDefaultColor();
|
||||
selPreview = new SpColorPickerPreview(selectedColor);
|
||||
|
||||
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
|
||||
colorSelect.setColor(selectedColor);
|
||||
colorSelect.setWidth("220px");
|
||||
|
||||
redSlider = createRGBSlider("", "red");
|
||||
redSlider.setId(SPUIComponentIdProvider.COLOR_PICKER_RED_SLIDER);
|
||||
greenSlider = createRGBSlider("", "green");
|
||||
blueSlider = createRGBSlider("", "blue");
|
||||
|
||||
selectors.add(colorSelect);
|
||||
}
|
||||
|
||||
public Slider createRGBSlider(final String caption, final String styleName) {
|
||||
final Slider slider = new Slider(caption, 0, 255);
|
||||
slider.setImmediate(true);
|
||||
slider.setWidth("150px");
|
||||
slider.addStyleName(styleName);
|
||||
return slider;
|
||||
}
|
||||
|
||||
public SpColorPickerPreview getSelPreview() {
|
||||
return selPreview;
|
||||
}
|
||||
|
||||
public void setSelPreview(final SpColorPickerPreview selPreview) {
|
||||
this.selPreview = selPreview;
|
||||
}
|
||||
|
||||
public ColorPickerGradient getColorSelect() {
|
||||
return colorSelect;
|
||||
}
|
||||
|
||||
public void setColorSelect(final ColorPickerGradient colorSelect) {
|
||||
this.colorSelect = colorSelect;
|
||||
}
|
||||
|
||||
public Set<ColorSelector> getSelectors() {
|
||||
return selectors;
|
||||
}
|
||||
|
||||
public Color getSelectedColor() {
|
||||
return selectedColor;
|
||||
}
|
||||
|
||||
public void setSelectedColor(final Color selectedColor) {
|
||||
this.selectedColor = selectedColor;
|
||||
}
|
||||
|
||||
public Coordinates2Color getRgbConverter() {
|
||||
return rgbConverter;
|
||||
}
|
||||
|
||||
public Color getDefaultColor() {
|
||||
return new Color(44, 151, 32);
|
||||
}
|
||||
|
||||
public Slider getRedSlider() {
|
||||
return redSlider;
|
||||
}
|
||||
|
||||
public void setRedSlider(final Slider redSlider) {
|
||||
this.redSlider = redSlider;
|
||||
}
|
||||
|
||||
public Slider getGreenSlider() {
|
||||
return greenSlider;
|
||||
}
|
||||
|
||||
public void setGreenSlider(final Slider greenSlider) {
|
||||
this.greenSlider = greenSlider;
|
||||
}
|
||||
|
||||
public Slider getBlueSlider() {
|
||||
return blueSlider;
|
||||
}
|
||||
|
||||
public void setBlueSlider(final Slider blueSlider) {
|
||||
this.blueSlider = blueSlider;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,493 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon;
|
||||
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
|
||||
import org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.vaadin.data.Container.ItemSetChangeEvent;
|
||||
import com.vaadin.data.Container.ItemSetChangeListener;
|
||||
import com.vaadin.data.Property.ValueChangeEvent;
|
||||
import com.vaadin.data.Property.ValueChangeListener;
|
||||
import com.vaadin.data.Validator;
|
||||
import com.vaadin.data.validator.NullValidator;
|
||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||
import com.vaadin.event.FieldEvents.TextChangeListener;
|
||||
import com.vaadin.event.FieldEvents.TextChangeNotifier;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.ui.AbstractComponent;
|
||||
import com.vaadin.ui.AbstractField;
|
||||
import com.vaadin.ui.AbstractLayout;
|
||||
import com.vaadin.ui.AbstractOrderedLayout;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Button.ClickListener;
|
||||
import com.vaadin.ui.CheckBox;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Field;
|
||||
import com.vaadin.ui.GridLayout;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
* Table pop-up-windows including a minimize and close icon in the upper right
|
||||
* corner and a save and cancel button at the bottom. Is not intended to reuse.
|
||||
*
|
||||
*/
|
||||
public class CommonDialogWindow extends Window implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final VerticalLayout mainLayout = new VerticalLayout();
|
||||
|
||||
private final String caption;
|
||||
|
||||
private final Component content;
|
||||
|
||||
private final String helpLink;
|
||||
|
||||
private Button saveButton;
|
||||
|
||||
private Button cancelButton;
|
||||
|
||||
private HorizontalLayout buttonsLayout;
|
||||
|
||||
protected ValueChangeListener buttonEnableListener;
|
||||
|
||||
private final ClickListener saveButtonClickListener;
|
||||
|
||||
private final ClickListener cancelButtonClickListener;
|
||||
|
||||
private final ClickListener close = event -> close();
|
||||
|
||||
private final transient Map<Component, Object> orginalValues;
|
||||
|
||||
private final List<AbstractField<?>> allComponents;
|
||||
|
||||
private final I18N i18n;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param caption
|
||||
* the caption
|
||||
* @param content
|
||||
* the content
|
||||
* @param helpLink
|
||||
* the helpLinks
|
||||
* @param saveButtonClickListener
|
||||
* the saveButtonClickListener
|
||||
* @param cancelButtonClickListener
|
||||
* the cancelButtonClickListener
|
||||
*/
|
||||
public CommonDialogWindow(final String caption, final Component content, final String helpLink,
|
||||
final ClickListener saveButtonClickListener, final ClickListener cancelButtonClickListener,
|
||||
final AbstractLayout layout, final I18N i18n) {
|
||||
checkNotNull(saveButtonClickListener);
|
||||
this.caption = caption;
|
||||
this.content = content;
|
||||
this.helpLink = helpLink;
|
||||
this.saveButtonClickListener = saveButtonClickListener;
|
||||
this.cancelButtonClickListener = cancelButtonClickListener;
|
||||
this.orginalValues = new HashMap<>();
|
||||
this.allComponents = getAllComponents(layout);
|
||||
this.i18n = i18n;
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
orginalValues.clear();
|
||||
removeListeners();
|
||||
allComponents.clear();
|
||||
this.saveButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
for (final AbstractField<?> field : allComponents) {
|
||||
removeTextListener(field);
|
||||
removeValueChangeListener(field);
|
||||
removeItemSetChangeistener(field);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItemSetChangeistener(final AbstractField<?> field) {
|
||||
if (!(field instanceof Table)) {
|
||||
return;
|
||||
}
|
||||
for (final Object listener : field.getListeners(ItemSetChangeEvent.class)) {
|
||||
if (listener instanceof ChangeListener) {
|
||||
((Table) field).removeItemSetChangeListener((ChangeListener) listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeTextListener(final AbstractField<?> field) {
|
||||
if (!(field instanceof TextChangeNotifier)) {
|
||||
return;
|
||||
}
|
||||
for (final Object listener : field.getListeners(TextChangeEvent.class)) {
|
||||
if (listener instanceof ChangeListener) {
|
||||
((TextChangeNotifier) field).removeTextChangeListener((ChangeListener) listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeValueChangeListener(final AbstractField<?> field) {
|
||||
for (final Object listener : field.getListeners(ValueChangeEvent.class)) {
|
||||
if (listener instanceof ChangeListener) {
|
||||
field.removeValueChangeListener((ChangeListener) listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void init() {
|
||||
|
||||
if (content instanceof AbstractOrderedLayout) {
|
||||
((AbstractOrderedLayout) content).setSpacing(true);
|
||||
((AbstractOrderedLayout) content).setMargin(true);
|
||||
}
|
||||
if (content instanceof GridLayout) {
|
||||
addStyleName("marginTop");
|
||||
}
|
||||
|
||||
if (null != content) {
|
||||
mainLayout.addComponent(content);
|
||||
}
|
||||
|
||||
createMandatoryLabel();
|
||||
|
||||
final HorizontalLayout buttonLayout = createActionButtonsLayout();
|
||||
mainLayout.addComponent(buttonLayout);
|
||||
mainLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER);
|
||||
|
||||
setCaption(caption);
|
||||
setContent(mainLayout);
|
||||
setResizable(false);
|
||||
center();
|
||||
setModal(true);
|
||||
addStyleName("fontsize");
|
||||
setOrginaleValues();
|
||||
addListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* saves the original values in a Map so we can use them for detecting
|
||||
* changes
|
||||
*/
|
||||
public final void setOrginaleValues() {
|
||||
for (final AbstractField<?> field : allComponents) {
|
||||
Object value = field.getValue();
|
||||
|
||||
if (field instanceof Table) {
|
||||
value = Sets.newHashSet(((Table) field).getContainerDataSource().getItemIds());
|
||||
}
|
||||
orginalValues.put(field, value);
|
||||
}
|
||||
saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(null, null));
|
||||
}
|
||||
|
||||
private final void addListeners() {
|
||||
for (final AbstractField<?> field : allComponents) {
|
||||
if (field instanceof TextChangeNotifier) {
|
||||
((TextChangeNotifier) field).addTextChangeListener(new ChangeListener(field));
|
||||
}
|
||||
|
||||
if (field instanceof Table) {
|
||||
((Table) field).addItemSetChangeListener(new ChangeListener(field));
|
||||
} else {
|
||||
field.addValueChangeListener(new ChangeListener(field));
|
||||
}
|
||||
}
|
||||
|
||||
saveButton.addClickListener(close);
|
||||
cancelButton.addClickListener(close);
|
||||
}
|
||||
|
||||
private boolean isSaveButtonEnabledAfterValueChange(final Component currentChangedComponent,
|
||||
final Object newValue) {
|
||||
return isMandatoryFieldNotEmptyAndValid(currentChangedComponent, newValue)
|
||||
&& isValuesChanged(currentChangedComponent, newValue);
|
||||
}
|
||||
|
||||
private boolean isValuesChanged(final Component currentChangedComponent, final Object newValue) {
|
||||
for (final AbstractField<?> field : allComponents) {
|
||||
Object originalValue = orginalValues.get(field);
|
||||
if (field instanceof CheckBox && originalValue == null) {
|
||||
originalValue = Boolean.FALSE;
|
||||
}
|
||||
final Object currentValue = getCurrentVaue(currentChangedComponent, newValue, field);
|
||||
|
||||
if (!isValueEquals(field, originalValue, currentValue)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValueEquals(final AbstractField<?> field, final Object orginalValue, final Object currentValue) {
|
||||
if (Set.class.equals(field.getType())) {
|
||||
return CollectionUtils.isEqualCollection(CollectionUtils.emptyIfNull((Collection<?>) orginalValue),
|
||||
CollectionUtils.emptyIfNull((Collection<?>) currentValue));
|
||||
}
|
||||
|
||||
if (String.class.equals(field.getType())) {
|
||||
return Objects.equals(Strings.emptyToNull((String) orginalValue),
|
||||
Strings.emptyToNull((String) currentValue));
|
||||
}
|
||||
|
||||
return Objects.equals(orginalValue, currentValue);
|
||||
}
|
||||
|
||||
private Object getCurrentVaue(final Component currentChangedComponent, final Object newValue,
|
||||
final AbstractField<?> field) {
|
||||
Object currentValue = field.getValue();
|
||||
if (field instanceof Table) {
|
||||
currentValue = ((Table) field).getContainerDataSource().getItemIds();
|
||||
}
|
||||
|
||||
if (field.equals(currentChangedComponent)) {
|
||||
currentValue = newValue;
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
private boolean shouldMandatoryLabelShown() {
|
||||
for (final AbstractField<?> field : allComponents) {
|
||||
if (field.isRequired()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isMandatoryFieldNotEmptyAndValid(final Component currentChangedComponent, final Object newValue) {
|
||||
|
||||
boolean valid = true;
|
||||
final List<AbstractField<?>> requiredComponents = allComponents.stream().filter(field -> field.isRequired())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
requiredComponents.addAll(allComponents.stream().filter(this::hasNullValidator).collect(Collectors.toList()));
|
||||
|
||||
for (final AbstractField field : requiredComponents) {
|
||||
Object value = getCurrentVaue(currentChangedComponent, newValue, field);
|
||||
|
||||
if (String.class.equals(field.getType())) {
|
||||
value = Strings.emptyToNull((String) value);
|
||||
}
|
||||
|
||||
if (Set.class.equals(field.getType())) {
|
||||
value = emptyToNull((Collection<?>) value);
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to loop through the entire loop for validity testing.
|
||||
// Otherwise the UI will only mark the
|
||||
// first field with errors and then stop. If there are several
|
||||
// fields with errors, this is bad.
|
||||
field.setValue(value);
|
||||
if (!field.isValid()) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
private static Object emptyToNull(final Collection<?> c) {
|
||||
return (c == null || c.isEmpty()) ? null : c;
|
||||
}
|
||||
|
||||
private boolean hasNullValidator(final Component component) {
|
||||
|
||||
if (component instanceof AbstractField<?>) {
|
||||
final AbstractField<?> fieldComponent = (AbstractField<?>) component;
|
||||
for (final Validator validator : fieldComponent.getValidators()) {
|
||||
if (validator instanceof NullValidator) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<AbstractField<?>> getAllComponents(final AbstractLayout abstractLayout) {
|
||||
final List<AbstractField<?>> components = new ArrayList<>();
|
||||
|
||||
final Iterator<Component> iterate = abstractLayout.iterator();
|
||||
while (iterate.hasNext()) {
|
||||
final Component c = iterate.next();
|
||||
if (c instanceof AbstractLayout) {
|
||||
components.addAll(getAllComponents((AbstractLayout) c));
|
||||
}
|
||||
|
||||
if (c instanceof AbstractField) {
|
||||
components.add((AbstractField<?>) c);
|
||||
}
|
||||
|
||||
if (c instanceof FlexibleOptionGroupItemComponent) {
|
||||
components.add(((FlexibleOptionGroupItemComponent) c).getOwner());
|
||||
}
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
private HorizontalLayout createActionButtonsLayout() {
|
||||
|
||||
buttonsLayout = new HorizontalLayout();
|
||||
buttonsLayout.setSizeFull();
|
||||
buttonsLayout.setSpacing(true);
|
||||
buttonsLayout.addStyleName("actionButtonsMargin");
|
||||
|
||||
createSaveButton();
|
||||
createCancelButton();
|
||||
|
||||
addHelpLink();
|
||||
|
||||
return buttonsLayout;
|
||||
}
|
||||
|
||||
private void createMandatoryLabel() {
|
||||
|
||||
if (!shouldMandatoryLabelShown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Label mandatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
||||
mandatoryLabel.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_TINY);
|
||||
|
||||
if (content instanceof TargetAddUpdateWindowLayout) {
|
||||
((TargetAddUpdateWindowLayout) content).getFormLayout().addComponent(mandatoryLabel);
|
||||
} else if (content instanceof SoftwareModuleAddUpdateWindow) {
|
||||
((SoftwareModuleAddUpdateWindow) content).getFormLayout().addComponent(mandatoryLabel);
|
||||
} else if (content instanceof AbstractCreateUpdateTagLayout) {
|
||||
((AbstractCreateUpdateTagLayout) content).getMainLayout().addComponent(mandatoryLabel);
|
||||
}
|
||||
|
||||
mainLayout.addComponent(mandatoryLabel);
|
||||
}
|
||||
|
||||
private void createCancelButton() {
|
||||
cancelButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.CANCEL_BUTTON, "Cancel", "", "", true,
|
||||
FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
cancelButton.setSizeUndefined();
|
||||
if (cancelButtonClickListener != null) {
|
||||
cancelButton.addClickListener(cancelButtonClickListener);
|
||||
}
|
||||
|
||||
buttonsLayout.addComponent(cancelButton);
|
||||
buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_LEFT);
|
||||
buttonsLayout.setExpandRatio(cancelButton, 1.0F);
|
||||
}
|
||||
|
||||
private void createSaveButton() {
|
||||
saveButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SAVE_BUTTON, "Save", "", "", true,
|
||||
FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class);
|
||||
saveButton.setSizeUndefined();
|
||||
saveButton.addClickListener(saveButtonClickListener);
|
||||
saveButton.setEnabled(false);
|
||||
buttonsLayout.addComponent(saveButton);
|
||||
buttonsLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT);
|
||||
buttonsLayout.setExpandRatio(saveButton, 1.0F);
|
||||
}
|
||||
|
||||
private void addHelpLink() {
|
||||
|
||||
if (StringUtils.isEmpty(helpLink)) {
|
||||
return;
|
||||
}
|
||||
final Link helpLinkComponent = SPUIComponentProvider.getHelpLink(helpLink);
|
||||
buttonsLayout.addComponent(helpLinkComponent);
|
||||
buttonsLayout.setComponentAlignment(helpLinkComponent, Alignment.MIDDLE_RIGHT);
|
||||
}
|
||||
|
||||
public AbstractComponent getButtonsLayout() {
|
||||
return this.buttonsLayout;
|
||||
}
|
||||
|
||||
private class ChangeListener implements ValueChangeListener, TextChangeListener, ItemSetChangeListener {
|
||||
|
||||
private final Field<?> field;
|
||||
|
||||
public ChangeListener(final Field<?> field) {
|
||||
super();
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textChange(final TextChangeEvent event) {
|
||||
saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(field, event.getText()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(field, field.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void containerItemSetChange(final ItemSetChangeEvent event) {
|
||||
if (!(field instanceof Table)) {
|
||||
return;
|
||||
}
|
||||
final Table table = (Table) field;
|
||||
saveButton.setEnabled(
|
||||
isSaveButtonEnabledAfterValueChange(table, table.getContainerDataSource().getItemIds()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the component manually to the allComponents-List and adds a
|
||||
* ValueChangeListener to it. Necessary in Update Distribution Type as the
|
||||
* CheckBox concerned is an ItemProperty...
|
||||
*
|
||||
* @param component
|
||||
* AbstractField
|
||||
*/
|
||||
public void updateAllComponents(final AbstractField component) {
|
||||
|
||||
allComponents.add(component);
|
||||
component.addValueChangeListener(new ChangeListener(component));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
|
||||
import com.vaadin.server.Resource;
|
||||
@@ -82,13 +82,14 @@ public class ConfirmationDialog implements Button.ClickListener {
|
||||
window.setIcon(icon);
|
||||
}
|
||||
|
||||
okButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.OK_BUTTON, okLabel, "",
|
||||
okButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.OK_BUTTON, okLabel, "",
|
||||
ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
|
||||
okButton.addClickListener(this);
|
||||
|
||||
final Button cancelButton = SPUIComponentProvider.getButton(null, cancelLabel, "", null, false, null,
|
||||
SPUIButtonStyleTiny.class);
|
||||
cancelButton.addClickListener(this);
|
||||
cancelButton.setId(SPUIComponentIdProvider.CANCEL_BUTTON);
|
||||
window.setModal(true);
|
||||
window.addStyleName(SPUIStyleDefinitions.CONFIRMBOX_WINDOW_SYLE);
|
||||
if (this.callback == null) {
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributionSetIdName implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String version;
|
||||
|
||||
public static DistributionSetIdName generate(final DistributionSet distributionSet) {
|
||||
return new DistributionSetIdName(distributionSet.getId(), distributionSet.getName(),
|
||||
distributionSet.getVersion());
|
||||
|
||||
}
|
||||
|
||||
public static DistributionSetIdName generate(final Long id, final String name, final String version) {
|
||||
return new DistributionSetIdName(id, name, version);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the {@link DistributionSet#getId()}
|
||||
* @param name
|
||||
* the {@link DistributionSet#getName()}
|
||||
* @param version
|
||||
* the {@link DistributionSet#getVersion()}
|
||||
*
|
||||
*/
|
||||
public DistributionSetIdName(final Long id, final String name, final String version) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DistributionSetIdName)) {
|
||||
return false;
|
||||
}
|
||||
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// only return the ID because it's used in vaadin for setting the item
|
||||
// id in the dom
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
@@ -41,6 +42,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
|
||||
private final Sort sort = new Sort(Direction.ASC, "name");
|
||||
private transient Page<DistributionSetType> firstPageDistSetType = null;
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
/**
|
||||
* Parametric constructor.
|
||||
@@ -57,8 +59,9 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
|
||||
|
||||
@Override
|
||||
protected DistributionSetType constructBean() {
|
||||
|
||||
return new DistributionSetType("", "", "", "");
|
||||
final DistributionSetType result = getEntityFactory().generateDistributionSetType("", "", "");
|
||||
result.setColour("");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +83,13 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
|
||||
return distributionSetManagement;
|
||||
}
|
||||
|
||||
private EntityFactory getEntityFactory() {
|
||||
if (entityFactory == null) {
|
||||
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
|
||||
}
|
||||
return entityFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DistributionSetType> loadBeans(final int startIndex, final int count) {
|
||||
Page<DistributionSetType> typeBeans;
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.common;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
@@ -31,6 +32,7 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
|
||||
private final Sort sort = new Sort(Direction.ASC, "name");
|
||||
private transient Page<SoftwareModuleType> firstPageSwModuleType = null;
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
/**
|
||||
* Parametric constructor.
|
||||
@@ -47,7 +49,14 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
|
||||
|
||||
@Override
|
||||
protected SoftwareModuleType constructBean() {
|
||||
return new SoftwareModuleType();
|
||||
return getEntityFactory().generateSoftwareModuleType();
|
||||
}
|
||||
|
||||
private EntityFactory getEntityFactory() {
|
||||
if (entityFactory == null) {
|
||||
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
|
||||
}
|
||||
return entityFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -175,11 +175,7 @@ public final class UserDetailsFormatter {
|
||||
private static UserDetails loadUserByUsername(final String username) {
|
||||
final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
|
||||
try {
|
||||
final UserDetails loadUserByUsername = userDetailsService.loadUserByUsername(username);
|
||||
if (loadUserByUsername == null) {
|
||||
throw new UsernameNotFoundException("User not found " + username);
|
||||
}
|
||||
return loadUserByUsername;
|
||||
return userDetailsService.loadUserByUsername(username);
|
||||
} catch (final UsernameNotFoundException e) {
|
||||
return new User(username, "", Collections.emptyList());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import javax.annotation.PostConstruct;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
|
||||
private void createActionMessgaeLabel() {
|
||||
actionMessage = SPUIComponentProvider.getLabel("", null);
|
||||
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
|
||||
actionMessage.setId(SPUIComponetIdProvider.ACTION_LABEL);
|
||||
actionMessage.setId(SPUIComponentIdProvider.ACTION_LABEL);
|
||||
actionMessage.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -238,7 +238,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
* it as we need full description.
|
||||
*/
|
||||
descLabel.removeStyleName("label-style");
|
||||
descLabel.setId(SPUIComponetIdProvider.DETAILS_DESCRIPTION_LABEL_ID);
|
||||
descLabel.setId(SPUIComponentIdProvider.DETAILS_DESCRIPTION_LABEL_ID);
|
||||
descriptionLayout.addComponent(descLabel);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
@@ -214,7 +215,7 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
.getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules);
|
||||
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
|
||||
unAssignedSw);
|
||||
manageDistUIState.setLastSelectedEntity(newDistributionSet.getDistributionSetIdName());
|
||||
manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet));
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
|
||||
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
||||
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));
|
||||
|
||||
@@ -34,19 +34,15 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Parent class for filter button layout.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractFilterButtons extends Table {
|
||||
|
||||
private static final long serialVersionUID = 7783305719009746375L;
|
||||
|
||||
|
||||
private static final String DEFAULT_GREEN = "rgb(44,151,32)";
|
||||
|
||||
protected static final String FILTER_BUTTON_COLUMN = "filterButton";
|
||||
|
||||
|
||||
@Autowired
|
||||
protected transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@@ -63,7 +59,7 @@ public abstract class AbstractFilterButtons extends Table {
|
||||
createTable();
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
@@ -125,8 +121,7 @@ public abstract class AbstractFilterButtons extends Table {
|
||||
} else if (id != null && isClickedByDefault(name)) {
|
||||
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
||||
}
|
||||
final DragAndDropWrapper wrapper = createDragAndDropWrapper(typeButton, name, id);
|
||||
return wrapper;
|
||||
return createDragAndDropWrapper(typeButton, name, id);
|
||||
}
|
||||
|
||||
protected boolean isNoTagSateSelected() {
|
||||
@@ -156,6 +151,7 @@ public abstract class AbstractFilterButtons extends Table {
|
||||
columnIds.add(FILTER_BUTTON_COLUMN);
|
||||
setVisibleColumns(columnIds.toArray());
|
||||
setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
|
||||
setColumnWidth(FILTER_BUTTON_COLUMN, 137);
|
||||
}
|
||||
|
||||
private Button createFilterButton(final Long id, final String name, final String description, final String color,
|
||||
@@ -180,6 +176,7 @@ public abstract class AbstractFilterButtons extends Table {
|
||||
button.setDescription(name);
|
||||
}
|
||||
button.setData(id == null ? SPUIDefinitions.NO_TAG_BUTTON_ID : itemId);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
||||
|
||||
private static final long serialVersionUID = -1388340600522323332L;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected SpPermissionChecker permChecker;
|
||||
|
||||
@@ -64,7 +63,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
||||
if (hasCreateUpdatePermission() && isAddTagRequired()) {
|
||||
config = SPUIComponentProvider.getButton(getConfigureFilterButtonId(), "", "", "", true, FontAwesome.COG,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
config.addClickListener(event -> settingsIconClicked(event));
|
||||
config.addClickListener(this::settingsIconClicked);
|
||||
}
|
||||
hideIcon = SPUIComponentProvider.getButton(getHideButtonId(), "", "", "", true, FontAwesome.TIMES,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
@@ -92,8 +91,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private Label createHeaderCaption() {
|
||||
final Label captionLabel = SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
return captionLabel;
|
||||
return SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,8 @@ import com.vaadin.ui.Button.ClickEvent;
|
||||
*/
|
||||
public abstract class AbstractFilterMultiButtonClick extends AbstractFilterButtonClickBehaviour {
|
||||
|
||||
protected final Set<Button> alreadyClickedButtons = new HashSet<>();
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected final transient Set<Button> alreadyClickedButtons = new HashSet<>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
@@ -130,7 +130,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
addComponent(hLayout);
|
||||
setComponentAlignment(hLayout, Alignment.BOTTOM_CENTER);
|
||||
}
|
||||
setStyleName("footer-layout");
|
||||
setStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
|
||||
setWidth("100%");
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
}
|
||||
|
||||
private Button createActionsButton() {
|
||||
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.PENDING_ACTION_BUTTON,
|
||||
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.PENDING_ACTION_BUTTON,
|
||||
getNoActionsButtonLabel(), "", "", false, FontAwesome.BELL, SPUIButtonStyleSmall.class);
|
||||
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||
button.addStyleName("del-action-button");
|
||||
@@ -165,10 +165,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
}
|
||||
|
||||
private Button createBulkUploadStatusButton() {
|
||||
final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "",
|
||||
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "",
|
||||
"", false, null, SPUIButtonStyleSmall.class);
|
||||
button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||
button.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
button.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
button.setWidth("100px");
|
||||
button.setHtmlContentAllowed(true);
|
||||
button.addClickListener(event -> onClickBulkUploadNotificationButton());
|
||||
@@ -199,7 +199,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
if (bulkUploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
if (bulkUploadStatusButton == null) {
|
||||
return;
|
||||
}
|
||||
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||
bulkUploadStatusButton.setIcon(null);
|
||||
}
|
||||
|
||||
@@ -216,10 +216,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
||||
return;
|
||||
}
|
||||
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
|
||||
SPUIComponetIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
|
||||
SPUIComponentIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
|
||||
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
|
||||
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
|
||||
unsavedActionsWindow.setId(SPUIComponetIdProvider.CONFIRMATION_POPUP_ID);
|
||||
unsavedActionsWindow.setId(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID);
|
||||
UI.getCurrent().addWindow(unsavedActionsWindow);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private TextField createSearchField() {
|
||||
final TextField textField = SPUIComponentProvider.getTextField("filter-box", "text-style filter-box-hide",
|
||||
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
textField.setId(getSearchBoxId());
|
||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
||||
@@ -123,14 +123,14 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
||||
private Button createAddButton() {
|
||||
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
button.addClickListener(event -> addNewItem(event));
|
||||
button.addClickListener(this::addNewItem);
|
||||
return button;
|
||||
}
|
||||
|
||||
private Button createCloseButton() {
|
||||
final Button button = SPUIComponentProvider.getButton(getCloseButtonId(), "", "", null, false,
|
||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
button.addClickListener(event -> onClose(event));
|
||||
button.addClickListener(this::onClose);
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.grid;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
@@ -70,9 +71,9 @@ public abstract class AbstractGridLayout extends VerticalLayout {
|
||||
private HorizontalLayout createCountMessageComponent() {
|
||||
final HorizontalLayout rolloutGroupTargetsCountLayout = new HorizontalLayout();
|
||||
final Label countMessageLabel = getCountMessageLabel();
|
||||
countMessageLabel.setId(SPUIComponetIdProvider.ROLLOUT_GROUP_TARGET_LABEL);
|
||||
countMessageLabel.setId(SPUIComponentIdProvider.ROLLOUT_GROUP_TARGET_LABEL);
|
||||
rolloutGroupTargetsCountLayout.addComponent(getCountMessageLabel());
|
||||
rolloutGroupTargetsCountLayout.setStyleName("footer-layout");
|
||||
rolloutGroupTargetsCountLayout.setStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
|
||||
rolloutGroupTargetsCountLayout.setWidth("100%");
|
||||
return rolloutGroupTargetsCountLayout;
|
||||
|
||||
|
||||
@@ -28,6 +28,16 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
|
||||
|
||||
private static final long serialVersionUID = 780050712209750719L;
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
setMultiSelect(true);
|
||||
setSelectable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
||||
|
||||
@@ -95,9 +95,6 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
||||
if (values == null) {
|
||||
values = Collections.emptySet();
|
||||
}
|
||||
if (values.contains(null)) {
|
||||
LOG.warn("Null values in table content. How could this happen?");
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -153,6 +150,16 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all rows in the table.
|
||||
*/
|
||||
protected void selectAll() {
|
||||
if (isMultiSelect()) {
|
||||
// only contains the ItemIds of the visible items in the table
|
||||
setValue(getItemIds());
|
||||
}
|
||||
}
|
||||
|
||||
private void setColumnProperties() {
|
||||
final List<TableColumn> columnList = getTableVisibleColumns();
|
||||
final List<Object> swColumnIds = new ArrayList<>();
|
||||
|
||||
@@ -36,10 +36,6 @@ import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
/**
|
||||
* Parent class for table header.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractTableHeader extends VerticalLayout {
|
||||
|
||||
@@ -213,7 +209,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private TextField createSearchField() {
|
||||
final TextField textField = SPUIComponentProvider.getTextField("filter-box", "text-style filter-box-hide",
|
||||
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
textField.setId(getSearchBoxId());
|
||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
||||
@@ -235,14 +231,14 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
||||
private Button createAddIcon() {
|
||||
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
button.addClickListener(event -> addNewItem(event));
|
||||
button.addClickListener(this::addNewItem);
|
||||
return button;
|
||||
}
|
||||
|
||||
private Button createBulkUploadIcon() {
|
||||
final Button button = SPUIComponentProvider.getButton(getBulkUploadIconId(), "", "", null, false,
|
||||
FontAwesome.UPLOAD, SPUIButtonStyleSmallNoBorder.class);
|
||||
button.addClickListener(event -> bulkUpload(event));
|
||||
button.addClickListener(this::bulkUpload);
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
package org.eclipse.hawkbit.ui.common.table;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.utils.ShortCutModifierUtils;
|
||||
|
||||
import com.vaadin.event.Action;
|
||||
import com.vaadin.event.Action.Handler;
|
||||
import com.vaadin.event.ShortcutAction;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Panel;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
@@ -18,23 +21,19 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Parent class for table layout.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractTableLayout extends VerticalLayout {
|
||||
|
||||
private static final long serialVersionUID = 8611248179949245460L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AbstractTableHeader tableHeader;
|
||||
|
||||
private AbstractTable table;
|
||||
private AbstractTable<?, ?> table;
|
||||
|
||||
private AbstractTableDetailsLayout detailsLayout;
|
||||
private AbstractTableDetailsLayout<?> detailsLayout;
|
||||
|
||||
protected void init(final AbstractTableHeader tableHeader, final AbstractTable table,
|
||||
final AbstractTableDetailsLayout detailsLayout) {
|
||||
protected void init(final AbstractTableHeader tableHeader, final AbstractTable<?, ?> table,
|
||||
final AbstractTableDetailsLayout<?> detailsLayout) {
|
||||
this.tableHeader = tableHeader;
|
||||
this.table = table;
|
||||
this.detailsLayout = detailsLayout;
|
||||
@@ -58,33 +57,33 @@ public abstract class AbstractTableLayout extends VerticalLayout {
|
||||
if (isShortCutKeysRequired()) {
|
||||
final Panel tablePanel = new Panel();
|
||||
tablePanel.setStyleName("table-panel");
|
||||
tablePanel.setHeight(100.0f, Unit.PERCENTAGE);
|
||||
tablePanel.setHeight(100.0F, Unit.PERCENTAGE);
|
||||
tablePanel.setContent(table);
|
||||
tablePanel.addActionHandler(getShortCutKeysHandler());
|
||||
tablePanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
|
||||
tableHeaderLayout.addComponent(tablePanel);
|
||||
tableHeaderLayout.setComponentAlignment(tablePanel, Alignment.TOP_CENTER);
|
||||
tableHeaderLayout.setExpandRatio(tablePanel, 1.0f);
|
||||
tableHeaderLayout.setExpandRatio(tablePanel, 1.0F);
|
||||
} else {
|
||||
tableHeaderLayout.addComponent(table);
|
||||
tableHeaderLayout.setComponentAlignment(table, Alignment.TOP_CENTER);
|
||||
tableHeaderLayout.setExpandRatio(table, 1.0f);
|
||||
tableHeaderLayout.setExpandRatio(table, 1.0F);
|
||||
}
|
||||
|
||||
addComponent(tableHeaderLayout);
|
||||
addComponent(detailsLayout);
|
||||
setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER);
|
||||
setComponentAlignment(detailsLayout, Alignment.TOP_CENTER);
|
||||
setExpandRatio(tableHeaderLayout, 1.0f);
|
||||
setExpandRatio(tableHeaderLayout, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* If any short cut keys required on the table.
|
||||
*
|
||||
* @return true if required else false. Default is 'false'.
|
||||
* @return true if required else false. Default is 'true'.
|
||||
*/
|
||||
protected boolean isShortCutKeysRequired() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,11 +93,38 @@ public abstract class AbstractTableLayout extends VerticalLayout {
|
||||
* Default is null.
|
||||
*/
|
||||
protected Handler getShortCutKeysHandler() {
|
||||
return null;
|
||||
return new TableShortCutHandler();
|
||||
}
|
||||
|
||||
protected void publishEvent() {
|
||||
// can be override by subclasses
|
||||
}
|
||||
|
||||
public void setShowFilterButtonVisible(final boolean visible) {
|
||||
tableHeader.setFilterButtonsIconVisible(visible);
|
||||
}
|
||||
|
||||
private class TableShortCutHandler implements Handler {
|
||||
|
||||
private static final String SELECT_ALL_TEXT = "Select All";
|
||||
private final ShortcutAction selectAllAction = new ShortcutAction(SELECT_ALL_TEXT, ShortcutAction.KeyCode.A,
|
||||
new int[] { ShortCutModifierUtils.getCtrlOrMetaModifier() });
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void handleAction(final Action action, final Object sender, final Object target) {
|
||||
if (!selectAllAction.equals(action)) {
|
||||
return;
|
||||
}
|
||||
table.selectAll();
|
||||
publishEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action[] getActions(final Object target, final Object sender) {
|
||||
return new Action[] { selectAllAction };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Abstract class for target/ds tag token layout.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractTagToken<T extends BaseEntity> implements Serializable {
|
||||
|
||||
@@ -58,9 +54,9 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
|
||||
|
||||
protected IndexedContainer container;
|
||||
|
||||
protected final Map<Long, TagData> tagDetails = new HashMap<>();
|
||||
protected final transient Map<Long, TagData> tagDetails = new HashMap<>();
|
||||
|
||||
protected final Map<Long, TagData> tokensAdded = new HashMap<>();
|
||||
protected final transient Map<Long, TagData> tokensAdded = new HashMap<>();
|
||||
|
||||
protected CssLayout tokenLayout = new CssLayout();
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.common.tagdetails;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -14,12 +14,12 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
|
||||
@@ -14,9 +14,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.eventbus.event.TargetTagAssigmentResultEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
package org.eclipse.hawkbit.ui.components;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
|
||||
/**
|
||||
* Proxy for {@link DistributionSet}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ProxyDistribution extends DistributionSet {
|
||||
public class ProxyDistribution {
|
||||
|
||||
private static final long serialVersionUID = -8891449133620645310L;
|
||||
|
||||
@@ -33,6 +34,11 @@ public class ProxyDistribution extends DistributionSet {
|
||||
|
||||
private String nameVersion;
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String version;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @return the nameVersion
|
||||
*/
|
||||
@@ -40,6 +46,10 @@ public class ProxyDistribution extends DistributionSet {
|
||||
return nameVersion;
|
||||
}
|
||||
|
||||
public DistributionSetIdName getDistributionSetIdName() {
|
||||
return DistributionSetIdName.generate(id, name, version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nameVersion
|
||||
* the nameVersion to set
|
||||
@@ -96,4 +106,36 @@ public class ProxyDistribution extends DistributionSet {
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,30 +8,33 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.components;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
|
||||
/**
|
||||
* Proxy for {@link Target}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author kaizimmerm
|
||||
*
|
||||
*/
|
||||
public class ProxyTarget extends Target {
|
||||
public class ProxyTarget implements Serializable {
|
||||
private static final long serialVersionUID = -8891449133620645310L;
|
||||
private String controllerId;
|
||||
private URI address = null;
|
||||
private Long lastTargetQuery = null;
|
||||
private Long installationDate;
|
||||
|
||||
private Long id;
|
||||
|
||||
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
|
||||
|
||||
private DistributionSet installedDistributionSet;
|
||||
@@ -56,11 +59,58 @@ public class ProxyTarget extends Target {
|
||||
|
||||
private Status status;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private TargetInfo targetInfo;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(final Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public TargetInfo getTargetInfo() {
|
||||
return targetInfo;
|
||||
}
|
||||
|
||||
public void setTargetInfo(final TargetInfo targetInfo) {
|
||||
this.targetInfo = targetInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerId
|
||||
*/
|
||||
public ProxyTarget() {
|
||||
super(null);
|
||||
final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE;
|
||||
targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString());
|
||||
}
|
||||
@@ -160,7 +210,6 @@ public class ProxyTarget extends Target {
|
||||
*
|
||||
* @return String as ID.
|
||||
*/
|
||||
@Override
|
||||
public String getControllerId() {
|
||||
return controllerId;
|
||||
}
|
||||
@@ -171,7 +220,6 @@ public class ProxyTarget extends Target {
|
||||
* @param controllerId
|
||||
* as ID
|
||||
*/
|
||||
@Override
|
||||
public void setControllerId(final String controllerId) {
|
||||
this.controllerId = controllerId;
|
||||
}
|
||||
@@ -262,18 +310,14 @@ public class ProxyTarget extends Target {
|
||||
* @param assignedDistributionSet
|
||||
* the assignedDistributionSet to set
|
||||
*/
|
||||
public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) {
|
||||
public void setAssignedDistributionSet(final DistributionSet assignedDistributionSet) {
|
||||
this.assignedDistributionSet = assignedDistributionSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetIdName
|
||||
*/
|
||||
@Override
|
||||
public TargetIdName getTargetIdName() {
|
||||
if (this.targetIdName == null) {
|
||||
return super.getTargetIdName();
|
||||
}
|
||||
return this.targetIdName;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.components;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ProxyTargetFilter extends TargetFilterQuery {
|
||||
public class ProxyTargetFilter {
|
||||
|
||||
private static final long serialVersionUID = 6622060929679084419L;
|
||||
|
||||
@@ -23,6 +21,12 @@ public class ProxyTargetFilter extends TargetFilterQuery {
|
||||
|
||||
private String modifiedDate;
|
||||
|
||||
private String name;
|
||||
private Long id;
|
||||
private String createdBy;
|
||||
private String lastModifiedBy;
|
||||
private String query;
|
||||
|
||||
public String getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
@@ -46,4 +50,44 @@ public class ProxyTargetFilter extends TargetFilterQuery {
|
||||
this.modifiedDate = modifiedDate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLastModifiedBy() {
|
||||
return lastModifiedBy;
|
||||
}
|
||||
|
||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||
this.lastModifiedBy = lastModifiedBy;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(final String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(final String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -155,6 +155,8 @@ public final class SPUIComponentProvider {
|
||||
/**
|
||||
* Get Label UI component.
|
||||
*
|
||||
* @param caption
|
||||
* set the caption of the textfield
|
||||
* @param style
|
||||
* set style
|
||||
* @param styleName
|
||||
@@ -163,7 +165,7 @@ public final class SPUIComponentProvider {
|
||||
* to set field as mandatory
|
||||
* @param data
|
||||
* component data
|
||||
* @param promt
|
||||
* @param prompt
|
||||
* prompt user for input
|
||||
* @param immediate
|
||||
* set component's immediate mode specified mode
|
||||
@@ -171,14 +173,18 @@ public final class SPUIComponentProvider {
|
||||
* maximum characters allowed
|
||||
* @return TextField text field
|
||||
*/
|
||||
public static TextField getTextField(final String style, final String styleName, final boolean required,
|
||||
final String data, final String promt, final boolean immediate, final int maxLengthAllowed) {
|
||||
return SPUITextFieldDecorator.decorate(style, styleName, required, data, promt, immediate, maxLengthAllowed);
|
||||
public static TextField getTextField(final String caption, final String style, final String styleName,
|
||||
final boolean required, final String data, final String prompt, final boolean immediate,
|
||||
final int maxLengthAllowed) {
|
||||
return SPUITextFieldDecorator.decorate(caption, style, styleName, required, data, prompt, immediate,
|
||||
maxLengthAllowed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label UI component. *
|
||||
*
|
||||
* @param caption
|
||||
* set the caption of the textArea
|
||||
* @param style
|
||||
* set style
|
||||
* @param styleName
|
||||
@@ -193,14 +199,16 @@ public final class SPUIComponentProvider {
|
||||
* maximum characters allowed
|
||||
* @return TextArea text area
|
||||
*/
|
||||
public static TextArea getTextArea(final String style, final String styleName, final boolean required,
|
||||
final String data, final String promt, final int maxLength) {
|
||||
return SPUITextAreaDecorator.decorate(style, styleName, required, data, promt, maxLength);
|
||||
public static TextArea getTextArea(final String caption, final String style, final String styleName,
|
||||
final boolean required, final String data, final String promt, final int maxLength) {
|
||||
return SPUITextAreaDecorator.decorate(caption, style, styleName, required, data, promt, maxLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label UI component.
|
||||
*
|
||||
* @param caption
|
||||
* caption of the combo box
|
||||
* @param height
|
||||
* combo box height
|
||||
* @param width
|
||||
@@ -217,9 +225,9 @@ public final class SPUIComponentProvider {
|
||||
* input prompt
|
||||
* @return ComboBox
|
||||
*/
|
||||
public static ComboBox getComboBox(final String height, final String width, final String style,
|
||||
final String styleName, final boolean required, final String data, final String promt) {
|
||||
return SPUIComboBoxDecorator.decorate(height, width, style, styleName, required, data, promt);
|
||||
public static ComboBox getComboBox(final String caption, final String height, final String width,
|
||||
final String style, final String styleName, final boolean required, final String data, final String promt) {
|
||||
return SPUIComboBoxDecorator.decorate(caption, height, width, style, styleName, required, data, promt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,39 +8,60 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.vaadin.client.renderers.ButtonRenderer;
|
||||
import com.vaadin.client.ui.VButton;
|
||||
import com.vaadin.client.widget.grid.RendererCellReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* Renders button with provided HTML content.
|
||||
* Used to display button with icons.
|
||||
*
|
||||
* Renders button with provided HTML content. Used to display button with icons.
|
||||
*/
|
||||
public class HtmlButtonRenderer extends ButtonRenderer {
|
||||
|
||||
public static final String DISABLE_VALUE = "_Disabled_";
|
||||
|
||||
@Override
|
||||
public void render(RendererCellReference cell, String text, Button button) {
|
||||
public void render(final RendererCellReference cell, final String text, final Button button) {
|
||||
final boolean buttonEnable = isButtonEnable(cell.getElement().getClassName());
|
||||
if (text != null) {
|
||||
button.setHTML(text);
|
||||
}
|
||||
applystyles(button);
|
||||
applystyles(button, buttonEnable);
|
||||
// this is to allow the button to disappear, if the text is null
|
||||
button.setVisible(text != null);
|
||||
button.getElement().setId("rollout.action.button.id");
|
||||
button.getElement().setId(SPUIComponentIdProvider.ROLLOUT_ACTION_ID + "." + cell.getColumnIndex());
|
||||
button.setEnabled(buttonEnable);
|
||||
}
|
||||
|
||||
private void applystyles(Button button) {
|
||||
/**
|
||||
* see here https://vaadin.com/forum#!/thread/9418390/9765924
|
||||
*
|
||||
* @param text
|
||||
* the button text
|
||||
* @return is button enable.
|
||||
*/
|
||||
private static boolean isButtonEnable(final String text) {
|
||||
return !text.contains(DISABLE_VALUE);
|
||||
}
|
||||
|
||||
private void applystyles(final Button button, final boolean buttonEnable) {
|
||||
|
||||
button.setStyleName(VButton.CLASSNAME);
|
||||
button.addStyleName(getStyle("tiny"));
|
||||
button.addStyleName(getStyle("borderless"));
|
||||
button.addStyleName(getStyle("icon-only"));
|
||||
button.addStyleName(getStyle("borderless-colored"));
|
||||
button.addStyleName(getStyle("button-no-border"));
|
||||
button.addStyleName(getStyle("action-type-padding"));
|
||||
|
||||
if (buttonEnable) {
|
||||
return;
|
||||
}
|
||||
button.addStyleName("v-disabled");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getStyle(final String style) {
|
||||
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class HtmlButtonRenderer extends ButtonRenderer {
|
||||
* @param listener
|
||||
* RendererClickListener
|
||||
*/
|
||||
public HtmlButtonRenderer(RendererClickListener listener) {
|
||||
public HtmlButtonRenderer(final RendererClickListener listener) {
|
||||
super(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.vaadin.server.Resource;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Decorator class for a borderless Button with an icon.
|
||||
*/
|
||||
public class SPUIButtonStyleNoBorderWithIcon implements SPUIButtonDecorator {
|
||||
|
||||
private Button button;
|
||||
|
||||
@Override
|
||||
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
|
||||
|
||||
this.button = button;
|
||||
button.setSizeFull();
|
||||
|
||||
button.addStyleName(ValoTheme.LABEL_SMALL);
|
||||
button.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
|
||||
setOrAddButtonStyle(style, setStyle);
|
||||
|
||||
setButtonIcon(icon);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private void setOrAddButtonStyle(final String style, final boolean setStyle) {
|
||||
|
||||
if (StringUtils.isEmpty(style)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (setStyle) {
|
||||
// overwrite all other styles
|
||||
button.setStyleName(style);
|
||||
} else {
|
||||
button.addStyleName(style);
|
||||
}
|
||||
}
|
||||
|
||||
private void setButtonIcon(final Resource icon) {
|
||||
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
button.setIcon(icon);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@@ -29,6 +31,8 @@ public final class SPUIComboBoxDecorator {
|
||||
/**
|
||||
* Decorate.
|
||||
*
|
||||
* @param caption
|
||||
* caption of the combobox
|
||||
* @param height
|
||||
* as H
|
||||
* @param width
|
||||
@@ -41,39 +45,42 @@ public final class SPUIComboBoxDecorator {
|
||||
* as T|F
|
||||
* @param data
|
||||
* as data
|
||||
* @param promt
|
||||
* @param prompt
|
||||
* as promt
|
||||
* @return ComboBox as comp
|
||||
*/
|
||||
public static ComboBox decorate(final String height, final String width, final String style, final String styleName,
|
||||
final boolean required, final String data, final String promt) {
|
||||
public static ComboBox decorate(final String caption, final String height, final String width, final String style,
|
||||
final String styleName, final boolean required, final String data, final String prompt) {
|
||||
final ComboBox spUICombo = new ComboBox();
|
||||
// Default settings
|
||||
spUICombo.setRequired(required);
|
||||
spUICombo.addStyleName(ValoTheme.COMBOBOX_TINY);
|
||||
|
||||
if (StringUtils.isNotEmpty(caption)) {
|
||||
spUICombo.setCaption(caption);
|
||||
}
|
||||
// Add style
|
||||
if (null != style) {
|
||||
if (StringUtils.isNotEmpty(style)) {
|
||||
spUICombo.setStyleName(style);
|
||||
}
|
||||
// Add style Name
|
||||
if (null != styleName) {
|
||||
if (StringUtils.isNotEmpty(styleName)) {
|
||||
spUICombo.addStyleName(styleName);
|
||||
}
|
||||
// Add height
|
||||
if (null != height) {
|
||||
if (StringUtils.isNotEmpty(height)) {
|
||||
spUICombo.setHeight(height);
|
||||
}
|
||||
// AddWidth
|
||||
if (null != width) {
|
||||
if (StringUtils.isNotEmpty(width)) {
|
||||
spUICombo.setWidth(width);
|
||||
}
|
||||
// Set promt
|
||||
if (null != promt) {
|
||||
spUICombo.setInputPrompt(promt);
|
||||
// Set prompt
|
||||
if (StringUtils.isNotEmpty(prompt)) {
|
||||
spUICombo.setInputPrompt(prompt);
|
||||
}
|
||||
// Set Data
|
||||
if (null != data) {
|
||||
if (StringUtils.isNotEmpty(data)) {
|
||||
spUICombo.setData(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions;
|
||||
|
||||
import com.vaadin.server.Resource;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
@@ -22,16 +20,10 @@ public class SPUITagButtonStyle implements SPUIButtonDecorator {
|
||||
@Override
|
||||
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
|
||||
|
||||
/**
|
||||
* Add ... for long name
|
||||
*/
|
||||
final String buttonCaption = button.getCaption();
|
||||
if (buttonCaption != null && buttonCaption.length() > SPUIButtonDefinitions.BUTTON_CAPTION_LENGTH) {
|
||||
button.setCaption(buttonCaption.substring(0, SPUIButtonDefinitions.BUTTON_CAPTION_LENGTH) + "...");
|
||||
}
|
||||
button.setImmediate(true);
|
||||
button.addStyleName("button-no-border" + " " + ValoTheme.BUTTON_BORDERLESS + " " + ValoTheme.BUTTON_TINY + " "
|
||||
button.addStyleName("generatedColumnPadding button-no-border" + " " + ValoTheme.BUTTON_BORDERLESS + " "
|
||||
+ "button-tag-no-border");
|
||||
|
||||
// Set Style
|
||||
if (null != style) {
|
||||
if (setStyle) {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@@ -37,33 +39,36 @@ public final class SPUITextAreaDecorator {
|
||||
* to set field as mandatory
|
||||
* @param data
|
||||
* component data
|
||||
* @param promt
|
||||
* @param prompt
|
||||
* as user for input
|
||||
* @param maxLength
|
||||
* maximum characters allowed
|
||||
* @return TextArea as comp
|
||||
*/
|
||||
public static TextArea decorate(String style, String styleName, boolean required, String data, String promt,
|
||||
int maxLength) {
|
||||
public static TextArea decorate(final String caption, final String style, final String styleName,
|
||||
final boolean required, final String data, final String prompt, final int maxLength) {
|
||||
final TextArea spUITxtArea = new TextArea();
|
||||
// Default settings
|
||||
spUITxtArea.setRequired(false);
|
||||
spUITxtArea.addStyleName(ValoTheme.COMBOBOX_SMALL);
|
||||
spUITxtArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
|
||||
if (StringUtils.isNotEmpty(caption)) {
|
||||
spUITxtArea.setCaption(caption);
|
||||
}
|
||||
if (required) {
|
||||
spUITxtArea.setRequired(true);
|
||||
}
|
||||
// Add style
|
||||
if (null != style) {
|
||||
if (StringUtils.isNotEmpty(style)) {
|
||||
spUITxtArea.setStyleName(style);
|
||||
}
|
||||
// Add style Name
|
||||
if (null != styleName) {
|
||||
if (StringUtils.isNotEmpty(styleName)) {
|
||||
spUITxtArea.addStyleName(styleName);
|
||||
}
|
||||
if (null != promt) {
|
||||
spUITxtArea.setInputPrompt(promt);
|
||||
if (StringUtils.isNotEmpty(prompt)) {
|
||||
spUITxtArea.setInputPrompt(prompt);
|
||||
}
|
||||
if (null != data) {
|
||||
if (StringUtils.isNotEmpty(data)) {
|
||||
spUITxtArea.setData(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@@ -27,8 +29,9 @@ public final class SPUITextFieldDecorator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate.
|
||||
*
|
||||
* @param caption
|
||||
* set the caption of the textfield
|
||||
* @param style
|
||||
* set style
|
||||
* @param styleName
|
||||
@@ -37,7 +40,7 @@ public final class SPUITextFieldDecorator {
|
||||
* to set field as mandatory
|
||||
* @param data
|
||||
* component data
|
||||
* @param promt
|
||||
* @param prompt
|
||||
* prompt user for input
|
||||
* @param immediate
|
||||
* as for display
|
||||
@@ -45,9 +48,13 @@ public final class SPUITextFieldDecorator {
|
||||
* maximum characters allowed
|
||||
* @return Text field as decorated
|
||||
*/
|
||||
public static TextField decorate(String style, String styleName, boolean required, String data, String promt,
|
||||
boolean immediate, int maxLengthAllowed) {
|
||||
public static TextField decorate(final String caption, final String style, final String styleName,
|
||||
final boolean required, final String data, final String prompt, final boolean immediate,
|
||||
final int maxLengthAllowed) {
|
||||
final TextField spUITxtFld = new TextField();
|
||||
if (StringUtils.isNotEmpty(caption)) {
|
||||
spUITxtFld.setCaption(caption);
|
||||
}
|
||||
// Default settings
|
||||
spUITxtFld.setRequired(false);
|
||||
spUITxtFld.addStyleName(ValoTheme.TEXTFIELD_SMALL);
|
||||
@@ -58,17 +65,17 @@ public final class SPUITextFieldDecorator {
|
||||
spUITxtFld.setImmediate(true);
|
||||
}
|
||||
// Add style
|
||||
if (null != style) {
|
||||
if (StringUtils.isNotEmpty(style)) {
|
||||
spUITxtFld.setStyleName(style);
|
||||
}
|
||||
// Add style Name
|
||||
if (null != styleName) {
|
||||
if (StringUtils.isNotEmpty(styleName)) {
|
||||
spUITxtFld.addStyleName(styleName);
|
||||
}
|
||||
if (null != promt) {
|
||||
spUITxtFld.setInputPrompt(promt);
|
||||
if (StringUtils.isNotEmpty(prompt)) {
|
||||
spUITxtFld.setInputPrompt(prompt);
|
||||
}
|
||||
if (null != data) {
|
||||
if (StringUtils.isNotEmpty(data)) {
|
||||
spUITxtFld.setData(data);
|
||||
}
|
||||
if (maxLengthAllowed > 0) {
|
||||
|
||||
@@ -8,9 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.decorators;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
|
||||
import com.vaadin.ui.AbstractLayout;
|
||||
import com.vaadin.ui.Button.ClickListener;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
/**
|
||||
@@ -28,6 +33,39 @@ public final class SPUIWindowDecorator {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates window based on type.
|
||||
*
|
||||
* @param caption
|
||||
* window caption
|
||||
* @param id
|
||||
* window id
|
||||
* @param type
|
||||
* window type
|
||||
* @return Window
|
||||
*/
|
||||
public static CommonDialogWindow getWindow(final String caption, final String id, final String type,
|
||||
final Component content, final ClickListener saveButtonClickListener,
|
||||
final ClickListener cancelButtonClickListener, final String helpLink, final AbstractLayout layout,
|
||||
final I18N i18n) {
|
||||
|
||||
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, saveButtonClickListener,
|
||||
cancelButtonClickListener, layout, i18n);
|
||||
if (null != id) {
|
||||
window.setId(id);
|
||||
}
|
||||
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
|
||||
window.setDraggable(false);
|
||||
window.setClosable(true);
|
||||
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
|
||||
|
||||
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
|
||||
window.setDraggable(true);
|
||||
window.setClosable(true);
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates window based on type.
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteri
|
||||
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.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
@@ -31,9 +31,6 @@ import com.vaadin.spring.annotation.ViewScope;
|
||||
|
||||
/**
|
||||
* Distribution Set Type filter buttons.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
@@ -50,7 +47,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
|
||||
@Override
|
||||
protected String getButtonsTableId() {
|
||||
|
||||
return SPUIComponetIdProvider.DISTRIBUTION_SET_TYPE_TABLE_ID;
|
||||
return SPUIComponentIdProvider.DISTRIBUTION_SET_TYPE_TABLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +65,7 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
|
||||
@Override
|
||||
protected String createButtonId(final String name) {
|
||||
|
||||
return SPUIComponetIdProvider.DS_TYPE_FILTER_BTN_ID + name;
|
||||
return SPUIComponentIdProvider.DS_TYPE_FILTER_BTN_ID + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
@@ -21,7 +22,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
/**
|
||||
* Distribution Set Type filter buttons header.
|
||||
@@ -38,6 +38,8 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
|
||||
@Autowired
|
||||
private CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout;
|
||||
|
||||
private CommonDialogWindow addUpdateWindow;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@@ -59,10 +61,8 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
|
||||
|
||||
@Override
|
||||
protected void settingsIconClicked(final ClickEvent event) {
|
||||
final Window addUpdateWindow = createUpdateDistSetTypeLayout.getWindow();
|
||||
addUpdateWindow = createUpdateDistSetTypeLayout.getWindow();
|
||||
UI.getCurrent().addWindow(addUpdateWindow);
|
||||
addUpdateWindow.setVisible(Boolean.TRUE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,11 +16,11 @@ import java.util.Set;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
@@ -32,7 +32,7 @@ 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.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -84,7 +84,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
private VerticalLayout tagsLayout;
|
||||
|
||||
Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
@@ -246,7 +246,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
if (type != null) {
|
||||
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
|
||||
type);
|
||||
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
detailsTabLayout.addComponent(typeLabel);
|
||||
}
|
||||
|
||||
@@ -259,8 +259,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@Override
|
||||
protected void onEdit(final ClickEvent event) {
|
||||
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
|
||||
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
|
||||
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(getSelectedBaseEntityId());
|
||||
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
|
||||
UI.getCurrent().addWindow(newDistWindow);
|
||||
newDistWindow.setVisible(Boolean.TRUE);
|
||||
@@ -268,7 +267,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@Override
|
||||
protected String getEditButtonId() {
|
||||
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
|
||||
return SPUIComponentIdProvider.DS_EDIT_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -358,7 +357,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
@Override
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
|
||||
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,12 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
@@ -39,7 +38,7 @@ 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.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -66,7 +65,6 @@ import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Distribution set table.
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
@@ -120,7 +118,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponetIdProvider.DIST_TABLE_ID;
|
||||
return SPUIComponentIdProvider.DIST_TABLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,11 +320,11 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
if (!validateSoftwareModule(sm, ds)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
distributionSetManagement.checkDistributionSetAlreadyUse(ds);
|
||||
} catch (final EntityLockedException exception) {
|
||||
LOG.error("Unable to update distribution : ", exception);
|
||||
notification.displayValidationError(exception.getMessage());
|
||||
|
||||
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
||||
notification.displayValidationError(
|
||||
String.format("Distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
ds.getName(), ds.getVersion()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -392,7 +390,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
||||
final Table source = (Table) compsource;
|
||||
if (compsource instanceof Table) {
|
||||
if (!source.getId().equals(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
|
||||
if (!source.getId().equals(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
|
||||
notification.displayValidationError(i18n.get("message.action.not.allowed"));
|
||||
return false;
|
||||
}
|
||||
@@ -454,7 +452,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
if (manageDistUIState.getSelectedDistributions().isPresent()) {
|
||||
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
|
||||
}
|
||||
select(baseEntity.getDistributionSetIdName());
|
||||
select(DistributionSetIdName.generate(baseEntity));
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -469,7 +467,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
@Override
|
||||
protected void setDataAvailable(final boolean available) {
|
||||
manageDistUIState.setNoDataAvailableDist(!available);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -57,17 +57,17 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getSearchBoxId() {
|
||||
return SPUIComponetIdProvider.DIST_SEARCH_TEXTFIELD;
|
||||
return SPUIComponentIdProvider.DIST_SEARCH_TEXTFIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSearchRestIconId() {
|
||||
return SPUIComponetIdProvider.DIST_SEARCH_ICON;
|
||||
return SPUIComponentIdProvider.DIST_SEARCH_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAddIconId() {
|
||||
return SPUIComponetIdProvider.DIST_ADD_ICON;
|
||||
return SPUIComponentIdProvider.DIST_ADD_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getMaxMinIconId() {
|
||||
return SPUIComponetIdProvider.DS_MAX_MIN_TABLE_ICON;
|
||||
return SPUIComponentIdProvider.DS_MAX_MIN_TABLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,7 +152,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected void addNewItem(final ClickEvent event) {
|
||||
final Window newDistWindow = addUpdateWindowLayout.getWindow();
|
||||
final Window newDistWindow = addUpdateWindowLayout.getWindow(null);
|
||||
newDistWindow.setCaption(i18n.get("caption.add.new.dist"));
|
||||
UI.getCurrent().addWindow(newDistWindow);
|
||||
newDistWindow.setVisible(Boolean.TRUE);
|
||||
|
||||
@@ -17,16 +17,14 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
|
||||
/**
|
||||
* Software module table layout.
|
||||
*
|
||||
*
|
||||
*
|
||||
* DistributionSet table layout
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class DistributionSetTableLayout extends AbstractTableLayout {
|
||||
|
||||
private static final long serialVersionUID = 6464291374980641235L;
|
||||
|
||||
/**
|
||||
* Details to be autowired before table as details listens to value change
|
||||
* of table.
|
||||
|
||||
@@ -14,11 +14,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
||||
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
|
||||
@@ -95,8 +95,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
distBeans = firstPageDistributionSets;
|
||||
} else if (Strings.isNullOrEmpty(searchText)) {
|
||||
// if no search filters available
|
||||
distBeans = getDistributionSetManagement()
|
||||
.findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, null);
|
||||
distBeans = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
|
||||
new OffsetBasedPageRequest(startIndex, count, sort), false, null);
|
||||
} else {
|
||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build();
|
||||
@@ -113,7 +113,6 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
proxyDistribution.setVersion(distributionSet.getVersion());
|
||||
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
|
||||
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
|
||||
proxyDistribution.setDescription(distributionSet.getDescription());
|
||||
proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
|
||||
proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
|
||||
proxyDistribution.setIsComplete(distributionSet.isComplete());
|
||||
@@ -132,8 +131,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
public int size() {
|
||||
if (Strings.isNullOrEmpty(searchText) && null == distributionSetType) {
|
||||
// if no search filters available
|
||||
firstPageDistributionSets = getDistributionSetManagement()
|
||||
.findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null);
|
||||
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
|
||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null);
|
||||
} else {
|
||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build();
|
||||
|
||||
@@ -11,16 +11,12 @@ package org.eclipse.hawkbit.ui.distributions.event;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* DistributionSetTypeEvent
|
||||
*/
|
||||
public class DistributionSetTypeEvent {
|
||||
|
||||
/**
|
||||
* DistributionSet type events in the Distribution UI.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum DistributionSetTypeEnum {
|
||||
ADD_DIST_SET_TYPE, DELETE_DIST_SET_TYPE, UPDATE_DIST_SET_TYPE, ON_VALUE_CHANGE
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
@@ -69,14 +69,14 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
final Map<String, List<String>> config = new HashMap<>();
|
||||
|
||||
// Delete drop area droppable components
|
||||
config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID,
|
||||
Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, SPUIComponetIdProvider.DIST_TABLE_ID,
|
||||
SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
|
||||
config.put(SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID,
|
||||
Arrays.asList(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, SPUIComponentIdProvider.DIST_TABLE_ID,
|
||||
SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE,
|
||||
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS));
|
||||
|
||||
// Distribution table drop components
|
||||
config.put(SPUIComponetIdProvider.DIST_TABLE_ID,
|
||||
Arrays.asList(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));
|
||||
config.put(SPUIComponentIdProvider.DIST_TABLE_ID,
|
||||
Arrays.asList(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE));
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -84,8 +84,8 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
|
||||
private static Map<String, Object> createDropHintConfigurations() {
|
||||
final Map<String, Object> config = new HashMap<>();
|
||||
config.put(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, DragEvent.DISTRIBUTION_TYPE_DRAG);
|
||||
config.put(SPUIComponetIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
|
||||
config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
|
||||
config.put(SPUIComponentIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG);
|
||||
config.put(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG);
|
||||
config.put(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS, DragEvent.SOFTWAREMODULE_TYPE_DRAG);
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
|
||||
/**
|
||||
* Event fired on discard of software module assignment.
|
||||
|
||||
@@ -16,9 +16,9 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
||||
@@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -115,7 +115,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
@Override
|
||||
protected String getDeleteAreaId() {
|
||||
|
||||
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
|
||||
return SPUIComponentIdProvider.DELETE_BUTTON_WRAPPER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,11 +262,11 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
}
|
||||
|
||||
private boolean isDistributionTable(final Component source) {
|
||||
return SPUIComponetIdProvider.DIST_TABLE_ID.equals(source.getId());
|
||||
return SPUIComponentIdProvider.DIST_TABLE_ID.equals(source.getId());
|
||||
}
|
||||
|
||||
private boolean isSoftwareModuleTable(final Component source) {
|
||||
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
|
||||
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,9 +19,9 @@ import java.util.stream.Collectors;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
|
||||
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
@@ -29,7 +29,7 @@ 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.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -124,7 +124,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
private ConfirmationTab createSMDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.SW_DELETE_ALL);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
|
||||
@@ -232,13 +232,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
|
||||
|
||||
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
|
||||
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_SW_MODULE_TYPE);
|
||||
tab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_SW_MODULE_TYPE);
|
||||
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
|
||||
|
||||
// Add items container to the table.
|
||||
@@ -324,7 +324,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
private ConfirmationTab createDistDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.DIST_DELETE_ALL);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteDistAll(tab));
|
||||
@@ -423,13 +423,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
private ConfirmationTab createDistSetTypeDeleteConfirmationTab() {
|
||||
final ConfirmationTab tab = new ConfirmationTab();
|
||||
|
||||
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_DIST_SET_TYPE);
|
||||
tab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_DELETE_DIST_SET_TYPE);
|
||||
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
|
||||
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
|
||||
tab.getConfirmAll().addClickListener(event -> deleteDistSetTypeAll(tab));
|
||||
|
||||
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
|
||||
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_DIST_SET_TYPE);
|
||||
tab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_DIST_SET_TYPE);
|
||||
tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab));
|
||||
|
||||
// Add items container to the table.
|
||||
@@ -511,13 +511,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
|
||||
assignmnetTab = new ConfirmationTab();
|
||||
|
||||
assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
|
||||
assignmnetTab.getConfirmAll().setId(SPUIComponentIdProvider.SAVE_ASSIGNMENT);
|
||||
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
|
||||
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
|
||||
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
|
||||
|
||||
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
|
||||
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
|
||||
assignmnetTab.getDiscardAll().setId(SPUIComponentIdProvider.DISCARD_ASSIGNMENT);
|
||||
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab));
|
||||
|
||||
// Add items container to the table.
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
||||
@@ -75,20 +75,20 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
||||
|
||||
@Override
|
||||
protected List<ProxyBaseSwModuleItem> loadBeans(final int startIndex, final int count) {
|
||||
final Slice<CustomSoftwareModule> swModuleBeans;
|
||||
final Slice<AssignedSoftwareModule> swModuleBeans;
|
||||
final List<ProxyBaseSwModuleItem> proxyBeans = new ArrayList<>();
|
||||
|
||||
swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type);
|
||||
|
||||
for (final CustomSoftwareModule swModule : swModuleBeans) {
|
||||
for (final AssignedSoftwareModule swModule : swModuleBeans) {
|
||||
proxyBeans.add(getProxyBean(swModule));
|
||||
}
|
||||
|
||||
return proxyBeans;
|
||||
}
|
||||
|
||||
private ProxyBaseSwModuleItem getProxyBean(final CustomSoftwareModule customSoftwareModule) {
|
||||
private ProxyBaseSwModuleItem getProxyBean(final AssignedSoftwareModule customSoftwareModule) {
|
||||
final SoftwareModule bean = customSoftwareModule.getSoftwareModule();
|
||||
final ProxyBaseSwModuleItem proxyItem = new ProxyBaseSwModuleItem();
|
||||
proxyItem.setSwId(bean.getId());
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityT
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -61,7 +61,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
|
||||
@Override
|
||||
protected String getEditButtonId() {
|
||||
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
|
||||
return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,19 +119,19 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
|
||||
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
|
||||
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
|
||||
vendorLabel.setId(SPUIComponentIdProvider.DETAILS_VENDOR_LABEL_ID);
|
||||
detailsTabLayout.addComponent(vendorLabel);
|
||||
|
||||
if (type != null) {
|
||||
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
|
||||
type);
|
||||
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
detailsTabLayout.addComponent(typeLabel);
|
||||
}
|
||||
|
||||
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
|
||||
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
|
||||
assignLabel.setId(SPUIComponentIdProvider.SWM_DTLS_MAX_ASSIGN);
|
||||
detailsTabLayout.addComponent(assignLabel);
|
||||
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
|
||||
|
||||
@Override
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponetIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteri
|
||||
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.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -126,7 +126,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -309,7 +309,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
||||
|
||||
private Button createShowArtifactDtlsButton(final String nameVersionStr) {
|
||||
final Button showArtifactDtlsBtn = SPUIComponentProvider.getButton(
|
||||
SPUIComponetIdProvider.SW_TABLE_ATRTIFACT_DETAILS_ICON + "." + nameVersionStr, "", "", null, false,
|
||||
SPUIComponentIdProvider.SW_TABLE_ATRTIFACT_DETAILS_ICON + "." + nameVersionStr, "", "", null, false,
|
||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||
showArtifactDtlsBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON);
|
||||
showArtifactDtlsBtn.setDescription(i18n.get("tooltip.artifact.icon"));
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -57,17 +57,17 @@ public class SwModuleTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getSearchBoxId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
|
||||
return SPUIComponentIdProvider.SW_MODULE_SEARCH_TEXT_FIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSearchRestIconId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON;
|
||||
return SPUIComponentIdProvider.SW_MODULE_SEARCH_RESET_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAddIconId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON;
|
||||
return SPUIComponentIdProvider.SW_MODULE_ADD_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +116,7 @@ public class SwModuleTableHeader extends AbstractTableHeader {
|
||||
|
||||
@Override
|
||||
protected String getMaxMinIconId() {
|
||||
return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON;
|
||||
return SPUIComponentIdProvider.SW_MAX_MIN_TABLE_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,10 +17,7 @@ import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
|
||||
/**
|
||||
* Implementation of software module Layout .
|
||||
*
|
||||
*
|
||||
*
|
||||
* Implementation of software module Layout
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -51,7 +51,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected String getButtonsTableId() {
|
||||
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,7 +76,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
||||
|
||||
@Override
|
||||
protected String createButtonId(final String name) {
|
||||
return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name;
|
||||
return SPUIComponentIdProvider.SM_TYPE_FILTER_BTN_ID + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout;
|
||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -51,7 +51,7 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
|
||||
|
||||
@Override
|
||||
protected String getHideButtonId() {
|
||||
return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID;
|
||||
return SPUIComponentIdProvider.SM_SHOW_FILTER_BUTTON_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,10 +66,9 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
|
||||
|
||||
@Override
|
||||
protected void settingsIconClicked(final ClickEvent event) {
|
||||
final Window addUpdateWindow = createUpdateSWTypeLayout.getWindow();
|
||||
UI.getCurrent().addWindow(addUpdateWindow);
|
||||
addUpdateWindow.setVisible(Boolean.TRUE);
|
||||
|
||||
final Window window = createUpdateSWTypeLayout.getWindow();
|
||||
UI.getCurrent().addWindow(window);
|
||||
window.setVisible(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,8 +16,8 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filter.target;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.filter.FilterExpression;
|
||||
|
||||
@@ -56,9 +58,10 @@ public class TargetSearchTextFilter implements FilterExpression {
|
||||
}
|
||||
|
||||
private boolean ipAddressIgnoreCase() {
|
||||
if (target.getTargetInfo().getAddress() == null) {
|
||||
final URI targetAddress = target.getTargetInfo().getAddress();
|
||||
if (targetAddress == null || targetAddress.getHost() == null) {
|
||||
return false;
|
||||
}
|
||||
return target.getTargetInfo().getAddress().getHost().toUpperCase().contains(searchTextUpper);
|
||||
return targetAddress.getHost().toUpperCase().contains(searchTextUpper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.concurrent.Executor;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
@@ -23,7 +24,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
@@ -68,7 +69,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
private static final long serialVersionUID = 7474232427119031474L;
|
||||
|
||||
private static final String breadcrumbCustomFilters = "breadcrumb.target.filter.custom.filters";
|
||||
private static final String BREADCRUMB_CUSTOM_FILTERS = "breadcrumb.target.filter.custom.filters";
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
@@ -95,6 +96,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
@Qualifier("uiExecutor")
|
||||
private transient Executor executor;
|
||||
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private HorizontalLayout breadcrumbLayout;
|
||||
|
||||
private Button breadcrumbButton;
|
||||
@@ -201,7 +205,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
statusIcon.setContentMode(ContentMode.HTML);
|
||||
statusIcon.setSizeFull();
|
||||
setInitialStatusIconStyle(statusIcon);
|
||||
statusIcon.setId(SPUIComponetIdProvider.VALIDATION_STATUS_ICON_ID);
|
||||
statusIcon.setId(SPUIComponentIdProvider.VALIDATION_STATUS_ICON_ID);
|
||||
return statusIcon;
|
||||
}
|
||||
|
||||
@@ -218,7 +222,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
|
||||
nameLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
||||
nameLabel.setId(SPUIComponetIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
|
||||
nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
|
||||
|
||||
nameTextField = createNameTextField();
|
||||
nameTextField.setWidth(380, Unit.PIXELS);
|
||||
@@ -238,19 +242,20 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
final Button createFilterViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
createFilterViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
|
||||
createFilterViewLink.setDescription(i18n.get(breadcrumbCustomFilters));
|
||||
createFilterViewLink.setCaption(i18n.get(breadcrumbCustomFilters));
|
||||
createFilterViewLink.setDescription(i18n.get(BREADCRUMB_CUSTOM_FILTERS));
|
||||
createFilterViewLink.setCaption(i18n.get(BREADCRUMB_CUSTOM_FILTERS));
|
||||
createFilterViewLink.addClickListener(value -> showCustomFiltersView());
|
||||
|
||||
return createFilterViewLink;
|
||||
}
|
||||
|
||||
private TextField createNameTextField() {
|
||||
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
nameField.setId(SPUIComponetIdProvider.CUSTOM_FILTER_ADD_NAME);
|
||||
final TextField nameField = SPUIComponentProvider.getTextField(i18n.get("textfield.customfiltername"), "",
|
||||
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.customfiltername"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
|
||||
nameField.setPropertyDataSource(nameLabel);
|
||||
nameField.addTextChangeListener(event -> onFilterNameChange(event));
|
||||
nameField.addTextChangeListener(this::onFilterNameChange);
|
||||
return nameField;
|
||||
}
|
||||
|
||||
@@ -294,7 +299,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
private void buildLayout() {
|
||||
captionLayout = new HorizontalLayout();
|
||||
captionLayout.setDescription(i18n.get("tooltip.click.to.edit"));
|
||||
captionLayout.setId(SPUIComponetIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID);
|
||||
captionLayout.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID);
|
||||
|
||||
titleFilterIconsLayout = new HorizontalLayout();
|
||||
titleFilterIconsLayout.addComponents(headerCaption, captionLayout);
|
||||
@@ -447,8 +452,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
private TextField createSearchField() {
|
||||
final TextField textField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, "", "",
|
||||
true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
||||
final TextField textField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, "",
|
||||
"", true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
||||
textField.setId("custom.query.text.Id");
|
||||
textField.addStyleName("target-filter-textfield");
|
||||
textField.setWidth(900.0F, Unit.PIXELS);
|
||||
@@ -468,8 +473,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
private Button createSaveButton() {
|
||||
saveButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON,
|
||||
SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON, "Save", null, false, FontAwesome.SAVE,
|
||||
saveButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON,
|
||||
SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON, "Save", null, false, FontAwesome.SAVE,
|
||||
SPUIButtonStyleSmallNoBorder.class);
|
||||
saveButton.addClickListener(this);
|
||||
saveButton.setEnabled(false);
|
||||
@@ -484,17 +489,13 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
*/
|
||||
@Override
|
||||
public void buttonClick(final ClickEvent event) {
|
||||
if (SPUIComponetIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
|
||||
if (SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
|
||||
&& manadatoryFieldsPresent()) {
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||
if (!doesAlreadyExists()) {
|
||||
createTargetFilterQuery();
|
||||
}
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed() && !doesAlreadyExists()) {
|
||||
createTargetFilterQuery();
|
||||
} else {
|
||||
if (!nameTextField.getValue().equals(oldFilterName)) {
|
||||
if (!doesAlreadyExists()) {
|
||||
updateCustomFilter();
|
||||
}
|
||||
if (!nameTextField.getValue().equals(oldFilterName) && !doesAlreadyExists()) {
|
||||
updateCustomFilter();
|
||||
} else {
|
||||
updateCustomFilter();
|
||||
}
|
||||
@@ -503,7 +504,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
private void createTargetFilterQuery() {
|
||||
final TargetFilterQuery targetFilterQuery = new TargetFilterQuery();
|
||||
final TargetFilterQuery targetFilterQuery = entityFactory.generateTargetFilterQuery();
|
||||
targetFilterQuery.setName(nameTextField.getValue());
|
||||
targetFilterQuery.setQuery(queryTextField.getValue());
|
||||
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||
@@ -90,7 +90,7 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
addCustomGeneratedColumns();
|
||||
restoreOnLoad();
|
||||
populateTableData();
|
||||
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||
setId(SPUIComponentIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||
setSelectable(false);
|
||||
eventBus.subscribe(this);
|
||||
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.footer.TargetFilterCountMessageLabel;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
@@ -152,7 +153,7 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
private HorizontalLayout addTargetFilterMessageLabel() {
|
||||
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
|
||||
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
|
||||
messageLabelLayout.addStyleName("footer-layout");
|
||||
messageLabelLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
|
||||
return messageLabelLayout;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -13,11 +13,10 @@ import javax.annotation.PostConstruct;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -79,9 +78,8 @@ public class TargetFilterHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private Label createHeaderCaption() {
|
||||
final Label captionLabel = SPUIComponentProvider.getLabel("Custom Filters",
|
||||
return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION,
|
||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
return captionLabel;
|
||||
}
|
||||
|
||||
private void buildLayout() {
|
||||
@@ -110,10 +108,9 @@ public class TargetFilterHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private Button createAddButton() {
|
||||
final Button button = SPUIComponentProvider.getButton("camp.search.add.Id", "Create Filter", "Create Filter",
|
||||
"", false, null, SPUIButtonStyleSmall.class);
|
||||
final Button button = SPUIComponentProvider.getButton(SPUIComponentIdProvider.TARGET_FILTER_ADD_ICON_ID, "", "",
|
||||
null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class);
|
||||
button.addClickListener(event -> addNewFilter());
|
||||
button.addStyleName("on-focus-no-border link");
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -124,7 +121,7 @@ public class TargetFilterHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private TextField createSearchField() {
|
||||
final TextField campSearchTextField = SPUIComponentProvider.getTextField("filter-box",
|
||||
final TextField campSearchTextField = SPUIComponentProvider.getTextField(null, "filter-box",
|
||||
"text-style filter-box-hide", false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
campSearchTextField.setId("target.filter.search.text.Id");
|
||||
campSearchTextField.setWidth(500.0f, Unit.PIXELS);
|
||||
@@ -179,7 +176,7 @@ public class TargetFilterHeader extends VerticalLayout {
|
||||
}
|
||||
|
||||
private String getSearchRestIconId() {
|
||||
return SPUIComponetIdProvider.TARGET_FILTER_TBL_SEARCH_RESET_ID;
|
||||
return SPUIComponentIdProvider.TARGET_FILTER_TBL_SEARCH_RESET_ID;
|
||||
}
|
||||
|
||||
protected void resetSearchText() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||
@@ -87,14 +87,14 @@ public class TargetFilterTable extends Table {
|
||||
setStyleName("sp-table");
|
||||
setSizeFull();
|
||||
setImmediate(true);
|
||||
setHeight(100.0f, Unit.PERCENTAGE);
|
||||
setHeight(100.0F, Unit.PERCENTAGE);
|
||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_SMALL);
|
||||
addCustomGeneratedColumns();
|
||||
populateTableData();
|
||||
setColumnCollapsingAllowed(true);
|
||||
setColumnProperties();
|
||||
setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID);
|
||||
setId(SPUIComponentIdProvider.TAEGET_FILTER_TABLE_ID);
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@@ -167,12 +167,12 @@ public class TargetFilterTable extends Table {
|
||||
SPUILabelDefinitions.DELETE_CUSTOM_FILTER, ValoTheme.BUTTON_TINY + " " + "redicon", true,
|
||||
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
|
||||
deleteIcon.setData(itemId);
|
||||
deleteIcon.addClickListener(event -> onDelete(event));
|
||||
deleteIcon.addClickListener(this::onDelete);
|
||||
return deleteIcon;
|
||||
}
|
||||
|
||||
private String getDeleteIconId(final String targetFilterName) {
|
||||
return new StringBuilder(SPUIComponetIdProvider.CUSTOM_FILTER_DELETE_ICON).append('.').append(targetFilterName)
|
||||
return new StringBuilder(SPUIComponentIdProvider.CUSTOM_FILTER_DELETE_ICON).append('.').append(targetFilterName)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class TargetFilterTable extends Table {
|
||||
SPUILabelDefinitions.UPDATE_CUSTOM_FILTER, null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
updateIcon.setData(tfName);
|
||||
updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
|
||||
updateIcon.addClickListener(event -> onClickOfDetailButton(event));
|
||||
updateIcon.addClickListener(this::onClickOfDetailButton);
|
||||
return updateIcon;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class TargetFilterTable extends Table {
|
||||
}
|
||||
|
||||
private static String getDetailLinkId(final String filterName) {
|
||||
return new StringBuilder(SPUIComponetIdProvider.CUSTOM_FILTER_DETAIL_LINK).append('.').append(filterName)
|
||||
return new StringBuilder(SPUIComponentIdProvider.CUSTOM_FILTER_DETAIL_LINK).append('.').append(filterName)
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -79,7 +79,7 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
private void applyStyle() {
|
||||
addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
|
||||
setContentMode(ContentMode.HTML);
|
||||
setId(SPUIComponetIdProvider.COUNT_LABEL);
|
||||
setId(SPUIComponentIdProvider.COUNT_LABEL);
|
||||
}
|
||||
|
||||
private void displayTargetFilterMessage() {
|
||||
|
||||
@@ -0,0 +1,611 @@
|
||||
/**
|
||||
* 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.layouts;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
|
||||
import com.vaadin.data.Property.ValueChangeEvent;
|
||||
import com.vaadin.data.Property.ValueChangeListener;
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.FormLayout;
|
||||
import com.vaadin.ui.GridLayout;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.OptionGroup;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Abstract class for create/update target tag layout.
|
||||
*/
|
||||
public abstract class AbstractCreateUpdateTagLayout extends CustomComponent
|
||||
implements ColorChangeListener, ColorSelector {
|
||||
private static final long serialVersionUID = 4229177824620576456L;
|
||||
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||
protected static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
||||
protected static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname";
|
||||
|
||||
@Autowired
|
||||
protected I18N i18n;
|
||||
|
||||
@Autowired
|
||||
protected transient TagManagement tagManagement;
|
||||
|
||||
@Autowired
|
||||
protected transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@Autowired
|
||||
protected SpPermissionChecker permChecker;
|
||||
|
||||
@Autowired
|
||||
protected transient UINotification uiNotification;
|
||||
|
||||
private final FormLayout formLayout = new FormLayout();
|
||||
|
||||
protected String createTagStr;
|
||||
protected String updateTagStr;
|
||||
protected Label comboLabel;
|
||||
protected CommonDialogWindow window;
|
||||
|
||||
protected Label colorLabel;
|
||||
protected TextField tagName;
|
||||
protected TextArea tagDesc;
|
||||
protected Button tagColorPreviewBtn;
|
||||
protected OptionGroup optiongroup;
|
||||
protected ComboBox tagNameComboBox;
|
||||
|
||||
protected VerticalLayout comboLayout;
|
||||
protected ColorPickerLayout colorPickerLayout;
|
||||
protected GridLayout mainLayout;
|
||||
protected VerticalLayout contentLayout;
|
||||
|
||||
protected boolean tagPreviewBtnClicked;
|
||||
|
||||
private String colorPicked;
|
||||
protected String tagNameValue;
|
||||
protected String tagDescValue;
|
||||
|
||||
protected abstract String getWindowCaption();
|
||||
|
||||
/**
|
||||
* Save new tag / update new tag.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
protected abstract void save(final Button.ClickEvent event);
|
||||
|
||||
/**
|
||||
* Discard the changes and close the popup.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
protected void discard(final Button.ClickEvent event) {
|
||||
UI.getCurrent().removeWindow(window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate target name combo.
|
||||
*/
|
||||
protected abstract void populateTagNameCombo();
|
||||
|
||||
protected abstract void setTagDetails(final String tagSelected);
|
||||
|
||||
/**
|
||||
* Init the layout.
|
||||
*/
|
||||
public void init() {
|
||||
|
||||
setSizeUndefined();
|
||||
createRequiredComponents();
|
||||
buildLayout();
|
||||
addListeners();
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
void destroy() {
|
||||
eventBus.unsubscribe(this);
|
||||
}
|
||||
|
||||
protected void createRequiredComponents() {
|
||||
|
||||
createTagStr = i18n.get("label.create.tag");
|
||||
updateTagStr = i18n.get("label.update.tag");
|
||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||
|
||||
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME, true, "", i18n.get("textfield.name"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
||||
|
||||
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC, false, "", i18n.get("textfield.description"),
|
||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
|
||||
tagDesc.setImmediate(true);
|
||||
tagDesc.setNullRepresentation("");
|
||||
|
||||
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", "", null, null, false, "",
|
||||
i18n.get("label.combobox.tag"));
|
||||
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
||||
tagNameComboBox.setImmediate(true);
|
||||
tagNameComboBox.setId(SPUIComponentIdProvider.DIST_TAG_COMBO);
|
||||
|
||||
tagColorPreviewBtn = new Button();
|
||||
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||
}
|
||||
|
||||
protected void buildLayout() {
|
||||
|
||||
mainLayout = new GridLayout(3, 2);
|
||||
mainLayout.setSpacing(true);
|
||||
comboLayout = new VerticalLayout();
|
||||
colorPickerLayout = new ColorPickerLayout();
|
||||
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||
contentLayout = new VerticalLayout();
|
||||
|
||||
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
|
||||
colorLabelLayout.setMargin(false);
|
||||
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
||||
|
||||
formLayout.addComponent(optiongroup);
|
||||
formLayout.addComponent(comboLayout);
|
||||
formLayout.addComponent(tagName);
|
||||
formLayout.addComponent(tagDesc);
|
||||
formLayout.addStyleName("form-lastrow");
|
||||
formLayout.setSizeFull();
|
||||
|
||||
contentLayout.addComponent(formLayout);
|
||||
contentLayout.addComponent(colorLabelLayout);
|
||||
contentLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
|
||||
contentLayout.setComponentAlignment(colorLabelLayout, Alignment.MIDDLE_LEFT);
|
||||
contentLayout.setSizeUndefined();
|
||||
|
||||
mainLayout.setSizeFull();
|
||||
mainLayout.addComponent(contentLayout, 0, 0);
|
||||
|
||||
colorPickerLayout.setVisible(false);
|
||||
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||
|
||||
setCompositionRoot(mainLayout);
|
||||
tagName.focus();
|
||||
}
|
||||
|
||||
protected void addListeners() {
|
||||
colorPickerLayout.getColorSelect().addColorChangeListener(this);
|
||||
colorPickerLayout.getSelPreview().addColorChangeListener(this);
|
||||
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
|
||||
tagNameComboBox.addValueChangeListener(this::tagNameChosen);
|
||||
slidersValueChangeListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open color picker on click of preview button. Auto select the color based
|
||||
* on target tag if already selected.
|
||||
*/
|
||||
protected void previewButtonClicked() {
|
||||
if (!tagPreviewBtnClicked) {
|
||||
setColor();
|
||||
}
|
||||
|
||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||
colorPickerLayout.setVisible(tagPreviewBtnClicked);
|
||||
}
|
||||
|
||||
private void setColor() {
|
||||
final String selectedOption = (String) optiongroup.getValue();
|
||||
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagStr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagNameComboBox.getValue() == null) {
|
||||
colorPickerLayout
|
||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
return;
|
||||
}
|
||||
|
||||
final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue().toString());
|
||||
|
||||
if (targetTagSelected == null) {
|
||||
final DistributionSetTag distTag = tagManagement
|
||||
.findDistributionSetTag(tagNameComboBox.getValue().toString());
|
||||
colorPickerLayout.setSelectedColor(
|
||||
distTag.getColour() != null ? ColorPickerHelper.rgbToColorConverter(distTag.getColour())
|
||||
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
} else {
|
||||
colorPickerLayout.setSelectedColor(targetTagSelected.getColour() != null
|
||||
? ColorPickerHelper.rgbToColorConverter(targetTagSelected.getColour())
|
||||
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
}
|
||||
}
|
||||
|
||||
private void tagNameChosen(final ValueChangeEvent event) {
|
||||
final String tagSelected = (String) event.getProperty().getValue();
|
||||
if (null != tagSelected) {
|
||||
setTagDetails(tagSelected);
|
||||
} else {
|
||||
resetTagNameField();
|
||||
}
|
||||
window.setOrginaleValues();
|
||||
}
|
||||
|
||||
protected void resetTagNameField() {
|
||||
tagName.setEnabled(false);
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
restoreComponentStyles();
|
||||
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
||||
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||
tagPreviewBtnClicked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for option group - Create tag/Update.
|
||||
*
|
||||
* @param event
|
||||
* ValueChangeEvent
|
||||
*/
|
||||
protected void optionValueChanged(final ValueChangeEvent event) {
|
||||
|
||||
if (updateTagStr.equals(event.getProperty().getValue())) {
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
tagName.setEnabled(false);
|
||||
populateTagNameCombo();
|
||||
// show target name combo
|
||||
comboLayout.addComponent(comboLabel);
|
||||
comboLayout.addComponent(tagNameComboBox);
|
||||
} else {
|
||||
tagName.setEnabled(true);
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
// hide target name combo
|
||||
comboLayout.removeComponent(comboLabel);
|
||||
comboLayout.removeComponent(tagNameComboBox);
|
||||
}
|
||||
// close the color picker layout
|
||||
tagPreviewBtnClicked = false;
|
||||
// reset the selected color - Set default color
|
||||
restoreComponentStyles();
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
colorPickerLayout.getSelPreview()
|
||||
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
window.setOrginaleValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the components.
|
||||
*/
|
||||
protected void reset() {
|
||||
tagName.setEnabled(true);
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
restoreComponentStyles();
|
||||
|
||||
// hide target name combo
|
||||
comboLayout.removeComponent(comboLabel);
|
||||
comboLayout.removeComponent(tagNameComboBox);
|
||||
|
||||
// Default green color
|
||||
colorPickerLayout.setVisible(false);
|
||||
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
||||
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||
tagPreviewBtnClicked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* On change of color in color picker ,change RGB sliders, components border
|
||||
* color and color of preview button.
|
||||
*/
|
||||
@Override
|
||||
public void colorChanged(final ColorChangeEvent event) {
|
||||
setColor(event.getColor());
|
||||
for (final ColorSelector select : colorPickerLayout.getSelectors()) {
|
||||
if (!event.getSource().equals(select) && select.equals(this)
|
||||
&& !select.getColor().equals(colorPickerLayout.getSelectedColor())) {
|
||||
select.setColor(colorPickerLayout.getSelectedColor());
|
||||
}
|
||||
}
|
||||
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||
getPreviewButtonColor(event.getColor().getCSS());
|
||||
createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic styles for window.
|
||||
*
|
||||
* @param top
|
||||
* int value
|
||||
* @param marginLeft
|
||||
* int value
|
||||
*/
|
||||
protected void getPreviewButtonColor(final String color) {
|
||||
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tag name and desc field border color based on chosen color.
|
||||
*
|
||||
* @param tagName
|
||||
* @param tagDesc
|
||||
* @param taregtTagColor
|
||||
*/
|
||||
protected void createDynamicStyleForComponents(final TextField tagName, final TextArea tagDesc,
|
||||
final String taregtTagColor) {
|
||||
|
||||
tagName.removeStyleName(SPUIDefinitions.TAG_NAME);
|
||||
tagDesc.removeStyleName(SPUIDefinitions.TAG_DESC);
|
||||
getTargetDynamicStyles(taregtTagColor);
|
||||
tagName.addStyleName(TAG_NAME_DYNAMIC_STYLE);
|
||||
tagDesc.addStyleName(TAG_DESC_DYNAMIC_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the tag name and tag description component border color.
|
||||
*/
|
||||
protected void restoreComponentStyles() {
|
||||
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
|
||||
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
|
||||
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
|
||||
tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target style - Dynamically as per the color picked, cannot be done
|
||||
* from the static css.
|
||||
*
|
||||
* @param colorPickedPreview
|
||||
*/
|
||||
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
||||
Page.getCurrent().getJavaScript()
|
||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(final Color color) {
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
colorPickerLayout.setSelectedColor(color);
|
||||
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||
final String colorPickedPreview = colorPickerLayout.getSelPreview().getColor().getCSS();
|
||||
if (tagName.isEnabled() && null != colorPickerLayout.getColorSelect()) {
|
||||
createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
|
||||
colorPickerLayout.getColorSelect().setColor(colorPickerLayout.getSelPreview().getColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* create option group with Create tag/Update tag based on permissions.
|
||||
*/
|
||||
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||
|
||||
optiongroup = new OptionGroup("Select Action");
|
||||
optiongroup.setId(SPUIComponentIdProvider.OPTION_GROUP);
|
||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||
optiongroup.addStyleName("custom-option-group");
|
||||
optiongroup.setNullSelectionAllowed(false);
|
||||
|
||||
if (hasCreatePermission) {
|
||||
optiongroup.addItem(createTagStr);
|
||||
}
|
||||
if (hasUpdatePermission) {
|
||||
optiongroup.addItem(updateTagStr);
|
||||
}
|
||||
|
||||
setOptionGroupDefaultValue(hasCreatePermission, hasUpdatePermission);
|
||||
}
|
||||
|
||||
protected void setOptionGroupDefaultValue(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||
|
||||
if (hasCreatePermission) {
|
||||
optiongroup.select(createTagStr);
|
||||
}
|
||||
if (hasUpdatePermission && !hasCreatePermission) {
|
||||
optiongroup.select(updateTagStr);
|
||||
}
|
||||
}
|
||||
|
||||
public ColorPickerLayout getColorPickerLayout() {
|
||||
return colorPickerLayout;
|
||||
}
|
||||
|
||||
public CommonDialogWindow getWindow() {
|
||||
reset();
|
||||
window = SPUIWindowDecorator.getWindow(getWindowCaption(), null, SPUIDefinitions.CREATE_UPDATE_WINDOW, this,
|
||||
this::save, this::discard, null, mainLayout, i18n);
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value change listeners implementations of sliders.
|
||||
*/
|
||||
private void slidersValueChangeListeners() {
|
||||
colorPickerLayout.getRedSlider().addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = -8336732888800920839L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double red = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color((int) red, colorPickerLayout.getSelectedColor().getGreen(),
|
||||
colorPickerLayout.getSelectedColor().getBlue());
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
colorPickerLayout.getGreenSlider().addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = 1236358037766775663L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double green = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(), (int) green,
|
||||
colorPickerLayout.getSelectedColor().getBlue());
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
colorPickerLayout.getBlueSlider().addValueChangeListener(new ValueChangeListener() {
|
||||
private static final long serialVersionUID = 8466370763686043947L;
|
||||
|
||||
@Override
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
final double blue = (Double) event.getProperty().getValue();
|
||||
final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(),
|
||||
colorPickerLayout.getSelectedColor().getGreen(), (int) blue);
|
||||
setColorToComponents(newColor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void setColorToComponents(final Color newColor) {
|
||||
setColor(newColor);
|
||||
colorPickerLayout.getColorSelect().setColor(newColor);
|
||||
getPreviewButtonColor(newColor.getCSS());
|
||||
createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new tag.
|
||||
*/
|
||||
protected void createNewTag() {
|
||||
colorPicked = ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview());
|
||||
tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||
tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* update tag.
|
||||
*/
|
||||
protected void updateExistingTag(final Tag targetObj) {
|
||||
final String nameUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||
final String descUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||
|
||||
if (null != nameUpdateValue) {
|
||||
targetObj.setName(nameUpdateValue);
|
||||
targetObj.setDescription(null != descUpdateValue ? descUpdateValue : null);
|
||||
targetObj.setColour(ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview()));
|
||||
if (targetObj instanceof TargetTag) {
|
||||
tagManagement.updateTargetTag((TargetTag) targetObj);
|
||||
} else if (targetObj instanceof DistributionSetTag) {
|
||||
tagManagement.updateDistributionSetTag((DistributionSetTag) targetObj);
|
||||
}
|
||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() }));
|
||||
} else {
|
||||
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
||||
}
|
||||
}
|
||||
|
||||
protected void displaySuccess(final String tagName) {
|
||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { tagName }));
|
||||
}
|
||||
|
||||
protected void displayValidationError(final String errorMessage) {
|
||||
uiNotification.displayValidationError(errorMessage);
|
||||
}
|
||||
|
||||
protected void setTagColor(final Color selectedColor, final String previewColor) {
|
||||
getColorPickerLayout().setSelectedColor(selectedColor);
|
||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||
createDynamicStyleForComponents(tagName, tagDesc, previewColor);
|
||||
getPreviewButtonColor(previewColor);
|
||||
}
|
||||
|
||||
protected Boolean checkIsDuplicate(final Tag existingTag) {
|
||||
if (existingTag != null) {
|
||||
displayValidationError(i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() }));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
public String getColorPicked() {
|
||||
return colorPicked;
|
||||
}
|
||||
|
||||
public void setColorPicked(final String colorPicked) {
|
||||
this.colorPicked = colorPicked;
|
||||
}
|
||||
|
||||
public String getTagNameValue() {
|
||||
return tagNameValue;
|
||||
}
|
||||
|
||||
public void setTagNameValue(final String tagNameValue) {
|
||||
this.tagNameValue = tagNameValue;
|
||||
}
|
||||
|
||||
public String getTagDescValue() {
|
||||
return tagDescValue;
|
||||
}
|
||||
|
||||
public void setTagDescValue(final String tagDescValue) {
|
||||
this.tagDescValue = tagDescValue;
|
||||
}
|
||||
|
||||
public FormLayout getFormLayout() {
|
||||
return formLayout;
|
||||
}
|
||||
|
||||
public GridLayout getMainLayout() {
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColorChangeListener(final ColorChangeListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeColorChangeListener(final ColorChangeListener listener) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
/**
|
||||
* 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.layouts;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
|
||||
import com.vaadin.data.Property.ValueChangeEvent;
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Button.ClickEvent;
|
||||
import com.vaadin.ui.OptionGroup;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
* Superclass defining common properties and methods for creating/updating
|
||||
* types.
|
||||
*/
|
||||
public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayout {
|
||||
|
||||
private static final long serialVersionUID = 5732904956185988397L;
|
||||
|
||||
protected String createTypeStr;
|
||||
protected String updateTypeStr;
|
||||
protected TextField typeKey;
|
||||
|
||||
public static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
super.addListeners();
|
||||
optiongroup.addValueChangeListener(this::optionValueChanged);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createRequiredComponents() {
|
||||
|
||||
createTypeStr = i18n.get("label.create.type");
|
||||
updateTypeStr = i18n.get("label.update.type");
|
||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||
|
||||
tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false,
|
||||
"", i18n.get("label.combobox.type"));
|
||||
tagNameComboBox.setId(SPUIDefinitions.NEW_DISTRIBUTION_SET_TYPE_NAME_COMBO);
|
||||
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
||||
tagNameComboBox.setImmediate(true);
|
||||
tagNameComboBox.setPageLength(SPUIDefinitions.DIST_TYPE_SIZE);
|
||||
|
||||
tagColorPreviewBtn = new Button();
|
||||
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||
|
||||
createOptionGroup(permChecker.hasCreateDistributionPermission(), permChecker.hasUpdateDistributionPermission());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColorToComponents(final Color newColor) {
|
||||
|
||||
super.setColorToComponents(newColor);
|
||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, newColor.getCSS());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tag name and desc field border color based on chosen color.
|
||||
*
|
||||
* @param tagName
|
||||
* @param tagDesc
|
||||
* @param taregtTagColor
|
||||
*/
|
||||
protected void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
|
||||
final TextArea typeDesc, final String typeTagColor) {
|
||||
|
||||
tagName.removeStyleName(SPUIDefinitions.TYPE_NAME);
|
||||
typeKey.removeStyleName(SPUIDefinitions.TYPE_KEY);
|
||||
typeDesc.removeStyleName(SPUIDefinitions.TYPE_DESC);
|
||||
getDynamicStyles(typeTagColor);
|
||||
tagName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target style - Dynamically as per the color picked, cannot be done
|
||||
* from the static css.
|
||||
*
|
||||
* @param colorPickedPreview
|
||||
*/
|
||||
private void getDynamicStyles(final String colorPickedPreview) {
|
||||
|
||||
Page.getCurrent().getJavaScript()
|
||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the components.
|
||||
*/
|
||||
@Override
|
||||
protected void reset() {
|
||||
|
||||
super.reset();
|
||||
typeKey.clear();
|
||||
restoreComponentStyles();
|
||||
setOptionGroupDefaultValue(permChecker.hasCreateDistributionPermission(),
|
||||
permChecker.hasUpdateDistributionPermission());
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for option group - Create tag/Update.
|
||||
*
|
||||
* @param event
|
||||
* ValueChangeEvent
|
||||
*/
|
||||
@Override
|
||||
protected void optionValueChanged(final ValueChangeEvent event) {
|
||||
|
||||
if (updateTypeStr.equals(event.getProperty().getValue())) {
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
typeKey.clear();
|
||||
typeKey.setEnabled(false);
|
||||
tagName.setEnabled(false);
|
||||
populateTagNameCombo();
|
||||
comboLayout.addComponent(comboLabel);
|
||||
comboLayout.addComponent(tagNameComboBox);
|
||||
} else {
|
||||
typeKey.setEnabled(true);
|
||||
tagName.setEnabled(true);
|
||||
tagName.clear();
|
||||
tagDesc.clear();
|
||||
typeKey.clear();
|
||||
comboLayout.removeComponent(comboLabel);
|
||||
comboLayout.removeComponent(tagNameComboBox);
|
||||
}
|
||||
restoreComponentStyles();
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
getColorPickerLayout().getSelPreview()
|
||||
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.vaadin.ui.components.colorpicker.ColorSelector#setColor(com.vaadin.
|
||||
* shared.ui.colorpicker .Color)
|
||||
*/
|
||||
@Override
|
||||
public void setColor(final Color color) {
|
||||
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
getColorPickerLayout().setSelectedColor(color);
|
||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||
final String colorPickedPreview = getColorPickerLayout().getSelPreview().getColor().getCSS();
|
||||
if (tagName.isEnabled() && null != getColorPickerLayout().getColorSelect()) {
|
||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, colorPickedPreview);
|
||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelPreview().getColor());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the tag name and tag description component border color.
|
||||
*/
|
||||
@Override
|
||||
protected void restoreComponentStyles() {
|
||||
super.restoreComponentStyles();
|
||||
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||
typeKey.addStyleName(SPUIDefinitions.TYPE_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* create option group with Create tag/Update tag based on permissions.
|
||||
*/
|
||||
@Override
|
||||
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||
|
||||
optiongroup = new OptionGroup("Select Action");
|
||||
optiongroup.setId(SPUIComponentIdProvider.OPTION_GROUP);
|
||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||
optiongroup.addStyleName("custom-option-group");
|
||||
optiongroup.setNullSelectionAllowed(false);
|
||||
|
||||
if (hasCreatePermission) {
|
||||
optiongroup.addItem(createTypeStr);
|
||||
}
|
||||
if (hasUpdatePermission) {
|
||||
optiongroup.addItem(updateTypeStr);
|
||||
}
|
||||
setOptionGroupDefaultValue(hasCreatePermission, hasUpdatePermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOptionGroupDefaultValue(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||
|
||||
if (hasCreatePermission) {
|
||||
optiongroup.select(createTypeStr);
|
||||
}
|
||||
if (hasUpdatePermission && !hasCreatePermission) {
|
||||
optiongroup.select(updateTypeStr);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setColorPickerComponentsColor(final String color) {
|
||||
|
||||
if (null == color) {
|
||||
getColorPickerLayout()
|
||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, ColorPickerConstants.DEFAULT_COLOR);
|
||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||
} else {
|
||||
getColorPickerLayout().setSelectedColor(ColorPickerHelper.rgbToColorConverter(color));
|
||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, color);
|
||||
getPreviewButtonColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void colorChanged(final ColorChangeEvent event) {
|
||||
setColor(event.getColor());
|
||||
for (final ColorSelector select : getColorPickerLayout().getSelectors()) {
|
||||
if (!event.getSource().equals(select) && select.equals(this)
|
||||
&& !select.getColor().equals(getColorPickerLayout().getSelectedColor())) {
|
||||
select.setColor(getColorPickerLayout().getSelectedColor());
|
||||
}
|
||||
}
|
||||
ColorPickerHelper.setRgbSliderValues(getColorPickerLayout());
|
||||
getPreviewButtonColor(event.getColor().getCSS());
|
||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, event.getColor().getCSS());
|
||||
}
|
||||
|
||||
protected Boolean checkIsDuplicate(final NamedEntity existingType) {
|
||||
|
||||
if (existingType != null) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
protected Boolean checkIsDuplicateByKey(final NamedEntity existingType) {
|
||||
|
||||
if (existingType != null) {
|
||||
if (existingType instanceof DistributionSetType) {
|
||||
uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check",
|
||||
new Object[] { ((DistributionSetType) existingType).getKey() }));
|
||||
return Boolean.TRUE;
|
||||
} else if (existingType instanceof SoftwareModuleType) {
|
||||
uiNotification.displayValidationError(i18n.get("message.type.key.swmodule.duplicate.check",
|
||||
new Object[] { ((SoftwareModuleType) existingType).getKey() }));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save(final ClickEvent event) {
|
||||
// is implemented in the inherited class
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateTagNameCombo() {
|
||||
// is implemented in the inherited class
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setTagDetails(final String tagSelected) {
|
||||
// is implemented in the inherited class
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.ui.login;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.Cookie;
|
||||
@@ -18,13 +19,14 @@ import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationTok
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.vaadin.spring.security.VaadinSecurity;
|
||||
|
||||
import com.vaadin.event.ShortcutAction.KeyCode;
|
||||
@@ -56,6 +58,12 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
@SpringView(name = "")
|
||||
@UIScope
|
||||
public class LoginView extends VerticalLayout implements View {
|
||||
private static final String TENANT_PATTERN_PLACEHOLDER = "tenant";
|
||||
private static final String USER_PATTERN_PLACEHOLDER = "user";
|
||||
private static final String LOGIN_TENANT_USER_URL_PATTERN = "**/#/{" + TENANT_PATTERN_PLACEHOLDER + "}/{"
|
||||
+ USER_PATTERN_PLACEHOLDER + "}";
|
||||
private static final String LOGIN_USER_URL_PATTERN = "**/#/{" + USER_PATTERN_PLACEHOLDER + "}";
|
||||
|
||||
private static final String LOGIN_TEXTFIELD = "login-textfield";
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class);
|
||||
@@ -75,6 +83,9 @@ public class LoginView extends VerticalLayout implements View {
|
||||
@Autowired
|
||||
private transient MultitenancyIndicator multiTenancyIndicator;
|
||||
|
||||
private final transient AntPathMatcher matcher = new AntPathMatcher();
|
||||
private boolean useCookie = true;
|
||||
|
||||
private TextField username;
|
||||
private TextField tenant;
|
||||
private PasswordField password;
|
||||
@@ -106,17 +117,45 @@ public class LoginView extends VerticalLayout implements View {
|
||||
*/
|
||||
@PostConstruct
|
||||
public void render() {
|
||||
|
||||
final URI spURI = Page.getCurrent().getLocation();
|
||||
final String lookForDemoFragment = spURI.toString();
|
||||
if (lookForDemoFragment.contains("?demo")) {
|
||||
final String uriPath = spURI.toString();
|
||||
if (uriPath.contains("?demo")) {
|
||||
login(uiProperties.getDemo().getTenant(), uiProperties.getDemo().getUser(),
|
||||
uiProperties.getDemo().getPassword(), false);
|
||||
}
|
||||
|
||||
final Component loginForm = buildLoginForm();
|
||||
addComponent(loginForm);
|
||||
setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
|
||||
|
||||
readCredentialsFromUriPath(uriPath);
|
||||
}
|
||||
|
||||
private void readCredentialsFromUriPath(final String uriPath) {
|
||||
String urlTenant = null;
|
||||
String urlUser = null;
|
||||
if (matcher.match(LOGIN_USER_URL_PATTERN, uriPath)) {
|
||||
urlUser = matcher.extractUriTemplateVariables(LOGIN_USER_URL_PATTERN, uriPath)
|
||||
.get(USER_PATTERN_PLACEHOLDER);
|
||||
} else if (matcher.match(LOGIN_TENANT_USER_URL_PATTERN, uriPath)) {
|
||||
final Map<String, String> extractUriTemplateVariables = matcher
|
||||
.extractUriTemplateVariables(LOGIN_TENANT_USER_URL_PATTERN, uriPath);
|
||||
urlTenant = extractUriTemplateVariables.get(TENANT_PATTERN_PLACEHOLDER);
|
||||
urlUser = extractUriTemplateVariables.get(USER_PATTERN_PLACEHOLDER);
|
||||
}
|
||||
|
||||
if (urlUser != null) {
|
||||
useCookie = false;
|
||||
filloutUsernameTenantFields(urlTenant, urlUser);
|
||||
}
|
||||
}
|
||||
|
||||
private void filloutUsernameTenantFields(final String tenantValue, final String userValue) {
|
||||
if (tenant != null && tenantValue != null) {
|
||||
tenant.setValue(tenantValue);
|
||||
}
|
||||
if (userValue != null) {
|
||||
username.setValue(userValue);
|
||||
}
|
||||
}
|
||||
|
||||
private Component buildLoginForm() {
|
||||
@@ -225,7 +264,7 @@ public class LoginView extends VerticalLayout implements View {
|
||||
final String linkStyle = "v-link";
|
||||
|
||||
if (!uiProperties.getLinks().getDocumentation().getRoot().isEmpty()) {
|
||||
final Link docuLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_DOCUMENTATION,
|
||||
final Link docuLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_DOCUMENTATION,
|
||||
i18n.get("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(),
|
||||
FontAwesome.QUESTION_CIRCLE, "_blank", linkStyle, true);
|
||||
links.addComponent(docuLink);
|
||||
@@ -233,14 +272,14 @@ public class LoginView extends VerticalLayout implements View {
|
||||
}
|
||||
|
||||
if (!uiProperties.getDemo().getUser().isEmpty()) {
|
||||
final Link demoLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_DEMO,
|
||||
final Link demoLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_DEMO,
|
||||
i18n.get("link.demo.name"), "?demo", FontAwesome.DESKTOP, "_top", linkStyle, true);
|
||||
links.addComponent(demoLink);
|
||||
demoLink.addStyleName(ValoTheme.LINK_SMALL);
|
||||
}
|
||||
|
||||
if (!uiProperties.getLinks().getRequestAccount().isEmpty()) {
|
||||
final Link requestAccountLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_REQUESTACCOUNT,
|
||||
final Link requestAccountLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_REQUESTACCOUNT,
|
||||
i18n.get("link.requestaccount.name"), uiProperties.getLinks().getRequestAccount(),
|
||||
FontAwesome.SHOPPING_CART, "", linkStyle, true);
|
||||
links.addComponent(requestAccountLink);
|
||||
@@ -248,7 +287,7 @@ public class LoginView extends VerticalLayout implements View {
|
||||
}
|
||||
|
||||
if (!uiProperties.getLinks().getUserManagement().isEmpty()) {
|
||||
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponetIdProvider.LINK_USERMANAGEMENT,
|
||||
final Link userManagementLink = SPUIComponentProvider.getLink(SPUIComponentIdProvider.LINK_USERMANAGEMENT,
|
||||
i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(),
|
||||
FontAwesome.USERS, "_blank", linkStyle, true);
|
||||
links.addComponent(userManagementLink);
|
||||
@@ -281,6 +320,9 @@ public class LoginView extends VerticalLayout implements View {
|
||||
*/
|
||||
@Override
|
||||
public void enter(final ViewChangeEvent event) {
|
||||
if (!useCookie) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Cookie usernameCookie = getCookieByName(SP_LOGIN_USER);
|
||||
|
||||
@@ -348,7 +390,7 @@ public class LoginView extends VerticalLayout implements View {
|
||||
vaadinSecurity.login(new UsernamePasswordAuthenticationToken(user, password));
|
||||
}
|
||||
/* set success login cookies */
|
||||
if (setCookies) {
|
||||
if (setCookies && useCookie) {
|
||||
setCookies();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
|
||||
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.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
@@ -50,15 +50,14 @@ import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.HierarchicalContainer;
|
||||
import com.vaadin.event.Action.Handler;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
@@ -69,15 +68,18 @@ import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
* Table for {@link Target#getActions()} history.
|
||||
*
|
||||
*/
|
||||
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
public class ActionHistoryTable extends TreeTable {
|
||||
|
||||
private static final long serialVersionUID = -1631514704696786653L;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActionHistoryTable.class);
|
||||
private static final String BUTTON_CANCEL = "button.cancel";
|
||||
private static final String BUTTON_OK = "button.ok";
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@@ -94,14 +96,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
private ManagementUIState managementUIState;
|
||||
|
||||
private Container hierarchicalContainer;
|
||||
private boolean alreadyHasMessages = false;
|
||||
private boolean alreadyHasMessages;
|
||||
|
||||
private Target target;
|
||||
|
||||
com.vaadin.event.Action actionCancel;
|
||||
com.vaadin.event.Action actionForce;
|
||||
com.vaadin.event.Action actionForceQuit;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActionHistoryTable.class);
|
||||
private static final String STATUS_ICON_GREEN = "statusIconGreen";
|
||||
|
||||
/**
|
||||
@@ -109,10 +107,6 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
actionCancel = new com.vaadin.event.Action(i18n.get("message.cancel.action"));
|
||||
actionForceQuit = new com.vaadin.event.Action(i18n.get("message.forcequit.action"));
|
||||
actionForceQuit.setIcon(FontAwesome.WARNING);
|
||||
actionForce = new com.vaadin.event.Action(i18n.get("message.force.action"));
|
||||
initializeTableSettings();
|
||||
buildComponent();
|
||||
restorePreviousState();
|
||||
@@ -149,28 +143,30 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
}
|
||||
|
||||
private void setColumnExpandRatioForMinimisedTable() {
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.3f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.15f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.3f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.15f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.3F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.15F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.3F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.15F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTIONS_COLUMN, 0.2F);
|
||||
}
|
||||
|
||||
private void initializeTableSettings() {
|
||||
|
||||
setId(SPUIComponetIdProvider.ACTION_HISTORY_TABLE_ID);
|
||||
setId(SPUIComponentIdProvider.ACTION_HISTORY_TABLE_ID);
|
||||
setSelectable(false);
|
||||
setMultiSelect(false);
|
||||
setSortEnabled(true);
|
||||
setColumnReorderingAllowed(true);
|
||||
setHeight(100.0f, Unit.PERCENTAGE);
|
||||
setWidth(100.0f, Unit.PERCENTAGE);
|
||||
setHeight(100.0F, Unit.PERCENTAGE);
|
||||
setWidth(100.0F, Unit.PERCENTAGE);
|
||||
setImmediate(true);
|
||||
setStyleName("sp-table");
|
||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_SMALL);
|
||||
setColumnAlignment(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Align.CENTER);
|
||||
setColumnAlignment(SPUIDefinitions.ACTION_HIS_TBL_STATUS, Align.CENTER);
|
||||
setColumnAlignment(SPUIDefinitions.ACTIONS_COLUMN, Align.CENTER);
|
||||
// listeners for child
|
||||
addExpandListener(event -> {
|
||||
expandParentActionRow(event.getItemId());
|
||||
@@ -180,11 +176,6 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
collapseParentActionRow(event.getItemId());
|
||||
managementUIState.getExpandParentActionRowId().remove(event.getItemId());
|
||||
});
|
||||
/*
|
||||
* Add the cancel action handler for active actions. To be used to
|
||||
* cancel the action.
|
||||
*/
|
||||
addActionHandler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,6 +194,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
null);
|
||||
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null);
|
||||
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class, null);
|
||||
|
||||
}
|
||||
|
||||
private List<Object> getVisbleColumns() {
|
||||
@@ -212,6 +204,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_DATETIME);
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_STATUS);
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_FORCED);
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTIONS_COLUMN);
|
||||
|
||||
if (managementUIState.isActionHistoryMaximized()) {
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME);
|
||||
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_MSGS);
|
||||
@@ -241,11 +235,14 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
|
||||
private void getcontainerData() {
|
||||
hierarchicalContainer.removeAllItems();
|
||||
/* service method to create action history for target */
|
||||
final List<ActionWithStatusCount> actionHistory = deploymentManagement
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
|
||||
|
||||
addDetailsToContainer(actionHistory);
|
||||
if (target != null) {
|
||||
/* service method to create action history for target */
|
||||
final List<ActionWithStatusCount> actionHistory = deploymentManagement
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
|
||||
|
||||
addDetailsToContainer(actionHistory);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,51 +265,50 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
|
||||
final Action action = actionWithStatusCount.getAction();
|
||||
|
||||
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
|
||||
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getAction().getId());
|
||||
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
|
||||
.setValue(actionWithStatusCount.getActionStatus());
|
||||
.setValue(actionWithStatusCount.getAction().getStatus());
|
||||
|
||||
/*
|
||||
* add action id.
|
||||
*/
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID)
|
||||
.setValue(actionWithStatusCount.getActionId().toString());
|
||||
.setValue(actionWithStatusCount.getAction().getId().toString());
|
||||
/*
|
||||
* add active/inactive status to the item which will be used in
|
||||
* Column generator to generate respective icon
|
||||
*/
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue(
|
||||
actionWithStatusCount.isActionActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE);
|
||||
actionWithStatusCount.getAction().isActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE);
|
||||
|
||||
/*
|
||||
* add action Id to the item which will be used for fetching child
|
||||
* items ( previous action status ) during expand
|
||||
*/
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
|
||||
.setValue(actionWithStatusCount.getActionId());
|
||||
.setValue(actionWithStatusCount.getAction().getId());
|
||||
|
||||
/*
|
||||
* add distribution name to the item which will be displayed in the
|
||||
* table. The name should not exceed certain limit.
|
||||
*/
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(HawkbitCommonUtil
|
||||
.getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion()));
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST)
|
||||
.setValue(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion());
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
|
||||
|
||||
/* Default no child */
|
||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
|
||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), false);
|
||||
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
|
||||
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null)
|
||||
? actionWithStatusCount.getActionLastModifiedAt()
|
||||
: actionWithStatusCount.getActionCreatedAt()));
|
||||
.setValue(SPDateTimeUtil.getFormattedDate(actionWithStatusCount.getAction().getLastModifiedAt()));
|
||||
|
||||
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME)
|
||||
.setValue(actionWithStatusCount.getRolloutName());
|
||||
|
||||
if (actionWithStatusCount.getActionStatusCount() > 0) {
|
||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
|
||||
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(),
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,12 +342,18 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
return getForcedColumn(itemId);
|
||||
}
|
||||
});
|
||||
|
||||
addGeneratedColumn(SPUIDefinitions.ACTIONS_COLUMN, new Table.ColumnGenerator() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||
return createActionBarColumn(itemId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @return
|
||||
*/
|
||||
private Component getForcedColumn(final Object itemId) {
|
||||
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
|
||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
|
||||
@@ -368,10 +370,6 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
return actionLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @return
|
||||
*/
|
||||
private Component getActiveColumn(final Object itemId) {
|
||||
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
|
||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
|
||||
@@ -393,10 +391,44 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
return activeStatusIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @return
|
||||
*/
|
||||
private HorizontalLayout createActionBarColumn(final Object itemId) {
|
||||
final HorizontalLayout actionBar = new HorizontalLayout();
|
||||
final Item item = hierarchicalContainer.getItem(itemId);
|
||||
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue();
|
||||
final String activeValue = (String) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN)
|
||||
.getValue();
|
||||
final Action actionWithActiveStatus = (Action) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED)
|
||||
.getValue();
|
||||
|
||||
if (actionWithActiveStatus == null) {
|
||||
return null;
|
||||
}
|
||||
final boolean isActionActive = target != null && SPUIDefinitions.ACTIVE.equals(activeValue);
|
||||
|
||||
final Button actionCancel = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, "", i18n.get("message.cancel.action"),
|
||||
ValoTheme.BUTTON_TINY, true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
actionCancel.setEnabled(isActionActive && !actionWithActiveStatus.isCancelingOrCanceled());
|
||||
actionCancel.addClickListener(event -> confirmAndCancelAction(actionId));
|
||||
|
||||
final Button actionForce = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, "", i18n.get("message.force.action"),
|
||||
ValoTheme.BUTTON_TINY, true, FontAwesome.BOLT, SPUIButtonStyleSmallNoBorder.class);
|
||||
actionForce.setEnabled(
|
||||
isActionActive && !actionWithActiveStatus.isForce() && !actionWithActiveStatus.isCancelingOrCanceled());
|
||||
actionForce.addClickListener(event -> confirmAndForceAction(actionId));
|
||||
|
||||
final Button actionForceQuit = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, "", i18n.get("message.forcequit.action"),
|
||||
ValoTheme.BUTTON_TINY + " redicon", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
actionForceQuit.setEnabled(isActionActive && actionWithActiveStatus.isCancelingOrCanceled());
|
||||
actionForceQuit.addClickListener(event -> confirmAndForceQuitAction(actionId));
|
||||
|
||||
actionBar.addComponents(actionCancel, actionForce, actionForceQuit);
|
||||
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
private Component getStatusColumn(final Object itemId) {
|
||||
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
|
||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
|
||||
@@ -422,8 +454,12 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
.findActionWithDetails(actionId);
|
||||
final Pageable pageReq = new PageRequest(0, 1000,
|
||||
new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName()));
|
||||
final Page<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action,
|
||||
managementUIState.isActionHistoryMaximized());
|
||||
final Page<ActionStatus> actionStatusList;
|
||||
if (managementUIState.isActionHistoryMaximized()) {
|
||||
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action);
|
||||
} else {
|
||||
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action);
|
||||
}
|
||||
final List<ActionStatus> content = actionStatusList.getContent();
|
||||
/*
|
||||
* Since the recent action status and messages are already
|
||||
@@ -441,9 +477,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
*/
|
||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue("");
|
||||
|
||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST)
|
||||
.setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":"
|
||||
+ action.getDistributionSet().getVersion()));
|
||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(
|
||||
action.getDistributionSet().getName() + ":" + action.getDistributionSet().getVersion());
|
||||
|
||||
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
|
||||
.setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
|
||||
@@ -629,14 +664,15 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
|
||||
private void setColumnExpantRatioOnTableMaximize() {
|
||||
/* set messages column can expand the rest of the available space */
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.2f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, 0.1f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_MSGS, 0.35f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.15f);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.2F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, 0.1F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_MSGS, 0.35F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.15F);
|
||||
setColumnExpandRatio(SPUIDefinitions.ACTIONS_COLUMN, 0.2F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -698,46 +734,6 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
setColumnExpandRatioForMinimisedTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAction(final com.vaadin.event.Action action, final Object sender, final Object target) {
|
||||
/* Get the actionId details of the cancel item or row */
|
||||
final Item item = hierarchicalContainer.getItem(target);
|
||||
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue();
|
||||
if (action.equals(actionCancel)) {
|
||||
if (actionId != null) {
|
||||
confirmAndCancelAction(actionId);
|
||||
}
|
||||
} else if (action.equals(actionForce)) {
|
||||
confirmAndForceAction(actionId);
|
||||
} else if (action.equals(actionForceQuit)) {
|
||||
confirmAndForceQuitAction(actionId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.vaadin.event.Action[] getActions(final Object target, final Object sender) {
|
||||
final List<com.vaadin.event.Action> actions = Lists.newArrayList();
|
||||
if (target != null) {
|
||||
/* Check if the row or item belongs to active action */
|
||||
final String activeValue = (String) hierarchicalContainer.getItem(target)
|
||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue();
|
||||
if (SPUIDefinitions.ACTIVE.equals(activeValue)) {
|
||||
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(target)
|
||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
|
||||
if (!actionWithActiveStatus.isForce()) {
|
||||
actions.add(actionForce);
|
||||
}
|
||||
if (!actionWithActiveStatus.isCancelingOrCanceled()) {
|
||||
actions.add(actionCancel);
|
||||
} else {
|
||||
actions.add(actionForceQuit);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return actions.toArray(new com.vaadin.event.Action[actions.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show confirmation window and if ok then only, force the action.
|
||||
*
|
||||
@@ -747,45 +743,36 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
private void confirmAndForceAction(final Long actionId) {
|
||||
/* Display the confirmation */
|
||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.force.action.confirmbox"),
|
||||
i18n.get("message.force.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||
if (ok) {
|
||||
/* cancel the action */
|
||||
deploymentManagement.forceTargetAction(actionId);
|
||||
|
||||
/*
|
||||
* Refresh the action history table to show latest
|
||||
* change of the action cancellation and update the
|
||||
* Target Details
|
||||
*/
|
||||
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.force.action.success"));
|
||||
i18n.get("message.force.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
deploymentManagement.forceTargetAction(actionId);
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.force.action.success"));
|
||||
});
|
||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||
|
||||
confirmDialog.getWindow().bringToFront();
|
||||
}
|
||||
|
||||
private void confirmAndForceQuitAction(final Long actionId) {
|
||||
/* Display the confirmation */
|
||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"),
|
||||
i18n.get("message.forcequit.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||
if (ok) {
|
||||
final boolean cancelResult = forceQuitActiveAction(actionId);
|
||||
if (cancelResult) {
|
||||
/*
|
||||
* Refresh the action history table to show latest
|
||||
* change of the action cancellation and update the
|
||||
* Target Details
|
||||
*/
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.forcequit.action.success"));
|
||||
} else {
|
||||
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
|
||||
}
|
||||
i18n.get("message.forcequit.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
} , FontAwesome.WARNING);
|
||||
final boolean cancelResult = forceQuitActiveAction(actionId);
|
||||
if (cancelResult) {
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.forcequit.action.success"));
|
||||
} else {
|
||||
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
|
||||
}
|
||||
}, FontAwesome.WARNING);
|
||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||
|
||||
confirmDialog.getWindow().bringToFront();
|
||||
}
|
||||
|
||||
@@ -796,21 +783,21 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
||||
* as Id if the action needs to be cancelled.
|
||||
*/
|
||||
private void confirmAndCancelAction(final Long actionId) {
|
||||
if (actionId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.cancel.action.confirmbox"),
|
||||
i18n.get("message.cancel.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> {
|
||||
if (ok) {
|
||||
final boolean cancelResult = cancelActiveAction(actionId);
|
||||
if (cancelResult) {
|
||||
/*
|
||||
* Refresh the action history table to show latest
|
||||
* change of the action cancellation and update the
|
||||
* Target Details
|
||||
*/
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.cancel.action.success"));
|
||||
} else {
|
||||
notification.displayValidationError(i18n.get("message.cancel.action.failed"));
|
||||
}
|
||||
i18n.get("message.cancel.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> {
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
final boolean cancelResult = cancelActiveAction(actionId);
|
||||
if (cancelResult) {
|
||||
populateAndupdateTargetDetails(target);
|
||||
notification.displaySuccess(i18n.get("message.cancel.action.success"));
|
||||
} else {
|
||||
notification.displayValidationError(i18n.get("message.cancel.action.failed"));
|
||||
}
|
||||
});
|
||||
UI.getCurrent().addWindow(confirmDialog.getWindow());
|
||||
|
||||
@@ -8,29 +8,28 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.dstable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantMetaDataRepository;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
@@ -43,34 +42,22 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||
import org.vaadin.spring.events.EventBus;
|
||||
|
||||
import com.vaadin.data.Property.ValueChangeEvent;
|
||||
import com.vaadin.data.Property.ValueChangeListener;
|
||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||
import com.vaadin.event.FieldEvents.TextChangeListener;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.CheckBox;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.FormLayout;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* WindowContent for adding/editing a Distribution
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
private static final long serialVersionUID = -5602182034230568435L;
|
||||
|
||||
@@ -92,30 +79,18 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
private transient SystemManagement systemManagement;
|
||||
|
||||
@Autowired
|
||||
private transient TenantMetaDataRepository tenantMetaDataRepository;
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private Button saveDistributionBtn;
|
||||
private Button discardDistributionBtn;
|
||||
private TextField distNameTextField;
|
||||
private TextField distVersionTextField;
|
||||
private Label madatoryLabel;
|
||||
private TextArea descTextArea;
|
||||
private CheckBox reqMigStepCheckbox;
|
||||
private ComboBox distsetTypeNameComboBox;
|
||||
private boolean editDistribution = Boolean.FALSE;
|
||||
private Long editDistId;
|
||||
private Window addDistributionWindow;
|
||||
private String originalDistName;
|
||||
private String originalDistVersion;
|
||||
private String originalDistDescription;
|
||||
private Boolean originalReqMigStep;
|
||||
private String originalDistSetType;
|
||||
private final List<Component> changedComponents = new ArrayList<>();
|
||||
private ValueChangeListener reqMigStepCheckboxListerner;
|
||||
private TextChangeListener descTextAreaListener;
|
||||
private TextChangeListener distNameTextFieldListener;
|
||||
private TextChangeListener distVersionTextFieldListener;
|
||||
private ValueChangeListener distsetTypeNameComboBoxListener;
|
||||
private CommonDialogWindow window;
|
||||
|
||||
private FormLayout formLayout;
|
||||
|
||||
/**
|
||||
* Initialize Distribution Add and Edit Window.
|
||||
@@ -127,74 +102,52 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
private void buildLayout() {
|
||||
/* action button layout ( save & discard ) */
|
||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
||||
buttonsLayout.setSizeFull();
|
||||
buttonsLayout.setStyleName("dist-buttons-horz-layout");
|
||||
buttonsLayout.addComponents(saveDistributionBtn, discardDistributionBtn);
|
||||
buttonsLayout.setComponentAlignment(saveDistributionBtn, Alignment.BOTTOM_LEFT);
|
||||
buttonsLayout.setComponentAlignment(discardDistributionBtn, Alignment.BOTTOM_RIGHT);
|
||||
buttonsLayout.addStyleName("window-style");
|
||||
|
||||
/*
|
||||
* The main layout of the window contains mandatory info, textboxes
|
||||
* (controller Id, name & description) and action buttons layout
|
||||
*/
|
||||
setSpacing(Boolean.TRUE);
|
||||
addStyleName("lay-color");
|
||||
setSizeUndefined();
|
||||
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
|
||||
reqMigStepCheckbox);
|
||||
|
||||
addComponent(buttonsLayout);
|
||||
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
|
||||
|
||||
formLayout = new FormLayout();
|
||||
formLayout.addComponent(distsetTypeNameComboBox);
|
||||
formLayout.addComponent(distNameTextField);
|
||||
formLayout.addComponent(distVersionTextField);
|
||||
formLayout.addComponent(descTextArea);
|
||||
formLayout.addComponent(reqMigStepCheckbox);
|
||||
|
||||
setCompositionRoot(formLayout);
|
||||
distNameTextField.focus();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create required UI components.
|
||||
*/
|
||||
private void createRequiredComponents() {
|
||||
distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
distNameTextField.setId(SPUIComponetIdProvider.DIST_ADD_NAME);
|
||||
distNameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
||||
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
|
||||
distNameTextField.setNullRepresentation("");
|
||||
|
||||
distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
||||
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
distVersionTextField.setId(SPUIComponetIdProvider.DIST_ADD_VERSION);
|
||||
distVersionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
||||
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
|
||||
distVersionTextField.setNullRepresentation("");
|
||||
|
||||
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
|
||||
i18n.get("label.combobox.type"));
|
||||
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, "",
|
||||
false, "", i18n.get("label.combobox.type"));
|
||||
distsetTypeNameComboBox.setImmediate(true);
|
||||
distsetTypeNameComboBox.setNullSelectionAllowed(false);
|
||||
distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
|
||||
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
||||
populateDistSetTypeNameCombo();
|
||||
|
||||
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
|
||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
descTextArea.setId(SPUIComponetIdProvider.DIST_ADD_DESC);
|
||||
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
||||
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
|
||||
descTextArea.setNullRepresentation("");
|
||||
|
||||
/* Label for mandatory symbol */
|
||||
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
||||
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
||||
|
||||
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
|
||||
"dist-checkbox-style", null, false, "");
|
||||
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
|
||||
reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
|
||||
|
||||
/* save or update button */
|
||||
saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
|
||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
||||
saveDistributionBtn.addClickListener(event -> saveDistribution());
|
||||
|
||||
/* close button */
|
||||
discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
|
||||
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
discardDistributionBtn.addClickListener(event -> discardDistribution());
|
||||
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,28 +169,17 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
return disttypeContainer;
|
||||
}
|
||||
|
||||
private void enableSaveButton() {
|
||||
saveDistributionBtn.setEnabled(true);
|
||||
}
|
||||
|
||||
private DistributionSetType getDefaultDistributionSetType() {
|
||||
final TenantMetaData tenantMetaData = tenantMetaDataRepository
|
||||
.findByTenantIgnoreCase(systemManagement.currentTenant());
|
||||
final TenantMetaData tenantMetaData = systemManagement.getTenantMetadata();
|
||||
return tenantMetaData.getDefaultDsType();
|
||||
}
|
||||
|
||||
private void disableSaveButton() {
|
||||
saveDistributionBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
private void saveDistribution() {
|
||||
/* add new or update target */
|
||||
if (editDistribution) {
|
||||
updateDistribution();
|
||||
} else {
|
||||
addNewDistribution();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,7 +191,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
final String distSetTypeName = HawkbitCommonUtil
|
||||
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
|
||||
|
||||
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
|
||||
if (duplicateCheck(name, version)) {
|
||||
final DistributionSet currentDS = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
|
||||
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
|
||||
@@ -267,23 +209,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
notificationMessage.displayValidationError(
|
||||
i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion()));
|
||||
}
|
||||
closeThisWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
reqMigStepCheckboxListerner = event -> checkValueChanged(originalReqMigStep, event);
|
||||
descTextAreaListener = event -> checkValueChanged(originalDistDescription, event);
|
||||
distNameTextFieldListener = event -> checkValueChanged(originalDistName, event);
|
||||
distVersionTextFieldListener = event -> checkValueChanged(originalDistVersion, event);
|
||||
distsetTypeNameComboBoxListener = event -> checkValueChanged(originalDistSetType, event);
|
||||
reqMigStepCheckbox.addValueChangeListener(reqMigStepCheckboxListerner);
|
||||
descTextArea.addTextChangeListener(descTextAreaListener);
|
||||
distNameTextField.addTextChangeListener(distNameTextFieldListener);
|
||||
distVersionTextField.addTextChangeListener(distVersionTextFieldListener);
|
||||
distsetTypeNameComboBox.addValueChangeListener(distsetTypeNameComboBoxListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Distribution set.
|
||||
*/
|
||||
@@ -294,31 +222,21 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
final String distSetTypeName = HawkbitCommonUtil
|
||||
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
|
||||
|
||||
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
|
||||
if (duplicateCheck(name, version)) {
|
||||
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
|
||||
DistributionSet newDist = new DistributionSet();
|
||||
DistributionSet newDist = entityFactory.generateDistributionSet();
|
||||
|
||||
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
|
||||
newDist = distributionSetManagement.createDistributionSet(newDist);
|
||||
|
||||
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
||||
new Object[] { newDist.getName(), newDist.getVersion() }));
|
||||
/* close the window */
|
||||
closeThisWindow();
|
||||
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.NEW_ENTITY, newDist));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close window.
|
||||
*/
|
||||
private void closeThisWindow() {
|
||||
addDistributionWindow.close();
|
||||
UI.getCurrent().removeWindow(addDistributionWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Values for Distribution set.
|
||||
*
|
||||
@@ -362,47 +280,6 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mandatory Check.
|
||||
*
|
||||
* @param name
|
||||
* as String
|
||||
* @param version
|
||||
* as String
|
||||
* @param selectedJVM
|
||||
* as String
|
||||
* @param selectedAgentHub
|
||||
* as String
|
||||
* @param selectedOs
|
||||
* as String
|
||||
* @return boolean as flag
|
||||
*/
|
||||
private boolean mandatoryCheck(final String name, final String version, final String distSetTypeName) {
|
||||
|
||||
if (name == null || version == null || distSetTypeName == null) {
|
||||
if (name == null) {
|
||||
distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||
}
|
||||
if (version == null) {
|
||||
distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||
}
|
||||
if (distSetTypeName == null) {
|
||||
distsetTypeNameComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
|
||||
}
|
||||
|
||||
notificationMessage.displayValidationError(i18n.get("message.mandatory.check"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void discardDistribution() {
|
||||
/* Just close this window */
|
||||
distsetTypeNameComboBox.removeValueChangeListener(distsetTypeNameComboBoxListener);
|
||||
closeThisWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the fields.
|
||||
*/
|
||||
@@ -415,134 +292,52 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
||||
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
|
||||
descTextArea.clear();
|
||||
reqMigStepCheckbox.clear();
|
||||
saveDistributionBtn.setEnabled(true);
|
||||
removeListeners();
|
||||
changedComponents.clear();
|
||||
|
||||
}
|
||||
|
||||
private void populateRequiredComponents() {
|
||||
populateDistSetTypeNameCombo();
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
reqMigStepCheckbox.removeValueChangeListener(reqMigStepCheckboxListerner);
|
||||
descTextArea.removeTextChangeListener(descTextAreaListener);
|
||||
distNameTextField.removeTextChangeListener(distNameTextFieldListener);
|
||||
distVersionTextField.removeTextChangeListener(distVersionTextFieldListener);
|
||||
}
|
||||
|
||||
public void setOriginalDistName(final String originalDistName) {
|
||||
this.originalDistName = originalDistName;
|
||||
}
|
||||
|
||||
public void setOriginalDistVersion(final String originalDistVersion) {
|
||||
this.originalDistVersion = originalDistVersion;
|
||||
}
|
||||
|
||||
public void setOriginalDistDescription(final String originalDistDescription) {
|
||||
this.originalDistDescription = originalDistDescription;
|
||||
}
|
||||
|
||||
private void checkValueChanged(final String originalValue, final TextChangeEvent event) {
|
||||
if (editDistribution) {
|
||||
final String newValue = event.getText();
|
||||
if (!originalValue.equalsIgnoreCase(newValue)) {
|
||||
changedComponents.add(event.getComponent());
|
||||
} else {
|
||||
changedComponents.remove(event.getComponent());
|
||||
}
|
||||
enableDisableSaveButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkValueChanged(final Boolean originalValue, final ValueChangeEvent event) {
|
||||
if (editDistribution) {
|
||||
if (!originalValue.equals(event.getProperty().getValue())) {
|
||||
changedComponents.add(reqMigStepCheckbox);
|
||||
} else {
|
||||
changedComponents.remove(reqMigStepCheckbox);
|
||||
}
|
||||
enableDisableSaveButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkValueChanged(final String originalValue, final ValueChangeEvent event) {
|
||||
if (editDistribution) {
|
||||
if (!originalValue.equals(event.getProperty().getValue())) {
|
||||
changedComponents.add(distsetTypeNameComboBox);
|
||||
} else {
|
||||
changedComponents.remove(distsetTypeNameComboBox);
|
||||
}
|
||||
enableDisableSaveButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void enableDisableSaveButton() {
|
||||
if (changedComponents.isEmpty()) {
|
||||
disableSaveButton();
|
||||
} else {
|
||||
enableSaveButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void setOriginalReqMigStep(final Boolean originalReqMigStep) {
|
||||
this.originalReqMigStep = originalReqMigStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* populate data.
|
||||
*
|
||||
* @param editDistId
|
||||
*/
|
||||
public void populateValuesOfDistribution(final Long editDistId) {
|
||||
private void populateValuesOfDistribution(final Long editDistId) {
|
||||
this.editDistId = editDistId;
|
||||
editDistribution = Boolean.TRUE;
|
||||
saveDistributionBtn.setEnabled(false);
|
||||
|
||||
if (editDistId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
|
||||
if (distSet != null) {
|
||||
distNameTextField.setValue(distSet.getName());
|
||||
distVersionTextField.setValue(distSet.getVersion());
|
||||
if (distSet.getType().isDeleted()) {
|
||||
distsetTypeNameComboBox.addItem(distSet.getType().getName());
|
||||
}
|
||||
distsetTypeNameComboBox.setValue(distSet.getType().getName());
|
||||
reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
|
||||
if (distSet.getDescription() != null) {
|
||||
descTextArea.setValue(distSet.getDescription());
|
||||
}
|
||||
setOriginalDistName(distSet.getName());
|
||||
setOriginalDistVersion(distSet.getVersion());
|
||||
setOriginalDistDescription(distSet.getDescription());
|
||||
setOriginalReqMigStep(distSet.isRequiredMigrationStep());
|
||||
setOriginalDistSetTYpe(distSet.getType().getName());
|
||||
addListeners();
|
||||
if (distSet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
editDistribution = Boolean.TRUE;
|
||||
distNameTextField.setValue(distSet.getName());
|
||||
distVersionTextField.setValue(distSet.getVersion());
|
||||
if (distSet.getType().isDeleted()) {
|
||||
distsetTypeNameComboBox.addItem(distSet.getType().getName());
|
||||
}
|
||||
distsetTypeNameComboBox.setValue(distSet.getType().getName());
|
||||
reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
|
||||
if (distSet.getDescription() != null) {
|
||||
descTextArea.setValue(distSet.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
public CommonDialogWindow getWindow(final Long editDistId) {
|
||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||
populateRequiredComponents();
|
||||
resetComponents();
|
||||
addDistributionWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.dist"), null,
|
||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
||||
addDistributionWindow.setContent(this);
|
||||
return addDistributionWindow;
|
||||
populateDistSetTypeNameCombo();
|
||||
populateValuesOfDistribution(editDistId);
|
||||
window = SPUIWindowDecorator.getWindow(i18n.get("caption.add.new.dist"), null,
|
||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> saveDistribution(), null, null, formLayout, i18n);
|
||||
window.getButtonsLayout().removeStyleName("actionButtonsMargin");
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate DistributionSet Type name combo.
|
||||
*/
|
||||
public void populateDistSetTypeNameCombo() {
|
||||
private void populateDistSetTypeNameCombo() {
|
||||
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
|
||||
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param originalDistSetTYpe
|
||||
* the originalDistSetTYpe to set
|
||||
*/
|
||||
public void setOriginalDistSetTYpe(final String originalDistSetType) {
|
||||
this.originalDistSetType = originalDistSetType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
||||
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
@@ -42,11 +42,11 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
||||
|
||||
private static final long serialVersionUID = 5862679853949173536L;
|
||||
private Sort sort = new Sort(Direction.ASC, "name", "version");
|
||||
private Collection<String> distributionTags = null;
|
||||
private String searchText = null;
|
||||
private String pinnedControllerId = null;
|
||||
private Collection<String> distributionTags;
|
||||
private String searchText;
|
||||
private String pinnedControllerId;
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
private transient Page<DistributionSet> firstPageDistributionSets = null;
|
||||
private transient Page<DistributionSet> firstPageDistributionSets;
|
||||
private Boolean noTagClicked = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
@@ -110,8 +110,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
||||
pinnedControllerId);
|
||||
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
||||
// if no search filters available
|
||||
distBeans = getDistributionSetManagement()
|
||||
.findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true);
|
||||
distBeans = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
|
||||
new OffsetBasedPageRequest(startIndex, count, sort), false, true);
|
||||
} else {
|
||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
||||
@@ -129,7 +129,6 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
||||
proxyDistribution.setVersion(distributionSet.getVersion());
|
||||
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
|
||||
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
|
||||
proxyDistribution.setDescription(distributionSet.getDescription());
|
||||
proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
|
||||
proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
|
||||
proxyDistribution.setNameVersion(
|
||||
@@ -152,8 +151,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
||||
pinnedControllerId);
|
||||
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
||||
// if no search filters available
|
||||
firstPageDistributionSets = getDistributionSetManagement()
|
||||
.findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
|
||||
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsByDeletedAndOrCompleted(
|
||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
|
||||
} else {
|
||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
@@ -77,8 +77,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
|
||||
@Override
|
||||
protected void onEdit(final ClickEvent event) {
|
||||
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
|
||||
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
|
||||
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(getSelectedBaseEntityId());
|
||||
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
|
||||
UI.getCurrent().addWindow(newDistWindow);
|
||||
newDistWindow.setVisible(Boolean.TRUE);
|
||||
@@ -86,7 +85,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
|
||||
@Override
|
||||
protected String getEditButtonId() {
|
||||
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
|
||||
return SPUIComponentIdProvider.DS_EDIT_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +106,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
|
||||
@Override
|
||||
protected String getTabSheetId() {
|
||||
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_TABSHEET;
|
||||
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_TABSHEET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,7 +131,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
if (type != null) {
|
||||
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
|
||||
type);
|
||||
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
typeLabel.setId(SPUIComponentIdProvider.DETAILS_TYPE_LABEL_ID);
|
||||
detailsTabLayout.addComponent(typeLabel);
|
||||
}
|
||||
|
||||
@@ -158,7 +157,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
|
||||
@Override
|
||||
protected String getDetailsHeaderCaptionId() {
|
||||
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
|
||||
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user