Clean Code Refactoring

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-02-09 10:16:07 +01:00
parent 9ae2ef0bc0
commit 1bb29338ac
35 changed files with 1614 additions and 1669 deletions

View File

@@ -75,7 +75,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private SpringViewProvider viewProvider;
@Autowired
private ApplicationContext context;
private transient ApplicationContext context;
@Autowired
private I18N i18n;
@@ -89,13 +89,13 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private ErrorView errorview;
@Autowired
protected EventBus.SessionEventBus eventBus;
protected transient EventBus.SessionEventBus eventBus;
/**
* An {@link com.google.common.eventbus.EventBus} subscriber which
* subscribes {@link EntityEvent} from the repository to dispatch these
* events to the UI {@link SessionEventBus}.
*
*
* @param event
* the entity event which has been published from the repository
*/
@@ -103,21 +103,28 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@AllowConcurrentEvents
public void dispatch(final org.eclipse.hawkbit.eventbus.event.Event event) {
final VaadinSession session = getSession();
if (session != null && session.getState() == State.OPEN) {
final WrappedSession wrappedSession = session.getSession();
if (wrappedSession != null) {
final SecurityContext userContext = (SecurityContext) wrappedSession
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
if (eventSecurityCheck(userContext, event)) {
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
access(new DispatcherRunnable(eventBus, session, userContext, event));
} finally {
SecurityContextHolder.setContext(oldContext);
}
}
}
if (session == null || session.getState() != State.OPEN) {
return;
}
final WrappedSession wrappedSession = session.getSession();
if (wrappedSession == null) {
return;
}
final SecurityContext userContext = (SecurityContext) wrappedSession
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
if (!eventSecurityCheck(userContext, event)) {
return;
}
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
access(new DispatcherRunnable(this.eventBus, session, userContext, event));
} finally {
SecurityContextHolder.setContext(oldContext);
}
}
protected boolean eventSecurityCheck(final SecurityContext userContext,
@@ -134,7 +141,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
/*
* (non-Javadoc)
*
*
* @see
* com.vaadin.server.ClientConnector.DetachListener#detach(com.vaadin.server
* .ClientConnector. DetachEvent)
@@ -149,7 +156,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
protected void init(final VaadinRequest vaadinRequest) {
LOG.info("ManagementUI init starts uiid - {}", getUI().getUIId());
addDetachListener(this);
SpringContextHelper.setContext(context);
SpringContextHelper.setContext(this.context);
Responsive.makeResponsive(this);
addStyleName(ValoTheme.UI_WITH_MENU);
@@ -158,25 +165,25 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
final HorizontalLayout rootLayout = new HorizontalLayout();
rootLayout.setSizeFull();
dashboardMenu.init();
dashboardMenu.setResponsive(Boolean.TRUE);
this.dashboardMenu.init();
this.dashboardMenu.setResponsive(Boolean.TRUE);
final VerticalLayout contentVerticalLayout = new VerticalLayout();
contentVerticalLayout.addComponent(buildHeader());
contentVerticalLayout.setSizeFull();
rootLayout.addComponent(dashboardMenu);
rootLayout.addComponent(this.dashboardMenu);
rootLayout.addComponent(contentVerticalLayout);
content = new HorizontalLayout();
contentVerticalLayout.addComponent(content);
content.setStyleName("view-content");
content.setSizeFull();
this.content = new HorizontalLayout();
contentVerticalLayout.addComponent(this.content);
this.content.setStyleName("view-content");
this.content.setSizeFull();
rootLayout.setExpandRatio(contentVerticalLayout, 1.0f);
contentVerticalLayout.setStyleName("main-content");
contentVerticalLayout.setExpandRatio(content, 1.0F);
contentVerticalLayout.setExpandRatio(this.content, 1.0F);
setContent(rootLayout);
final Resource resource = context
final Resource resource = this.context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
@@ -185,7 +192,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
} catch (final IOException ex) {
LOG.error("Footer file is missing", ex);
}
final Navigator navigator = new Navigator(this, content);
final Navigator navigator = new Navigator(this, this.content);
navigator.addViewChangeListener(new ViewChangeListener() {
@Override
public boolean beforeViewChange(final ViewChangeEvent event) {
@@ -194,17 +201,17 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@Override
public void afterViewChange(final ViewChangeEvent event) {
final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
dashboardMenu.postViewChange(new PostViewChangeEvent(view));
final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(event.getViewName());
HawkbitUI.this.dashboardMenu.postViewChange(new PostViewChangeEvent(view));
if (view == null) {
content.setCaption(null);
HawkbitUI.this.content.setCaption(null);
return;
}
content.setCaption(view.getDashboardCaptionLong());
HawkbitUI.this.content.setCaption(view.getDashboardCaptionLong());
}
});
navigator.setErrorView(errorview);
navigator.setErrorView(this.errorview);
navigator.addProvider(new ManagementViewProvider());
setNavigator(navigator);
navigator.addView(EMPTY_VIEW, new Navigator.EmptyView());
@@ -214,7 +221,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
setLocale(new Locale(locale));
UI.getCurrent().setErrorHandler(new SPUIErrorHandler());
LOG.info("Current locale of the application is : {}", i18n.getLocale());
LOG.info("Current locale of the application is : {}", this.i18n.getLocale());
}
private Component buildHeader() {
@@ -225,7 +232,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
/**
* Get Specific Locale.
*
*
* @param availableLocalesInApp
* as set
* @return String as preferred locale
@@ -269,20 +276,20 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
@Override
public String getViewName(final String viewAndParameters) {
return viewProvider.getViewName(getStartView(viewAndParameters));
return HawkbitUI.this.viewProvider.getViewName(getStartView(viewAndParameters));
}
@Override
public View getView(final String viewName) {
return viewProvider.getView(getStartView(viewName));
return HawkbitUI.this.viewProvider.getView(getStartView(viewName));
}
private String getStartView(final String viewName) {
final DashboardMenuItem view = dashboardMenu.getByViewName(viewName);
if ("".equals(viewName) && !dashboardMenu.isAccessibleViewsEmpty()) {
return dashboardMenu.getInitialViewName();
final DashboardMenuItem view = HawkbitUI.this.dashboardMenu.getByViewName(viewName);
if ("".equals(viewName) && !HawkbitUI.this.dashboardMenu.isAccessibleViewsEmpty()) {
return HawkbitUI.this.dashboardMenu.getInitialViewName();
}
if (view == null || dashboardMenu.isAccessDenied(viewName)) {
if (view == null || HawkbitUI.this.dashboardMenu.isAccessDenied(viewName)) {
return " ";
}
return viewName;

View File

@@ -44,9 +44,9 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract layout of confirm actions window.
*
*
*
*
*
*/
@SpringComponent
@ViewScope
@@ -84,18 +84,18 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.confirmwindow.layout.
* AbstractConfirmationWindowLayout# getConfimrationTabs()
*/
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<String, ConfirmationTab>();
if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) {
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
final Map<String, ConfirmationTab> tabs = new HashMap<>();
if (!this.artifactUploadState.getDeleteSofwareModules().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
}
if (!artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
if (!this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
}
return tabs;
}
@@ -105,10 +105,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
tab.getDiscardAll().setCaption(i18n.get("button.discard.all"));
tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all"));
tab.getDiscardAll().addClickListener(event -> discardSMAll(tab));
// Add items container to the table.
@@ -131,8 +131,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_NAME_MSG);
visibleColumnIds.add(SW_DISCARD_CHGS);
visibleColumnLabels.add(i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -145,7 +145,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
/**
* Get SWModule table container.
*
*
* @return IndexedContainer
*/
@SuppressWarnings("unchecked")
@@ -153,12 +153,11 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
final IndexedContainer swcontactContainer = new IndexedContainer();
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
Item item = null;
for (final Long swModuleID : artifactUploadState.getDeleteSofwareModules().keySet()) {
item = swcontactContainer.addItem(swModuleID);
for (final Long swModuleID : this.artifactUploadState.getDeleteSofwareModules().keySet()) {
final Item item = swcontactContainer.addItem(swModuleID);
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
item.getItemProperty(SW_MODULE_NAME_MSG)
.setValue(artifactUploadState.getDeleteSofwareModules().get(swModuleID));
.setValue(this.artifactUploadState.getDeleteSofwareModules().get(swModuleID));
}
return swcontactContainer;
}
@@ -166,56 +165,56 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final Long swmoduleId = (Long) ((Button) event.getComponent()).getData();
if (null != artifactUploadState.getDeleteSofwareModules()
&& !artifactUploadState.getDeleteSofwareModules().isEmpty()
&& artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) {
artifactUploadState.getDeleteSofwareModules().remove(swmoduleId);
if (null != this.artifactUploadState.getDeleteSofwareModules()
&& !this.artifactUploadState.getDeleteSofwareModules().isEmpty()
&& this.artifactUploadState.getDeleteSofwareModules().containsKey(swmoduleId)) {
this.artifactUploadState.getDeleteSofwareModules().remove(swmoduleId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
} else {
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE);
}
}
private void deleteSMAll(final ConfirmationTab tab) {
final Set<Long> swmoduleIds = artifactUploadState.getDeleteSofwareModules().keySet();
softwareManagement.deleteSoftwareModules(swmoduleIds);
final Set<Long> swmoduleIds = this.artifactUploadState.getDeleteSofwareModules().keySet();
this.softwareManagement.deleteSoftwareModules(swmoduleIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size()));
+ this.i18n.get("message.swModule.deleted", this.artifactUploadState.getDeleteSofwareModules().size()));
/*
* Check if any information / files pending to upload for the deleted
* software modules. If so, then delete the files from the upload list.
*/
final List<CustomFile> tobeRemoved = new ArrayList<>();
for (final Long id : swmoduleIds) {
final String deleteSoftwareNameVersion = artifactUploadState.getDeleteSofwareModules().get(id);
final String deleteSoftwareNameVersion = this.artifactUploadState.getDeleteSofwareModules().get(id);
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
for (final CustomFile customFile : this.artifactUploadState.getFileSelected()) {
final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion(
customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
if (HawkbitCommonUtil.bothSame(deleteSoftwareNameVersion, swNameVersion)) {
if (deleteSoftwareNameVersion != null && deleteSoftwareNameVersion.equals(swNameVersion)) {
tobeRemoved.add(customFile);
}
}
}
if (!tobeRemoved.isEmpty()) {
artifactUploadState.getFileSelected().removeAll(tobeRemoved);
this.artifactUploadState.getFileSelected().removeAll(tobeRemoved);
}
artifactUploadState.getDeleteSofwareModules().clear();
this.artifactUploadState.getDeleteSofwareModules().clear();
removeCurrentTab(tab);
setActionMessage(i18n.get("message.software.delete.success"));
eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE);
setActionMessage(this.i18n.get("message.software.delete.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE);
}
private void discardSMAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
artifactUploadState.getDeleteSofwareModules().clear();
setActionMessage(i18n.get("message.software.discard.success"));
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
this.artifactUploadState.getDeleteSofwareModules().clear();
setActionMessage(this.i18n.get("message.software.discard.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE);
}
private ConfirmationTab createSMtypeDeleteConfirmationTab() {
@@ -223,10 +222,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get("button.delete.all"));
tab.getConfirmAll().setCaption(this.i18n.get("button.delete.all"));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
tab.getDiscardAll().setCaption(i18n.get("button.discard.all"));
tab.getDiscardAll().setCaption(this.i18n.get("button.discard.all"));
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
// Add items container to the table.
@@ -252,8 +251,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_TYPE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -271,7 +270,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, "");
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) {
final Item saveTblitem = contactContainer.addItem(swModuleTypeName);
saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(swModuleTypeName);
}
@@ -280,40 +279,40 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) {
if (null != artifactUploadState.getSelectedDeleteSWModuleTypes()
&& !artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()
&& artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
if (null != this.artifactUploadState.getSelectedDeleteSWModuleTypes()
&& !this.artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()
&& this.artifactUploadState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
this.artifactUploadState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
} else {
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE);
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_DELETE_SOFTWARE_TYPE);
}
}
private void deleteSMtypeAll(final ConfirmationTab tab) {
final int deleteSWModuleTypeCount = artifactUploadState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
final int deleteSWModuleTypeCount = this.artifactUploadState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : this.artifactUploadState.getSelectedDeleteSWModuleTypes()) {
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
this.softwareManagement
.deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
+ this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
removeCurrentTab(tab);
setActionMessage(i18n.get("message.software.type.delete.success"));
eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE);
setActionMessage(this.i18n.get("message.software.type.delete.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE);
}
private void discardSMtypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(i18n.get("message.software.type.discard.success"));
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
this.artifactUploadState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(this.i18n.get("message.software.type.discard.success"));
this.eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE);
}
}

View File

@@ -38,13 +38,13 @@ public class ArtifactUploadState implements Serializable {
private final Map<Long, String> deleteSofwareModules = new HashMap<>();
private final Set<CustomFile> fileSelected = new HashSet<CustomFile>();
private final Set<CustomFile> fileSelected = new HashSet<>();
private Long selectedBaseSwModuleId;
private SoftwareModule selectedBaseSoftwareModule;
private final Map<String, SoftwareModule> baseSwModuleList = new HashMap<String, SoftwareModule>();
private final Map<String, SoftwareModule> baseSwModuleList = new HashMap<>();
private Set<Long> selectedSoftwareModules = Collections.emptySet();
@@ -60,25 +60,25 @@ public class ArtifactUploadState implements Serializable {
/**
* Set software.
*
*
* @return
*/
public SoftwareModuleFilters getSoftwareModuleFilters() {
return softwareModuleFilters;
return this.softwareModuleFilters;
}
/**
* @return the selectedSofwareModules
*/
public Map<Long, String> getDeleteSofwareModules() {
return deleteSofwareModules;
return this.deleteSofwareModules;
}
/**
* @return the fileSelected
*/
public Set<CustomFile> getFileSelected() {
return fileSelected;
return this.fileSelected;
}
/**
@@ -116,14 +116,14 @@ public class ArtifactUploadState implements Serializable {
* @return the baseSwModuleList
*/
public Map<String, SoftwareModule> getBaseSwModuleList() {
return baseSwModuleList;
return this.baseSwModuleList;
}
/**
* @return the selectedSoftwareModules
*/
public Set<Long> getSelectedSoftwareModules() {
return selectedSoftwareModules;
return this.selectedSoftwareModules;
}
/**
@@ -138,7 +138,7 @@ public class ArtifactUploadState implements Serializable {
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return swTypeFilterClosed;
return this.swTypeFilterClosed;
}
/**
@@ -153,7 +153,7 @@ public class ArtifactUploadState implements Serializable {
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return isSwModuleTableMaximized;
return this.isSwModuleTableMaximized;
}
/**
@@ -165,14 +165,14 @@ public class ArtifactUploadState implements Serializable {
}
public Set<String> getSelectedDeleteSWModuleTypes() {
return selectedDeleteSWModuleTypes;
return this.selectedDeleteSWModuleTypes;
}
/**
* @return the isArtifactDetailsMaximized
*/
public boolean isArtifactDetailsMaximized() {
return isArtifactDetailsMaximized;
return this.isArtifactDetailsMaximized;
}
/**
@@ -187,7 +187,7 @@ public class ArtifactUploadState implements Serializable {
* @return the noDataAvilableSoftwareModule
*/
public boolean isNoDataAvilableSoftwareModule() {
return noDataAvilableSoftwareModule;
return this.noDataAvilableSoftwareModule;
}
/**

View File

@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.state;
import java.io.Serializable;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
/**
* Custom file to hold details of uploaded file.
*
@@ -98,7 +96,7 @@ public class CustomFile implements Serializable {
}
public String getBaseSoftwareModuleName() {
return baseSoftwareModuleName;
return this.baseSoftwareModuleName;
}
public void setBaseSoftwareModuleName(final String baseSoftwareModuleName) {
@@ -106,7 +104,7 @@ public class CustomFile implements Serializable {
}
public String getBaseSoftwareModuleVersion() {
return baseSoftwareModuleVersion;
return this.baseSoftwareModuleVersion;
}
public void setBaseSoftwareModuleVersion(final String baseSoftwareModuleVersion) {
@@ -114,11 +112,11 @@ public class CustomFile implements Serializable {
}
public String getFileName() {
return fileName;
return this.fileName;
}
public long getFileSize() {
return fileSize;
return this.fileSize;
}
public void setFileSize(final long fileSize) {
@@ -126,7 +124,7 @@ public class CustomFile implements Serializable {
}
public String getFilePath() {
return filePath;
return this.filePath;
}
public void setFilePath(final String filePath) {
@@ -134,7 +132,7 @@ public class CustomFile implements Serializable {
}
public String getMimeType() {
return mimeType;
return this.mimeType;
}
/**
@@ -142,7 +140,7 @@ public class CustomFile implements Serializable {
* @return the isValid
*/
public Boolean getIsValid() {
return isValid;
return this.isValid;
}
/**
@@ -165,39 +163,54 @@ public class CustomFile implements Serializable {
* @return the failureReason
*/
public String getFailureReason() {
return failureReason;
return this.failureReason;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() { // NOSONAR - as this is generated
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (fileName == null ? 0 : fileName.hashCode());
result = prime * result + ((this.baseSoftwareModuleName == null) ? 0 : this.baseSoftwareModuleName.hashCode());
result = prime * result
+ ((this.baseSoftwareModuleVersion == null) ? 0 : this.baseSoftwareModuleVersion.hashCode());
result = prime * result + ((this.fileName == null) ? 0 : this.fileName.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CustomFile)) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CustomFile other = (CustomFile) obj;
return HawkbitCommonUtil.bothSame(fileName, other.fileName)
&& HawkbitCommonUtil.bothSame(baseSoftwareModuleName, other.baseSoftwareModuleName)
&& HawkbitCommonUtil.bothSame(baseSoftwareModuleVersion, other.baseSoftwareModuleVersion);
if (this.baseSoftwareModuleName == null) {
if (other.baseSoftwareModuleName != null) {
return false;
}
} else if (!this.baseSoftwareModuleName.equals(other.baseSoftwareModuleName)) {
return false;
}
if (this.baseSoftwareModuleVersion == null) {
if (other.baseSoftwareModuleVersion != null) {
return false;
}
} else if (!this.baseSoftwareModuleVersion.equals(other.baseSoftwareModuleVersion)) {
return false;
}
if (this.fileName == null) {
if (other.fileName != null) {
return false;
}
} else if (!this.fileName.equals(other.fileName)) {
return false;
}
return true;
}
}

View File

@@ -8,8 +8,6 @@
*/
package org.eclipse.hawkbit.ui.common.filterlayout;
import java.util.Optional;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.ui.Button;
@@ -17,20 +15,20 @@ import com.vaadin.ui.Button.ClickEvent;
/**
* Abstract Single button click behaviour of filter buttons layout.
*
*
*
*
*
*
*/
public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButtonClickBehaviour {
private static final long serialVersionUID = 478874092615793581L;
private Optional<Button> alreadyClickedButton = Optional.empty();
private Button alreadyClickedButton;
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClick#
* processFilterButtonClick(com.vaadin.ui. Button.ClickEvent)
*/
@@ -40,18 +38,18 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
if (isButtonUnClicked(clickedButton)) {
/* If same button clicked */
clickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
alreadyClickedButton = Optional.empty();
this.alreadyClickedButton = null;
filterUnClicked(clickedButton);
} else if (alreadyClickedButton.isPresent()) {
} else if (this.alreadyClickedButton != null) {
/* If button clicked and some other button is already clicked */
alreadyClickedButton.get().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
this.alreadyClickedButton.removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
alreadyClickedButton = Optional.of(clickedButton);
this.alreadyClickedButton = clickedButton;
filterClicked(clickedButton);
} else {
/* If button clicked and not other button is clicked currently */
clickedButton.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
alreadyClickedButton = Optional.of(clickedButton);
this.alreadyClickedButton = clickedButton;
filterClicked(clickedButton);
}
}
@@ -61,21 +59,19 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
* @return
*/
private boolean isButtonUnClicked(final Button clickedButton) {
return alreadyClickedButton.isPresent() && alreadyClickedButton.get().equals(clickedButton);
return this.alreadyClickedButton != null && this.alreadyClickedButton.equals(clickedButton);
}
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#
* setDefaultClickedButton(com.vaadin .ui.Button)
*/
@Override
protected void setDefaultClickedButton(final Button button) {
if (button == null) {
alreadyClickedButton = Optional.empty();
} else {
alreadyClickedButton = Optional.of(button);
this.alreadyClickedButton = button;
if (button != null) {
button.addStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
}
}
@@ -83,15 +79,15 @@ public abstract class AbstractFilterSingleButtonClick extends AbstractFilterButt
/**
* @return the alreadyClickedButton
*/
public Optional<Button> getAlreadyClickedButton() {
return alreadyClickedButton;
public Button getAlreadyClickedButton() {
return this.alreadyClickedButton;
}
/**
* @param alreadyClickedButton
* the alreadyClickedButton to set
*/
public void setAlreadyClickedButton(final Optional<Button> alreadyClickedButton) {
public void setAlreadyClickedButton(final Button alreadyClickedButton) {
this.alreadyClickedButton = alreadyClickedButton;
}

View File

@@ -32,7 +32,7 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract class for target/ds tag token layout.
*
*
*
*
*
@@ -47,9 +47,9 @@ public abstract class AbstractTagToken implements Serializable {
protected IndexedContainer container;
protected final Map<Long, TagData> tagDetails = new HashMap<Long, TagData>();
protected final Map<Long, TagData> tagDetails = new HashMap<>();
protected final Map<Long, TagData> tokensAdded = new HashMap<Long, TagData>();
protected final Map<Long, TagData> tokensAdded = new HashMap<>();
protected CssLayout tokenLayout = new CssLayout();
@@ -63,16 +63,16 @@ public abstract class AbstractTagToken implements Serializable {
private void createTokenField() {
final Container tokenContainer = createContainer();
tokenField = createTokenField(tokenContainer);
tokenField.setContainerDataSource(tokenContainer);
tokenField.setNewTokensAllowed(false);
tokenField.setFilteringMode(FilteringMode.CONTAINS);
tokenField.setInputPrompt(getTokenInputPrompt());
tokenField.setTokenInsertPosition(InsertPosition.AFTER);
tokenField.setImmediate(true);
tokenField.addStyleName(ValoTheme.COMBOBOX_TINY);
tokenField.setSizeFull();
tokenField.setTokenCaptionPropertyId("name");
this.tokenField = createTokenField(tokenContainer);
this.tokenField.setContainerDataSource(tokenContainer);
this.tokenField.setNewTokensAllowed(false);
this.tokenField.setFilteringMode(FilteringMode.CONTAINS);
this.tokenField.setInputPrompt(getTokenInputPrompt());
this.tokenField.setTokenInsertPosition(InsertPosition.AFTER);
this.tokenField.setImmediate(true);
this.tokenField.addStyleName(ValoTheme.COMBOBOX_TINY);
this.tokenField.setSizeFull();
this.tokenField.setTokenCaptionPropertyId("name");
}
protected void repopulateToken() {
@@ -81,26 +81,26 @@ public abstract class AbstractTagToken implements Serializable {
}
private Container createContainer() {
container = new IndexedContainer();
container.addContainerProperty("name", String.class, "");
container.addContainerProperty("id", Long.class, "");
container.addContainerProperty(COLOR_PROPERTY, String.class, "");
return container;
this.container = new IndexedContainer();
this.container.addContainerProperty("name", String.class, "");
this.container.addContainerProperty("id", Long.class, "");
this.container.addContainerProperty(COLOR_PROPERTY, String.class, "");
return this.container;
}
protected void addNewToken(final Long tagId) {
tokenField.addToken(tagId);
this.tokenField.addToken(tagId);
removeTagAssignedFromCombo(tagId);
}
private void removeTagAssignedFromCombo(final Long tagId) {
tokensAdded.put(tagId, new TagData(tagId, getTagName(tagId), getColor(tagId)));
container.removeItem(tagId);
this.tokensAdded.put(tagId, new TagData(tagId, getTagName(tagId), getColor(tagId)));
this.container.removeItem(tagId);
}
protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) {
tagDetails.put(tagId, new TagData(tagId, tagName, tagColor));
final Item item = container.addItem(tagId);
this.tagDetails.put(tagId, new TagData(tagId, tagName, tagColor));
final Item item = this.container.addItem(tagId);
item.getItemProperty("id").setValue(tagId);
updateItem(tagName, tagColor, item);
}
@@ -112,12 +112,12 @@ public abstract class AbstractTagToken implements Serializable {
protected void checkIfTagAssignedIsAllowed() {
if (!isToggleTagAssignmentAllowed()) {
tokenField.addStyleName("hideTokenFieldcombo");
this.tokenField.addStyleName("hideTokenFieldcombo");
}
}
private TokenField createTokenField(final Container tokenContainer) {
return new CustomTokenField(tokenLayout, tokenContainer);
return new CustomTokenField(this.tokenLayout, tokenContainer);
}
class CustomTokenField extends TokenField {
@@ -166,12 +166,12 @@ public abstract class AbstractTagToken implements Serializable {
}
private Property getItemNameProperty(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
return item.getItemProperty("name");
}
private String getColor(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
if (item.getItemProperty(COLOR_PROPERTY).getValue() != null) {
return (String) item.getItemProperty(COLOR_PROPERTY).getValue();
} else {
@@ -180,23 +180,23 @@ public abstract class AbstractTagToken implements Serializable {
}
private String getTagName(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId);
final Item item = this.tokenField.getContainerDataSource().getItem(tokenId);
return (String) item.getItemProperty("name").getValue();
}
private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
final Item item = this.tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(this.tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(this.tagDetails.get(tokenId).getColor());
unassignTag(this.tagDetails.get(tokenId).getName());
}
protected void removePreviouslyAddedTokens() {
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
this.tokensAdded.keySet().forEach(previouslyAddedToken -> this.tokenField.removeToken(previouslyAddedToken));
}
protected Long getTagIdByTagName(final String tagName) {
final Optional<Map.Entry<Long, TagData>> mapEntry = tagDetails.entrySet().stream()
final Optional<Map.Entry<Long, TagData>> mapEntry = this.tagDetails.entrySet().stream()
.filter(entry -> entry.getValue().getName().equals(tagName)).findFirst();
if (mapEntry.isPresent()) {
return mapEntry.get().getKey();
@@ -205,13 +205,13 @@ public abstract class AbstractTagToken implements Serializable {
}
protected void removeTokenItem(final Long tokenId, final String name) {
tokenField.removeToken(tokenId);
setContainerPropertValues(tokenId, name, tokensAdded.get(tokenId).getColor());
this.tokenField.removeToken(tokenId);
setContainerPropertValues(tokenId, name, this.tokensAdded.get(tokenId).getColor());
}
protected void removeTagFromCombo(final Long deletedTagId) {
if (deletedTagId != null) {
container.removeItem(deletedTagId);
this.container.removeItem(deletedTagId);
}
}
@@ -230,14 +230,16 @@ public abstract class AbstractTagToken implements Serializable {
protected abstract void populateContainer();
public TokenField getTokenField() {
return tokenField;
return this.tokenField;
}
/**
* Tag details.
*
*
*/
public static class TagData {
public static class TagData implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
@@ -247,7 +249,7 @@ public abstract class AbstractTagToken implements Serializable {
/**
* Tag data constructor.
*
*
* @param id
* @param name
* @param color
@@ -262,7 +264,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the name
*/
public String getName() {
return name;
return this.name;
}
/**
@@ -277,7 +279,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the id
*/
public Long getId() {
return id;
return this.id;
}
/**
@@ -292,7 +294,7 @@ public abstract class AbstractTagToken implements Serializable {
* @return the color
*/
public String getColor() {
return color;
return this.color;
}
/**

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.distributions.dstable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -57,7 +58,7 @@ import com.vaadin.ui.Window;
/**
* Distribution set details layout.
*
*
*
*
*/
@@ -113,16 +114,17 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
@Override
@PostConstruct
protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState);
this.softwareModuleTable = new SoftwareModuleDetailsTable();
this.softwareModuleTable.init(this.i18n, true, this.permissionChecker, this.distributionSetManagement,
this.eventBus, this.manageDistUIState);
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
this.ui = UI.getCurrent();
this.eventBus.subscribe(this);
}
protected VerticalLayout createTagsLayout() {
tagsLayout = getTabLayout();
return tagsLayout;
this.tagsLayout = getTabLayout();
return this.tagsLayout;
}
private void populateDetailsWidget(final DistributionSet ds) {
@@ -146,19 +148,20 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
}
private void populteModule(final DistributionSet distributionSet) {
softwareModuleTable.populateModule(distributionSet);
this.softwareModuleTable.populateModule(distributionSet);
showUnsavedAssignment();
}
@SuppressWarnings("unchecked")
private void showUnsavedAssignment() {
Item item;
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = this.manageDistUIState
.getAssignedList();
final Long selectedDistId = this.manageDistUIState.getLastSelectedDistribution().isPresent()
? this.manageDistUIState.getLastSelectedDistribution().get().getId() : null;
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
for (final Map.Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
for (final Map.Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
if (entry.getKey().getId().equals(selectedDistId)) {
softwareModuleIdNameList = entry.getValue();
break;
@@ -167,22 +170,22 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (null != softwareModuleIdNameList) {
for (final SoftwareModuleIdName swIdName : softwareModuleIdNameList) {
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(swIdName.getId());
if (assignedSWModule.containsKey(softwareModule.getType().getName())) {
assignedSWModule.get(softwareModule.getType().getName()).append("</br>").append("<I>")
final SoftwareModule softwareModule = this.softwareManagement.findSoftwareModuleById(swIdName.getId());
if (this.assignedSWModule.containsKey(softwareModule.getType().getName())) {
this.assignedSWModule.get(softwareModule.getType().getName()).append("</br>").append("<I>")
.append(getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
.append("<I>");
} else {
assignedSWModule.put(softwareModule.getType().getName(),
this.assignedSWModule.put(softwareModule.getType().getName(),
new StringBuilder().append("<I>").append(
getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
.append("<I>"));
}
}
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
for (final Map.Entry<String, StringBuilder> entry : this.assignedSWModule.entrySet()) {
item = this.softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
if (item != null) {
item.getItemProperty(SOFT_MODULE)
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
@@ -198,8 +201,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* @param entry
*/
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
if (this.permissionChecker.hasUpdateDistributionPermission() && this.distributionSetManagement
.findDistributionSetById(this.manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
@@ -215,8 +218,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
@SuppressWarnings("unchecked")
private void updateSoftwareModule(final SoftwareModule module) {
softwareModuleTable.getContainerDataSource().getItemIds();
if (assignedSWModule.containsKey(module.getType().getName())) {
this.softwareModuleTable.getContainerDataSource().getItemIds();
if (this.assignedSWModule.containsKey(module.getType().getName())) {
/*
* If software module type is software, means multiple softwares can
* assigned to that type. Hence if multipe softwares belongs to same
@@ -224,7 +227,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
*/
if (module.getType().getMaxAssignments() == Integer.MAX_VALUE) {
assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>")
this.assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>");
}
@@ -234,17 +237,17 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* same type is dropped, then override with previous one.
*/
if (module.getType().getMaxAssignments() == 1) {
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
this.assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
}
} else {
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
this.assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
}
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
for (final Map.Entry<String, StringBuilder> entry : this.assignedSWModule.entrySet()) {
final Item item = this.softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
if (item != null) {
item.getItemProperty(SOFT_MODULE)
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
@@ -257,23 +260,23 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private VerticalLayout createSoftwareModuleTab() {
final VerticalLayout softwareLayout = getTabLayout();
softwareLayout.setSizeFull();
softwareLayout.addComponent(softwareModuleTable);
softwareLayout.addComponent(this.softwareModuleTable);
return softwareLayout;
}
private void populateTags(final DistributionSet ds) {
tagsLayout.removeAllComponents();
this.tagsLayout.removeAllComponents();
if (null != ds) {
tagsLayout.addComponent(distributionTagToken.getTokenField());
this.tagsLayout.addComponent(this.distributionTagToken.getTokenField());
}
}
private void populateLog(final DistributionSet ds) {
if (null != ds) {
updateLogLayout(getLogLayout(), ds.getLastModifiedAt(), ds.getLastModifiedBy(), ds.getCreatedAt(),
ds.getCreatedBy(), i18n);
ds.getCreatedBy(), this.i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, this.i18n);
}
}
@@ -287,9 +290,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private void populateDescription(final DistributionSet ds) {
if (ds != null) {
updateDescriptionLayout(i18n.get("label.description"), ds.getDescription());
updateDescriptionLayout(this.i18n.get("label.description"), ds.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
updateDescriptionLayout(this.i18n.get("label.description"), null);
}
}
@@ -298,21 +301,21 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(this.i18n.get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
if (isMigrationRequired != null) {
detailsTabLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
this.i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? this.i18n.get("label.yes") : this.i18n.get("label.no")));
}
}
public Long getDsId() {
return dsId;
return this.dsId;
}
public void setDsId(final Long dsId) {
@@ -321,22 +324,22 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onEdit(com.vaadin.ui .Button.ClickEvent)
*/
@Override
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getDsId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
final Window newDistWindow = this.distributionAddUpdateWindowLayout.getWindow();
this.distributionAddUpdateWindowLayout.populateValuesOfDistribution(getDsId());
newDistWindow.setCaption(this.i18n.get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getEditButtonId()
*/
@@ -347,67 +350,67 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsSwModuleSelected ()
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return manageDistUIState.getSelectedDistributions().isPresent()
&& !manageDistUIState.getSelectedDistributions().get().isEmpty();
return this.manageDistUIState.getSelectedDistributions().isPresent()
&& !this.manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsTableMaximized ()
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return manageDistUIState.isDsTableMaximized();
return this.manageDistUIState.isDsTableMaximized();
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* populateDetailsWidget()
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedDsModule);
populateDetailsWidget(this.selectedDsModule);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getDefaultCaption()
*/
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
return this.i18n.get("distribution.details.header");
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* addTabs(com.vaadin. ui.TabSheet)
*/
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
detailsTab.addTab(createDetailsLayout(), this.i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), this.i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), this.i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), this.i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), this.i18n.get("caption.logs.tab"), null);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* clearDetails()
*/
@@ -418,19 +421,19 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* hasEditSoftwareModulePermission()
*/
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return this.permissionChecker.hasUpdateDistributionPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE) {
ui.access(() -> updateSoftwareModule(event.getSoftwareModule()));
this.ui.access(() -> updateSoftwareModule(event.getSoftwareModule()));
}
}
@@ -439,37 +442,37 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|| distributionTableEvent
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
assignedSWModule.clear();
ui.access(() -> {
this.assignedSWModule.clear();
this.ui.access(() -> {
/**
* distributionTableEvent.getDistributionSet() is null when
* table has no data.
*/
if (distributionTableEvent.getDistributionSet() != null) {
selectedDsModule = distributionTableEvent.getDistributionSet();
this.selectedDsModule = distributionTableEvent.getDistributionSet();
populateData(true);
} else {
populateData(false);
}
});
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
ui.access(() -> showLayout());
this.ui.access(() -> showLayout());
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
ui.access(() -> hideLayout());
this.ui.access(() -> hideLayout());
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleAssignmentDiscardEvent softwareModuleAssignmentDiscardEvent) {
if (softwareModuleAssignmentDiscardEvent.getDistributionSetIdName() != null) {
ui.access(() -> {
this.ui.access(() -> {
final DistributionSetIdName distIdName = softwareModuleAssignmentDiscardEvent
.getDistributionSetIdName();
if (distIdName.getId().equals(selectedDsModule.getId())
&& distIdName.getName().equals(selectedDsModule.getName())) {
selectedDsModule = distributionSetManagement
.findDistributionSetByIdWithDetails(selectedDsModule.getId());
populteModule(selectedDsModule);
if (distIdName.getId().equals(this.selectedDsModule.getId())
&& distIdName.getName().equals(this.selectedDsModule.getName())) {
this.selectedDsModule = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.selectedDsModule.getId());
populteModule(this.selectedDsModule);
}
});
}
@@ -479,10 +482,11 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
&& selectedDsModule != null) {
assignedSWModule.clear();
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId());
ui.access(() -> populteModule(selectedDsModule));
&& this.selectedDsModule != null) {
this.assignedSWModule.clear();
this.selectedDsModule = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.selectedDsModule.getId());
this.ui.access(() -> populteModule(this.selectedDsModule));
}
}
@@ -491,7 +495,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
if (saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ASSIGNMENT
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DELETE_ALL_SOFWARE) {
assignedSWModule.clear();
this.assignedSWModule.clear();
showUnsavedAssignment();
}
}
@@ -502,12 +506,12 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
* It's good to do this, even though vaadin-spring will automatically
* unsubscribe .
*/
eventBus.unsubscribe(this);
this.eventBus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getTabSheetId()
*/

View File

@@ -73,7 +73,7 @@ import com.vaadin.ui.UI;
/**
* Distribution set table.
*
*
*
*
*/
@@ -124,7 +124,7 @@ public class DistributionSetTable extends AbstractTable {
super.init();
addTableStyleGenerator();
setNoDataAvailable();
eventBus.subscribe(this);
this.eventBus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -138,7 +138,7 @@ public class DistributionSetTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#getTableId()
*/
@@ -149,7 +149,7 @@ public class DistributionSetTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#createContainer(
* )
@@ -157,28 +157,25 @@ public class DistributionSetTable extends AbstractTable {
@Override
protected Container createContainer() {
final Map<String, Object> queryConfiguration = new HashMap<String, Object>();
manageDistUIState.getManageDistFilters().getSearchText()
final Map<String, Object> queryConfiguration = new HashMap<>();
this.manageDistUIState.getManageDistFilters().getSearchText()
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
if (null != this.manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE,
manageDistUIState.getManageDistFilters().getClickedDistSetType());
this.manageDistUIState.getManageDistFilters().getClickedDistSetType());
}
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<ManageDistBeanQuery>(
ManageDistBeanQuery.class);
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<>(ManageDistBeanQuery.class);
distributionQF.setQueryConfiguration(queryConfiguration);
final LazyQueryContainer distContainer = new LazyQueryContainer(
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
return distContainer;
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties
* (com.vaadin.data.Container )
*/
@@ -191,7 +188,7 @@ public class DistributionSetTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable#
* addCustomGeneratedColumns ()
*/
@@ -204,38 +201,38 @@ public class DistributionSetTable extends AbstractTable {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable#
* isFirstRowSelectedOnLoad ()
*/
@Override
protected boolean isFirstRowSelectedOnLoad() {
return !manageDistUIState.getSelectedDistributions().isPresent()
|| manageDistUIState.getSelectedDistributions().get().isEmpty();
return !this.manageDistUIState.getSelectedDistributions().isPresent()
|| this.manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.table.AbstractTable#getItemIdToSelect()
*/
@Override
protected Object getItemIdToSelect() {
if (manageDistUIState.getSelectedDistributions().isPresent()) {
return manageDistUIState.getSelectedDistributions().get();
if (this.manageDistUIState.getSelectedDistributions().isPresent()) {
return this.manageDistUIState.getSelectedDistributions().get();
}
return null;
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#onValueChange()
*/
@Override
protected void onValueChange() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
@SuppressWarnings("unchecked")
final Set<DistributionSetIdName> values = (Set<DistributionSetIdName>) getValue();
DistributionSetIdName value = null;
@@ -250,48 +247,48 @@ public class DistributionSetTable extends AbstractTable {
* getValue returns null.
*/
if (null != value) {
manageDistUIState.setSelectedDistributions(values);
manageDistUIState.setLastSelectedDistribution(value);
this.manageDistUIState.setSelectedDistributions(values);
this.manageDistUIState.setLastSelectedDistribution(value);
final DistributionSet lastSelectedDistSet = distributionSetManagement
final DistributionSet lastSelectedDistSet = this.distributionSetManagement
.findDistributionSetByIdWithDetails(value.getId());
eventBus.publish(this,
this.eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet));
}
} else {
manageDistUIState.setSelectedDistributions(null);
manageDistUIState.setLastSelectedDistribution(null);
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, null));
this.manageDistUIState.setSelectedDistributions(null);
this.manageDistUIState.setLastSelectedDistribution(null);
this.eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, null));
}
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
this.eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#isMaximized()
*/
@Override
protected boolean isMaximized() {
return manageDistUIState.isDsTableMaximized();
return this.manageDistUIState.isDsTableMaximized();
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.table.AbstractTable#getTableVisibleColumns
* ()
*/
@Override
protected List<TableColumn> getTableVisibleColumns() {
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, i18n);
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, this.i18n);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.common.table.AbstractTable#getTableDropHandler()
*/
@Override
@@ -301,7 +298,7 @@ public class DistributionSetTable extends AbstractTable {
@Override
public AcceptCriterion getAcceptCriterion() {
return distributionsViewAcceptCriteria;
return DistributionSetTable.this.distributionsViewAcceptCriteria;
}
@Override
@@ -317,7 +314,7 @@ public class DistributionSetTable extends AbstractTable {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final Table source = transferable.getSourceComponent();
final Set<Long> softwareModuleSelected = (Set<Long>) source.getValue();
final Set<Long> softwareModulesIdList = new HashSet<Long>();
final Set<Long> softwareModulesIdList = new HashSet<>();
if (!softwareModuleSelected.contains(transferable.getData("itemId"))) {
softwareModulesIdList.add((Long) transferable.getData("itemId"));
@@ -345,12 +342,12 @@ public class DistributionSetTable extends AbstractTable {
final String distVersion = (String) item.getItemProperty("version").getValue();
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
final Map<Long, Set<SoftwareModuleIdName>> map;
if (manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
map = manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
final HashMap<Long, HashSet<SoftwareModuleIdName>> map;
if (this.manageDistUIState.getConsolidatedDistSoftwarewList().containsKey(distributionSetIdName)) {
map = this.manageDistUIState.getConsolidatedDistSoftwarewList().get(distributionSetIdName);
} else {
map = new HashMap<Long, Set<SoftwareModuleIdName>>();
manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
map = new HashMap<>();
this.manageDistUIState.getConsolidatedDistSoftwarewList().put(distributionSetIdName, map);
}
for (final Long softwareModuleId : softwareModulesIdList) {
@@ -358,7 +355,7 @@ public class DistributionSetTable extends AbstractTable {
final String name = (String) softwareItem.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final String swVersion = (String) softwareItem.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
final SoftwareModule softwareModule = this.softwareManagement.findSoftwareModuleById(softwareModuleId);
if (validSoftwareModule(distId, softwareModule)) {
final SoftwareModuleIdName softwareModuleIdName = new SoftwareModuleIdName(softwareModuleId,
name.concat(":" + swVersion));
@@ -382,7 +379,8 @@ public class DistributionSetTable extends AbstractTable {
}
}
final Set<SoftwareModuleIdName> softwareModules = new HashSet<SoftwareModuleIdName>();
// hashset is seriablizable
final HashSet<SoftwareModuleIdName> softwareModules = new HashSet<>();
map.keySet().forEach(typeId -> softwareModules.addAll(map.get(typeId)));
updateDropedDetails(distributionSetIdName, softwareModules);
@@ -393,9 +391,9 @@ public class DistributionSetTable extends AbstractTable {
* @param softwareModule
*/
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
if (manageDistUIState.getLastSelectedDistribution().isPresent()
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
eventBus.publish(this,
if (this.manageDistUIState.getLastSelectedDistribution().isPresent()
&& this.manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
this.eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule));
}
}
@@ -405,8 +403,8 @@ public class DistributionSetTable extends AbstractTable {
* @param softwareModule
* @param softwareModuleIdName
*/
private void handleFirmwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
final SoftwareModuleIdName softwareModuleIdName) {
private void handleFirmwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() == 1) {
if (!map.containsKey(softwareModule.getType().getId())) {
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
@@ -423,8 +421,8 @@ public class DistributionSetTable extends AbstractTable {
* @param softwareModule
* @param softwareModuleIdName
*/
private void handleSoftwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
final SoftwareModuleIdName softwareModuleIdName) {
private void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
if (!map.containsKey(softwareModule.getType().getId())) {
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
@@ -434,43 +432,43 @@ public class DistributionSetTable extends AbstractTable {
}
private void updateDropedDetails(final DistributionSetIdName distributionSetIdName,
final Set<SoftwareModuleIdName> softwareModules) {
final HashSet<SoftwareModuleIdName> softwareModules) {
LOG.debug("Adding a log to check if distributionSetIdName is null : {} ", distributionSetIdName);
manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
this.manageDistUIState.getAssignedList().put(distributionSetIdName, softwareModules);
eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
this.eventBus.publish(this, DistributionsUIEvent.UPDATE_COUNT);
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
private boolean validSoftwareModule(final Long distId, final SoftwareModule sm) {
if (!isSoftwareModuleDragged(distId, sm)) {
return false;
}
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(distId);
final DistributionSet ds = this.distributionSetManagement.findDistributionSetByIdWithDetails(distId);
if (!validateSoftwareModule(sm, ds)) {
return false;
}
try {
distributionSetManagement.checkDistributionSetAlreadyUse(ds);
this.distributionSetManagement.checkDistributionSetAlreadyUse(ds);
} catch (final EntityLockedException exception) {
LOG.error("Unable to update distribution : ", exception);
notification.displayValidationError(exception.getMessage());
this.notification.displayValidationError(exception.getMessage());
return false;
}
return true;
}
private boolean validateSoftwareModule(final SoftwareModule sm, final DistributionSet ds) {
if (targetManagement.countTargetByFilters(null, null, ds.getId(), Boolean.FALSE, new String[] {}) > 0) {
if (this.targetManagement.countTargetByFilters(null, null, ds.getId(), Boolean.FALSE, new String[] {}) > 0) {
/* Distribution is already assigned */
notification.displayValidationError(i18n.get("message.dist.inuse",
this.notification.displayValidationError(this.i18n.get("message.dist.inuse",
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion())));
return false;
}
if (ds.getModules().contains(sm)) {
/* Already has software module */
notification.displayValidationError(i18n.get("message.software.dist.already.assigned",
this.notification.displayValidationError(this.i18n.get("message.software.dist.already.assigned",
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion()),
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
return false;
@@ -478,7 +476,7 @@ public class DistributionSetTable extends AbstractTable {
if (!ds.getType().containsModuleType(sm.getType())) {
/* Invalid type of the software module */
notification.displayValidationError(i18n.get("message.software.dist.type.notallowed",
this.notification.displayValidationError(this.i18n.get("message.software.dist.type.notallowed",
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion()),
HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion())));
return false;
@@ -487,20 +485,20 @@ public class DistributionSetTable extends AbstractTable {
}
private boolean isSoftwareModuleDragged(final Long distId, final SoftwareModule sm) {
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : manageDistUIState.getAssignedList()
.entrySet()) {
if (distId.equals(entry.getKey().getId())) {
final Set<SoftwareModuleIdName> swModuleIdNames = entry.getValue();
for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) {
if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) {
notification.displayValidationError(i18n.get("message.software.already.dragged",
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
return false;
}
}
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : this.manageDistUIState
.getAssignedList().entrySet()) {
if (!distId.equals(entry.getKey().getId())) {
continue;
}
final Set<SoftwareModuleIdName> swModuleIdNames = entry.getValue();
for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) {
if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) {
this.notification.displayValidationError(this.i18n.get("message.software.already.dragged",
HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion())));
return false;
}
}
}
return true;
}
@@ -513,19 +511,19 @@ public class DistributionSetTable extends AbstractTable {
* @return boolean as flag
*/
private Boolean doValidation(final DragAndDropEvent dragEvent) {
if (!permissionChecker.hasUpdateDistributionPermission()) {
notification.displayValidationError(i18n.get("message.permission.insufficient"));
if (!this.permissionChecker.hasUpdateDistributionPermission()) {
this.notification.displayValidationError(this.i18n.get("message.permission.insufficient"));
return false;
} else {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
final Table source = (Table) compsource;
if (compsource instanceof Table) {
if (!source.getId().equals(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
notification.displayValidationError(i18n.get("message.action.not.allowed"));
this.notification.displayValidationError(this.i18n.get("message.action.not.allowed"));
return false;
}
} else {
notification.displayValidationError(i18n.get("message.action.not.allowed"));
this.notification.displayValidationError(this.i18n.get("message.action.not.allowed"));
return false;
}
}
@@ -557,28 +555,25 @@ public class DistributionSetTable extends AbstractTable {
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete());
if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
if (this.manageDistUIState.getSelectedDistributions().isPresent()) {
this.manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
}
select(distributionSet.getDistributionSetIdName());
}
private void addTableStyleGenerator() {
setCellStyleGenerator(new Table.CellStyleGenerator() {
@Override
public String getStyle(final Table source, final Object itemId, final Object propertyId) {
if (propertyId == null) {
// Styling for row
final Item item = getItem(itemId);
final Boolean isComplete = (Boolean) item
.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
if (!isComplete) {
return SPUIDefinitions.DISABLE_DISTRIBUTION;
}
return null;
} else {
return null;
setCellStyleGenerator((source, itemId, propertyId) -> {
if (propertyId == null) {
// Styling for row
final Item item = getItem(itemId);
final Boolean isComplete = (Boolean) item
.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
if (!isComplete) {
return SPUIDefinitions.DISABLE_DISTRIBUTION;
}
return null;
} else {
return null;
}
});
}
@@ -603,7 +598,7 @@ public class DistributionSetTable extends AbstractTable {
/**
* DistributionTableFilterEvent.
*
*
* @param event
* as instance of {@link DistributionTableFilterEvent}
*/
@@ -622,15 +617,15 @@ public class DistributionSetTable extends AbstractTable {
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
this.eventBus.unsubscribe(this);
}
private void setNoDataAvailable() {
final int containerSize = getContainerDataSource().size();
if (containerSize == 0) {
manageDistUIState.setNoDataAvailableDist(true);
this.manageDistUIState.setNoDataAvailableDist(true);
} else {
manageDistUIState.setNoDataAvailableDist(false);
this.manageDistUIState.setNoDataAvailableDist(false);
}
}
}

View File

@@ -51,9 +51,9 @@ import com.vaadin.ui.UI;
/**
* Distributions footer layout implementation.
*
*
*
*
*
*/
@org.springframework.stereotype.Component
@ViewScope
@@ -94,14 +94,15 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
this.eventBus.subscribe(this);
}
@PreDestroy
@@ -110,7 +111,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
this.eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -128,9 +129,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
UI.getCurrent().access(() -> {
if (!hasUnsavedActions()) {
closeUnsavedActionsWindow();
final String message = distConfirmationWindowLayout.getConsolidatedMessage();
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) {
notification.displaySuccess(message);
this.notification.displaySuccess(message);
}
}
updateDSActionCount();
@@ -140,20 +141,20 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasDeletePermission()
*/
@Override
protected boolean hasDeletePermission() {
return permChecker.hasDeleteDistributionPermission();
return this.permChecker.hasDeleteDistributionPermission();
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUpdatePermission()
@@ -161,24 +162,24 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected boolean hasUpdatePermission() {
return permChecker.hasUpdateDistributionPermission();
return this.permChecker.hasUpdateDistributionPermission();
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteAreaLabel()
*/
@Override
protected String getDeleteAreaLabel() {
return i18n.get("label.components.drop.area");
return this.i18n.get("label.components.drop.area");
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteAreaId()
@@ -191,7 +192,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteLayoutAcceptCriteria ()
@@ -199,12 +200,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return distributionsViewAcceptCriteria;
return this.distributionsViewAcceptCriteria;
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* processDroppedComponent(com .vaadin.event.dd.DragAndDropEvent)
@@ -227,7 +228,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
processDeleteSWType(sourceComponent.getId());
}
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
hideDropHints();
}
@@ -236,24 +237,24 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
if (isDsTypeSelected(distTypeName)) {
notification
.displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
this.notification.displayValidationError(
this.i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
} else if (isDefaultDsType(distTypeName)) {
notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype"));
this.notification.displayValidationError(this.i18n.get("message.cannot.delete.default.dstype"));
} else {
manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName);
this.manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName);
updateDSActionCount();
}
}
/**
* Check if distribution set type is selected.
*
*
* @param distTypeName
* @return true if ds type is selected
*/
private boolean isDsTypeSelected(final String distTypeName) {
return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() && manageDistUIState
return null != this.manageDistUIState.getManageDistFilters().getClickedDistSetType() && this.manageDistUIState
.getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName);
}
@@ -261,13 +262,13 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
final String swModuleTypeName = HawkbitCommonUtil.removePrefix(swTypeId,
SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS);
if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
if (this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& this.manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
.equalsIgnoreCase(swModuleTypeName)) {
notification.displayValidationError(
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
this.notification.displayValidationError(
this.i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
} else {
manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
this.manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
updateDSActionCount();
}
@@ -276,7 +277,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
@SuppressWarnings("unchecked")
final Set<DistributionSetIdName> distSelected = (Set<DistributionSetIdName>) sourceTable.getValue();
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<DistributionSetIdName>();
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<>();
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID));
} else {
@@ -287,9 +288,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* the deleted list (or) some distributions are already in the deleted
* distribution list.
*/
final int existingDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = manageDistUIState.getDeletedDistributionList().size();
final int existingDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size();
this.manageDistUIState.getDeletedDistributionList().addAll(distributionIdNameSet);
final int newDeletedDistributionsSize = this.manageDistUIState.getDeletedDistributionList().size();
if (newDeletedDistributionsSize == existingDeletedDistributionsSize) {
/*
* No new distributions are added, all distributions dropped now are
@@ -297,7 +298,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.targets.already.deleted"));
this.uiNotification.displayValidationError(this.i18n.get("message.targets.already.deleted"));
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/*
* Not the all distributions dropped now are added to the delete
@@ -305,7 +306,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* delete list. Hence display warning message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.dist.deleted.pending"));
this.uiNotification.displayValidationError(this.i18n.get("message.dist.deleted.pending"));
}
}
@@ -314,7 +315,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@SuppressWarnings("unchecked")
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
final Set<Long> swModuleIdNameSet = new HashSet<Long>();
final Set<Long> swModuleIdNameSet = new HashSet<>();
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
} else {
@@ -323,7 +324,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
swModuleIdNameSet.forEach(id -> {
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
manageDistUIState.getDeleteSofwareModulesList().put(id, swModuleName);
this.manageDistUIState.getDeleteSofwareModulesList().put(id, swModuleName);
});
}
@@ -331,21 +332,21 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* Update the software module delete count.
*/
private void updateDSActionCount() {
int count = manageDistUIState.getSelectedDeleteDistSetTypes().size()
+ manageDistUIState.getSelectedDeleteSWModuleTypes().size()
+ manageDistUIState.getDeleteSofwareModulesList().size()
+ manageDistUIState.getDeletedDistributionList().size();
int count = this.manageDistUIState.getSelectedDeleteDistSetTypes().size()
+ this.manageDistUIState.getSelectedDeleteSWModuleTypes().size()
+ this.manageDistUIState.getDeleteSofwareModulesList().size()
+ this.manageDistUIState.getDeletedDistributionList().size();
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> mapEntry : manageDistUIState
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> mapEntry : this.manageDistUIState
.getAssignedList().entrySet()) {
count += manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
count += this.manageDistUIState.getAssignedList().get(mapEntry.getKey()).size();
}
updateActionsCount(count);
}
/**
* DistributionsUIEvent.
*
*
* @param event
* as instance of {@link DistributionsUIEvent}
*/
@@ -357,39 +358,29 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
/**
*
* @param source
* @return true if it is distribution table
*/
private boolean isDistributionTable(final Component source) {
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID);
return SPUIComponetIdProvider.DIST_TABLE_ID.equals(source.getId());
}
/**
*
* @param source
* @return true if it is SoftwareModule table
*/
private boolean isSoftwareModuleTable(final Component source) {
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE);
return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE.equals(source.getId());
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getNoActionsButtonLabel()
*/
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
return this.i18n.get("button.no.actions");
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getActionsButtonLabel()
@@ -397,13 +388,13 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
return this.i18n.get("button.actions");
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* reloadActionCount()
@@ -416,48 +407,48 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowCaption ()
*/
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
return this.i18n.get("caption.save.window");
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* unsavedActionsWindowClosed()
*/
@Override
protected void unsavedActionsWindowClosed() {
final String message = distConfirmationWindowLayout.getConsolidatedMessage();
final String message = this.distConfirmationWindowLayout.getConsolidatedMessage();
if (message != null && message.length() > 0) {
notification.displaySuccess(message);
this.notification.displaySuccess(message);
}
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowContent ()
*/
@Override
protected Component getUnsavedActionsWindowContent() {
distConfirmationWindowLayout.init();
return distConfirmationWindowLayout;
this.distConfirmationWindowLayout.init();
return this.distConfirmationWindowLayout;
}
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUnsavedActions()
@@ -466,12 +457,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
protected boolean hasUnsavedActions() {
boolean unSavedActionsTypes = false;
boolean unSavedActionsTables = false;
if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
|| !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
|| !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
unSavedActionsTypes = true;
} else if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()
|| !manageDistUIState.getDeletedDistributionList().isEmpty()
|| !manageDistUIState.getAssignedList().isEmpty()) {
} else if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()
|| !this.manageDistUIState.getDeletedDistributionList().isEmpty()
|| !this.manageDistUIState.getAssignedList().isEmpty()) {
unSavedActionsTables = true;
}
@@ -490,7 +481,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* hasBulkUploadPermission()
*/
@@ -501,7 +492,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* showBulkUploadWindow()
*/
@@ -514,7 +505,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* restoreBulkUploadStatusCount()
*/
@@ -526,12 +517,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private DistributionSetType getCurrentDistributionSetType() {
return systemManagement.getTenantMetadata().getDefaultDsType();
return this.systemManagement.getTenantMetadata().getDefaultDsType();
}
/**
* Check if the distribution set type is default.
*
*
* @param dsTypeName
* distribution set name
* @return true if distribution set type is set default in configuration

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.footer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -52,9 +53,9 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract layout of confirm actions window.
*
*
*
*
*
*/
@org.springframework.stereotype.Component
@ViewScope
@@ -107,37 +108,38 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.confirmwindow.layout.
* AbstractConfirmationWindowLayout# getConfimrationTabs()
*/
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<String, ConfirmationTab>();
final Map<String, ConfirmationTab> tabs = new HashMap<>();
/* Create tab for SW Modules delete */
if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
if (!this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab());
}
/* Create tab for SW Module Type delete */
if (!manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
if (!this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab());
}
/* Create tab for Distributions delete */
if (!manageDistUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab());
if (!this.manageDistUIState.getDeletedDistributionList().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab());
}
/* Create tab for Distribution Set Types delete */
if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(i18n.get("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab());
if (!this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) {
tabs.put(this.i18n.get("caption.delete.dist.set.type.accordion.tab"),
createDistSetTypeDeleteConfirmationTab());
}
/* Create tab for Assign Software Module */
if (!manageDistUIState.getAssignedList().isEmpty()) {
tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
if (!this.manageDistUIState.getAssignedList().isEmpty()) {
tabs.put(this.i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab());
}
return tabs;
@@ -149,10 +151,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SW_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().addClickListener(event -> discardSMAll(tab));
/* Add items container to the table. */
@@ -175,8 +177,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_NAME_MSG);
visibleColumnIds.add(SW_DISCARD_CHGS);
visibleColumnLabels.add(i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
visibleColumnLabels.add(this.i18n.get("upload.swModuleTable.header"));
visibleColumnLabels.add(this.i18n.get("header.second.deletetarget.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -188,49 +190,51 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void deleteSMAll(final ConfirmationTab tab) {
final Set<Long> swmoduleIds = manageDistUIState.getDeleteSofwareModulesList().keySet();
if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entryAssignSM : manageDistUIState
.getAssignedList().entrySet()) {
for (final Entry<Long, String> entryDeleteSM : manageDistUIState.getDeleteSofwareModulesList()
.entrySet()) {
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
entryDeleteSM.getValue());
if (entryAssignSM.getValue().contains(smIdName)) {
entryAssignSM.getValue().remove(smIdName);
assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
}
if (entryAssignSM.getValue().isEmpty()) {
manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
}
}
}
final Set<Long> swmoduleIds = this.manageDistUIState.getDeleteSofwareModulesList().keySet();
if (this.manageDistUIState.getAssignedList() == null || this.manageDistUIState.getAssignedList().isEmpty()) {
removeAssignedSoftwareModules();
}
softwareManagement.deleteSoftwareModules(swmoduleIds);
this.softwareManagement.deleteSoftwareModules(swmoduleIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.swModule.deleted", swmoduleIds.size()));
manageDistUIState.getDeleteSofwareModulesList().clear();
+ this.i18n.get("message.swModule.deleted", swmoduleIds.size()));
this.manageDistUIState.getDeleteSofwareModulesList().clear();
removeCurrentTab(tab);
setActionMessage(i18n.get("message.software.delete.success"));
eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
setActionMessage(this.i18n.get("message.software.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE);
}
private void removeAssignedSoftwareModules() {
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entryAssignSM : this.manageDistUIState
.getAssignedList().entrySet()) {
for (final Entry<Long, String> entryDeleteSM : this.manageDistUIState.getDeleteSofwareModulesList()
.entrySet()) {
final SoftwareModuleIdName smIdName = new SoftwareModuleIdName(entryDeleteSM.getKey(),
entryDeleteSM.getValue());
if (entryAssignSM.getValue().contains(smIdName)) {
entryAssignSM.getValue().remove(smIdName);
this.assignmnetTab.getTable().removeItem(HawkbitCommonUtil.concatStrings("|||",
entryAssignSM.getKey().getId().toString(), smIdName.getId().toString()));
}
if (entryAssignSM.getValue().isEmpty()) {
this.manageDistUIState.getAssignedList().remove(entryAssignSM.getKey());
}
}
}
}
private void discardSMAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
manageDistUIState.getDeleteSofwareModulesList().clear();
setActionMessage(i18n.get("message.software.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
this.manageDistUIState.getDeleteSofwareModulesList().clear();
setActionMessage(this.i18n.get("message.software.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
}
/**
* Get SWModule table container.
*
*
* @return IndexedContainer
*/
@SuppressWarnings("unchecked")
@@ -238,30 +242,29 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final IndexedContainer swcontactContainer = new IndexedContainer();
swcontactContainer.addContainerProperty("SWModuleId", String.class, "");
swcontactContainer.addContainerProperty(SW_MODULE_NAME_MSG, String.class, "");
Item item = null;
for (final Long swModuleID : manageDistUIState.getDeleteSofwareModulesList().keySet()) {
item = swcontactContainer.addItem(swModuleID);
for (final Long swModuleID : this.manageDistUIState.getDeleteSofwareModulesList().keySet()) {
final Item item = swcontactContainer.addItem(swModuleID);
item.getItemProperty("SWModuleId").setValue(swModuleID.toString());
item.getItemProperty(SW_MODULE_NAME_MSG)
.setValue(manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
.setValue(this.manageDistUIState.getDeleteSofwareModulesList().get(swModuleID));
}
return swcontactContainer;
}
private void discardSoftwareDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final Long swmoduleId = (Long) ((Button) event.getComponent()).getData();
if (null != manageDistUIState.getDeleteSofwareModulesList()
&& !manageDistUIState.getDeleteSofwareModulesList().isEmpty()
&& manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) {
manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId);
if (null != this.manageDistUIState.getDeleteSofwareModulesList()
&& !this.manageDistUIState.getDeleteSofwareModulesList().isEmpty()
&& this.manageDistUIState.getDeleteSofwareModulesList().containsKey(swmoduleId)) {
this.manageDistUIState.getDeleteSofwareModulesList().remove(swmoduleId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE);
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SOFTWARE);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SOFTWARE);
}
}
@@ -270,10 +273,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_SW_MODULE_TYPE);
tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));
@@ -300,8 +303,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(SW_MODULE_TYPE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.first.delete.swmodule.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.swmodule.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -314,32 +317,32 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void deleteSMtypeAll(final ConfirmationTab tab) {
final int deleteSWModuleTypeCount = manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
final int deleteSWModuleTypeCount = this.manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : this.manageDistUIState.getSelectedDeleteSWModuleTypes()) {
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
this.softwareManagement
.deleteSoftwareModuleType(this.softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
+ this.i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
removeCurrentTab(tab);
setActionMessage(i18n.get("message.software.type.delete.success"));
eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES);
setActionMessage(this.i18n.get("message.software.type.delete.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES);
}
private void discardSMtypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(i18n.get("message.software.type.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
this.manageDistUIState.getSelectedDeleteSWModuleTypes().clear();
setActionMessage(this.i18n.get("message.software.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
}
private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, "");
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
for (final String swModuleTypeName : this.manageDistUIState.getSelectedDeleteSWModuleTypes()) {
final Item saveTblitem = contactContainer.addItem(swModuleTypeName);
saveTblitem.getItemProperty(SW_MODULE_TYPE_NAME).setValue(swModuleTypeName);
@@ -350,18 +353,18 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardSoftwareTypeDelete(final String discardSWModuleType, final Object itemId,
final ConfirmationTab tab) {
if (null != manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
&& manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
if (null != this.manageDistUIState.getSelectedDeleteSWModuleTypes()
&& !this.manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteSWModuleTypes().contains(discardSWModuleType)) {
this.manageDistUIState.getSelectedDeleteSWModuleTypes().remove(discardSWModuleType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES);
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SW_MODULE_TYPE);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_SW_MODULE_TYPE);
}
}
@@ -371,10 +374,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.DIST_DELETE_ALL);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().addClickListener(event -> discardDistAll(tab));
/* Add items container to the table. */
@@ -397,8 +400,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(i18n.get("header.second.deletedist.table"));
visibleColumnLabels.add(this.i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(this.i18n.get("header.second.deletedist.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
@@ -411,12 +414,12 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Delete Distributions. */
private void deleteDistAll(final ConfirmationTab tab) {
final Long[] deletedIds = manageDistUIState.getDeletedDistributionList().stream().map(idName -> idName.getId())
.toArray(Long[]::new);
if (null != manageDistUIState.getAssignedList() && !manageDistUIState.getAssignedList().isEmpty()) {
manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (manageDistUIState.getAssignedList().containsKey(distSetName)) {
manageDistUIState.getAssignedList().remove(distSetName);
final Long[] deletedIds = this.manageDistUIState.getDeletedDistributionList().stream()
.map(idName -> idName.getId()).toArray(Long[]::new);
if (null != this.manageDistUIState.getAssignedList() && !this.manageDistUIState.getAssignedList().isEmpty()) {
this.manageDistUIState.getDeletedDistributionList().forEach(distSetName -> {
if (this.manageDistUIState.getAssignedList().containsKey(distSetName)) {
this.manageDistUIState.getAssignedList().remove(distSetName);
}
@@ -424,23 +427,23 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
dsManagement.deleteDistributionSet(deletedIds);
this.dsManagement.deleteDistributionSet(deletedIds);
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.dist.deleted", deletedIds.length));
+ this.i18n.get("message.dist.deleted", deletedIds.length));
manageDistUIState.getDeletedDistributionList()
.forEach(deletedIdname -> manageDistUIState.getAssignedList().remove(deletedIdname));
this.manageDistUIState.getDeletedDistributionList()
.forEach(deletedIdname -> this.manageDistUIState.getAssignedList().remove(deletedIdname));
removeCurrentTab(tab);
manageDistUIState.getDeletedDistributionList().clear();
eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
this.manageDistUIState.getDeletedDistributionList().clear();
this.eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
}
private void discardDistAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
manageDistUIState.getDeletedDistributionList().clear();
setActionMessage(i18n.get("message.dist.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
this.manageDistUIState.getDeletedDistributionList().clear();
setActionMessage(this.i18n.get("message.dist.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
}
@@ -449,7 +452,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(DIST_NAME, String.class, "");
Item item;
for (final DistributionSetIdName distIdName : manageDistUIState.getDeletedDistributionList()) {
for (final DistributionSetIdName distIdName : this.manageDistUIState.getDeletedDistributionList()) {
item = contactContainer.addItem(distIdName);
item.getItemProperty(DIST_NAME).setValue(distIdName.getName().concat(":" + distIdName.getVersion()));
}
@@ -460,18 +463,18 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistDelete(final Button.ClickEvent event, final Object itemId, final ConfirmationTab tab) {
final DistributionSetIdName distId = (DistributionSetIdName) ((Button) event.getComponent()).getData();
if (null != manageDistUIState.getDeletedDistributionList()
&& !manageDistUIState.getDeletedDistributionList().isEmpty()
&& manageDistUIState.getDeletedDistributionList().contains(distId)) {
manageDistUIState.getDeletedDistributionList().remove(distId);
if (null != this.manageDistUIState.getDeletedDistributionList()
&& !this.manageDistUIState.getDeletedDistributionList().isEmpty()
&& this.manageDistUIState.getDeletedDistributionList().contains(distId)) {
this.manageDistUIState.getDeletedDistributionList().remove(distId);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS);
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DEL_DISTRIBUTION);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DEL_DISTRIBUTION);
}
}
@@ -482,10 +485,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
tab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_DELETE_DIST_SET_TYPE);
tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL));
tab.getConfirmAll().addClickListener(event -> deleteDistSetTypeAll(tab));
tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
tab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_DIST_SET_TYPE);
tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab));
@@ -512,8 +515,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DIST_SET_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(i18n.get("header.first.delete.dist.type.table"));
visibleColumnLabels.add(i18n.get("header.second.delete.dist.type.table"));
visibleColumnLabels.add(this.i18n.get("header.first.delete.dist.type.table"));
visibleColumnLabels.add(this.i18n.get("header.second.delete.dist.type.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
@@ -527,31 +530,32 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void deleteDistSetTypeAll(final ConfirmationTab tab) {
final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
final int deleteDistTypeCount = this.manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : this.manageDistUIState.getSelectedDeleteDistSetTypes()) {
dsManagement.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
this.dsManagement
.deleteDistributionSetType(this.dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
manageDistUIState.getSelectedDeleteDistSetTypes().clear();
+ this.i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear();
removeCurrentTab(tab);
setActionMessage(i18n.get("message.dist.set.type.deleted.success"));
eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES);
setActionMessage(this.i18n.get("message.dist.set.type.deleted.success"));
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES);
}
private void discardDistSetTypeAll(final ConfirmationTab tab) {
removeCurrentTab(tab);
manageDistUIState.getSelectedDeleteDistSetTypes().clear();
setActionMessage(i18n.get("message.dist.type.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
this.manageDistUIState.getSelectedDeleteDistSetTypes().clear();
setActionMessage(this.i18n.get("message.dist.type.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
}
private IndexedContainer getDistSetTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(DIST_SET_NAME, String.class, "");
for (final String distTypeMName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
for (final String distTypeMName : this.manageDistUIState.getSelectedDeleteDistSetTypes()) {
final Item saveTblitem = contactContainer.addItem(distTypeMName);
saveTblitem.getItemProperty(DIST_SET_NAME).setValue(distTypeMName);
@@ -563,40 +567,40 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private void discardDistTypeDelete(final String discardDSType, final Object itemId, final ConfirmationTab tab) {
if (null != manageDistUIState.getSelectedDeleteDistSetTypes()
&& !manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
&& manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
if (null != this.manageDistUIState.getSelectedDeleteDistSetTypes()
&& !this.manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()
&& this.manageDistUIState.getSelectedDeleteDistSetTypes().contains(discardDSType)) {
this.manageDistUIState.getSelectedDeleteDistSetTypes().remove(discardDSType);
}
tab.getTable().getContainerDataSource().removeItem(itemId);
final int deleteCount = tab.getTable().size();
if (0 == deleteCount) {
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES);
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_DELETE_DIST_SET_TYPE);
}
}
/* For Assign software modules */
private ConfirmationTab createAssignSWModuleConfirmationTab() {
assignmnetTab = new ConfirmationTab();
this.assignmnetTab = new ConfirmationTab();
assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
this.assignmnetTab.getConfirmAll().setId(SPUIComponetIdProvider.SAVE_ASSIGNMENT);
this.assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
this.assignmnetTab.getConfirmAll().setCaption(this.i18n.get("button.assign.all"));
this.assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(this.assignmnetTab));
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab));
this.assignmnetTab.getDiscardAll().setCaption(this.i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
this.assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
this.assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(this.assignmnetTab));
// Add items container to the table.
assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer());
this.assignmnetTab.getTable().setContainerDataSource(getSWAssignmentsTableContainer());
// Add the discard action column
assignmnetTab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
this.assignmnetTab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' ');
style.append(SPUIStyleDefinitions.REDICON);
@@ -605,7 +609,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
deleteIcon.setData(itemId);
deleteIcon.setImmediate(true);
deleteIcon.addClickListener(event -> discardSWAssignment((String) ((Button) event.getComponent()).getData(),
itemId, assignmnetTab));
itemId, this.assignmnetTab));
return deleteIcon;
});
@@ -616,19 +620,19 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
visibleColumnIds.add(DIST_NAME);
visibleColumnIds.add(SOFTWARE_MODULE_NAME);
visibleColumnIds.add(DISCARD);
visibleColumnLabels.add(i18n.get("header.dist.first.assignment.table"));
visibleColumnLabels.add(i18n.get("header.dist.second.assignment.table"));
visibleColumnLabels.add(i18n.get("header.third.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.dist.first.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.dist.second.assignment.table"));
visibleColumnLabels.add(this.i18n.get("header.third.assignment.table"));
}
assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
this.assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
this.assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER);
return assignmnetTab;
this.assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);
this.assignmnetTab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
this.assignmnetTab.getTable().setColumnAlignment(DISCARD, Align.CENTER);
return this.assignmnetTab;
}
@@ -640,7 +644,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
contactContainer.addContainerProperty(DIST_ID_NAME, DistributionSetIdName.class, "");
contactContainer.addContainerProperty(SOFTWARE_MODULE_ID_NAME, SoftwareModuleIdName.class, "");
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = this.manageDistUIState
.getAssignedList();
assignedList.forEach((distIdname, softIdNameSet) -> softIdNameSet.forEach(softIdName -> {
final String itemId = HawkbitCommonUtil.concatStrings("|||", distIdname.getId().toString(),
@@ -658,38 +663,38 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
private void saveAllAssignments(final ConfirmationTab tab) {
manageDistUIState.getAssignedList().forEach((distIdName, softIdNameSet) -> {
this.manageDistUIState.getAssignedList().forEach((distIdName, softIdNameSet) -> {
final DistributionSet ds = dsManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final DistributionSet ds = this.dsManagement.findDistributionSetByIdWithDetails(distIdName.getId());
final List<Long> softIds = softIdNameSet.stream().map(softIdName -> softIdName.getId())
.collect(Collectors.toList());
final List<SoftwareModule> softwareModules = softwareManagement.findSoftwareModulesById(softIds);
final List<SoftwareModule> softwareModules = this.softwareManagement.findSoftwareModulesById(softIds);
softwareModules.forEach(ds::addModule);
dsManagement.updateDistributionSet(ds);
this.dsManagement.updateDistributionSet(ds);
});
int count = 0;
for (final Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : manageDistUIState.getAssignedList()
.entrySet()) {
for (final Entry<DistributionSetIdName, HashSet<SoftwareModuleIdName>> entry : this.manageDistUIState
.getAssignedList().entrySet()) {
count += entry.getValue().size();
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.software.assignment", new Object[] { count }));
manageDistUIState.getAssignedList().clear();
manageDistUIState.getConsolidatedDistSoftwarewList().clear();
+ this.i18n.get("message.software.assignment", new Object[] { count }));
this.manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear();
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS);
this.eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS);
}
private void discardAllSWAssignments(final ConfirmationTab tab) {
removeCurrentTab(tab);
manageDistUIState.getAssignedList().clear();
manageDistUIState.getConsolidatedDistSoftwarewList().clear();
setActionMessage(i18n.get("message.assign.discard.success"));
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
this.manageDistUIState.getAssignedList().clear();
this.manageDistUIState.getConsolidatedDistSoftwarewList().clear();
setActionMessage(this.i18n.get("message.assign.discard.success"));
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
}
private void discardSWAssignment(final String discardSW, final Object itemId, final ConfirmationTab tab) {
@@ -700,23 +705,23 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final SoftwareModuleIdName discardSoftIdName = (SoftwareModuleIdName) rowitem
.getItemProperty(SOFTWARE_MODULE_ID_NAME).getValue();
final Set<SoftwareModuleIdName> softIdNameSet = manageDistUIState.getAssignedList().get(discardDistIdName);
manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName);
final Set<SoftwareModuleIdName> softIdNameSet = this.manageDistUIState.getAssignedList().get(discardDistIdName);
this.manageDistUIState.getAssignedList().get(discardDistIdName).remove(discardSoftIdName);
softIdNameSet.remove(discardSoftIdName);
tab.getTable().getContainerDataSource().removeItem(itemId);
if (softIdNameSet.isEmpty()) {
manageDistUIState.getAssignedList().remove(discardDistIdName);
this.manageDistUIState.getAssignedList().remove(discardDistIdName);
}
final Map<Long, Set<SoftwareModuleIdName>> map = manageDistUIState.getConsolidatedDistSoftwarewList()
final Map<Long, HashSet<SoftwareModuleIdName>> map = this.manageDistUIState.getConsolidatedDistSoftwarewList()
.get(discardDistIdName);
map.keySet().forEach(typeId -> map.get(typeId).remove(discardSoftIdName));
final int assigCount = tab.getTable().getContainerDataSource().size();
if (0 == assigCount) {
removeCurrentTab(tab);
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS);
} else {
eventBus.publish(this, SaveActionWindowEvent.DISCARD_ASSIGNMENT);
this.eventBus.publish(this, SaveActionWindowEvent.DISCARD_ASSIGNMENT);
}
}

View File

@@ -40,11 +40,11 @@ public class ManageDistUIState implements Serializable {
@Autowired
private ManageSoftwareModuleFilters softwareModuleFilters;
private final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = new HashMap<DistributionSetIdName, Set<SoftwareModuleIdName>>();
private final Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> assignedList = new HashMap<>();
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<DistributionSetIdName>();
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<>();
private Set<DistributionSetIdName> selectedDistributions = new HashSet<DistributionSetIdName>();
private Set<DistributionSetIdName> selectedDistributions = new HashSet<>();
private DistributionSetIdName lastSelectedDistribution;
@@ -66,9 +66,9 @@ public class ManageDistUIState implements Serializable {
private boolean isDsTableMaximized = Boolean.FALSE;
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<String, SoftwareModuleIdName>();
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
private final Map<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>>();
private final Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<>();
private boolean noDataAvilableSwModule = Boolean.FALSE;
@@ -78,36 +78,37 @@ public class ManageDistUIState implements Serializable {
* @return the manageDistFilters
*/
public ManageDistFilters getManageDistFilters() {
return manageDistFilters;
return this.manageDistFilters;
}
/**
* @return the deletedDistributionList
*/
public Set<DistributionSetIdName> getDeletedDistributionList() {
return deletedDistributionList;
return this.deletedDistributionList;
}
/**
*
* Need HashSet because the Set have to be serializable
*
* @return the assignedList
*/
public Map<DistributionSetIdName, Set<SoftwareModuleIdName>> getAssignedList() {
return assignedList;
public Map<DistributionSetIdName, HashSet<SoftwareModuleIdName>> getAssignedList() {
return this.assignedList;
}
/**
* @return the slectedDistributions
*/
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() {
return selectedDistributions == null ? Optional.empty() : Optional.of(selectedDistributions);
return this.selectedDistributions == null ? Optional.empty() : Optional.of(this.selectedDistributions);
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
return lastSelectedDistribution == null ? Optional.empty() : Optional.of(lastSelectedDistribution);
return this.lastSelectedDistribution == null ? Optional.empty() : Optional.of(this.lastSelectedDistribution);
}
/**
@@ -126,14 +127,14 @@ public class ManageDistUIState implements Serializable {
* @return the softwareModuleFilters
*/
public ManageSoftwareModuleFilters getSoftwareModuleFilters() {
return softwareModuleFilters;
return this.softwareModuleFilters;
}
/**
* @return the selectedSoftwareModules
*/
public Set<Long> getSelectedSoftwareModules() {
return selectedSoftwareModules;
return this.selectedSoftwareModules;
}
/**
@@ -163,7 +164,7 @@ public class ManageDistUIState implements Serializable {
* @return the distTypeFilterClosed
*/
public boolean isDistTypeFilterClosed() {
return distTypeFilterClosed;
return this.distTypeFilterClosed;
}
/**
@@ -178,7 +179,7 @@ public class ManageDistUIState implements Serializable {
* @return the swTypeFilterClosed
*/
public boolean isSwTypeFilterClosed() {
return swTypeFilterClosed;
return this.swTypeFilterClosed;
}
/**
@@ -193,11 +194,11 @@ public class ManageDistUIState implements Serializable {
* @return the deleteSofwareModulesList
*/
public Map<Long, String> getDeleteSofwareModulesList() {
return deleteSofwareModulesList;
return this.deleteSofwareModulesList;
}
public Set<String> getSelectedDeleteDistSetTypes() {
return selectedDeleteDistSetTypes;
return this.selectedDeleteDistSetTypes;
}
public void setSelectedDeleteDistSetTypes(final Set<String> selectedDeleteDistSetTypes) {
@@ -205,7 +206,7 @@ public class ManageDistUIState implements Serializable {
}
public Set<String> getSelectedDeleteSWModuleTypes() {
return selectedDeleteSWModuleTypes;
return this.selectedDeleteSWModuleTypes;
}
public void setSelectedDeleteSWModuleTypes(final Set<String> selectedDeleteSWModuleTypes) {
@@ -214,16 +215,16 @@ public class ManageDistUIState implements Serializable {
/**
* Get isSwModuleTableMaximized.
*
*
* @return boolean
*/
public boolean isDsTableMaximized() {
return isDsTableMaximized;
return this.isDsTableMaximized;
}
/***
* Set isDsModuleTableMaximized.
*
*
* @param isDsModuleTableMaximized
*/
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
@@ -231,14 +232,14 @@ public class ManageDistUIState implements Serializable {
}
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
return assignedSoftwareModuleDetails;
return this.assignedSoftwareModuleDetails;
}
/**
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return isSwModuleTableMaximized;
return this.isSwModuleTableMaximized;
}
/**
@@ -253,7 +254,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvilableSwModule
*/
public boolean isNoDataAvilableSwModule() {
return noDataAvilableSwModule;
return this.noDataAvilableSwModule;
}
/**
@@ -268,7 +269,7 @@ public class ManageDistUIState implements Serializable {
* @return the noDataAvailableDist
*/
public boolean isNoDataAvailableDist() {
return noDataAvailableDist;
return this.noDataAvailableDist;
}
/**
@@ -279,8 +280,13 @@ public class ManageDistUIState implements Serializable {
this.noDataAvailableDist = noDataAvailableDist;
}
public Map<DistributionSetIdName, Map<Long, Set<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
return consolidatedDistSoftwarewList;
/**
* Need HashSet because the Set have to be serializable
*
* @return map
*/
public Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> getConsolidatedDistSoftwarewList() {
return this.consolidatedDistSoftwarewList;
}
}

View File

@@ -49,11 +49,11 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
private SpringViewProvider viewProvider;
@Autowired
private ApplicationContext context;
private transient ApplicationContext context;
@Override
protected void init(final VaadinRequest request) {
SpringContextHelper.setContext(context);
SpringContextHelper.setContext(this.context);
final VerticalLayout rootLayout = new VerticalLayout();
final Component header = buildHeader();
@@ -69,7 +69,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
rootLayout.setExpandRatio(header, 1.0F);
rootLayout.setExpandRatio(content, 2.0F);
final Resource resource = context
final Resource resource = this.context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
@@ -81,7 +81,7 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
setContent(rootLayout);
final Navigator navigator = new Navigator(this, content);
navigator.addProvider(viewProvider);
navigator.addProvider(this.viewProvider);
setNavigator(navigator);
}

View File

@@ -79,10 +79,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private I18N i18n;
@Autowired
private DeploymentManagement deploymentManagement;
private transient DeploymentManagement deploymentManagement;
@Autowired
private EventBus.SessionEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired
private UINotification notification;
@@ -106,21 +106,21 @@ 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"));
this.actionCancel = new com.vaadin.event.Action(this.i18n.get("message.cancel.action"));
this.actionForceQuit = new com.vaadin.event.Action(this.i18n.get("message.forcequit.action"));
this.actionForceQuit.setIcon(FontAwesome.WARNING);
this.actionForce = new com.vaadin.event.Action(this.i18n.get("message.force.action"));
initializeTableSettings();
buildComponent();
restorePreviousState();
setVisibleColumns(getVisbleColumns().toArray());
eventBus.subscribe(this);
this.eventBus.subscribe(this);
setPageLength(SPUIDefinitions.PAGE_SIZE);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
this.eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -140,7 +140,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
private void buildComponent() {
// create an empty container
createContainer();
setContainerDataSource(hierarchicalContainer);
setContainerDataSource(this.hierarchicalContainer);
addGeneratedColumns();
setColumnExpandRatioForMinimisedTable();
}
@@ -171,11 +171,11 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// listeners for child
addExpandListener(event -> {
expandParentActionRow(event.getItemId());
managementUIState.getExpandParentActionRowId().add(event.getItemId());
this.managementUIState.getExpandParentActionRowId().add(event.getItemId());
});
addCollapseListener(event -> {
collapseParentActionRow(event.getItemId());
managementUIState.getExpandParentActionRowId().remove(event.getItemId());
this.managementUIState.getExpandParentActionRowId().remove(event.getItemId());
});
/*
* Add the cancel action handler for active actions. To be used to
@@ -189,25 +189,28 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
public void createContainer() {
/* Create HierarchicalContainer container */
hierarchicalContainer = new HierarchicalContainer();
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Action.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN, Long.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, String.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN, Action.Status.class,
this.hierarchicalContainer = new HierarchicalContainer();
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN, String.class,
null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Action.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN, Long.class,
null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, String.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN,
Action.Status.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null);
this.hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class,
null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null);
hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class, null);
}
/**
* Get Action based on status.
*
*
* @param type
* as Action.Type
*
*
* @return List of Actions
*/
private List<Object> getVisbleColumns() {
@@ -217,7 +220,7 @@ 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);
if (managementUIState.isActionHistoryMaximized()) {
if (this.managementUIState.isActionHistoryMaximized()) {
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME);
visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_MSGS);
visibleColumnIds.add(1, SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID);
@@ -227,7 +230,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* fetch the target details using controller id, and set it globally.
*
*
* @param selectedTarget
* reference of target
*/
@@ -245,17 +248,17 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
private void getcontainerData() {
hierarchicalContainer.removeAllItems();
this.hierarchicalContainer.removeAllItems();
/* service method to create action history for target */
final List<ActionWithStatusCount> actionHistory = deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
final List<ActionWithStatusCount> actionHistory = this.deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(this.target);
addDetailsToContainer(actionHistory);
}
/**
* Populate Container for Action.
*
*
* @param isActiveActions
* as flag
* @param reversedActions
@@ -273,16 +276,16 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final Action action = actionWithStatusCount.getAction();
final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
final Item item = this.hierarchicalContainer.addItem(actionWithStatusCount.getActionId());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue(
actionWithStatusCount.getActionStatus());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.setValue(actionWithStatusCount.getActionStatus());
/*
* add action id.
*/
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID).setValue(
actionWithStatusCount.getActionId().toString());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID)
.setValue(actionWithStatusCount.getActionId().toString());
/*
* add active/inactive status to the item which will be used in
* Column generator to generate respective icon
@@ -294,31 +297,31 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* 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());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
.setValue(actionWithStatusCount.getActionId());
/*
* 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(HawkbitCommonUtil
.getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion()));
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action);
/* Default no child */
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false);
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
.setValue(
SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null) ? actionWithStatusCount
.getActionLastModifiedAt() : actionWithStatusCount.getActionCreatedAt()));
.setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null)
? actionWithStatusCount.getActionLastModifiedAt()
: actionWithStatusCount.getActionCreatedAt()));
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME).setValue(
actionWithStatusCount.getRolloutName());
item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME)
.setValue(actionWithStatusCount.getRolloutName());
if (actionWithStatusCount.getActionStatusCount() > 0) {
((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true);
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(),
true);
}
}
}
@@ -359,7 +362,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getForcedColumn(final Object itemId) {
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
final Action actionWithActiveStatus = (Action) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
final Label actionLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
actionLabel.setContentMode(ContentMode.HTML);
@@ -379,21 +382,21 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getActiveColumn(final Object itemId) {
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
final Action.Status status = (Action.Status) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
String activeValue;
if (status == Action.Status.SCHEDULED) {
activeValue = Action.Status.SCHEDULED.toString().toLowerCase();
} else {
activeValue = (String) hierarchicalContainer.getItem(itemId)
activeValue = (String) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue();
}
final String distName = (String) hierarchicalContainer.getItem(itemId)
final String distName = (String) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).getValue();
final Label activeStatusIcon = createActiveStatusLabel(
activeValue,
(Action.Status) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue() == Action.Status.ERROR);
final Label activeStatusIcon = createActiveStatusLabel(activeValue,
(Action.Status) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.getValue() == Action.Status.ERROR);
activeStatusIcon.setId(new StringJoiner(".").add(distName).add(itemId.toString())
.add(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE).add(activeValue).toString());
return activeStatusIcon;
@@ -404,7 +407,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* @return
*/
private Component getStatusColumn(final Object itemId) {
final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId)
final Action.Status status = (Action.Status) this.hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue();
return getStatusIcon(status);
}
@@ -412,24 +415,24 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* Load the rows of previous status history of the selected action row and
* add it next to the selected action row.
*
*
* @param parentRowIdx
* index of the selected action row.
*/
@SuppressWarnings("unchecked")
private void expandParentActionRow(final Object parentRowIdx) {
/* Get the item for which the expand is made */
final Item item = hierarchicalContainer.getItem(parentRowIdx);
final Item item = this.hierarchicalContainer.getItem(parentRowIdx);
if (null != item) {
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN)
.getValue();
final org.eclipse.hawkbit.repository.model.Action action = deploymentManagement
final org.eclipse.hawkbit.repository.model.Action action = this.deploymentManagement
.findActionWithDetails(actionId);
final Pageable pageReq = new PageRequest(0, 1000);
final Page<ActionStatus> actionStatusList = deploymentManagement
final Page<ActionStatus> actionStatusList = this.deploymentManagement
.findActionStatusMessagesByActionInDescOrder(pageReq, action,
managementUIState.isActionHistoryMaximized());
this.managementUIState.isActionHistoryMaximized());
final List<ActionStatus> content = actionStatusList.getContent();
/*
* Since the recent action status and messages are already
@@ -439,7 +442,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
int childIdx = 1;
for (final ActionStatus actionStatus : content) {
final String childId = parentRowIdx + " -> " + childIdx;
final Item childItem = hierarchicalContainer.addItem(childId);
final Item childItem = this.hierarchicalContainer.addItem(childId);
if (null != childItem) {
/*
* For better UI, no need to display active/inactive icon
@@ -447,19 +450,19 @@ 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() + ":"
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST)
.setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":"
+ action.getDistributionSet().getVersion()));
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME).setValue(
SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue(
actionStatus.getStatus());
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME)
.setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt()));
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN)
.setValue(actionStatus.getStatus());
showOrHideMessage(childItem, actionStatus);
/* No further child items allowed for the child items */
((Hierarchical) hierarchicalContainer).setChildrenAllowed(childId, false);
((Hierarchical) this.hierarchicalContainer).setChildrenAllowed(childId, false);
/* Assign this childItem to the parent */
((Hierarchical) hierarchicalContainer).setParent(childId, parentRowIdx);
((Hierarchical) this.hierarchicalContainer).setParent(childId, parentRowIdx);
childIdx++;
}
@@ -469,25 +472,25 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* Hide the rows of previous status history of the selected action row.
*
*
* @param parentRowIdx
* index of the selected action row.
*/
public void collapseParentActionRow(final Object parentRowIdx) {
/* Remove all child items for the clear the memory. */
final Collection<?> children = ((Hierarchical) hierarchicalContainer).getChildren(parentRowIdx);
final Collection<?> children = ((Hierarchical) this.hierarchicalContainer).getChildren(parentRowIdx);
if (children != null && !children.isEmpty()) {
String ids = children.toString().substring(1);
ids = ids.substring(0, ids.length() - 1);
for (final String childId : ids.split(", ")) {
((Hierarchical) hierarchicalContainer).removeItem(childId);
((Hierarchical) this.hierarchicalContainer).removeItem(childId);
}
}
}
/**
* Get status icon.
*
*
* @param status
* as Status
* @return Label as UI
@@ -497,42 +500,42 @@ public class ActionHistoryTable extends TreeTable implements Handler {
final String statusIconPending = "statusIconPending";
label.setContentMode(ContentMode.HTML);
if (Action.Status.FINISHED == status) {
label.setDescription(i18n.get("label.finished"));
label.setDescription(this.i18n.get("label.finished"));
label.setStyleName(STATUS_ICON_GREEN);
label.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
} else if (Action.Status.ERROR == status) {
label.setDescription(i18n.get("label.error"));
label.setDescription(this.i18n.get("label.error"));
label.setStyleName("statusIconRed");
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (Action.Status.WARNING == status) {
label.setStyleName("statusIconOrange");
label.setDescription(i18n.get("label.warning"));
label.setDescription(this.i18n.get("label.warning"));
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (Action.Status.RUNNING == status) {
// dynamic spinner
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.running"));
label.setDescription(this.i18n.get("label.running"));
label.setValue(FontAwesome.ADJUST.getHtml());
} else if (Action.Status.CANCELING == status) {
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.cancelling"));
label.setDescription(this.i18n.get("label.cancelling"));
label.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
} else if (Action.Status.CANCELED == status) {
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.cancelled"));
label.setDescription(this.i18n.get("label.cancelled"));
label.setStyleName(STATUS_ICON_GREEN);
label.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
} else if (Action.Status.RETRIEVED == status) {
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.retrieved"));
label.setDescription(this.i18n.get("label.retrieved"));
label.setValue(FontAwesome.CIRCLE_O.getHtml());
} else if (Action.Status.DOWNLOAD == status) {
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.download"));
label.setDescription(this.i18n.get("label.download"));
label.setValue(FontAwesome.CLOUD_DOWNLOAD.getHtml());
} else if (Action.Status.SCHEDULED == status) {
label.setStyleName(statusIconPending);
label.setDescription(i18n.get("label.scheduled"));
label.setDescription(this.i18n.get("label.scheduled"));
label.setValue(FontAwesome.BULLSEYE.getHtml());
} else {
label.setDescription("");
@@ -561,13 +564,11 @@ public class ActionHistoryTable extends TreeTable implements Handler {
if (actionWithActiveStatus.isHitAutoForceTime(currentTimeMillis)) {
autoForceLabel.setDescription("autoforced");
autoForceLabel.setStyleName(STATUS_ICON_GREEN);
autoForceLabel.setDescription("auto forced since "
+ SPDateTimeUtil.getDurationFormattedString(actionWithActiveStatus.getForcedTime(),
currentTimeMillis, i18n));
autoForceLabel.setDescription("auto forced since " + SPDateTimeUtil
.getDurationFormattedString(actionWithActiveStatus.getForcedTime(), currentTimeMillis, this.i18n));
} else {
autoForceLabel.setDescription("auto forcing in "
+ SPDateTimeUtil.getDurationFormattedString(currentTimeMillis,
actionWithActiveStatus.getForcedTime(), i18n));
autoForceLabel.setDescription("auto forcing in " + SPDateTimeUtil
.getDurationFormattedString(currentTimeMillis, actionWithActiveStatus.getForcedTime(), this.i18n));
autoForceLabel.setStyleName("statusIconPending");
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
}
@@ -576,7 +577,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* Create Status Label.
*
*
* @param activeValue
* as String
* @return Labeal as UI
@@ -609,7 +610,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void createTableContentForMax() {
setColumnCollapsingAllowed(true);
if (!alreadyHasMessages) {
if (!this.alreadyHasMessages) {
/*
* check to avoid DB call for fetching the messages again and again
* if already available in container.
@@ -617,7 +618,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
getcontainerData();
// to expand parent row , if already expanded.
expandParentRow();
alreadyHasMessages = true;
this.alreadyHasMessages = true;
}
addGeneratedColumn(SPUIDefinitions.ACTION_HIS_TBL_MSGS, new Table.ColumnGenerator() {
@@ -626,8 +627,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
@SuppressWarnings("unchecked")
@Override
public Component generateCell(final Table source, final Object itemId, final Object columnId) {
final List<String> messages = (List<String>) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).getValue();
final List<String> messages = (List<String>) ActionHistoryTable.this.hierarchicalContainer
.getItem(itemId).getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).getValue();
return createMessagesBlock(messages);
}
});
@@ -649,7 +650,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* create Message block for Actions.
*
*
* @param messages
* as List of msg
* @return Component as UI
@@ -671,7 +672,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
} else {
/* Messages are not available */
updateStatusMessages.append(i18n.get("message.no.available"));
updateStatusMessages.append(this.i18n.get("message.no.available"));
}
textArea.setValue(updateStatusMessages.toString());
textArea.setReadOnly(Boolean.TRUE);
@@ -690,7 +691,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
@SuppressWarnings("unchecked")
private void showOrHideMessage(final Item childItem, final ActionStatus actionStatus) {
if (managementUIState.isActionHistoryMaximized()) {
if (this.managementUIState.isActionHistoryMaximized()) {
childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN).setValue(actionStatus.getMessages());
}
}
@@ -700,7 +701,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void normalActionHistoryTable() {
setColumnCollapsingAllowed(false);
managementUIState.setActionHistoryMaximized(false);
this.managementUIState.setActionHistoryMaximized(false);
removeGeneratedColumn(SPUIDefinitions.ACTION_HIS_TBL_MSGS);
setVisibleColumns(getVisbleColumns().toArray());
setColumnExpandRatioForMinimisedTable();
@@ -709,15 +710,15 @@ public class ActionHistoryTable extends TreeTable implements Handler {
@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 Item item = this.hierarchicalContainer.getItem(target);
final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue();
if (action.equals(actionCancel)) {
if (action.equals(this.actionCancel)) {
if (actionId != null) {
confirmAndCancelAction(actionId);
}
} else if (action.equals(actionForce)) {
} else if (action.equals(this.actionForce)) {
confirmAndForceAction(actionId);
} else if (action.equals(actionForceQuit)) {
} else if (action.equals(this.actionForceQuit)) {
confirmAndForceQuitAction(actionId);
}
}
@@ -727,18 +728,18 @@ public class ActionHistoryTable extends TreeTable implements Handler {
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)
final String activeValue = (String) this.hierarchicalContainer.getItem(target)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue();
if (SPUIDefinitions.ACTIVE.equals(activeValue)) {
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(target)
final Action actionWithActiveStatus = (Action) this.hierarchicalContainer.getItem(target)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
if (!actionWithActiveStatus.isForce()) {
actions.add(actionForce);
actions.add(this.actionForce);
}
if (!actionWithActiveStatus.isCancelingOrCanceled()) {
actions.add(actionCancel);
actions.add(this.actionCancel);
} else {
actions.add(actionForceQuit);
actions.add(this.actionForceQuit);
}
}
@@ -748,17 +749,18 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* Show confirmation window and if ok then only, force the action.
*
*
* @param actionId
* as Id if the action needs to be forced.
*/
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 -> {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
this.i18n.get("caption.force.action.confirmbox"), this.i18n.get("message.force.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
if (ok) {
/* cancel the action */
deploymentManagement.forceTargetAction(actionId);
this.deploymentManagement.forceTargetAction(actionId);
/*
* Refresh the action history table to show latest
@@ -766,8 +768,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* Target Details
*/
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.force.action.success"));
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.force.action.success"));
}
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
@@ -777,8 +779,8 @@ public class ActionHistoryTable extends TreeTable implements Handler {
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 -> {
this.i18n.get("caption.forcequit.action.confirmbox"), this.i18n.get("message.forcequit.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
if (ok) {
final boolean cancelResult = forceQuitActiveAction(actionId);
if (cancelResult) {
@@ -787,26 +789,27 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* change of the action cancellation and update the
* Target Details
*/
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.forcequit.action.success"));
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.forcequit.action.success"));
} else {
notification.displayValidationError(i18n.get("message.forcequit.action.failed"));
this.notification.displayValidationError(this.i18n.get("message.forcequit.action.failed"));
}
}
}, FontAwesome.WARNING);
} , FontAwesome.WARNING);
UI.getCurrent().addWindow(confirmDialog.getWindow());
confirmDialog.getWindow().bringToFront();
}
/**
* Show confirmation window and if ok then only, cancel the action.
*
*
* @param actionId
* as Id if the action needs to be cancelled.
*/
private void confirmAndCancelAction(final Long actionId) {
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 -> {
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
this.i18n.get("caption.cancel.action.confirmbox"), this.i18n.get("message.cancel.action.confirm"),
this.i18n.get("button.ok"), this.i18n.get("button.cancel"), ok -> {
if (ok) {
final boolean cancelResult = cancelActiveAction(actionId);
if (cancelResult) {
@@ -815,10 +818,10 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* change of the action cancellation and update the
* Target Details
*/
populateAndupdateTargetDetails(target);
notification.displaySuccess(i18n.get("message.cancel.action.success"));
populateAndupdateTargetDetails(this.target);
this.notification.displaySuccess(this.i18n.get("message.cancel.action.success"));
} else {
notification.displayValidationError(i18n.get("message.cancel.action.failed"));
this.notification.displayValidationError(this.i18n.get("message.cancel.action.failed"));
}
}
});
@@ -836,9 +839,9 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// service call to cancel the active action
private boolean cancelActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = deploymentManagement.findAction(actionId);
final Action activeAction = this.deploymentManagement.findAction(actionId);
try {
deploymentManagement.cancelAction(activeAction, target);
this.deploymentManagement.cancelAction(activeAction, this.target);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Cancel action not allowed exception :{}", e);
@@ -851,9 +854,9 @@ public class ActionHistoryTable extends TreeTable implements Handler {
// service call to cancel the active action
private boolean forceQuitActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = deploymentManagement.findAction(actionId);
final Action activeAction = this.deploymentManagement.findAction(actionId);
try {
deploymentManagement.forceQuitAction(activeAction, target);
this.deploymentManagement.forceQuitAction(activeAction, this.target);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Force Cancel action not allowed exception :{}", e);
@@ -868,7 +871,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
* Update the target status in the Target table and update the color
* settings for DS in DS table.
*/
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.EDIT_TARGET, target));
this.eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.EDIT_TARGET, this.target));
updateDistributionTableStyle();
}
@@ -878,13 +881,13 @@ public class ActionHistoryTable extends TreeTable implements Handler {
*/
private void updateDistributionTableStyle() {
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters()
if (this.managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& null != this.managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) {
final String alreadyPinnedControllerId = this.managementUIState.getDistributionTableFilters()
.getPinnedTargetId().get();
// if the current target is pinned publish a pin event again
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) {
eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(this.target.getControllerId())) {
this.eventBus.publish(this, PinUnpinEvent.PIN_TARGET);
}
}
}
@@ -898,7 +901,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
/**
* Set messages false.
*
*
* @param alreadyHasMessages
* the alreadyHasMessages to set
*/
@@ -907,15 +910,15 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
private void restorePreviousState() {
if (managementUIState.isActionHistoryMaximized()) {
if (this.managementUIState.isActionHistoryMaximized()) {
createTableContentForMax();
}
}
private void expandParentRow() {
if (null != managementUIState.getExpandParentActionRowId()
&& !managementUIState.getExpandParentActionRowId().isEmpty()) {
for (final Object obj : managementUIState.getExpandParentActionRowId()) {
if (null != this.managementUIState.getExpandParentActionRowId()
&& !this.managementUIState.getExpandParentActionRowId().isEmpty()) {
for (final Object obj : this.managementUIState.getExpandParentActionRowId()) {
expandParentActionRow(obj);
}
}

View File

@@ -54,6 +54,7 @@ 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.TextArea;
@@ -109,7 +110,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private String originalDistDescription;
private Boolean originalReqMigStep;
private String originalDistSetType;
private final List<Object> changedComponents = new ArrayList<Object>();
private final List<Component> changedComponents = new ArrayList<>();
private ValueChangeListener reqMigStepCheckboxListerner;
private TextChangeListener descTextAreaListener;
private TextChangeListener distNameTextFieldListener;
@@ -130,9 +131,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
final HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSizeFull();
buttonsLayout.setStyleName("dist-buttons-horz-layout");
buttonsLayout.addComponents(saveDistribution, discardDistribution);
buttonsLayout.setComponentAlignment(saveDistribution, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardDistribution, Alignment.BOTTOM_RIGHT);
buttonsLayout.addComponents(this.saveDistribution, this.discardDistribution);
buttonsLayout.setComponentAlignment(this.saveDistribution, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(this.discardDistribution, Alignment.BOTTOM_RIGHT);
buttonsLayout.addStyleName("window-style");
/*
@@ -142,11 +143,11 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
setSpacing(Boolean.TRUE);
addStyleName("lay-color");
setSizeUndefined();
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
reqMigStepCheckbox);
addComponents(this.madatoryLabel, this.distsetTypeNameComboBox, this.distNameTextField,
this.distVersionTextField, this.descTextArea, this.reqMigStepCheckbox);
addComponent(buttonsLayout);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
setComponentAlignment(this.madatoryLabel, Alignment.MIDDLE_LEFT);
}
@@ -154,55 +155,55 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* 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.setNullRepresentation("");
this.distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
this.i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.distNameTextField.setId(SPUIComponetIdProvider.DIST_ADD_NAME);
this.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.setNullRepresentation("");
this.distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
this.i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.distVersionTextField.setId(SPUIComponetIdProvider.DIST_ADD_VERSION);
this.distVersionTextField.setNullRepresentation("");
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
i18n.get("label.combobox.type"));
distsetTypeNameComboBox.setImmediate(true);
distsetTypeNameComboBox.setNullSelectionAllowed(false);
distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
this.distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
this.i18n.get("label.combobox.type"));
this.distsetTypeNameComboBox.setImmediate(true);
this.distsetTypeNameComboBox.setNullSelectionAllowed(false);
this.distsetTypeNameComboBox.setId(SPUIComponetIdProvider.DIST_ADD_DISTSETTYPE);
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.setNullRepresentation("");
this.descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
this.i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
this.descTextArea.setId(SPUIComponetIdProvider.DIST_ADD_DESC);
this.descTextArea.setNullRepresentation("");
/* Label for mandatory symbol */
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
this.madatoryLabel = new Label(this.i18n.get("label.mandatory.field"));
this.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);
this.reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(
this.i18n.get("checkbox.dist.required.migration.step"), "dist-checkbox-style", null, false, "");
this.reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
this.reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
/* save or update button */
saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
this.saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
saveDistribution.addClickListener(event -> saveDistribution());
this.saveDistribution.addClickListener(event -> saveDistribution());
/* close button */
discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardDistribution.addClickListener(event -> discardDistribution());
this.discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
this.discardDistribution.addClickListener(event -> discardDistribution());
}
/**
* Get the LazyQueryContainer instance for DistributionSetTypes.
*
*
* @return
*/
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
final Map<String, Object> queryConfig = new HashMap<String, Object>();
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<DistributionSetTypeBeanQuery>(
final Map<String, Object> queryConfig = new HashMap<>();
final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(
DistributionSetTypeBeanQuery.class);
dtQF.setQueryConfiguration(queryConfig);
@@ -215,22 +216,22 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void enableSaveButton() {
saveDistribution.setEnabled(true);
this.saveDistribution.setEnabled(true);
}
private DistributionSetType getDefaultDistributionSetType() {
final TenantMetaData tenantMetaData = tenantMetaDataRepository
.findByTenantIgnoreCase(systemManagement.currentTenant());
final TenantMetaData tenantMetaData = this.tenantMetaDataRepository
.findByTenantIgnoreCase(this.systemManagement.currentTenant());
return tenantMetaData.getDefaultDsType();
}
private void disableSaveButton() {
saveDistribution.setEnabled(false);
this.saveDistribution.setEnabled(false);
}
private void saveDistribution() {
/* add new or update target */
if (editDistribution) {
if (this.editDistribution) {
updateDistribution();
} else {
addNewDistribution();
@@ -242,71 +243,73 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* Update Distribution.
*/
private void updateDistribution() {
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(this.distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(this.distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
.trimAndNullIfEmpty((String) this.distsetTypeNameComboBox.getValue());
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final DistributionSet currentDS = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
final DistributionSet currentDS = this.distributionSetManagement
.findDistributionSetByIdWithDetails(this.editDistId);
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(this.descTextArea.getValue());
final boolean isMigStepReq = this.reqMigStepCheckbox.getValue();
/* identify the changes */
setDistributionValues(currentDS, name, version, distSetTypeName, desc, isMigStepReq);
try {
distributionSetManagement.updateDistributionSet(currentDS);
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
this.distributionSetManagement.updateDistributionSet(currentDS);
this.notificationMessage.displaySuccess(this.i18n.get("message.new.dist.save.success",
new Object[] { currentDS.getName(), currentDS.getVersion() }));
// update table row+details layout
eventBus.publish(this,
this.eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS));
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
notificationMessage.displayValidationError(
i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion()));
this.notificationMessage.displayValidationError(this.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);
this.reqMigStepCheckboxListerner = event -> checkValueChanged(this.originalReqMigStep, event);
this.descTextAreaListener = event -> checkValueChanged(this.originalDistDescription, event);
this.distNameTextFieldListener = event -> checkValueChanged(this.originalDistName, event);
this.distVersionTextFieldListener = event -> checkValueChanged(this.originalDistVersion, event);
this.distsetTypeNameComboBoxListener = event -> checkValueChanged(this.originalDistSetType, event);
this.reqMigStepCheckbox.addValueChangeListener(this.reqMigStepCheckboxListerner);
this.descTextArea.addTextChangeListener(this.descTextAreaListener);
this.distNameTextField.addTextChangeListener(this.distNameTextFieldListener);
this.distVersionTextField.addTextChangeListener(this.distVersionTextFieldListener);
this.distsetTypeNameComboBox.addValueChangeListener(this.distsetTypeNameComboBoxListener);
}
/**
* Add new Distribution set.
*/
private void addNewDistribution() {
editDistribution = Boolean.FALSE;
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(distVersionTextField.getValue());
this.editDistribution = Boolean.FALSE;
final String name = HawkbitCommonUtil.trimAndNullIfEmpty(this.distNameTextField.getValue());
final String version = HawkbitCommonUtil.trimAndNullIfEmpty(this.distVersionTextField.getValue());
final String distSetTypeName = HawkbitCommonUtil
.trimAndNullIfEmpty((String) distsetTypeNameComboBox.getValue());
.trimAndNullIfEmpty((String) this.distsetTypeNameComboBox.getValue());
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(this.descTextArea.getValue());
final boolean isMigStepReq = this.reqMigStepCheckbox.getValue();
DistributionSet newDist = new DistributionSet();
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
newDist = distributionSetManagement.createDistributionSet(newDist);
newDist = this.distributionSetManagement.createDistributionSet(newDist);
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
this.notificationMessage.displaySuccess(this.i18n.get("message.new.dist.save.success",
new Object[] { newDist.getName(), newDist.getVersion() }));
/* close the window */
closeThisWindow();
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ADD_DISTRIBUTION, newDist));
this.eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ADD_DISTRIBUTION, newDist));
}
}
@@ -314,8 +317,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* Close window.
*/
private void closeThisWindow() {
addDistributionWindow.close();
UI.getCurrent().removeWindow(addDistributionWindow);
this.addDistributionWindow.close();
UI.getCurrent().removeWindow(this.addDistributionWindow);
}
/**
@@ -336,7 +339,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
final String distSetTypeName, final String desc, final boolean isMigStepReq) {
distributionSet.setName(name);
distributionSet.setVersion(version);
distributionSet.setType(distributionSetManagement.findDistributionSetTypeByName(distSetTypeName));
distributionSet.setType(this.distributionSetManagement.findDistributionSetTypeByName(distSetTypeName));
distributionSet.setDescription(desc != null ? desc : "");
distributionSet.setRequiredMigrationStep(isMigStepReq);
}
@@ -351,18 +354,20 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* @return
*/
private boolean duplicateCheck(final String name, final String version) {
final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version);
final DistributionSet existingDs = this.distributionSetManagement.findDistributionSetByNameAndVersion(name,
version);
/*
* Distribution should not exists with the same name & version. Display
* error message, when the "existingDs" is not null and it is add window
* (or) when the "existingDs" is not null and it is edit window and the
* distribution Id of the edit window is different then the "existingDs"
*/
if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) {
distNameTextField.addStyleName("v-textfield-error");
distVersionTextField.addStyleName("v-textfield-error");
notificationMessage.displayValidationError(
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
if (existingDs != null
&& (!this.editDistribution || this.editDistribution && !existingDs.getId().equals(this.editDistId))) {
this.distNameTextField.addStyleName("v-textfield-error");
this.distVersionTextField.addStyleName("v-textfield-error");
this.notificationMessage.displayValidationError(this.i18n.get("message.duplicate.dist",
new Object[] { existingDs.getName(), existingDs.getVersion() }));
return false;
} else {
@@ -389,16 +394,16 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
if (name == null || version == null || distSetTypeName == null) {
if (name == null) {
distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
}
if (version == null) {
distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
}
if (distSetTypeName == null) {
distsetTypeNameComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
this.distsetTypeNameComboBox.addStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
}
notificationMessage.displayValidationError(i18n.get("message.mandatory.check"));
this.notificationMessage.displayValidationError(this.i18n.get("message.mandatory.check"));
return false;
}
@@ -407,7 +412,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private void discardDistribution() {
/* Just close this window */
distsetTypeNameComboBox.removeValueChangeListener(distsetTypeNameComboBoxListener);
this.distsetTypeNameComboBox.removeValueChangeListener(this.distsetTypeNameComboBoxListener);
closeThisWindow();
}
@@ -415,17 +420,17 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
* clear all the fields.
*/
public void resetComponents() {
editDistribution = Boolean.FALSE;
distNameTextField.clear();
distNameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distVersionTextField.clear();
distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
descTextArea.clear();
reqMigStepCheckbox.clear();
saveDistribution.setEnabled(true);
this.editDistribution = Boolean.FALSE;
this.distNameTextField.clear();
this.distNameTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distVersionTextField.clear();
this.distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
this.distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
this.descTextArea.clear();
this.reqMigStepCheckbox.clear();
this.saveDistribution.setEnabled(true);
removeListeners();
changedComponents.clear();
this.changedComponents.clear();
}
private void populateRequiredComponents() {
@@ -433,10 +438,10 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void removeListeners() {
reqMigStepCheckbox.removeValueChangeListener(reqMigStepCheckboxListerner);
descTextArea.removeTextChangeListener(descTextAreaListener);
distNameTextField.removeTextChangeListener(distNameTextFieldListener);
distVersionTextField.removeTextChangeListener(distVersionTextFieldListener);
this.reqMigStepCheckbox.removeValueChangeListener(this.reqMigStepCheckboxListerner);
this.descTextArea.removeTextChangeListener(this.descTextAreaListener);
this.distNameTextField.removeTextChangeListener(this.distNameTextFieldListener);
this.distVersionTextField.removeTextChangeListener(this.distVersionTextFieldListener);
}
public void setOriginalDistName(final String originalDistName) {
@@ -452,41 +457,41 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void checkValueChanged(final String originalValue, final TextChangeEvent event) {
if (editDistribution) {
if (this.editDistribution) {
final String newValue = event.getText();
if (!originalValue.equalsIgnoreCase(newValue)) {
changedComponents.add(event.getComponent());
this.changedComponents.add(event.getComponent());
} else {
changedComponents.remove(event.getComponent());
this.changedComponents.remove(event.getComponent());
}
enableDisableSaveButton();
}
}
private void checkValueChanged(final Boolean originalValue, final ValueChangeEvent event) {
if (editDistribution) {
if (this.editDistribution) {
if (!originalValue.equals(event.getProperty().getValue())) {
changedComponents.add(reqMigStepCheckbox);
this.changedComponents.add(this.reqMigStepCheckbox);
} else {
changedComponents.remove(reqMigStepCheckbox);
this.changedComponents.remove(this.reqMigStepCheckbox);
}
enableDisableSaveButton();
}
}
private void checkValueChanged(final String originalValue, final ValueChangeEvent event) {
if (editDistribution) {
if (this.editDistribution) {
if (!originalValue.equals(event.getProperty().getValue())) {
changedComponents.add(distsetTypeNameComboBox);
this.changedComponents.add(this.distsetTypeNameComboBox);
} else {
changedComponents.remove(distsetTypeNameComboBox);
this.changedComponents.remove(this.distsetTypeNameComboBox);
}
enableDisableSaveButton();
}
}
private void enableDisableSaveButton() {
if (changedComponents.isEmpty()) {
if (this.changedComponents.isEmpty()) {
disableSaveButton();
} else {
enableSaveButton();
@@ -499,24 +504,24 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
/**
* populate data.
*
*
* @param editDistId
*/
public void populateValuesOfDistribution(final Long editDistId) {
this.editDistId = editDistId;
editDistribution = Boolean.TRUE;
saveDistribution.setEnabled(false);
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
this.editDistribution = Boolean.TRUE;
this.saveDistribution.setEnabled(false);
final DistributionSet distSet = this.distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
if (distSet != null) {
distNameTextField.setValue(distSet.getName());
distVersionTextField.setValue(distSet.getVersion());
this.distNameTextField.setValue(distSet.getName());
this.distVersionTextField.setValue(distSet.getVersion());
if (distSet.getType().isDeleted()) {
distsetTypeNameComboBox.addItem(distSet.getType().getName());
this.distsetTypeNameComboBox.addItem(distSet.getType().getName());
}
distsetTypeNameComboBox.setValue(distSet.getType().getName());
reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
this.distsetTypeNameComboBox.setValue(distSet.getType().getName());
this.reqMigStepCheckbox.setValue(distSet.isRequiredMigrationStep());
if (distSet.getDescription() != null) {
descTextArea.setValue(distSet.getDescription());
this.descTextArea.setValue(distSet.getDescription());
}
setOriginalDistName(distSet.getName());
setOriginalDistVersion(distSet.getVersion());
@@ -528,22 +533,22 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
public Window getWindow() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
this.eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
populateRequiredComponents();
resetComponents();
addDistributionWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.dist"), null,
this.addDistributionWindow = SPUIComponentProvider.getWindow(this.i18n.get("caption.add.new.dist"), null,
SPUIDefinitions.CREATE_UPDATE_WINDOW);
addDistributionWindow.setContent(this);
return addDistributionWindow;
this.addDistributionWindow.setContent(this);
return this.addDistributionWindow;
}
/**
* Populate DistributionSet Type name combo.
*/
public void populateDistSetTypeNameCombo() {
distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
this.distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
this.distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
this.distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getName());
}
/**

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.ui.management.footer;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -27,7 +26,7 @@ public final class DeleteActionsLayoutHelper {
/**
* Checks if component is a target tag.
*
*
* @param source
* Component dropped
* @return true if it component is target tag
@@ -45,7 +44,7 @@ public final class DeleteActionsLayoutHelper {
/**
* Checks if component is distribution tag.
*
*
* @param source
* component dropped
* @return true if it component is distribution tag
@@ -63,29 +62,29 @@ public final class DeleteActionsLayoutHelper {
/**
* Checks if component is target table.
*
*
* @param source
* component dropped
* @return true if it component is target table
*/
public static boolean isTargetTable(final Component source) {
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.TARGET_TABLE_ID);
return SPUIComponetIdProvider.TARGET_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**
* Checks id component is distribution table.
*
*
* @param source
* component dropped
* @return true if it component is distribution table
*/
public static boolean isDistributionTable(final Component source) {
return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID);
return SPUIComponetIdProvider.DIST_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**
* Check if dropped component can be deleted.
*
*
* @param source
* component dropped
* @return true if component can be deleted

View File

@@ -35,17 +35,19 @@ public class ManagementUIState implements Serializable {
private static final long serialVersionUID = 7301409196969723794L;
private final transient Set<Object> expandParentActionRowId = new HashSet<>();
@Autowired
private DistributionTableFilters distributionTableFilters;
@Autowired
private TargetTableFilters targetTableFilters;
private final Map<TargetIdName, DistributionSetIdName> assignedList = new HashMap<TargetIdName, DistributionSetIdName>();
private final Map<TargetIdName, DistributionSetIdName> assignedList = new HashMap<>();
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<DistributionSetIdName>();
private final Set<DistributionSetIdName> deletedDistributionList = new HashSet<>();
private final Set<TargetIdName> deletedTargetList = new HashSet<TargetIdName>();
private final Set<TargetIdName> deletedTargetList = new HashSet<>();
private Boolean targetTagLayoutVisible = Boolean.TRUE;
@@ -79,9 +81,7 @@ public class ManagementUIState implements Serializable {
private boolean noDataAvailableDistribution = Boolean.FALSE;
private final Set<String> canceledTargetName = new HashSet<String>();
private final Set<Object> expandParentActionRowId = new HashSet<Object>();
private final Set<String> canceledTargetName = new HashSet<>();
private boolean customFilterSelected;
@@ -91,7 +91,7 @@ public class ManagementUIState implements Serializable {
* @return the bulkUploadWindowMinimised
*/
public boolean isBulkUploadWindowMinimised() {
return bulkUploadWindowMinimised;
return this.bulkUploadWindowMinimised;
}
/**
@@ -106,7 +106,7 @@ public class ManagementUIState implements Serializable {
* @return the isCustomFilterSelected
*/
public boolean isCustomFilterSelected() {
return customFilterSelected;
return this.customFilterSelected;
}
/**
@@ -118,11 +118,11 @@ public class ManagementUIState implements Serializable {
}
public Set<Object> getExpandParentActionRowId() {
return expandParentActionRowId;
return this.expandParentActionRowId;
}
public Set<String> getCanceledTargetName() {
return canceledTargetName;
return this.canceledTargetName;
}
public void setDistTagLayoutVisible(final Boolean distTagLayoutVisible) {
@@ -130,7 +130,7 @@ public class ManagementUIState implements Serializable {
}
public Boolean getDistTagLayoutVisible() {
return distTagLayoutVisible;
return this.distTagLayoutVisible;
}
public void setTargetTagLayoutVisible(final Boolean targetTagVisible) {
@@ -138,31 +138,31 @@ public class ManagementUIState implements Serializable {
}
public Boolean getTargetTagLayoutVisible() {
return targetTagLayoutVisible;
return this.targetTagLayoutVisible;
}
public TargetTableFilters getTargetTableFilters() {
return targetTableFilters;
return this.targetTableFilters;
}
public DistributionTableFilters getDistributionTableFilters() {
return distributionTableFilters;
return this.distributionTableFilters;
}
public Map<TargetIdName, DistributionSetIdName> getAssignedList() {
return assignedList;
return this.assignedList;
}
public Set<DistributionSetIdName> getDeletedDistributionList() {
return deletedDistributionList;
return this.deletedDistributionList;
}
public Set<TargetIdName> getDeletedTargetList() {
return deletedTargetList;
return this.deletedTargetList;
}
public TargetIdName getLastSelectedTargetIdName() {
return lastSelectedTargetIdName;
return this.lastSelectedTargetIdName;
}
public void setLastSelectedTargetIdName(final TargetIdName lastSelectedTargetIdName) {
@@ -170,7 +170,7 @@ public class ManagementUIState implements Serializable {
}
public Optional<Set<TargetIdName>> getSelectedTargetIdName() {
return selectedTargetIdName == null ? Optional.empty() : Optional.of(selectedTargetIdName);
return this.selectedTargetIdName == null ? Optional.empty() : Optional.of(this.selectedTargetIdName);
}
public void setSelectedTargetIdName(final Set<TargetIdName> selectedTargetIdName) {
@@ -181,7 +181,7 @@ public class ManagementUIState implements Serializable {
* @return the targetTagFilterClosed
*/
public boolean isTargetTagFilterClosed() {
return targetTagFilterClosed;
return this.targetTagFilterClosed;
}
/**
@@ -196,7 +196,7 @@ public class ManagementUIState implements Serializable {
* @return the distTagFilterClosed
*/
public boolean isDistTagFilterClosed() {
return distTagFilterClosed;
return this.distTagFilterClosed;
}
/**
@@ -211,7 +211,7 @@ public class ManagementUIState implements Serializable {
* @return the targetsTruncated
*/
public Long getTargetsTruncated() {
return targetsTruncated;
return this.targetsTruncated;
}
/**
@@ -226,7 +226,7 @@ public class ManagementUIState implements Serializable {
* @return the targetsCountAll
*/
public long getTargetsCountAll() {
return targetsCountAll.get();
return this.targetsCountAll.get();
}
/**
@@ -255,7 +255,7 @@ public class ManagementUIState implements Serializable {
}
public boolean isDsTableMaximized() {
return isDsTableMaximized;
return this.isDsTableMaximized;
}
public void setDsTableMaximized(final boolean isDsTableMaximized) {
@@ -263,7 +263,7 @@ public class ManagementUIState implements Serializable {
}
public DistributionSetIdName getLastSelectedDsIdName() {
return lastSelectedDsIdName;
return this.lastSelectedDsIdName;
}
public void setLastSelectedDsIdName(final DistributionSetIdName lastSelectedDsIdName) {
@@ -275,14 +275,14 @@ public class ManagementUIState implements Serializable {
}
public Optional<Set<DistributionSetIdName>> getSelectedDsIdName() {
return selectedDsIdName == null ? Optional.empty() : Optional.of(selectedDsIdName);
return this.selectedDsIdName == null ? Optional.empty() : Optional.of(this.selectedDsIdName);
}
/**
* @return the isTargetTableMaximized
*/
public boolean isTargetTableMaximized() {
return isTargetTableMaximized;
return this.isTargetTableMaximized;
}
/**
@@ -297,7 +297,7 @@ public class ManagementUIState implements Serializable {
* @return the isActionHistoryMaximized
*/
public boolean isActionHistoryMaximized() {
return isActionHistoryMaximized;
return this.isActionHistoryMaximized;
}
/**
@@ -312,7 +312,7 @@ public class ManagementUIState implements Serializable {
* @return the noDataAvilableTarget
*/
public boolean isNoDataAvilableTarget() {
return noDataAvilableTarget;
return this.noDataAvilableTarget;
}
/**
@@ -327,7 +327,7 @@ public class ManagementUIState implements Serializable {
* @return the noDataAvailableDistribution
*/
public boolean isNoDataAvailableDistribution() {
return noDataAvailableDistribution;
return this.noDataAvailableDistribution;
}
/**

View File

@@ -56,12 +56,7 @@ import com.vaadin.ui.components.colorpicker.ColorSelector;
import com.vaadin.ui.themes.ValoTheme;
/**
*
* Abstract class for create/update target tag layout.
*
*
*
*
*/
public abstract class CreateUpdateTagLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
private static final long serialVersionUID = 4229177824620576456L;
@@ -78,7 +73,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
protected I18N i18n;
@Autowired
protected TagManagement tagManagement;
protected transient TagManagement tagManagement;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@@ -124,14 +119,14 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
/**
* 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 abstract void discard(final Button.ClickEvent event);
@@ -155,126 +150,126 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
createRequiredComponents();
addListeners();
buildLayout();
eventBus.subscribe(this);
this.eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
this.eventBus.unsubscribe(this);
}
private void createRequiredComponents() {
createTagNw = i18n.get("label.create.tag");
updateTagNw = i18n.get("label.update.tag");
createTag = SPUIComponentProvider.getLabel(createTagNw, null);
updateTag = SPUIComponentProvider.getLabel(i18n.get("label.update.tag"), null);
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
madatoryLabel = getMandatoryLabel();
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
this.createTagNw = this.i18n.get("label.create.tag");
this.updateTagNw = this.i18n.get("label.update.tag");
this.createTag = SPUIComponentProvider.getLabel(this.createTagNw, null);
this.updateTag = SPUIComponentProvider.getLabel(this.i18n.get("label.update.tag"), null);
this.comboLabel = SPUIComponentProvider.getLabel(this.i18n.get("label.choose.tag"), null);
this.madatoryLabel = getMandatoryLabel();
this.colorLabel = SPUIComponentProvider.getLabel(this.i18n.get("label.choose.tag.color"), null);
this.colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
this.tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
true, "", this.i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
this.tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC,
false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
this.tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC,
false, "", this.i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
tagDesc.setImmediate(true);
tagDesc.setNullRepresentation("");
this.tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
this.tagDesc.setImmediate(true);
this.tagDesc.setNullRepresentation("");
tagNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
i18n.get("label.combobox.tag"));
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
tagNameComboBox.setImmediate(true);
this.tagNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
this.i18n.get("label.combobox.tag"));
this.tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
this.tagNameComboBox.setImmediate(true);
saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_SAVE, "", "", "", true,
this.saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
this.saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
this.discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
"discard-button-style", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
this.discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
tagColorPreviewBtn = new Button();
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
this.tagColorPreviewBtn = new Button();
this.tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
getPreviewButtonColor(DEFAULT_COLOR);
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
this.tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
selectors = new HashSet<ColorSelector>();
selectedColor = new Color(44, 151, 32);
selPreview = new SpColorPickerPreview(selectedColor);
this.selectors = new HashSet<>();
this.selectedColor = new Color(44, 151, 32);
this.selPreview = new SpColorPickerPreview(this.selectedColor);
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
colorSelect.setColor(selectedColor);
colorSelect.setWidth("220px");
this.colorSelect = new ColorPickerGradient("rgb-gradient", this.rgbConverter);
this.colorSelect.setColor(this.selectedColor);
this.colorSelect.setWidth("220px");
redSlider = createRGBSlider("", "red");
greenSlider = createRGBSlider("", "green");
blueSlider = createRGBSlider("", "blue");
setRgbSliderValues(selectedColor);
this.redSlider = createRGBSlider("", "red");
this.greenSlider = createRGBSlider("", "green");
this.blueSlider = createRGBSlider("", "blue");
setRgbSliderValues(this.selectedColor);
createOptionGroup();
}
private void buildLayout() {
comboLayout = new VerticalLayout();
this.comboLayout = new VerticalLayout();
sliders = new VerticalLayout();
sliders.addComponents(redSlider, greenSlider, blueSlider);
this.sliders = new VerticalLayout();
this.sliders.addComponents(this.redSlider, this.greenSlider, this.blueSlider);
selectors.add(colorSelect);
this.selectors.add(this.colorSelect);
colorPickerLayout = new VerticalLayout();
colorPickerLayout.setStyleName("rgb-vertical-layout");
colorPickerLayout.addComponent(selPreview);
colorPickerLayout.addComponent(colorSelect);
this.colorPickerLayout = new VerticalLayout();
this.colorPickerLayout.setStyleName("rgb-vertical-layout");
this.colorPickerLayout.addComponent(this.selPreview);
this.colorPickerLayout.addComponent(this.colorSelect);
fieldLayout = new VerticalLayout();
fieldLayout.setSpacing(false);
fieldLayout.setMargin(false);
fieldLayout.setWidth("100%");
fieldLayout.setHeight(null);
fieldLayout.addComponent(optiongroup);
fieldLayout.addComponent(comboLayout);
fieldLayout.addComponent(madatoryLabel);
fieldLayout.addComponent(tagName);
fieldLayout.addComponent(tagDesc);
this.fieldLayout = new VerticalLayout();
this.fieldLayout.setSpacing(false);
this.fieldLayout.setMargin(false);
this.fieldLayout.setWidth("100%");
this.fieldLayout.setHeight(null);
this.fieldLayout.addComponent(this.optiongroup);
this.fieldLayout.addComponent(this.comboLayout);
this.fieldLayout.addComponent(this.madatoryLabel);
this.fieldLayout.addComponent(this.tagName);
this.fieldLayout.addComponent(this.tagDesc);
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
fieldLayout.addComponent(colorLabelLayout);
colorLabelLayout.addComponents(this.colorLabel, this.tagColorPreviewBtn);
this.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.addComponent(this.saveTag);
buttonLayout.addComponent(this.discardTag);
buttonLayout.setComponentAlignment(this.discardTag, Alignment.BOTTOM_RIGHT);
buttonLayout.setComponentAlignment(this.saveTag, Alignment.BOTTOM_LEFT);
buttonLayout.addStyleName("window-style");
buttonLayout.setWidth("152px");
final VerticalLayout fieldButtonLayout = new VerticalLayout();
fieldButtonLayout.addComponent(fieldLayout);
fieldButtonLayout.addComponent(this.fieldLayout);
fieldButtonLayout.addComponent(buttonLayout);
fieldButtonLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);
mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout);
this.mainLayout = new HorizontalLayout();
this.mainLayout.addComponent(fieldButtonLayout);
setCompositionRoot(mainLayout);
setCompositionRoot(this.mainLayout);
}
private void addListeners() {
saveTag.addClickListener(event -> save(event));
discardTag.addClickListener(event -> discard(event));
colorSelect.addColorChangeListener(this);
selPreview.addColorChangeListener(this);
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
optiongroup.addValueChangeListener(event -> optionValueChanged(event));
tagNameComboBox.addValueChangeListener(event -> tagNameChosen(event));
this.saveTag.addClickListener(event -> save(event));
this.discardTag.addClickListener(event -> discard(event));
this.colorSelect.addColorChangeListener(this);
this.selPreview.addColorChangeListener(this);
this.tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
this.optiongroup.addValueChangeListener(event -> optionValueChanged(event));
this.tagNameComboBox.addValueChangeListener(event -> tagNameChosen(event));
slidersValueChangeListeners();
}
@@ -283,63 +278,68 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* on target tag if already selected.
*/
private void previewButtonClicked() {
if (!tagPreviewBtnClicked) {
final String selectedOption = (String) optiongroup.getValue();
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTagNw)) {
if (null != tagNameComboBox.getValue()) {
final TargetTag targetTagSelected = tagManagement
.findTargetTag(tagNameComboBox.getValue().toString());
if (null != targetTagSelected) {
selectedColor = targetTagSelected.getColour() != null
? rgbToColorConverter(targetTagSelected.getColour())
: rgbToColorConverter(DEFAULT_COLOR);
} else {
final DistributionSetTag distTag = tagManagement
.findDistributionSetTag(tagNameComboBox.getValue().toString());
selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
: rgbToColorConverter(DEFAULT_COLOR);
}
} else {
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
}
}
selPreview.setColor(selectedColor);
fieldLayout.addComponent(sliders);
mainLayout.addComponent(colorPickerLayout);
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
if (!this.tagPreviewBtnClicked) {
setColor();
this.selPreview.setColor(this.selectedColor);
this.fieldLayout.addComponent(this.sliders);
this.mainLayout.addComponent(this.colorPickerLayout);
this.mainLayout.setComponentAlignment(this.colorPickerLayout, Alignment.BOTTOM_CENTER);
}
tagPreviewBtnClicked = !tagPreviewBtnClicked;
this.tagPreviewBtnClicked = !this.tagPreviewBtnClicked;
}
private void setColor() {
final String selectedOption = (String) this.optiongroup.getValue();
if (selectedOption == null || !selectedOption.equalsIgnoreCase(this.updateTagNw)) {
return;
}
if (this.tagNameComboBox.getValue() == null) {
this.selectedColor = rgbToColorConverter(DEFAULT_COLOR);
return;
}
final TargetTag targetTagSelected = this.tagManagement
.findTargetTag(this.tagNameComboBox.getValue().toString());
if (targetTagSelected == null) {
final DistributionSetTag distTag = this.tagManagement
.findDistributionSetTag(this.tagNameComboBox.getValue().toString());
this.selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
: rgbToColorConverter(DEFAULT_COLOR);
} else {
this.selectedColor = targetTagSelected.getColour() != null
? rgbToColorConverter(targetTagSelected.getColour()) : rgbToColorConverter(DEFAULT_COLOR);
}
}
/**
* Covert RGB code to {@Color}.
*
*
* @param value
* RGB vale
* @return Color
*/
protected Color rgbToColorConverter(final String value) {
if (value.startsWith("rgb")) {
// 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);
} else {
return new Color(red, green, blue);
}
if (!value.startsWith("rgb")) {
return null;
}
// 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);
} else {
return new Color(red, green, blue);
}
return null;
}
private Label getMandatoryLabel() {
final Label label = new Label(i18n.get("label.mandatory.field"));
final Label label = new Label(this.i18n.get("label.mandatory.field"));
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
return label;
}
@@ -354,51 +354,51 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
}
private void resetTagNameField() {
tagName.setEnabled(false);
tagName.clear();
this.tagName.setEnabled(false);
this.tagName.clear();
tagDesc.clear();
this.tagDesc.clear();
restoreComponentStyles();
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
selectedColor = new Color(44, 151, 32);
selPreview.setColor(selectedColor);
tagPreviewBtnClicked = false;
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
this.selectedColor = new Color(44, 151, 32);
this.selPreview.setColor(this.selectedColor);
this.tagPreviewBtnClicked = false;
}
/**
* Listener for option group - Create tag/Update.
*
*
* @param event
* ValueChangeEvent
*/
private void optionValueChanged(final ValueChangeEvent event) {
if ("Update Tag".equals(event.getProperty().getValue())) {
tagName.clear();
tagDesc.clear();
tagName.setEnabled(false);
this.tagName.clear();
this.tagDesc.clear();
this.tagName.setEnabled(false);
populateTagNameCombo();
// show target name combo
comboLayout.addComponent(comboLabel);
comboLayout.addComponent(tagNameComboBox);
this.comboLayout.addComponent(this.comboLabel);
this.comboLayout.addComponent(this.tagNameComboBox);
} else {
tagName.setEnabled(true);
tagName.clear();
tagDesc.clear();
this.tagName.setEnabled(true);
this.tagName.clear();
this.tagDesc.clear();
// hide target name combo
comboLayout.removeComponent(comboLabel);
comboLayout.removeComponent(tagNameComboBox);
this.comboLayout.removeComponent(this.comboLabel);
this.comboLayout.removeComponent(this.tagNameComboBox);
}
// close the color picker layout
tagPreviewBtnClicked = false;
this.tagPreviewBtnClicked = false;
// reset the selected color - Set defualt color
restoreComponentStyles();
getPreviewButtonColor(DEFAULT_COLOR);
selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
this.selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
// remove the sliders and color picker layout
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
}
@@ -406,23 +406,23 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* reset the components.
*/
protected void reset() {
tagName.setEnabled(true);
tagName.clear();
tagDesc.clear();
this.tagName.setEnabled(true);
this.tagName.clear();
this.tagDesc.clear();
restoreComponentStyles();
// hide target name combo
comboLayout.removeComponent(comboLabel);
comboLayout.removeComponent(tagNameComboBox);
fieldLayout.removeComponent(sliders);
mainLayout.removeComponent(colorPickerLayout);
this.comboLayout.removeComponent(this.comboLabel);
this.comboLayout.removeComponent(this.tagNameComboBox);
this.fieldLayout.removeComponent(this.sliders);
this.mainLayout.removeComponent(this.colorPickerLayout);
optiongroup.select(createTagNw);
this.optiongroup.select(this.createTagNw);
// Default green color
selectedColor = new Color(44, 151, 32);
selPreview.setColor(selectedColor);
tagPreviewBtnClicked = false;
this.selectedColor = new Color(44, 151, 32);
this.selPreview.setColor(this.selectedColor);
this.tagPreviewBtnClicked = false;
}
/**
@@ -432,14 +432,15 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
@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);
for (final ColorSelector select : this.selectors) {
if (!event.getSource().equals(select) && select.equals(this)
&& !select.getColor().equals(this.selectedColor)) {
select.setColor(this.selectedColor);
}
}
setRgbSliderValues(selectedColor);
setRgbSliderValues(this.selectedColor);
getPreviewButtonColor(event.getColor().getCSS());
createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
createDynamicStyleForComponents(this.tagName, this.tagDesc, event.getColor().getCSS());
}
/**
@@ -465,11 +466,11 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
private void setRgbSliderValues(final Color color) {
try {
final double redColorValue = color.getRed();
redSlider.setValue(new Double(redColorValue));
this.redSlider.setValue(new Double(redColorValue));
final double blueColorValue = color.getBlue();
blueSlider.setValue(new Double(blueColorValue));
this.blueSlider.setValue(new Double(blueColorValue));
final double greenColorValue = color.getGreen();
greenSlider.setValue(new Double(greenColorValue));
this.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);
@@ -478,7 +479,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
/**
* Set tag name and desc field border color based on chosen color.
*
*
* @param tagName
* @param tagDesc
* @param taregtTagColor
@@ -496,17 +497,17 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* reset the tag name and tag description component border color.
*/
private void restoreComponentStyles() {
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
this.tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
this.tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
this.tagName.addStyleName(SPUIDefinitions.TAG_NAME);
this.tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
getPreviewButtonColor(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) {
@@ -524,12 +525,12 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
if (color == null) {
return;
}
selectedColor = color;
selPreview.setColor(selectedColor);
final String colorPickedPreview = selPreview.getColor().getCSS();
if (tagName.isEnabled() && null != colorSelect) {
createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
colorSelect.setColor(selPreview.getColor());
this.selectedColor = color;
this.selPreview.setColor(this.selectedColor);
final String colorPickedPreview = this.selPreview.getColor().getCSS();
if (this.tagName.isEnabled() && null != this.colorSelect) {
createDynamicStyleForComponents(this.tagName, this.tagDesc, colorPickedPreview);
this.colorSelect.setColor(this.selPreview.getColor());
}
}
@@ -537,33 +538,36 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
* Value change listeners implementations of sliders.
*/
private void slidersValueChangeListeners() {
redSlider.addValueChangeListener(new ValueChangeListener() {
this.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());
final Color newColor = new Color((int) red, CreateUpdateTagLayout.this.selectedColor.getGreen(),
CreateUpdateTagLayout.this.selectedColor.getBlue());
setColorToComponents(newColor);
}
});
greenSlider.addValueChangeListener(new ValueChangeListener() {
this.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());
final Color newColor = new Color(CreateUpdateTagLayout.this.selectedColor.getRed(), (int) green,
CreateUpdateTagLayout.this.selectedColor.getBlue());
setColorToComponents(newColor);
}
});
blueSlider.addValueChangeListener(new ValueChangeListener() {
this.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);
final Color newColor = new Color(CreateUpdateTagLayout.this.selectedColor.getRed(),
CreateUpdateTagLayout.this.selectedColor.getGreen(), (int) blue);
setColorToComponents(newColor);
}
});
@@ -571,9 +575,9 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
private void setColorToComponents(final Color newColor) {
setColor(newColor);
colorSelect.setColor(newColor);
this.colorSelect.setColor(newColor);
getPreviewButtonColor(newColor.getCSS());
createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
createDynamicStyleForComponents(this.tagName, this.tagDesc, newColor.getCSS());
}
@Override

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.ui.management.targettag;
import java.io.Serializable;
import java.util.Optional;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@@ -27,9 +26,9 @@ import com.vaadin.ui.Button.ClickEvent;
/**
* Single button click behaviour of custom target filter buttons layout.
*
*
*
*
*
*/
@SpringComponent
@ViewScope
@@ -48,28 +47,28 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
/*
* (non-Javadoc)
*
*
* @see org.eclipse.hawkbit.server.ui.common.filterlayout.
* AbstractFilterButtonClickBehaviour#filterUnClicked (com.vaadin.ui.Button)
*/
@Override
protected void filterUnClicked(final Button clickedButton) {
managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
this.eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
}
/*
* (non-Javadoc)
*
*
* @see hawkbit.server.ui.layouts.SPFilterButtonClickBehaviour#filterClicked
* (com.vaadin.ui.Button )
*/
@Override
protected void filterClicked(final Button clickedButton) {
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
final TargetFilterQuery targetFilterQuery = this.targetFilterQueryManagement
.findTargetFilterQueryById((Long) clickedButton.getData());
managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
this.eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
}
protected void processButtonClick(final ClickEvent event) {
@@ -77,12 +76,12 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
}
protected void clearAppliedTargetFilterQuery() {
if (getAlreadyClickedButton().isPresent()) {
getAlreadyClickedButton().get().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
setAlreadyClickedButton(Optional.empty());
if (getAlreadyClickedButton() != null) {
getAlreadyClickedButton().removeStyleName(SPUIStyleDefinitions.SP_FILTER_BTN_CLICKED_STYLE);
setAlreadyClickedButton(null);
}
managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(null);
this.eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY);
}
protected void setDefaultButtonClicked(final Button button) {

View File

@@ -8,12 +8,14 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import java.io.Serializable;
import com.vaadin.ui.Component;
/**
* Interface to be implemented by any tenant specific configuration to show on
* the UI.
*
*
*
*
*
@@ -48,7 +50,7 @@ public interface TenantConfigurationItem extends Component {
/**
* Adds a configuration change listener to notify about configuration
* changes.
*
*
* @param listener
* the listener to be notified in case the item changes some
* configuration
@@ -58,11 +60,12 @@ public interface TenantConfigurationItem extends Component {
/**
* Configuration Change Listener to be notified about configuration changes
* in configuration item.
*
*
*
*
*/
interface TenantConfigurationChangeListener {
@FunctionalInterface
interface TenantConfigurationChangeListener extends Serializable {
/**
* called to notify about configuration has been changed.
*/

View File

@@ -57,7 +57,7 @@ import com.vaadin.ui.UI;
/**
* Common util class.
*
*
*
*
*/
@@ -122,7 +122,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -138,7 +138,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -154,7 +154,7 @@ public final class HawkbitCommonUtil {
/**
* Check Map is valid.
*
*
* @param mapCheck
* as Map
* @return boolean as flag
@@ -170,7 +170,7 @@ public final class HawkbitCommonUtil {
/**
* Check List is valid.
*
*
* @param listCheck
* as List
* @return boolean as flag
@@ -186,7 +186,7 @@ public final class HawkbitCommonUtil {
/**
* Check Boolean Array is valid.
*
*
* @param bolArray
* as List
* @return boolean as flag
@@ -202,7 +202,7 @@ public final class HawkbitCommonUtil {
/**
* Check String null, return empty.
*
*
* @param nString
* as String
* @return String
@@ -217,7 +217,7 @@ public final class HawkbitCommonUtil {
/**
* Check valid String.
*
*
* @param nString
* as String
* @return boolean as flag
@@ -232,7 +232,7 @@ public final class HawkbitCommonUtil {
/**
* Trim the text and convert into null in case of empty string.
*
*
* @param text
* as text to be trimed
* @return null if the text is null or if the text is blank, text.trim() if
@@ -249,7 +249,7 @@ public final class HawkbitCommonUtil {
/**
* Concatenate the given text all the string arguments with the given
* delimiter.
*
*
* @param delimiter
* the delimiter text to be used while concatenation.
* @param texts
@@ -263,20 +263,19 @@ public final class HawkbitCommonUtil {
public static String concatStrings(final String delimiter, final String... texts) {
final String delim = delimiter == null ? SP_STRING_EMPTY : delimiter;
final StringBuilder conCatStrBldr = new StringBuilder();
String conCatedStr = null;
if (null != texts) {
for (final String text : texts) {
conCatStrBldr.append(delim);
conCatStrBldr.append(text);
}
}
conCatedStr = conCatStrBldr.toString();
final String conCatedStr = conCatStrBldr.toString();
return delim.length() > 0 && conCatedStr.startsWith(delim) ? conCatedStr.substring(1) : conCatedStr;
}
/**
* Returns the input text within html bold tag <b>..</b>.
*
*
* @param text
* is the text to be converted in to Bold
* @return null if the input text param is null returns text with <b>...</b>
@@ -295,7 +294,7 @@ public final class HawkbitCommonUtil {
/**
* Get target label Id.
*
*
* @param controllerId
* as String
* @return String as label name
@@ -343,31 +342,6 @@ public final class HawkbitCommonUtil {
return labelId.toString();
}
/**
* Check if two objects are same or not.
*
* @param obj1
* as reference
* @param obj2
* as reference
* @return true if both obj1 & obj2 are null (or) if the .equals() method
* return true. false if only either one of obj1 & obj2 is null (or)
* if .equals() method return false.
*/
public static boolean bothSame(final Object obj1, final Object obj2) {
boolean result = false;
if (obj1 == null && obj2 == null) {
result = true;
} else if (obj1 == null && obj2 != null) {
result = false;
} else if (obj1 != null && obj2 == null) {
result = false;
} else {
result = obj2.equals(obj1);
}
return result;
}
/**
* Get label with software module name and description.
*
@@ -386,7 +360,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Artifact Details.
*
*
* @param name
* @return
*/
@@ -399,7 +373,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Artifact Details.
*
*
* @param caption
* as caption of the details
* @param name
@@ -415,7 +389,7 @@ public final class HawkbitCommonUtil {
/**
* Get Label for Action History Details.
*
*
* @param name
* @return
*/
@@ -428,7 +402,7 @@ public final class HawkbitCommonUtil {
/**
* Get tool tip for Poll status.
*
*
* @param pollStatus
* @param i18N
* @return
@@ -475,7 +449,7 @@ public final class HawkbitCommonUtil {
/**
* Find extra height required to increase by all the components to utilize
* the full height of browser for the responsive UI.
*
*
* @param newBrowserHeight
* as current browser height.
* @return extra height required to increase.
@@ -694,7 +668,7 @@ public final class HawkbitCommonUtil {
/**
* Create javascript to display number of targets or distributions your are
* dragging in the drag image.
*
*
* @param count
* @return
*/
@@ -714,7 +688,7 @@ public final class HawkbitCommonUtil {
/**
* Get IM User for user UUID.
*
*
* @param uuid
* @return imReslovedUser user details
*/
@@ -738,7 +712,7 @@ public final class HawkbitCommonUtil {
/**
* Get formatted label.Appends ellipses if content does not fit the label.
*
*
* @param labelContent
* content
* @return Label
@@ -816,7 +790,7 @@ public final class HawkbitCommonUtil {
/**
* Duplicate check - Unique Key.
*
*
* @param name
* as string
* @param version
@@ -835,7 +809,7 @@ public final class HawkbitCommonUtil {
/**
* Add new base software module.
*
*
* @param bsname
* base software module name
* @param bsversion
@@ -883,7 +857,7 @@ public final class HawkbitCommonUtil {
/**
* Display Target Tag action message.
*
*
* @param targTagName
* as tag name
* @param result
@@ -929,7 +903,7 @@ public final class HawkbitCommonUtil {
/**
* Get message to be displayed after distribution tag assignment.
*
*
* @param targTagName
* tag name
* @param result
@@ -975,40 +949,36 @@ public final class HawkbitCommonUtil {
/**
* Create a lazy query container for the given query bean factory with empty
* configurations.
*
*
* @param queryFactory
* is reference of {@link BeanQueryFactory<? extends
* AbstractBeanQuery>} on which lazy container should create.
* @return instance of {@link LazyQueryContainer}.
*/
public static LazyQueryContainer createLazyQueryContainer(
final BeanQueryFactory<? extends AbstractBeanQuery> queryFactory) {
final Map<String, Object> queryConfig = new HashMap<String, Object>();
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
final Map<String, Object> queryConfig = new HashMap<>();
queryFactory.setQueryConfiguration(queryConfig);
final LazyQueryContainer typeContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory);
return typeContainer;
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory);
}
/**
*
*
* Create lazy query container for DS type.
*
*
* @param queryFactory
* @return LazyQueryContainer
*/
public static LazyQueryContainer createDSLazyQueryContainer(
final BeanQueryFactory<? extends AbstractBeanQuery> queryFactory) {
final Map<String, Object> queryConfig = new HashMap<String, Object>();
final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
final Map<String, Object> queryConfig = new HashMap<>();
queryFactory.setQueryConfiguration(queryConfig);
final LazyQueryContainer typeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"),
queryFactory);
return typeContainer;
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"), queryFactory);
}
/**
* Set distribution table column properties.
*
*
* @param container
* table container
*/
@@ -1026,7 +996,7 @@ public final class HawkbitCommonUtil {
/**
* Get visible columns in table.
*
*
* @param isMaximized
* true if table is maximized
* @param isShowPinColumn
@@ -1037,7 +1007,7 @@ public final class HawkbitCommonUtil {
*/
public static List<TableColumn> getTableVisibleColumns(final Boolean isMaximized, final Boolean isShowPinColumn,
final I18N i18n) {
final List<TableColumn> columnList = new ArrayList<TableColumn>();
final List<TableColumn> columnList = new ArrayList<>();
if (isMaximized) {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.2f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get(HEADER_VERSION), 0.1f));
@@ -1063,7 +1033,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the software module table rows highlight css.
*
*
* @return javascript to rest software module table rows highlight css.
*/
public static String getScriptSMHighlightReset() {
@@ -1072,7 +1042,7 @@ public final class HawkbitCommonUtil {
/**
* Highlight software module rows with the color of sw-type.
*
*
* @param colorCSS
* color to generate the css script.
* @return javascript to append software module table rows with highlighted
@@ -1088,7 +1058,7 @@ public final class HawkbitCommonUtil {
/**
* Get javascript to reflect new color selection in color picker preview for
* name and description fields .
*
*
* @param colorPickedPreview
* changed color
* @return javascript for the selected color.
@@ -1108,7 +1078,7 @@ public final class HawkbitCommonUtil {
/**
* Get javascript to reflect new color selection for preview button.
*
*
* @param color
* changed color
* @return javascript for the selected color.
@@ -1125,7 +1095,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to display drop hints for tags.
*
*
* @return javascript
*/
public static String dispTargetTagsDropHintScript() {
@@ -1138,7 +1108,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to hide drop hints for tags.
*
*
* @return javascript
*/
public static String hideTargetTagsDropHintScript() {
@@ -1147,7 +1117,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to display drop hint for Delete button.
*
*
* @return javascript
*/
public static String dispDeleteDropHintScript() {
@@ -1160,7 +1130,7 @@ public final class HawkbitCommonUtil {
/**
* Java script to hide drop hint for delete button.
*
*
* @return javascript
*/
public static String hideDeleteDropHintScript() {
@@ -1169,7 +1139,7 @@ public final class HawkbitCommonUtil {
/**
* Get the details of selected rows of {@link TargetTable}.
*
*
* @param sourceTable
* @return set of {@link TargetIdName}
*/
@@ -1184,7 +1154,7 @@ public final class HawkbitCommonUtil {
/**
* Get the details of selected rows of {@link DistributionTable}.
*
*
* @param sourceTable
* @return set of {@link DistributionSetIdName}
*/
@@ -1198,9 +1168,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Add target table container properties.
*
*
* @param container
* table container
*/
@@ -1232,9 +1202,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Apply style for status label in target table.
*
*
* @param targetTable
* target table
* @param pinBtn
@@ -1264,7 +1234,7 @@ public final class HawkbitCommonUtil {
/**
* Set status progress bar value.
*
*
* @param bar
* DistributionBar
* @param statusName
@@ -1283,7 +1253,7 @@ public final class HawkbitCommonUtil {
/**
* Initialize status progress bar with values and number of parts on load.
*
*
* @param bar
* DistributionBar
* @param item
@@ -1312,7 +1282,7 @@ public final class HawkbitCommonUtil {
/**
* Formats the finished percentage of a rollout group into a string with one
* digit after comma.
*
*
* @param rolloutGroup
* the rollout group
* @param finishedPercentage
@@ -1341,7 +1311,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the values of status progress bar on change of values.
*
*
* @param bar
* DistributionBar
* @param item