Merge branch 'master_copy_to_merge_rollout_issues' into

Rollout_Management_issues_refactor

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java
This commit is contained in:
venu1278
2016-04-14 11:23:33 +05:30
188 changed files with 3232 additions and 4184 deletions

View File

@@ -15,12 +15,12 @@ import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.ArtifactDetailsEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.footer.SMDeleteActionsLayout;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleTableLayout;
import org.eclipse.hawkbit.ui.artifacts.smtype.SMTypeFilterLayout;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -111,9 +111,9 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeSwTable();
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
maximizeSwTable();
}
}

View File

@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -110,8 +111,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
private boolean fullWindowMode = false;
private UI ui;
private boolean readOnly = false;
/**
@@ -122,7 +121,6 @@ public class ArtifactDetailsLayout extends VerticalLayout {
createComponents();
buildLayout();
eventBus.subscribe(this);
ui = UI.getCurrent();
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
populateArtifactDetails(selectedSoftwareModule.getId(), HawkbitCommonUtil
@@ -461,23 +459,23 @@ public class ArtifactDetailsLayout extends VerticalLayout {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) {
ui.access(() -> {
if (softwareModuleEvent.getSoftwareModule() != null) {
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
softwareModuleEvent.getSoftwareModule().getVersion()));
if (BaseEntityEventType.SELECTED_ENTITY == softwareModuleEvent.getEventType()) {
UI.getCurrent().access(() -> {
if (softwareModuleEvent.getEntity() != null) {
populateArtifactDetails(softwareModuleEvent.getEntity().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getEntity().getName(),
softwareModuleEvent.getEntity().getVersion()));
} else {
populateArtifactDetails(null, null);
}
});
}
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
ui.access(() -> {
if (softwareModuleEvent.getSoftwareModule() != null) {
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
softwareModuleEvent.getSoftwareModule().getVersion()));
UI.getCurrent().access(() -> {
if (softwareModuleEvent.getEntity() != null) {
populateArtifactDetails(softwareModuleEvent.getEntity().getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getEntity().getName(),
softwareModuleEvent.getEntity().getVersion()));
} else {
populateArtifactDetails(null, null);
}

View File

@@ -9,58 +9,53 @@
package org.eclipse.hawkbit.ui.artifacts.event;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
* Event to represent software add, update or delete.
*
*
*
*/
public class SoftwareModuleEvent {
public class SoftwareModuleEvent extends BaseEntityEvent<SoftwareModule> {
/**
* Software module events in the Upload UI.
*
*
*
*/
public enum SoftwareModuleEventType {
NEW_SOFTWARE_MODULE, UPDATED_SOFTWARE_MODULE, DELETE_SOFTWARE_MODULE, SELECTED_SOFTWARE_MODULE, MAXIMIZED, MINIMIZED, ARTIFACTS_CHANGED, ASSIGN_SOFTWARE_MODULE
ARTIFACTS_CHANGED, ASSIGN_SOFTWARE_MODULE
}
private SoftwareModuleEventType softwareModuleEventType;
private SoftwareModule softwareModule;
/**
* Creates software module event.
*
* @param entityEventType
* the event type
* @param softwareModule
* the module
*/
public SoftwareModuleEvent(final BaseEntityEventType entityEventType, final SoftwareModule softwareModule) {
super(entityEventType, softwareModule);
}
/**
* Creates software module event.
*
* @param softwareModuleEventType
* reference of {@link SoftwareModuleEventType}
* the event type
* @param softwareModule
* reference of {@link SoftwareModule}
* the module
*/
public SoftwareModuleEvent(final SoftwareModuleEventType softwareModuleEventType,
final SoftwareModule softwareModule) {
super();
super(null, softwareModule);
this.softwareModuleEventType = softwareModuleEventType;
this.softwareModule = softwareModule;
}
public SoftwareModuleEventType getSoftwareModuleEventType() {
return softwareModuleEventType;
}
public void setSoftwareModuleEventType(final SoftwareModuleEventType softwareModuleEventType) {
this.softwareModuleEventType = softwareModuleEventType;
}
public SoftwareModule getSoftwareModule() {
return softwareModule;
}
public void setSoftwareModule(final SoftwareModule softwareModule) {
this.softwareModule = softwareModule;
}
}

View File

@@ -14,12 +14,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -28,8 +23,6 @@ import com.vaadin.ui.Component;
/**
* Upload UI View for Accept criteria.
*
*
*
*/
@SpringComponent
@ViewScope
@@ -41,29 +34,6 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -78,11 +48,6 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -11,22 +11,15 @@ package org.eclipse.hawkbit.ui.artifacts.footer;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -35,7 +28,6 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.TableTransferable;
import com.vaadin.ui.UI;
@@ -50,18 +42,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -3273982053389866299L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private ArtifactUploadState artifactUploadState;
@@ -71,22 +51,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
@@ -211,26 +175,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
updateActionsCount(count);
}
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
@Override
protected void restoreActionCount() {
updateSWActionCount();
}
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
@Override
protected void unsavedActionsWindowClosed() {
final String message = uploadViewConfirmationWindowLayout.getConsolidatedMessage();
@@ -241,7 +190,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected Component getUnsavedActionsWindowContent() {
uploadViewConfirmationWindowLayout.init();
uploadViewConfirmationWindowLayout.initialize();
return uploadViewConfirmationWindowLayout;
}
@@ -251,33 +200,4 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|| !artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty();
}
@Override
protected boolean hasCountMessage() {
return false;
}
@Override
protected Label getCountMessageLabel() {
return null;
}
@Override
protected boolean hasBulkUploadPermission() {
return false;
}
@Override
protected void showBulkUploadWindow() {
/**
* Bulk upload not supported .No implementation required.
*/
}
@Override
protected void restoreBulkUploadStatusCount() {
/**
* Bulk upload not supported .No implementation required.
*/
}
}

View File

@@ -14,23 +14,17 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -39,8 +33,8 @@ import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract layout of confirm actions window.
@@ -62,32 +56,12 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
private static final String DISCARD = "Discard";
@Autowired
private I18N i18n;
@Autowired
private transient SoftwareManagement softwareManagement;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ArtifactUploadState artifactUploadState;
/**
* Initialze the component.
*/
@PostConstruct
void init() {
super.inittialize();
}
/*
* (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<>();
@@ -116,26 +90,13 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
// Add the discard action column
tab.getTable().addGeneratedColumn(SW_DISCARD_CHGS, (source, itemId, columnId) -> {
final Button deleteswIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deleteswIcon.setData(itemId);
deleteswIcon.setImmediate(true);
deleteswIcon.addClickListener(event -> discardSoftwareDelete(event, itemId, tab));
return deleteswIcon;
final ClickListener clickListener = event -> discardSoftwareDelete(event, itemId, tab);
return createDiscardButton(itemId, clickListener);
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(SW_MODULE_NAME_MSG, SW_DISCARD_CHGS);
tab.getTable().setColumnHeaders(i18n.get("upload.swModuleTable.header"),
i18n.get("header.second.deletetarget.table"));
tab.getTable().setColumnExpandRatio(SW_MODULE_NAME_MSG, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH);
tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -233,30 +194,14 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
// Add the discard action column
tab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' ');
style.append("redicon");
final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId);
deleteIcon.setImmediate(true);
deleteIcon.addClickListener(event -> discardSoftwareTypeDelete(
(String) ((Button) event.getComponent()).getData(), itemId, tab));
return deleteIcon;
final ClickListener clickListener = event -> discardSoftwareTypeDelete(
(String) ((Button) event.getComponent()).getData(), itemId, tab);
return createDiscardButton(itemId, clickListener);
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(SW_MODULE_TYPE_NAME, DISCARD);
tab.getTable().setColumnHeaders(i18n.get("header.first.delete.swmodule.type.table"),
i18n.get("header.second.delete.swmodule.type.table"));
tab.getTable().setColumnExpandRatio(SW_MODULE_TYPE_NAME, 2);
tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -264,9 +209,6 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
return tab;
}
/**
* @return
*/
private Container getSWModuleTypeTableContainer() {
final IndexedContainer contactContainer = new IndexedContainer();
contactContainer.addContainerProperty(SW_MODULE_TYPE_NAME, String.class, "");

View File

@@ -13,8 +13,8 @@ import java.io.Serializable;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -282,8 +282,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
/* display success message */
uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] {
newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() }));
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.NEW_SOFTWARE_MODULE,
newBaseSoftwareModule));
eventBus.publish(this,
new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule));
}
// close the window
closeThisWindow();
@@ -302,8 +302,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
uiNotifcation.displaySuccess(i18n.get("message.save.success",
new Object[] { newSWModule.getName() + ":" + newSWModule.getVersion() }));
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.UPDATED_SOFTWARE_MODULE, newSWModule));
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.UPDATED_ENTITY, newSWModule));
}
closeThisWindow();
}

View File

@@ -8,21 +8,14 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -42,42 +35,16 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> {
private static final long serialVersionUID = -4900381301076646366L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired
private ArtifactUploadState artifactUploadState;
private UI ui;
private Long swModuleId;
private SoftwareModule selectedSwModule;
/**
* Initialize the component.
*/
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON;
@@ -85,28 +52,31 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
@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(createLogLayout(), i18n.get("caption.logs.tab"), null);
detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
}
@Override
protected void onEdit(final ClickEvent event) {
final Window addSoftwareModule = softwareModuleAddUpdateWindow.createUpdateSoftwareModuleWindow(swModuleId);
addSoftwareModule.setCaption(i18n.get("upload.caption.update.swmodule"));
final Window addSoftwareModule = softwareModuleAddUpdateWindow
.createUpdateSoftwareModuleWindow(getSelectedBaseEntityId());
addSoftwareModule.setCaption(getI18n().get("upload.caption.update.swmodule"));
UI.getCurrent().addWindow(addSoftwareModule);
addSoftwareModule.setVisible(Boolean.TRUE);
}
private void populateDetails(final SoftwareModule swModule) {
@Override
protected void populateDetailsWidget() {
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
if (swModule != null) {
if (swModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = i18n.get("label.multiAssign.type");
if (getSelectedBaseEntity() != null) {
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = getI18n().get("label.multiAssign.type");
} else {
maxAssign = i18n.get("label.singleAssign.type");
maxAssign = getI18n().get("label.singleAssign.type");
}
updateSoftwareModuleDetailsLayout(swModule.getType().getName(), swModule.getVendor(), maxAssign);
updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().getVendor(), maxAssign);
} else {
updateSoftwareModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY,
maxAssign);
@@ -118,160 +88,50 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout {
detailsTabLayout.removeAllComponents();
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.vendor"),
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.assigned.type"),
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);
}
private void populateLog(final SoftwareModule softwareModule) {
if (null != softwareModule) {
updateLogLayout(getLogLayout(), softwareModule.getLastModifiedAt(), softwareModule.getLastModifiedBy(),
softwareModule.getCreatedAt(), softwareModule.getCreatedBy(), i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
}
}
public void setSwModuleId(final Long swModuleId) {
this.swModuleId = swModuleId;
}
private void populateDetailsWidget(final SoftwareModule swModule) {
if (swModule != null) {
setSwModuleId(swModule.getId());
setName(getDefaultCaption(),
HawkbitCommonUtil.getFormattedNameVersion(swModule.getName(), swModule.getVersion()));
populateDetails(swModule);
populateDescription(swModule);
populateLog(swModule);
} else {
setSwModuleId(null);
setName(getDefaultCaption(), HawkbitCommonUtil.SP_STRING_EMPTY);
populateDetails(null);
populateDescription(null);
populateLog(null);
}
}
private void populateDescription(final SoftwareModule swModule) {
if (swModule != null) {
updateDescriptionLayout(i18n.get("label.description"), swModule.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* getDefaultCaption()
*/
@Override
protected String getDefaultCaption() {
return i18n.get("upload.swModuleTable.header");
return getI18n().get("upload.swModuleTable.header");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* onLoadIsSwModuleSelected()
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return artifactUploadState.getSelectedBaseSoftwareModule().isPresent();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* onLoadIsTableMaximized()
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return artifactUploadState.isSwModuleTableMaximized();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout#
* populateDetailsWidget()
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedSwModule);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE
|| softwareModuleEvent
.getSoftwareModuleEventType() == SoftwareModuleEventType.UPDATED_SOFTWARE_MODULE) {
ui.access(() -> {
/**
* softwareModuleEvent.getSoftwareModule() is null when table
* has no data.
*/
if (softwareModuleEvent.getSoftwareModule() != null) {
selectedSwModule = softwareModuleEvent.getSoftwareModule();
populateData(true);
} else {
populateData(false);
}
});
} else if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
showLayout();
} else if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
hideLayout();
}
}
@Override
protected void clearDetails() {
populateDetailsWidget(null);
onBaseEntityEvent(softwareModuleEvent);
}
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getTabSheetId()
*/
@Override
protected String getTabSheetId() {
return null;

View File

@@ -8,29 +8,20 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -39,7 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -58,45 +48,19 @@ import com.vaadin.ui.UI;
*/
@SpringComponent
@ViewScope
public class SoftwareModuleTable extends AbstractTable {
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
private static final long serialVersionUID = 6469417305487144809L;
@Autowired
private I18N i18n;
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient SoftwareManagement softwareManagement;
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
/**
* Initialize the filter layout.
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
setNoDataAvailable();
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SMFilterEvent filterEvent) {
UI.getCurrent().access(() -> {
@@ -150,74 +114,40 @@ public class SoftwareModuleTable extends AbstractTable {
lqc.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
}
@Override
protected void addCustomGeneratedColumns() {
/* No generated columns */
}
@Override
protected boolean isFirstRowSelectedOnLoad() {
return artifactUploadState.getSelectedSoftwareModules().isEmpty();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.SPTable#getItemIdToSelect()
*/
@Override
protected Object getItemIdToSelect() {
return artifactUploadState.getSelectedSoftwareModules();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.table.SPTable#isMaximized()
*/
@Override
protected boolean isMaximized() {
return artifactUploadState.isSwModuleTableMaximized();
}
@SuppressWarnings("rawtypes")
@Override
protected void onValueChange() {
eventBus.publish(this, UploadArtifactUIEvent.HIDE_DROP_HINTS);
@SuppressWarnings("unchecked")
final Set<Long> values = (Set) getValue();
if (values != null && !values.isEmpty()) {
final Iterator<Long> iterator = values.iterator();
Long value = null;
while (iterator.hasNext()) {
value = iterator.next();
}
if (null != value) {
artifactUploadState.setSelectedBaseSwModuleId(value);
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule);
artifactUploadState.setSelectedSoftwareModules(values);
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule));
}
} else {
artifactUploadState.setSelectedBaseSwModuleId(null);
artifactUploadState.setSelectedBaseSoftwareModule(null);
artifactUploadState.setSelectedSoftwareModules(Collections.emptySet());
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, null));
}
protected SoftwareModule findEntityByTableValue(final Long entityTableId) {
return softwareManagement.findSoftwareModuleById(entityTableId);
}
@Override
protected ArtifactUploadState getManagmentEntityState() {
return artifactUploadState;
}
@Override
protected void publishEntityAfterValueChange(final SoftwareModule lastSoftwareModule) {
artifactUploadState.setSelectedBaseSoftwareModule(lastSoftwareModule);
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastSoftwareModule));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.NEW_SOFTWARE_MODULE) {
UI.getCurrent().access(() -> addSoftwareModule(event.getSoftwareModule()));
}
onBaseEntityEvent(event);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -227,55 +157,31 @@ public class SoftwareModuleTable extends AbstractTable {
}
}
/**
* Add new software module to table.
*
* @param swModule
* new software module
*/
@SuppressWarnings("unchecked")
private void addSoftwareModule(final SoftwareModule swModule) {
final Object addItem = addItem();
final Item item = getItem(addItem);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", swModule.getName(), swModule.getVersion());
@Override
protected Item addEntity(final SoftwareModule baseEntity) {
final Item item = super.addEntity(baseEntity);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(swModule.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(swModule.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(swModule.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(swModule.getVersion());
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(swModule.getName());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
artifactUploadState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
artifactUploadState.getSelectedSoftwareModules().stream().forEach(this::unselect);
}
select(swModule.getId());
select(baseEntity.getId());
return item;
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
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));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
} else {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F));
final List<TableColumn> columnList = super.getTableVisibleColumns();
if (!isMaximized()) {
return columnList;
}
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
return columnList;
}
@@ -297,12 +203,8 @@ public class SoftwareModuleTable extends AbstractTable {
};
}
private void setNoDataAvailable() {
final int containerSize = getContainerDataSource().size();
if (containerSize == 0) {
artifactUploadState.setNoDataAvilableSoftwareModule(true);
} else {
artifactUploadState.setNoDataAvilableSoftwareModule(false);
}
@Override
protected void setDataAvailable(final boolean available) {
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
}
}

View File

@@ -8,20 +8,14 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -44,31 +38,12 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
/**
* Initialize the components.
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE) {
@@ -76,15 +51,6 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventbus.unsubscribe(this);
}
@Override
protected String getHeaderCaption() {
return i18n.get("upload.swModuleTable.header");
@@ -164,14 +130,14 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
artifactUploadState.setSwModuleTableMaximized(Boolean.TRUE);
eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MAXIMIZED, null));
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED, null));
}
@Override
public void minimizeTable() {
artifactUploadState.setSwModuleTableMaximized(Boolean.FALSE);
eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MINIMIZED, null));
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED, null));
}
@Override

View File

@@ -8,21 +8,17 @@
*/
package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -48,26 +44,6 @@ public class SMTypeFilterButtons extends AbstractFilterButtons {
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Autowired
private transient EventBus.SessionEventBus eventBus;
/**
* Initialize component.
*
* @param filterButtonClickBehaviour
* the clickable behaviour.
*/
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleTypeEvent event) {
if (event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.artifacts.smtype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
@@ -18,7 +17,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -35,12 +33,6 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -4855810338059032342L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ArtifactUploadState artifactUploadState;
@@ -84,7 +76,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
artifactUploadState.setSwTypeFilterClosed(true);
eventbus.publish(this, UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE);
eventBus.publish(this, UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE);
}
@Override

View File

@@ -17,6 +17,7 @@ import java.util.Optional;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -29,7 +30,7 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
*/
@VaadinSessionScope
@SpringComponent
public class ArtifactUploadState implements Serializable {
public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializable {
private static final long serialVersionUID = 8273440375917450859L;
@@ -85,30 +86,7 @@ public class ArtifactUploadState implements Serializable {
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
}
/**
* @param selectedBaseSwModuleId
* the selectedBaseSwModuleId to set
*/
public void setSelectedBaseSwModuleId(final Long selectedBaseSwModuleId) {
this.selectedBaseSwModuleId = selectedBaseSwModuleId;
}
/**
* @return the selectedBaseSoftwareModule
*/
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
return selectedBaseSoftwareModule == null ? Optional.empty() : Optional.of(selectedBaseSoftwareModule);
}
/**
* @param selectedBaseSoftwareModule
* the selectedBaseSoftwareModule to set
*/
public void setSelectedBaseSoftwareModule(final SoftwareModule selectedBaseSoftwareModule) {
this.selectedBaseSoftwareModule = selectedBaseSoftwareModule;
return Optional.ofNullable(selectedBaseSwModuleId);
}
/**
@@ -125,12 +103,15 @@ public class ArtifactUploadState implements Serializable {
return selectedSoftwareModules;
}
/**
* @param selectedSoftwareModules
* the selectedSoftwareModules to set
*/
public void setSelectedSoftwareModules(final Set<Long> selectedSoftwareModules) {
this.selectedSoftwareModules = selectedSoftwareModules;
@Override
public void setLastSelectedEntity(final Long value) {
this.selectedBaseSwModuleId = value;
}
@Override
public void setSelectedEnitities(final Set<Long> values) {
this.selectedSoftwareModules = values;
}
/**
@@ -197,4 +178,11 @@ public class ArtifactUploadState implements Serializable {
this.noDataAvilableSoftwareModule = noDataAvilableSoftwareModule;
}
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
return Optional.ofNullable(selectedBaseSoftwareModule);
}
public void setSelectedBaseSoftwareModule(final SoftwareModule selectedBaseSoftwareModule) {
this.selectedBaseSoftwareModule = selectedBaseSoftwareModule;
}
}

View File

@@ -215,13 +215,15 @@ public class UploadLayout extends VerticalLayout {
hasDirectory = Boolean.TRUE;
}
}
}
private static boolean isDirectory(final Html5File file) {
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) {
return true;
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
}
private boolean isDirectory(final Html5File file) {
return Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0;
}
return false;
}
private void displayCompositeMessage() {
@@ -282,11 +284,6 @@ public class UploadLayout extends VerticalLayout {
discardBtn.addClickListener(event -> discardUploadData(event));
}
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
}
boolean checkForDuplicate(final String filename) {
final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
if (isDuplicate) {
@@ -349,17 +346,17 @@ public class UploadLayout extends VerticalLayout {
}
}
Boolean validate(DragAndDropEvent event) {
Boolean validate(final DragAndDropEvent event) {
// check if drop is valid.If valid ,check if software module is
// selected.
if(!isFilesDropped(event)){
if (!isFilesDropped(event)) {
uiNotification.displayValidationError(i18n.get("message.action.not.allowed"));
return false;
}
return checkIfSoftwareModuleIsSelected();
}
private boolean isFilesDropped(DragAndDropEvent event) {
private boolean isFilesDropped(final DragAndDropEvent event) {
if (event.getTransferable() instanceof WrapperTransferable) {
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
// other components can also be wrapped in WrapperTransferable , so
@@ -448,7 +445,7 @@ public class UploadLayout extends VerticalLayout {
}
private String getDuplicateFileValidationMessage() {
StringBuilder message = new StringBuilder();
final StringBuilder message = new StringBuilder();
if (!duplicateFileNamesList.isEmpty()) {
final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList);
if (duplicateFileNamesList.size() == 1) {
@@ -655,8 +652,7 @@ public class UploadLayout extends VerticalLayout {
return uiNotification;
}
public void setHasDirectory(Boolean hasDirectory) {
public void setHasDirectory(final Boolean hasDirectory) {
this.hasDirectory = hasDirectory;
}
}

View File

@@ -13,8 +13,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
@@ -27,9 +32,6 @@ import com.vaadin.ui.Table;
/**
* Abstract class for Accept criteria.
*
*
*
*
*/
public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
@@ -37,13 +39,12 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
private int previousRowCount;
/*
* (non-Javadoc)
*
* @see
* com.vaadin.event.dd.acceptcriteria.AcceptCriterion#accept(com.vaadin.
* event.dd.DragAndDropEvent )
*/
@Autowired
protected transient UINotification uiNotification;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Override
public boolean accept(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
@@ -129,7 +130,7 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = getDropHintConfigurations().get(sourceID);
publishDragStartEvent(event);
eventBus.publish(this, event);
}
/**
@@ -159,23 +160,19 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion {
*/
protected abstract String getComponentId(final Component component);
/**
* publish the given event into eventBus.
*
* @param event
* to be published in eventBus.
*/
protected abstract void publishDragStartEvent(Object event);
/**
* Hide the drop hints. Dragging is stopped.
*/
protected abstract void hideDropHints();
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
/**
* Display invalid drop message.
*/
protected abstract void invalidDrop();
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
/**
* @return

View File

@@ -0,0 +1,35 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common;
import java.util.Set;
/**
* Interface for all entity states UI to show the details to a entity.
*/
public interface ManagmentEntityState<T> {
/**
* The selected entities for the detail.
*
* @param values
* the selected entities.
*
*/
void setSelectedEnitities(Set<T> values);
/**
* The last selected value.
*
* @param value
* the value
*/
void setLastSelectedEntity(T value);
}

View File

@@ -11,21 +11,29 @@ package org.eclipse.hawkbit.ui.common.confirmwindow.layout;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract layout of confirm actions window.
*
*
*
*
*/
public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
@@ -37,33 +45,25 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
private String consolidatedMessage;
protected void inittialize() {
// Remove all components
@Autowired
protected I18N i18n;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@PostConstruct
public void initialize() {
removeAllComponents();
consolidatedMessage = "";
// create components again
createComponents();
// Build layout.
buildLayout();
}
/**
* Create accordion and add respective tabs.
*/
private void createComponents() {
// create accordion
createAccordian();
// create action message label
createActionMessgaeLabel();
}
/**
* Create a message label to show the results of any actions which user does
* in the confirmation window.
*/
private void createActionMessgaeLabel() {
actionMessage = SPUIComponentProvider.getLabel("", null);
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
@@ -138,4 +138,14 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
public String getConsolidatedMessage() {
return consolidatedMessage;
}
protected Button createDiscardButton(final Object itemId, final ClickListener clickListener) {
final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deletesDsIcon.setData(itemId);
deletesDsIcon.setImmediate(true);
deletesDsIcon.addClickListener(clickListener);
return deletesDsIcon;
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.detailslayout;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
/**
*
*
*/
public abstract class AbstractNamedVersionedEntityTableDetailsLayout<T extends NamedVersionedEntity>
extends AbstractTableDetailsLayout<T> {
private static final long serialVersionUID = 1L;
@Override
protected String getName() {
return HawkbitCommonUtil.getFormattedNameVersion(getSelectedBaseEntity().getName(),
getSelectedBaseEntity().getVersion());
}
}

View File

@@ -10,7 +10,15 @@ package org.eclipse.hawkbit.ui.common.detailslayout;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -19,6 +27,8 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
@@ -27,16 +37,28 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
/**
*
* Abstract Layout to show the entity details.
*
*/
public abstract class AbstractTableDetailsLayout extends VerticalLayout {
public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends VerticalLayout {
private static final long serialVersionUID = 4862529368471627190L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
private T selectedBaseEntity;
private Label caption;
private Button editButton;
@@ -54,20 +76,57 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
/**
* Initialize components.
*/
@PostConstruct
protected void init() {
createComponents();
buildLayout();
/**
* On load of UI/Refresh details will be loaded based on the row
* selected in table.
*/
restoreState();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
protected SpPermissionChecker getPermissionChecker() {
return permissionChecker;
}
protected EventBus.SessionEventBus getEventBus() {
return eventBus;
}
protected I18N getI18n() {
return i18n;
}
protected T getSelectedBaseEntity() {
return selectedBaseEntity;
}
public void setSelectedBaseEntity(final T selectedBaseEntity) {
this.selectedBaseEntity = selectedBaseEntity;
}
/**
* Default implementation to handle an entity event.
*
* @param baseEntityEvent
* the event
*/
protected void onBaseEntityEvent(final BaseEntityEvent<T> baseEntityEvent) {
final BaseEntityEventType eventType = baseEntityEvent.getEventType();
if (BaseEntityEventType.SELECTED_ENTITY == eventType || BaseEntityEventType.UPDATED_ENTITY == eventType) {
UI.getCurrent().access(() -> populateData(baseEntityEvent.getEntity()));
} else if (BaseEntityEventType.MINIMIZED == eventType) {
UI.getCurrent().access(() -> setVisible(true));
} else if (BaseEntityEventType.MAXIMIZED == eventType) {
UI.getCurrent().access(() -> setVisible(false));
}
}
private void createComponents() {
/**
* Default caption is set.Reset on selecting table row.
*/
caption = createHeaderCaption();
caption.setImmediate(true);
caption.setContentMode(ContentMode.HTML);
@@ -76,7 +135,7 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
editButton = SPUIComponentProvider.getButton("", "", "", null, false, FontAwesome.PENCIL_SQUARE_O,
SPUIButtonStyleSmallNoBorder.class);
editButton.setId(getEditButtonId());
editButton.addClickListener(event -> onEdit(event));
editButton.addClickListener(this::onEdit);
editButton.setEnabled(false);
@@ -90,7 +149,6 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
}
private void buildLayout() {
final HorizontalLayout nameEditLayout = new HorizontalLayout();
nameEditLayout.setWidth(100.0f, Unit.PERCENTAGE);
nameEditLayout.addComponent(caption);
@@ -130,44 +188,29 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
private void restoreState() {
if (onLoadIsTableRowSelected()) {
populateData(true);
populateData(null);
editButton.setEnabled(true);
}
if (onLoadIsTableMaximized()) {
/**
* If table is maximized hide details layout.
*/
hideLayout();
setVisible(false);
}
}
protected void showLayout() {
setVisible(true);
}
protected void hideLayout() {
setVisible(false);
}
/**
* If no data in table (i,e no row selected),then disable the edit button.
* If row is selected ,enable edit button.
*/
protected void populateData(final Boolean isRowSelected) {
if (isRowSelected) {
populateDetailsWidget();
enableEditButton();
private void populateData(final T selectedBaseEntity) {
this.selectedBaseEntity = selectedBaseEntity;
editButton.setEnabled(selectedBaseEntity != null);
if (selectedBaseEntity == null) {
setName(getDefaultCaption(), StringUtils.EMPTY);
} else {
disableEditButton();
clearDetails();
setName(getDefaultCaption(), getName());
}
}
protected void enableEditButton() {
editButton.setEnabled(true);
}
protected void disableEditButton() {
editButton.setEnabled(false);
populateLog();
populateDescription();
populateDetailsWidget();
}
protected void updateLogLayout(final VerticalLayout changeLogLayout, final Long lastModifiedAt,
@@ -271,13 +314,6 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
protected abstract String getTabSheetId();
/**
* Populate details layout.
*/
protected abstract void populateDetailsWidget();
protected abstract void clearDetails();
protected abstract Boolean hasEditPermission();
public VerticalLayout getDetailsLayout() {
@@ -288,6 +324,31 @@ public abstract class AbstractTableDetailsLayout extends VerticalLayout {
return logLayout;
}
private void populateLog() {
if (selectedBaseEntity == null) {
updateLogLayout(getLogLayout(), null, StringUtils.EMPTY, null, null, i18n);
return;
}
updateLogLayout(getLogLayout(), selectedBaseEntity.getLastModifiedAt(), selectedBaseEntity.getLastModifiedBy(),
selectedBaseEntity.getCreatedAt(), selectedBaseEntity.getCreatedBy(), i18n);
}
private void populateDescription() {
if (selectedBaseEntity != null) {
updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
protected abstract void populateDetailsWidget();
protected Long getSelectedBaseEntityId() {
return selectedBaseEntity == null ? null : selectedBaseEntity.getId();
}
protected abstract String getDetailsHeaderCaptionId();
protected abstract String getName();
}

View File

@@ -16,12 +16,12 @@ import org.eclipse.hawkbit.repository.exception.EntityLockedException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
@@ -214,9 +214,8 @@ public class SoftwareModuleDetailsTable extends Table {
.getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules);
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
unAssignedSw);
manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName());
eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, newDistributionSet));
manageDistUIState.setLastSelectedEntity(newDistributionSet.getDistributionSetIdName());
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));
}

View File

@@ -11,13 +11,17 @@ package org.eclipse.hawkbit.ui.common.filterlayout;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUITagButtonStyle;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler;
@@ -38,10 +42,13 @@ import com.vaadin.ui.themes.ValoTheme;
public abstract class AbstractFilterButtons extends Table {
private static final long serialVersionUID = 7783305719009746375L;
private static final String DEFAULT_GREEN = "rgb(44,151,32)";
protected static final String FILTER_BUTTON_COLUMN = "filterButton";
@Autowired
protected transient EventBus.SessionEventBus eventBus;
private AbstractFilterButtonClickBehaviour filterButtonClickBehaviour;
@@ -54,6 +61,12 @@ public abstract class AbstractFilterButtons extends Table {
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
createTable();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void createTable() {
@@ -88,12 +101,7 @@ public abstract class AbstractFilterButtons extends Table {
@SuppressWarnings("serial")
protected void addColumn() {
addGeneratedColumn(FILTER_BUTTON_COLUMN, new ColumnGenerator() {
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
return addGeneratedCell(itemId);
}
});
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
}
/**

View File

@@ -8,10 +8,13 @@
*/
package org.eclipse.hawkbit.ui.common.filterlayout;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.Alignment;
@@ -31,6 +34,13 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
private static final long serialVersionUID = -1388340600522323332L;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
private Label title;
private Button config;

View File

@@ -8,12 +8,20 @@
*/
package org.eclipse.hawkbit.ui.common.footer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
@@ -34,14 +42,23 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Parent class for footer layout.
*
*
*
*
*/
public abstract class AbstractDeleteActionsLayout extends VerticalLayout implements DropHandler {
private static final long serialVersionUID = -6047975388519155509L;
@Autowired
protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected transient UINotification notification;
private DragAndDropWrapper deleteWrapper;
private Button noActionBtn;
@@ -53,12 +70,19 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
/**
* Initialize.
*/
@PostConstruct
protected void init() {
if (hasCountMessage() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) {
createComponents();
buildLayout();
reload();
}
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
private void reload() {
@@ -158,40 +182,45 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
protected void setUploadStatusButtonCaption(final Long count) {
if (null != bulkUploadStatusButton) {
bulkUploadStatusButton.setCaption("<div class='unread'>" + count + "</div>");
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.setCaption("<div class='unread'>" + count + "</div>");
}
protected void enableBulkUploadStatusButton() {
if (null != bulkUploadStatusButton) {
bulkUploadStatusButton.setVisible(true);
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.setVisible(true);
}
protected void updateUploadBtnIconToComplete() {
if (null != bulkUploadStatusButton) {
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
}
protected void updateUploadBtnIconToProgressIndicator() {
if (null != bulkUploadStatusButton) {
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(null);
if (bulkUploadStatusButton == null) {
return;
}
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
bulkUploadStatusButton.setIcon(null);
}
protected void actionButtonClicked() {
if (hasUnsavedActions()) {
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
SPUIComponetIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
unsavedActionsWindow.setId(SPUIComponetIdProvider.CONFIRMATION_POPUP_ID);
UI.getCurrent().addWindow(unsavedActionsWindow);
if (!hasUnsavedActions()) {
return;
}
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
SPUIComponetIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
unsavedActionsWindow.setId(SPUIComponetIdProvider.CONFIRMATION_POPUP_ID);
UI.getCurrent().addWindow(unsavedActionsWindow);
}
/**
@@ -201,22 +230,11 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
UI.getCurrent().removeWindow(unsavedActionsWindow);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.event.dd.DropHandler#getAcceptCriterion()
*/
@Override
public AcceptCriterion getAcceptCriterion() {
return getDeleteLayoutAcceptCriteria();
}
/*
* (non-Javadoc)
*
* @see com.vaadin.event.dd.DropHandler#drop(com.vaadin.event.dd.
* DragAndDropEvent)
*/
@Override
public void drop(final DragAndDropEvent event) {
processDroppedComponent(event);
@@ -263,6 +281,42 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
}
}
/**
*
* @return true if the count label is displayed false is not displayed
*/
protected boolean hasCountMessage() {
return false;
}
/**
*
* @return the count message label
*/
protected Label getCountMessageLabel() {
return null;
}
/**
* @return true if bulk upload is allowed and has required create
* permissions.
*/
protected boolean hasBulkUploadPermission() {
// can be overriden
return false;
}
protected void showBulkUploadWindow() {
// can be overriden
}
/**
* restore the upload status count.
*/
protected void restoreBulkUploadStatusCount() {
// can be overriden
}
/**
* Check user has delete permission.
*
@@ -311,31 +365,32 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
*
* @return the no actions label.
*/
protected abstract String getNoActionsButtonLabel();
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
/**
* Get the pending actions button label.
*
* @return the actions label.
*/
protected abstract String getActionsButtonLabel();
/**
* reload the count value.
*/
protected abstract void restoreActionCount();
/**
* restore the upload status count.
*/
protected abstract void restoreBulkUploadStatusCount();
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
/**
* Get caption of unsaved actions window.
*
* @return caption of the window.
*/
protected abstract String getUnsavedActionsWindowCaption();
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
/**
* reload the count value.
*/
protected abstract void restoreActionCount();
/**
* This method will be called when unsaved actions window is closed.
@@ -357,21 +412,4 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
*/
protected abstract boolean hasUnsavedActions();
/**
* Only in deployment view count message is displayed.
*
* @return
*/
protected abstract boolean hasCountMessage();
protected abstract Label getCountMessageLabel();
/**
* @return true if bulk upload is allowed and has required create
* permissions.
*/
protected abstract boolean hasBulkUploadPermission();
protected abstract void showBulkUploadWindow();
}

View File

@@ -8,7 +8,13 @@
*/
package org.eclipse.hawkbit.ui.common.grid;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Container;
import com.vaadin.data.Container.Indexed;
@@ -21,10 +27,18 @@ import com.vaadin.ui.Grid;
public abstract class AbstractGrid extends Grid {
private static final long serialVersionUID = 4856562746502217630L;
@Autowired
protected I18N i18n;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
/**
* Initialize the components.
*/
@PostConstruct
protected void init() {
setSizeFull();
setImmediate(true);
@@ -32,6 +46,12 @@ public abstract class AbstractGrid extends Grid {
setSelectionMode(SelectionMode.NONE);
setColumnReorderingAllowed(true);
addNewContainerDS();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
public void addNewContainerDS() {
@@ -43,13 +63,13 @@ public abstract class AbstractGrid extends Grid {
setColumnHeaderNames();
addColumnRenderes();
CellDescriptionGenerator cellDescriptionGenerator = getDescriptionGenerator();
final CellDescriptionGenerator cellDescriptionGenerator = getDescriptionGenerator();
if (getDescriptionGenerator() != null) {
setCellDescriptionGenerator(cellDescriptionGenerator);
}
// Allow column hiding
for (Column c : getColumns()) {
for (final Column c : getColumns()) {
c.setHidable(true);
}
setHiddenColumns();

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.table;
import java.util.List;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import com.vaadin.data.Item;
/**
* Abstract table to handling {@link NamedVersionedEntity}
*
* @param <E>
* e is the entity class
* @param <I>
* i is the id of the table
*/
public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity, I> extends AbstractTable<E, I> {
private static final long serialVersionUID = 780050712209750719L;
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = super.getTableVisibleColumns();
final float versionColumnSize = isMaximized() ? 0.1F : 0.2F;
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), versionColumnSize));
return columnList;
}
@SuppressWarnings("unchecked")
@Override
protected void updateEntity(final E baseEntity, final Item item) {
super.updateEntity(baseEntity, item);
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
}
}

View File

@@ -9,34 +9,64 @@
package org.eclipse.hawkbit.ui.common.table;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
* Parent class for table.
*
*
* Abstract table to handling entity
*
* @param <E>
* e is the entity class
* @param <I>
* i is the id of the table
*/
public abstract class AbstractTable extends Table {
public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
private static final long serialVersionUID = 4856562746502217630L;
private static final Logger LOG = LoggerFactory.getLogger(AbstractTable.class);
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected I18N i18n;
/**
* Initialize the components.
*/
@PostConstruct
protected void init() {
setStyleName("sp-table");
setSizeFull();
setImmediate(true);
setHeight(100.0f, Unit.PERCENTAGE);
setHeight(100.0F, Unit.PERCENTAGE);
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
addStyleName(ValoTheme.TABLE_SMALL);
setSortEnabled(false);
@@ -48,6 +78,50 @@ public abstract class AbstractTable extends Table {
addValueChangeListener(event -> onValueChange());
selectRow();
setPageLength(SPUIDefinitions.PAGE_SIZE);
setDataAvailable(getContainerDataSource().size() != 0);
eventBus.subscribe(this);
}
@PreDestroy
protected void destroy() {
eventBus.unsubscribe(this);
}
public static <T> Set<T> getTableValue(final Table table) {
@SuppressWarnings("unchecked")
Set<T> values = (Set<T>) table.getValue();
if (values == null) {
values = Collections.emptySet();
}
if (values.contains(null)) {
LOG.warn("Null values in table content. How could this happen?");
}
return values;
}
private void onValueChange() {
eventBus.publish(this, UploadArtifactUIEvent.HIDE_DROP_HINTS);
final Set<I> values = getTableValue(this);
E entity = null;
I lastId = null;
if (!values.isEmpty()) {
lastId = Iterables.getLast(values);
entity = findEntityByTableValue(lastId);
}
setManagementEntitiyStateValues(values, lastId);
publishEntityAfterValueChange(entity);
}
protected void setManagementEntitiyStateValues(final Set<I> values, final I lastId) {
final ManagmentEntityState<I> managmentEntityState = getManagmentEntityState();
if (managmentEntityState == null) {
return;
}
managmentEntityState.setLastSelectedEntity(lastId);
managmentEntityState.setSelectedEnitities(values);
}
private void setDefault() {
@@ -118,6 +192,51 @@ public abstract class AbstractTable extends Table {
selectRow();
}
/**
* Add new software module to table.
*
* @param baseEntity
* new software module
*/
protected Item addEntity(final E baseEntity) {
final Object addItem = addItem();
final Item item = getItem(addItem);
updateEntity(baseEntity, item);
return item;
}
@SuppressWarnings("unchecked")
protected void updateEntity(final E baseEntity, final Item item) {
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(baseEntity.getName());
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getCreatedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getLastModifiedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getLastModifiedAt()));
}
protected void onBaseEntityEvent(final BaseEntityEvent<E> event) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (BaseEntityEventType.NEW_ENTITY == event.getEventType()) {
UI.getCurrent().access(() -> addEntity(event.getEntity()));
}
}
protected abstract E findEntityByTableValue(I lastSelectedId);
protected abstract void publishEntityAfterValueChange(E selectedLastEntity);
protected abstract ManagmentEntityState<I> getManagmentEntityState();
/**
* Get Id of the table.
*
@@ -141,7 +260,9 @@ public abstract class AbstractTable extends Table {
/**
* Add any generated columns if required.
*/
protected abstract void addCustomGeneratedColumns();
protected void addCustomGeneratedColumns() {
// can be overriden
}
/**
* Check if first row should be selected by default on load.
@@ -157,11 +278,6 @@ public abstract class AbstractTable extends Table {
*/
protected abstract Object getItemIdToSelect();
/**
* On select of row.
*/
protected abstract void onValueChange();
/**
* Check if the table is maximized or minimized.
*
@@ -174,7 +290,26 @@ public abstract class AbstractTable extends Table {
*
* @return List<TableColumn> list of visible columns
*/
protected abstract List<TableColumn> getTableVisibleColumns();
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<>();
if (!isMaximized()) {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"),
getColumnNameMinimizedSize()));
return columnList;
}
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
return columnList;
}
protected float getColumnNameMinimizedSize() {
return 0.8F;
}
/**
* Get drop handler for the table.
@@ -183,4 +318,6 @@ public abstract class AbstractTable extends Table {
*/
protected abstract DropHandler getTableDropHandler();
protected abstract void setDataAvailable(boolean available);
}

View File

@@ -8,13 +8,20 @@
*/
package org.eclipse.hawkbit.ui.common.table;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.server.FontAwesome;
@@ -37,6 +44,16 @@ import com.vaadin.ui.VerticalLayout;
public abstract class AbstractTableHeader extends VerticalLayout {
private static final long serialVersionUID = 4881626370291837175L;
@Autowired
protected I18N i18n;
@Autowired
protected SpPermissionChecker permChecker;
@Autowired
protected transient EventBus.SessionEventBus eventbus;
private Label headerCaption;
@@ -59,10 +76,17 @@ public abstract class AbstractTableHeader extends VerticalLayout {
/**
* Initialze components.
*/
@PostConstruct
protected void init() {
createComponents();
buildLayout();
restoreState();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
private void createComponents() {

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.table;
import org.eclipse.hawkbit.repository.model.BaseEntity;
/**
* Event to represent add, update or delete.
*
*/
public class BaseEntityEvent<T extends BaseEntity> {
private final BaseEntityEventType eventType;
private final T entity;
/**
* Base entity event
*
* @param eventType
* the event type
* @param entity
* the entity reference
*/
public BaseEntityEvent(final BaseEntityEventType eventType, final T entity) {
this.eventType = eventType;
this.entity = entity;
}
public T getEntity() {
return entity;
}
public BaseEntityEventType getEventType() {
return eventType;
}
}

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.table;
/**
* Types of the entity event.
*
*/
public enum BaseEntityEventType {
NEW_ENTITY, UPDATED_ENTITY, DELETE_ENTITY, SELECTED_ENTITY, MAXIMIZED, MINIMIZED;
}

View File

@@ -13,10 +13,20 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.tokenfield.TokenField;
import org.vaadin.tokenfield.TokenField.InsertPosition;
@@ -28,6 +38,7 @@ import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
@@ -37,7 +48,7 @@ import com.vaadin.ui.themes.ValoTheme;
*
*
*/
public abstract class AbstractTagToken implements Serializable {
public abstract class AbstractTagToken<T extends BaseEntity> implements Serializable {
private static final String COLOR_PROPERTY = "color";
@@ -53,12 +64,46 @@ public abstract class AbstractTagToken implements Serializable {
protected CssLayout tokenLayout = new CssLayout();
@Autowired
protected SpPermissionChecker checker;
@Autowired
protected I18N i18n;
@Autowired
protected UINotification uinotification;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected ManagementUIState managementUIState;
protected T selectedEntity;
@PostConstruct
protected void init() {
createTokenField();
checkIfTagAssignedIsAllowed();
eventBus.subscribe(this);
}
@PreDestroy
protected void destroy() {
eventBus.unsubscribe(this);
}
protected void onBaseEntityEvent(final BaseEntityEvent<T> baseEntityEvent) {
if (BaseEntityEventType.SELECTED_ENTITY != baseEntityEvent.getEventType()) {
return;
}
UI.getCurrent().access(() -> {
final T entity = baseEntityEvent.getEntity();
if (entity != null) {
selectedEntity = entity;
repopulateToken();
}
});
}
private void createTokenField() {
@@ -151,18 +196,25 @@ public abstract class AbstractTagToken implements Serializable {
}
}
}
private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml()
+ "</span>" + " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
}
private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml() + "</span>"
+ " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
}
private void onTokenSearch(final Object tokenId) {
assignTag(getItemNameProperty(tokenId).getValue().toString());
removeTagAssignedFromCombo((Long) tokenId);
}
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());
}
private void onTokenSearch(final Object tokenId) {
assignTag(getItemNameProperty(tokenId).getValue().toString());
removeTagAssignedFromCombo((Long) tokenId);
}
private Property getItemNameProperty(final Object tokenId) {
@@ -184,13 +236,6 @@ public abstract class AbstractTagToken implements Serializable {
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());
}
protected void removePreviouslyAddedTokens() {
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
}

View File

@@ -8,55 +8,25 @@
*/
package org.eclipse.hawkbit.ui.common.tagdetails;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.ui.UI;
/**
* Abstract class for target tag token layout.
*/
public abstract class AbstractTargetTagToken extends AbstractTagToken {
public abstract class AbstractTargetTagToken<T extends BaseEntity> extends AbstractTagToken<T> {
private static final long serialVersionUID = 7772876588903171201L;
protected UI ui;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
@Autowired
protected I18N i18n;
@Autowired
protected transient TagManagement tagManagement;
@Autowired
protected SpPermissionChecker checker;
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
for (final TargetTag tag : event.getEntities()) {

View File

@@ -14,34 +14,25 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Item;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.UI;
/**
* Implementation of target/ds tag token layout.
@@ -49,44 +40,18 @@ import com.vaadin.ui.UI;
*/
@SpringComponent
@ViewScope
public class DistributionTagToken extends AbstractTagToken {
public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
private static final long serialVersionUID = -8022738301736043396L;
@Autowired
private SpPermissionChecker spChecker;
@Autowired
private I18N i18n;
@Autowired
private UINotification uinotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient TagManagement tagManagement;
@Autowired
private transient DistributionSetManagement distributionSetManagement;
private DistributionSet selectedDS;
private UI ui;
// To Be Done : have to set this value based on view???
private static final Boolean NOTAGS_SELECTED = Boolean.FALSE;
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@Override
protected String getTagStyleName() {
return "distribution-tag-";
@@ -111,10 +76,10 @@ public class DistributionTagToken extends AbstractTagToken {
private DistributionSetTagAssignmentResult toggleAssignment(final String tagNameSelected) {
final Set<Long> distributionList = new HashSet<>();
distributionList.add(selectedDS.getId());
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
distributionList.add(selectedEntity.getId());
final DistributionSetTagAssignmentResult result = distributionSetManagement
.toggleTagAssignment(distributionList, tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(tagNameSelected, result, i18n));
return result;
}
@@ -140,14 +105,14 @@ public class DistributionTagToken extends AbstractTagToken {
@Override
protected Boolean isToggleTagAssignmentAllowed() {
return spChecker.hasUpdateDistributionPermission();
return checker.hasUpdateDistributionPermission();
}
@Override
public void displayAlreadyAssignedTags() {
removePreviouslyAddedTokens();
if (selectedDS != null) {
for (final DistributionSetTag tag : selectedDS.getTags()) {
if (selectedEntity != null) {
for (final DistributionSetTag tag : selectedEntity.getTags()) {
addNewToken(tag.getId());
}
}
@@ -163,18 +128,7 @@ public class DistributionTagToken extends AbstractTagToken {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent distributionTableEvent) {
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE) {
ui.access(() -> {
/**
* distributionTableEvent.getDistributionSet() is null when
* table has no data.
*/
if (distributionTableEvent.getDistributionSet() != null) {
selectedDS = distributionTableEvent.getDistributionSet();
repopulateToken();
}
});
}
onBaseEntityEvent(distributionTableEvent);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -214,7 +168,7 @@ public class DistributionTagToken extends AbstractTagToken {
protected boolean isAssign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId())
final List<Long> assignedDsNames = assignmentResult.getAssignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;
@@ -225,7 +179,7 @@ public class DistributionTagToken extends AbstractTagToken {
protected boolean isUnassign(final DistributionSetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<Long> assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId())
final List<Long> assignedDsNames = assignmentResult.getUnassignedEntity().stream().map(t -> t.getId())
.collect(Collectors.toList());
if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) {
return true;
@@ -234,9 +188,4 @@ public class DistributionTagToken extends AbstractTagToken {
return false;
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -22,7 +22,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,7 +39,7 @@ import com.vaadin.spring.annotation.ViewScope;
*/
@SpringComponent
@ViewScope
public class TargetTagToken extends AbstractTargetTagToken {
public class TargetTagToken extends AbstractTargetTagToken<Target> {
private static final long serialVersionUID = 7124887018280196721L;
@@ -53,8 +52,6 @@ public class TargetTagToken extends AbstractTargetTagToken {
@Autowired
private transient TargetManagement targetManagement;
private Target selectedTarget;
@Override
protected String getTagStyleName() {
return "target-tag-";
@@ -79,9 +76,9 @@ public class TargetTagToken extends AbstractTargetTagToken {
private TargetTagAssignmentResult toggleAssignment(final String tagNameSelected) {
final Set<String> targetList = new HashSet<>();
targetList.add(selectedTarget.getControllerId());
targetList.add(selectedEntity.getControllerId());
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, tagNameSelected);
uinotification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(tagNameSelected, result, i18n));
uinotification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(tagNameSelected, result, i18n));
return result;
}
@@ -113,8 +110,8 @@ public class TargetTagToken extends AbstractTargetTagToken {
@Override
protected void displayAlreadyAssignedTags() {
removePreviouslyAddedTokens();
if (selectedTarget != null) {
for (final TargetTag tag : selectedTarget.getTags()) {
if (selectedEntity != null) {
for (final TargetTag tag : selectedEntity.getTags()) {
addNewToken(tag.getId());
}
}
@@ -151,7 +148,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
protected boolean isAssign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getAssigned() > 0) {
final List<String> assignedTargetNames = assignmentResult.getAssignedTargets().stream()
final List<String> assignedTargetNames = assignmentResult.getAssignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
@@ -162,7 +159,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
protected boolean isUnassign(final TargetTagAssignmentResult assignmentResult) {
if (assignmentResult.getUnassigned() > 0) {
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream()
final List<String> unassignedTargetNamesList = assignmentResult.getUnassignedEntity().stream()
.map(t -> t.getControllerId()).collect(Collectors.toList());
if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) {
return true;
@@ -173,16 +170,7 @@ public class TargetTagToken extends AbstractTargetTagToken {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent targetTableEvent) {
if (targetTableEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET
&& targetTableEvent.getTarget() != null) {
ui.access(() -> {
/**
* targetTableEvent.getTarget() is null when table has no data.
*/
selectedTarget = targetTableEvent.getTarget();
repopulateToken();
});
}
onBaseEntityEvent(targetTableEvent);
}
}

View File

@@ -13,7 +13,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterLayout;
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTableLayout;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
@@ -22,7 +22,6 @@ import org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTableLayout;
import org.eclipse.hawkbit.ui.distributions.smtype.DistSMTypeFilterLayout;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -160,18 +159,18 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent event) {
if (event.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeDistTable();
} else if (event.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
maximizeDistTable();
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeSwTable();
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
maximizeSwTable();
}
}

View File

@@ -8,10 +8,7 @@
*/
package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
@@ -23,7 +20,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -45,27 +41,12 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 771251569981876005L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
/**
* Initialize component.
*
* @param filterButtonClickBehaviour
* the clickable behaviour.
*/
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@Override
protected String getButtonsTableId() {
@@ -140,9 +121,4 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
setContainerDataSource(createButtonsLazyQueryContainer());
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -34,12 +32,6 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = 3433417459392880222L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIState;
@@ -81,8 +73,7 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
manageDistUIState.setDistTypeFilterClosed(true);
eventbus.publish(this, DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE);
eventBus.publish(this, DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE);
}
@Override

View File

@@ -13,19 +13,15 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -35,12 +31,9 @@ import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscar
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -64,7 +57,7 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class DistributionSetDetails extends AbstractTableDetailsLayout {
public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDetailsLayout<DistributionSet> {
private static final long serialVersionUID = -4595004466943546669L;
@@ -72,15 +65,6 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private ManageDistUIState manageDistUIState;
@@ -100,25 +84,17 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
private VerticalLayout tagsLayout;
private DistributionSet selectedDsModule;
private Long dsId;
private UI ui;
Map<String, StringBuilder> assignedSWModule = new HashMap<>();
/**
* softwareLayout Initialize the component.
*/
@Override
@PostConstruct
protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState);
softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(),
manageDistUIState);
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
protected VerticalLayout createTagsLayout() {
@@ -126,28 +102,15 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
return tagsLayout;
}
private void populateDetailsWidget(final DistributionSet ds) {
if (ds != null) {
setDsId(ds.getId());
setName(getDefaultCaption(), HawkbitCommonUtil.getFormattedNameVersion(ds.getName(), ds.getVersion()));
populateDetails(ds);
populateDescription(ds);
populateLog(ds);
populteModule(ds);
populateTags(ds);
} else {
setDsId(null);
setName(getDefaultCaption(), HawkbitCommonUtil.SP_STRING_EMPTY);
populateDetails(null);
populateDescription(null);
populteModule(null);
populateTags(null);
populateLog(null);
}
@Override
protected void populateDetailsWidget() {
populateDetails();
populateModule();
populateTags();
}
private void populteModule(final DistributionSet distributionSet) {
softwareModuleTable.populateModule(distributionSet);
private void populateModule() {
softwareModuleTable.populateModule(getSelectedBaseEntity());
showUnsavedAssignment();
}
@@ -179,7 +142,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
assignedSWModule.put(softwareModule.getType().getName(),
new StringBuilder().append("<I>").append(
getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
.append("<I>"));
.append("<I>"));
}
}
@@ -195,12 +158,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
}
}
/**
* @param item
* @param entry
*/
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement
if (getPermissionChecker().hasUpdateDistributionPermission() && distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
@@ -263,215 +222,108 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
return softwareLayout;
}
private void populateTags(final DistributionSet ds) {
private void populateTags() {
tagsLayout.removeAllComponents();
if (null != ds) {
tagsLayout.addComponent(distributionTagToken.getTokenField());
if (getSelectedBaseEntity() == null) {
return;
}
tagsLayout.addComponent(distributionTagToken.getTokenField());
}
private void populateLog(final DistributionSet ds) {
if (null != ds) {
updateLogLayout(getLogLayout(), ds.getLastModifiedAt(), ds.getLastModifiedBy(), ds.getCreatedAt(),
ds.getCreatedBy(), i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
}
}
private void populateDetails(final DistributionSet ds) {
if (ds != null) {
updateDistributionSetDetailsLayout(ds.getType().getName(), ds.isRequiredMigrationStep());
private void populateDetails() {
if (getSelectedBaseEntity() != null) {
updateDistributionSetDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().isRequiredMigrationStep());
} else {
updateDistributionSetDetailsLayout(null, null);
}
}
private void populateDescription(final DistributionSet ds) {
if (ds != null) {
updateDescriptionLayout(i18n.get("label.description"), ds.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
private void updateDistributionSetDetailsLayout(final String type, final Boolean isMigrationRequired) {
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().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(
getI18n().get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no")));
}
}
public Long getDsId() {
return dsId;
}
public void setDsId(final Long dsId) {
this.dsId = dsId;
}
/*
* (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"));
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getEditButtonId()
*/
@Override
protected String getEditButtonId() {
return SPUIComponetIdProvider.DS_EDIT_BUTTON;
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsSwModuleSelected ()
*/
@Override
protected Boolean onLoadIsTableRowSelected() {
return manageDistUIState.getSelectedDistributions().isPresent()
&& !manageDistUIState.getSelectedDistributions().get().isEmpty();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* onLoadIsTableMaximized ()
*/
@Override
protected Boolean onLoadIsTableMaximized() {
return manageDistUIState.isDsTableMaximized();
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* populateDetailsWidget()
*/
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedDsModule);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getDefaultCaption()
*/
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
return getI18n().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(), getI18n().get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* clearDetails()
*/
@Override
protected void clearDetails() {
populateDetailsWidget(null);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* hasEditSoftwareModulePermission()
*/
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE) {
ui.access(() -> updateSoftwareModule(event.getSoftwareModule()));
UI.getCurrent().access(() -> updateSoftwareModule(event.getEntity()));
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent distributionTableEvent) {
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|| distributionTableEvent
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
assignedSWModule.clear();
ui.access(() -> {
/**
* distributionTableEvent.getDistributionSet() is null when
* table has no data.
*/
if (distributionTableEvent.getDistributionSet() != null) {
selectedDsModule = distributionTableEvent.getDistributionSet();
populateData(true);
} else {
populateData(false);
}
});
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
ui.access(() -> showLayout());
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
ui.access(() -> hideLayout());
}
onBaseEntityEvent(distributionTableEvent);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleAssignmentDiscardEvent softwareModuleAssignmentDiscardEvent) {
if (softwareModuleAssignmentDiscardEvent.getDistributionSetIdName() != null) {
ui.access(() -> {
UI.getCurrent().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(getSelectedBaseEntityId())
&& distIdName.getName().equals(getSelectedBaseEntity().getName())) {
setSelectedBaseEntity(
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
populateModule();
}
});
}
@@ -481,10 +333,11 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
&& selectedDsModule != null) {
&& getSelectedBaseEntity() != null) {
assignedSWModule.clear();
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId());
ui.access(() -> populteModule(selectedDsModule));
setSelectedBaseEntity(
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
UI.getCurrent().access(() -> populateModule());
}
}
@@ -498,21 +351,6 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
}
}
@PreDestroy
void destroy() {
/*
* It's good to do this, even though vaadin-spring will automatically
* unsubscribe .
*/
eventBus.unsubscribe(this);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout#
* getTabSheetId()
*/
@Override
protected String getTabSheetId() {
return null;

View File

@@ -12,15 +12,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
@@ -32,23 +28,20 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +49,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -77,7 +69,7 @@ import com.vaadin.ui.UI;
*/
@SpringComponent
@ViewScope
public class DistributionSetTable extends AbstractTable {
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
private static final long serialVersionUID = -7731776093470487988L;
@@ -86,18 +78,12 @@ public class DistributionSetTable extends AbstractTable {
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(
Arrays.asList(DragEvent.SOFTWAREMODULE_DRAG));
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient DistributionSetManagement distributionSetManagement;
@@ -117,12 +103,9 @@ public class DistributionSetTable extends AbstractTable {
* Initialize the component.
*/
@Override
@PostConstruct
protected void init() {
super.init();
addTableStyleGenerator();
setNoDataAvailable();
eventBus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -171,13 +154,6 @@ public class DistributionSetTable extends AbstractTable {
Boolean.class, null, false, true);
}
@Override
protected void addCustomGeneratedColumns() {
/**
* No generated columns.
*/
}
@Override
protected boolean isFirstRowSelectedOnLoad() {
return !manageDistUIState.getSelectedDistributions().isPresent()
@@ -193,37 +169,19 @@ public class DistributionSetTable extends AbstractTable {
}
@Override
protected void onValueChange() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
@SuppressWarnings("unchecked")
final Set<DistributionSetIdName> values = (Set<DistributionSetIdName>) getValue();
DistributionSetIdName value = null;
if (values != null && !values.isEmpty()) {
final Iterator<DistributionSetIdName> iterator = values.iterator();
protected DistributionSet findEntityByTableValue(final DistributionSetIdName entityTableId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(entityTableId.getId());
}
while (iterator.hasNext()) {
value = iterator.next();
}
/**
* Adding null check to make to avoid NPE.Its weird that at times
* getValue returns null.
*/
if (null != value) {
manageDistUIState.setSelectedDistributions(values);
manageDistUIState.setLastSelectedDistribution(value);
@Override
protected ManageDistUIState getManagmentEntityState() {
return manageDistUIState;
}
final DistributionSet lastSelectedDistSet = distributionSetManagement
.findDistributionSetByIdWithDetails(value.getId());
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));
}
@Override
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
}
@Override
@@ -231,11 +189,6 @@ public class DistributionSetTable extends AbstractTable {
return manageDistUIState.isDsTableMaximized();
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, i18n);
}
@Override
protected DropHandler getTableDropHandler() {
return new DropHandler() {
@@ -331,10 +284,6 @@ public class DistributionSetTable extends AbstractTable {
updateDropedDetails(distributionSetIdName, softwareModules);
}
/**
* @param distId
* @param softwareModule
*/
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
if (manageDistUIState.getLastSelectedDistribution().isPresent()
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
@@ -343,11 +292,6 @@ public class DistributionSetTable extends AbstractTable {
}
}
/**
* @param map
* @param softwareModule
* @param softwareModuleIdName
*/
private void handleFirmwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() == 1) {
@@ -361,11 +305,6 @@ public class DistributionSetTable extends AbstractTable {
}
}
/**
* @param map
* @param softwareModule
* @param softwareModuleIdName
*/
private void handleSoftwareCase(final Map<Long, HashSet<SoftwareModuleIdName>> map,
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
@@ -475,37 +414,6 @@ public class DistributionSetTable extends AbstractTable {
return true;
}
/**
* Add new software module to table.
*
* @param swModule
* new software module
*/
@SuppressWarnings("unchecked")
private void addDistributionSet(final DistributionSet distributionSet) {
final Object addItem = addItem();
final Item item = getItem(addItem);
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(distributionSet.getName());
item.getItemProperty(SPUILabelDefinitions.DIST_ID).setValue(distributionSet.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(distributionSet.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(distributionSet.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(distributionSet.getVersion());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
.setValue(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
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));
}
select(distributionSet.getDistributionSetIdName());
}
private void addTableStyleGenerator() {
setCellStyleGenerator((source, itemId, propertyId) -> {
if (propertyId == null) {
@@ -525,13 +433,7 @@ public class DistributionSetTable extends AbstractTable {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent event) {
if (event.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (event.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (event.getDistributionComponentEvent() == DistributionComponentEvent.ADD_DISTRIBUTION) {
UI.getCurrent().access(() -> addDistributionSet(event.getDistributionSet()));
}
onBaseEntityEvent(event);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -556,21 +458,24 @@ public class DistributionSetTable extends AbstractTable {
}
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
@Override
@SuppressWarnings("unchecked")
protected Item addEntity(final DistributionSet baseEntity) {
final Item item = super.addEntity(baseEntity);
item.getItemProperty(SPUILabelDefinitions.DIST_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(baseEntity.isComplete());
if (manageDistUIState.getSelectedDistributions().isPresent()) {
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
}
select(baseEntity.getDistributionSetIdName());
return item;
}
private void setNoDataAvailable() {
final int containerSize = getContainerDataSource().size();
if (containerSize == 0) {
manageDistUIState.setNoDataAvailableDist(true);
} else {
manageDistUIState.setNoDataAvailableDist(false);
}
@Override
protected void setDataAvailable(final boolean available) {
manageDistUIState.setNoDataAvailableDist(!available);
}
}

View File

@@ -8,22 +8,16 @@
*/
package org.eclipse.hawkbit.ui.distributions.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,28 +37,12 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = -3483238438474530748L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIstate;
@Autowired
private DistributionAddUpdateWindowLayout addUpdateWindowLayout;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_DIST_FILTER_BY_TYPE) {
@@ -147,13 +125,13 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
manageDistUIstate.setDsTableMaximized(Boolean.TRUE);
eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MAXIMIZED, null));
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED, null));
}
@Override
public void minimizeTable() {
manageDistUIstate.setDsTableMaximized(Boolean.FALSE);
eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MINIMIZED, null));
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED, null));
}
@Override
@@ -181,11 +159,6 @@ public class DistributionSetTableHeader extends AbstractTableHeader {
eventbus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@Override
protected Boolean isAddNewItemAllowed() {
return Boolean.TRUE;

View File

@@ -16,10 +16,6 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -39,29 +35,6 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, List<String>> DROP_CONFIGS = createDropConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -78,11 +51,6 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -15,10 +15,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -30,13 +26,10 @@ import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -44,7 +37,6 @@ import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.TableTransferable;
import com.vaadin.ui.UI;
@@ -65,21 +57,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
DragEvent.SOFTWAREMODULE_TYPE_DRAG));
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient SystemManagement systemManagement;
@@ -92,28 +69,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init()
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DragEvent event) {
if (event == DragEvent.HIDE_DROP_HINT) {
@@ -139,77 +94,34 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasDeletePermission()
*/
@Override
protected boolean hasDeletePermission() {
return permChecker.hasDeleteDistributionPermission();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUpdatePermission()
*/
@Override
protected boolean hasUpdatePermission() {
return 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");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteAreaId()
*/
@Override
protected String getDeleteAreaId() {
return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getDeleteLayoutAcceptCriteria ()
*/
@Override
protected AcceptCriterion getDeleteLayoutAcceptCriteria() {
return distributionsViewAcceptCriteria;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* processDroppedComponent(com .vaadin.event.dd.DragAndDropEvent)
*/
@Override
protected void processDroppedComponent(final DragAndDropEvent event) {
final Component sourceComponent = event.getTransferable().getSourceComponent();
@@ -298,7 +210,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.targets.already.deleted"));
notification.displayValidationError(i18n.get("message.targets.already.deleted"));
} else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) {
/*
* Not the all distributions dropped now are added to the delete
@@ -306,7 +218,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
* delete list. Hence display warning message accordingly.
*/
uiNotification.displayValidationError(i18n.get("message.dist.deleted.pending"));
notification.displayValidationError(i18n.get("message.dist.deleted.pending"));
}
}
@@ -366,64 +278,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
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");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getActionsButtonLabel()
*/
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* reloadActionCount()
*/
@Override
protected void restoreActionCount() {
updateDSActionCount();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowCaption ()
*/
@Override
protected String getUnsavedActionsWindowCaption() {
return 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();
@@ -433,26 +293,12 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* getUnsavedActionsWindowContent ()
*/
@Override
protected Component getUnsavedActionsWindowContent() {
distConfirmationWindowLayout.init();
distConfirmationWindowLayout.initialize();
return distConfirmationWindowLayout;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout#
* hasUnsavedActions()
*/
@Override
protected boolean hasUnsavedActions() {
boolean unSavedActionsTypes = false;
@@ -469,53 +315,6 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
return unSavedActionsTables || unSavedActionsTypes;
}
@Override
protected boolean hasCountMessage() {
return false;
}
@Override
protected Label getCountMessageLabel() {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* hasBulkUploadPermission()
*/
@Override
protected boolean hasBulkUploadPermission() {
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* showBulkUploadWindow()
*/
@Override
protected void showBulkUploadWindow() {
/**
* Bulk upload not supported No implementation required.
*/
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
* restoreBulkUploadStatusCount()
*/
@Override
protected void restoreBulkUploadStatusCount() {
/**
* No implementation required.As no bulk upload in Distribution view.
*/
}
private DistributionSetType getCurrentDistributionSetType() {
return systemManagement.getTenantMetadata().getDefaultDsType();
}

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.ui.distributions.footer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -17,8 +16,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -32,13 +29,11 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -48,6 +43,7 @@ import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
import com.vaadin.ui.themes.ValoTheme;
@@ -83,12 +79,6 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
private ConfirmationTab assignmnetTab;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient DistributionSetManagement dsManagement;
@@ -98,20 +88,6 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
@Autowired
private ManageDistUIState manageDistUIState;
/**
* Initialze the component.
*/
@PostConstruct
public void init() {
super.inittialize();
}
/*
* (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<>();
@@ -161,26 +137,13 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Add the discard action column */
tab.getTable().addGeneratedColumn(SW_DISCARD_CHGS, (source, itemId, columnId) -> {
final Button deleteswIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deleteswIcon.setData(itemId);
deleteswIcon.setImmediate(true);
deleteswIcon.addClickListener(event -> discardSoftwareDelete(event, itemId, tab));
return deleteswIcon;
final ClickListener clickListener = event -> discardSoftwareDelete(event, itemId, tab);
return createDiscardButton(itemId, clickListener);
});
/* set the visible columns */
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(SW_MODULE_NAME_MSG, SW_DISCARD_CHGS);
tab.getTable().setColumnHeaders(i18n.get("upload.swModuleTable.header"),
i18n.get("header.second.deletetarget.table"));
tab.getTable().setColumnExpandRatio(SW_MODULE_NAME_MSG, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH);
tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -295,18 +258,9 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
return deleteIcon;
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(SW_MODULE_TYPE_NAME, DISCARD);
tab.getTable().setColumnHeaders(i18n.get("header.first.delete.swmodule.type.table"),
i18n.get("header.second.delete.swmodule.type.table"));
tab.getTable().setColumnExpandRatio(SW_MODULE_TYPE_NAME, 2);
tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -383,26 +337,14 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
/* Add the discard action column */
tab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
final Button deleteswIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deleteswIcon.setData(itemId);
deleteswIcon.setImmediate(true);
deleteswIcon.addClickListener(event -> discardDistDelete(event, itemId, tab));
return deleteswIcon;
final ClickListener clickListener = event -> discardDistDelete(event, itemId, tab);
return createDiscardButton(itemId, clickListener);
});
/* set the visible columns */
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(DIST_NAME, DISCARD);
tab.getTable().setColumnHeaders(i18n.get("header.one.deletedist.table"),
i18n.get("header.second.deletedist.table"));
tab.getTable().setColumnExpandRatio(DIST_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH);
tab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -495,30 +437,15 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
// Add the discard action column
tab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' ');
style.append(SPUIStyleDefinitions.REDICON);
final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId);
deleteIcon.setImmediate(true);
deleteIcon.addClickListener(
event -> discardDistTypeDelete((String) ((Button) event.getComponent()).getData(), itemId, tab));
return deleteIcon;
final ClickListener clickListener = event -> discardDistTypeDelete(
(String) ((Button) event.getComponent()).getData(), itemId, tab);
return createDiscardButton(itemId, clickListener);
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
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"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(DIST_SET_NAME, DISCARD);
tab.getTable().setColumnHeaders(i18n.get("header.first.delete.dist.type.table"),
i18n.get("header.second.delete.dist.type.table"));
tab.getTable().setColumnExpandRatio(DIST_SET_NAME, 2);
tab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -610,20 +537,9 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
return deleteIcon;
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
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"));
}
assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
assignmnetTab.getTable().setVisibleColumns(DIST_NAME, SOFTWARE_MODULE_NAME, DISCARD);
assignmnetTab.getTable().setColumnHeaders(i18n.get("header.dist.first.assignment.table"),
i18n.get("header.dist.second.assignment.table"), i18n.get("header.third.assignment.table"));
assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2);

View File

@@ -8,22 +8,15 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -42,76 +35,26 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class SwModuleDetails extends AbstractTableDetailsLayout {
public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLayout<SoftwareModule> {
private static final long serialVersionUID = -1052279281066089812L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Autowired
private ManageDistUIState manageDistUIState;
private UI ui;
private Long swModuleId;
private SoftwareModule selectedSwModule;
@Override
@PostConstruct
protected void init() {
super.init();
ui = UI.getCurrent();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE
|| softwareModuleEvent
.getSoftwareModuleEventType() == SoftwareModuleEventType.UPDATED_SOFTWARE_MODULE) {
ui.access(() -> {
/**
* softwareModuleEvent.getSoftwareModule() is null when table
* has no data.
*/
if (softwareModuleEvent.getSoftwareModule() != null) {
selectedSwModule = softwareModuleEvent.getSoftwareModule();
populateData(true);
} else {
populateData(false);
}
});
} else if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
showLayout();
} else if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
hideLayout();
}
onBaseEntityEvent(softwareModuleEvent);
}
@Override
protected void onEdit(final ClickEvent event) {
final Window addSoftwareModule = softwareModuleAddUpdateWindow.createUpdateSoftwareModuleWindow(swModuleId);
addSoftwareModule.setCaption(i18n.get("upload.caption.update.swmodule"));
final Window addSoftwareModule = softwareModuleAddUpdateWindow
.createUpdateSoftwareModuleWindow(getSelectedBaseEntityId());
addSoftwareModule.setCaption(getI18n().get("upload.caption.update.swmodule"));
UI.getCurrent().addWindow(addSoftwareModule);
addSoftwareModule.setVisible(Boolean.TRUE);
}
@@ -123,14 +66,14 @@ public class SwModuleDetails extends AbstractTableDetailsLayout {
@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(createLogLayout(), i18n.get("caption.logs.tab"), null);
detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
}
@Override
protected String getDefaultCaption() {
return i18n.get("upload.swModuleTable.header");
return getI18n().get("upload.swModuleTable.header");
}
@Override
@@ -143,19 +86,9 @@ public class SwModuleDetails extends AbstractTableDetailsLayout {
return manageDistUIState.isSwModuleTableMaximized();
}
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedSwModule);
}
@Override
protected void clearDetails() {
populateDetailsWidget(null);
}
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@Override
@@ -163,81 +96,49 @@ public class SwModuleDetails extends AbstractTableDetailsLayout {
return null;
}
private void populateDetails(final SoftwareModule swModule) {
private void populateDetails() {
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
if (swModule != null) {
if (swModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = i18n.get("label.multiAssign.type");
if (getSelectedBaseEntity() != null) {
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = getI18n().get("label.multiAssign.type");
} else {
maxAssign = i18n.get("label.singleAssign.type");
maxAssign = getI18n().get("label.singleAssign.type");
}
updateSwModuleDetailsLayout(swModule.getType().getName(), swModule.getVendor(), maxAssign);
updateSwModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().getVendor(), maxAssign);
} else {
updateSwModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY,
maxAssign);
}
}
private void populateDescription(final SoftwareModule sw) {
if (sw != null) {
updateDescriptionLayout(i18n.get("label.description"), sw.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
private void updateSwModuleDetailsLayout(final String type, final String vendor, final String maxAssign) {
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.vendor"),
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.assigned.type"),
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);
}
private void populateLog(final SoftwareModule softwareModule) {
if (null != softwareModule) {
updateLogLayout(getLogLayout(), softwareModule.getLastModifiedAt(), softwareModule.getLastModifiedBy(),
softwareModule.getCreatedAt(), softwareModule.getCreatedBy(), i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
}
}
public void setSwModuleId(final Long swModuleId) {
this.swModuleId = swModuleId;
}
private void populateDetailsWidget(final SoftwareModule swModule) {
if (swModule != null) {
setSwModuleId(swModule.getId());
setName(getDefaultCaption(),
HawkbitCommonUtil.getFormattedNameVersion(swModule.getName(), swModule.getVersion()));
populateDetails(swModule);
populateDescription(swModule);
populateLog(swModule);
} else {
setSwModuleId(null);
setName(getDefaultCaption(), HawkbitCommonUtil.SP_STRING_EMPTY);
populateDetails(null);
populateDescription(null);
populateLog(null);
}
@Override
protected void populateDetailsWidget() {
populateDetails();
}
@Override

View File

@@ -8,34 +8,26 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.DragEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -45,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -71,19 +62,13 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class SwModuleTable extends AbstractTable {
public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
private static final long serialVersionUID = 6785314784507424750L;
@Autowired
private I18N i18n;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient SoftwareManagement softwareManagement;
@@ -97,21 +82,9 @@ public class SwModuleTable extends AbstractTable {
* Initialize the filter layout.
*/
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
styleTableOnDistSelection();
setNoDataAvailable();
}
@PreDestroy
void destroy() {
/*
* It's good manners to do this, even though vaadin-spring will
* automatically unsubscribe when this UI is garbage collected.
*/
eventBus.unsubscribe(this);
}
/* All event Listeners */
@@ -148,13 +121,7 @@ public class SwModuleTable extends AbstractTable {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleEvent event) {
if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MINIMIZED) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.MAXIMIZED) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (event.getSoftwareModuleEventType() == SoftwareModuleEventType.NEW_SOFTWARE_MODULE) {
UI.getCurrent().access(() -> addSoftwareModule(event.getSoftwareModule()));
}
onBaseEntityEvent(event);
}
@Override
@@ -237,56 +204,43 @@ public class SwModuleTable extends AbstractTable {
return manageDistUIState.isSwModuleTableMaximized();
}
@SuppressWarnings("rawtypes")
@Override
protected void onValueChange() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
@SuppressWarnings("unchecked")
final Set<Long> values = (Set) getValue();
if (values != null && !values.isEmpty()) {
final Iterator<Long> iterator = values.iterator();
Long value = null;
while (iterator.hasNext()) {
value = iterator.next();
}
if (null != value) {
manageDistUIState.setSelectedBaseSwModuleId(value);
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
manageDistUIState.setSelectedSoftwareModules(values);
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule));
}
} else {
manageDistUIState.setSelectedBaseSwModuleId(null);
manageDistUIState.setSelectedSoftwareModules(Collections.emptySet());
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, null));
}
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
}
@Override
protected void setManagementEntitiyStateValues(final Set<Long> values, final Long lastId) {
manageDistUIState.setSelectedBaseSwModuleId(lastId);
manageDistUIState.setSelectedSoftwareModules(values);
}
@Override
protected SoftwareModule findEntityByTableValue(final Long lastSelectedId) {
return softwareManagement.findSoftwareModuleById(lastSelectedId);
}
@Override
protected ManagmentEntityState<Long> getManagmentEntityState() {
return null;
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<>();
final List<TableColumn> columnList = super.getTableVisibleColumns();
if (isMaximized()) {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
} else {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.7F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.ARTIFACT_ICON, "", 0.1F));
}
return columnList;
}
@Override
protected float getColumnNameMinimizedSize() {
return 0.7F;
}
@Override
protected DropHandler getTableDropHandler() {
return new DropHandler() {
@@ -369,30 +323,23 @@ public class SwModuleTable extends AbstractTable {
return name + "." + version;
}
@Override
@SuppressWarnings("unchecked")
private void addSoftwareModule(final SoftwareModule swModule) {
final Object addItem = addItem();
final Item item = getItem(addItem);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", swModule.getName(), swModule.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(swModule.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(swModule.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(swModule.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(swModule.getVersion());
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(swModule.getName());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
protected Item addEntity(final SoftwareModule baseEntity) {
final Item item = super.addEntity(baseEntity);
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
baseEntity.getVersion());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
item.getItemProperty("swId").setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour());
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(swModule.getType().getColour());
if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
manageDistUIState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
manageDistUIState.getSelectedSoftwareModules().stream().forEach(this::unselect);
}
select(swModule.getId());
select(baseEntity.getId());
return item;
}
private void showArtifactDetailsWindow(final Long itemId, final String nameVersionStr) {
@@ -431,13 +378,10 @@ public class SwModuleTable extends AbstractTable {
UI.getCurrent().addWindow(atrifactDtlsWindow);
}
private void setNoDataAvailable() {
final int conatinerSize = getContainerDataSource().size();
if (conatinerSize == 0) {
manageDistUIState.setNoDataAvilableSwModule(true);
} else {
manageDistUIState.setNoDataAvilableSwModule(false);
}
@Override
protected void setDataAvailable(final boolean available) {
manageDistUIState.setNoDataAvilableSwModule(!available);
}
}

View File

@@ -8,21 +8,15 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,33 +37,12 @@ public class SwModuleTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 242961845006626297L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionsUIEvent event) {
if (event == DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE) {
@@ -149,14 +122,14 @@ public class SwModuleTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
manageDistUIState.setSwModuleTableMaximized(Boolean.TRUE);
eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MAXIMIZED, null));
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MAXIMIZED, null));
}
@Override
public void minimizeTable() {
manageDistUIState.setSwModuleTableMaximized(Boolean.FALSE);
eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MINIMIZED, null));
eventbus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.MINIMIZED, null));
}
@Override

View File

@@ -11,11 +11,8 @@ package org.eclipse.hawkbit.ui.distributions.smtype;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
@@ -27,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -47,21 +43,12 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 6804534533362387433L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;
@Autowired
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
eventBus.subscribe(this);
}
@Override
protected String getButtonsTableId() {
return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID;
@@ -135,9 +122,5 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
setContainerDataSource(createButtonsLazyQueryContainer());
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
}

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.distributions.smtype;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
@@ -19,7 +18,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -36,12 +34,6 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = -8763788280848718344L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManageDistUIState manageDistUIState;

View File

@@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -30,7 +31,7 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
*/
@SpringComponent
@VaadinSessionScope
public class ManageDistUIState implements Serializable {
public class ManageDistUIState implements ManagmentEntityState<DistributionSetIdName>, Serializable {
private static final long serialVersionUID = -7569047247017742928L;
@@ -101,26 +102,23 @@ public class ManageDistUIState implements Serializable {
* @return the slectedDistributions
*/
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() {
return selectedDistributions == null ? Optional.empty() : Optional.of(selectedDistributions);
return Optional.ofNullable(selectedDistributions);
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
return lastSelectedDistribution == null ? Optional.empty() : Optional.of(lastSelectedDistribution);
return Optional.ofNullable(lastSelectedDistribution);
}
/**
* @param lastSelectedDistribution
* the lastSelectedDistribution to set
*/
public void setLastSelectedDistribution(final DistributionSetIdName lastSelectedDistribution) {
this.lastSelectedDistribution = lastSelectedDistribution;
@Override
public void setLastSelectedEntity(final DistributionSetIdName value) {
this.lastSelectedDistribution = value;
}
public void setSelectedDistributions(final Set<DistributionSetIdName> slectedDistributions) {
selectedDistributions = slectedDistributions;
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
selectedDistributions = values;
}
/**
@@ -141,7 +139,7 @@ public class ManageDistUIState implements Serializable {
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
return Optional.ofNullable(selectedBaseSwModuleId);
}
/**

View File

@@ -12,6 +12,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.actionhistory.ActionHistoryComponent;
import org.eclipse.hawkbit.ui.management.dstable.DistributionTableLayout;
import org.eclipse.hawkbit.ui.management.dstag.DistributionTagLayout;
@@ -108,19 +109,18 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent event) {
if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MINIMIZED) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeDistTable();
} else if (event
.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MAXIMIZED) {
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
maximizeDistTable();
}
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent event) {
if (event.getTargetComponentEvent() == TargetTableEvent.TargetComponentEvent.MINIMIZED) {
if (BaseEntityEventType.MINIMIZED == event.getEventType()) {
minimizeTargetTable();
} else if (event.getTargetComponentEvent() == TargetTableEvent.TargetComponentEvent.MAXIMIZED) {
} else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) {
maximizeTargetTable();
}
}

View File

@@ -12,8 +12,8 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -62,9 +62,9 @@ public class ActionHistoryComponent extends VerticalLayout {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent targetUIEvent) {
if (targetUIEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET) {
if (BaseEntityEventType.SELECTED_ENTITY == targetUIEvent.getEventType()) {
setData(SPUIDefinitions.DATA_AVAILABLE);
UI.getCurrent().access(() -> populateActionHistoryDetails(targetUIEvent.getTarget()));
UI.getCurrent().access(() -> populateActionHistoryDetails(targetUIEvent.getEntity()));
}
}

View File

@@ -25,11 +25,11 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -855,11 +855,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
}
private void updateTargetAndDsTable() {
/*
* 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));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, target));
updateDistributionTableStyle();
}

View File

@@ -23,10 +23,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -260,8 +260,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
new Object[] { currentDS.getName(), currentDS.getVersion() }));
// update table row+details layout
eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS));
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS));
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
notificationMessage.displayValidationError(
@@ -307,7 +306,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
/* close the window */
closeThisWindow();
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ADD_DISTRIBUTION, newDist));
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.NEW_ENTITY, newDist));
}
}

View File

@@ -8,23 +8,15 @@
*/
package org.eclipse.hawkbit.ui.management.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -42,19 +34,10 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class DistributionDetails extends AbstractTableDetailsLayout {
public class DistributionDetails extends AbstractNamedVersionedEntityTableDetailsLayout<DistributionSet> {
private static final long serialVersionUID = 350360207334118826L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private ManagementUIState managementUIState;
@@ -66,70 +49,37 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
private SoftwareModuleDetailsTable softwareModuleTable;
private Long dsId;
private DistributionSet selectedDsModule;
private UI ui;
@Override
@PostConstruct
protected void init() {
eventBus.subscribe(this);
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, false, permissionChecker, null, null, null);
softwareModuleTable.init(getI18n(), false, getPermissionChecker(), null, null, null);
super.init();
ui = UI.getCurrent();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent distributionTableEvent) {
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|| distributionTableEvent
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
ui.access(() -> {
/**
* distributionTableEvent.getDistributionSet() is null when
* table has no data.
*/
if (distributionTableEvent.getDistributionSet() != null) {
selectedDsModule = distributionTableEvent.getDistributionSet();
populateData(true);
} else {
populateData(false);
}
});
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
ui.access(() -> showLayout());
} else if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
ui.access(() -> hideLayout());
}
onBaseEntityEvent(distributionTableEvent);
}
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
return getI18n().get("distribution.details.header");
}
@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(), getI18n().get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
}
@Override
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getDsId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@@ -150,19 +100,9 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
return managementUIState.isDsTableMaximized();
}
@Override
protected void populateDetailsWidget() {
populateDetailsWidget(selectedDsModule);
}
@Override
protected void clearDetails() {
populateDetailsWidget(null);
}
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@Override
@@ -170,31 +110,11 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_TABSHEET;
}
private void populateDetailsWidget(final DistributionSet dist) {
if (dist != null) {
setDsId(dist.getId());
setName(getDefaultCaption(), HawkbitCommonUtil.getFormattedNameVersion(dist.getName(), dist.getVersion()));
populateDetails(dist);
populateDescription(dist);
populateLog(dist);
softwareModuleTable.populateModule(dist);
} else {
setDsId(null);
setName(getDefaultCaption(), HawkbitCommonUtil.SP_STRING_EMPTY);
populateDetails(null);
populateDescription(null);
softwareModuleTable.populateModule(null);
populateLog(null);
}
}
@Override
protected void populateDetailsWidget() {
softwareModuleTable.populateModule(getSelectedBaseEntity());
populateDetails(getSelectedBaseEntity());
private void populateLog(final DistributionSet ds) {
if (null != ds) {
updateLogLayout(getLogLayout(), ds.getLastModifiedAt(), ds.getLastModifiedBy(), ds.getCreatedAt(),
ds.getCreatedBy(), i18n);
} else {
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
}
}
private void populateDetails(final DistributionSet ds) {
@@ -205,29 +125,21 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
}
}
private void populateDescription(final DistributionSet ds) {
if (ds != null) {
updateDescriptionLayout(i18n.get("label.description"), ds.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
}
private void updateDistributionDetailsLayout(final String type, final Boolean isMigrationRequired) {
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().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(
getI18n().get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no")));
}
}
@@ -244,14 +156,6 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
return tagsLayout;
}
public Long getDsId() {
return dsId;
}
public void setDsId(final Long dsId) {
this.dsId = dsId;
}
@Override
protected String getDetailsHeaderCaptionId() {
return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;

View File

@@ -11,15 +11,12 @@ package org.eclipse.hawkbit.ui.management.dstable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
@@ -28,10 +25,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
@@ -40,8 +37,6 @@ import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -52,7 +47,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -76,22 +70,16 @@ import com.vaadin.ui.UI;
*/
@SpringComponent
@ViewScope
public class DistributionTable extends AbstractTable {
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
private static final long serialVersionUID = -1928335256399519494L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permissionChecker;
@Autowired
private UINotification notification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManagementUIState managementUIState;
@@ -111,17 +99,9 @@ public class DistributionTable extends AbstractTable {
private Button distributinPinnedBtn;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
notAllowedMsg = i18n.get("message.action.not.allowed");
setNoDataAvailable();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
/**
@@ -151,13 +131,12 @@ public class DistributionTable extends AbstractTable {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent event) {
if (event.getDistributionComponentEvent() == DistributionComponentEvent.MINIMIZED) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (event.getDistributionComponentEvent() == DistributionComponentEvent.MAXIMIZED) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (event.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
UI.getCurrent().access(() -> updateDistributionInTable(event.getDistributionSet()));
onBaseEntityEvent(event);
if (BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) {
return;
}
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -194,24 +173,11 @@ public class DistributionTable extends AbstractTable {
});
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#getTableId()
*/
@Override
protected String getTableId() {
return SPUIComponetIdProvider.DIST_TABLE_ID;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#createContainer(
* )
*/
@Override
protected Container createContainer() {
final Map<String, Object> queryConfiguration = prepareQueryConfigFilters();
@@ -272,31 +238,18 @@ public class DistributionTable extends AbstractTable {
}
@Override
protected void onValueChange() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
final Set<DistributionSetIdName> values = HawkbitCommonUtil.getSelectedDSDetails(this);
DistributionSetIdName value = null;
if (values != null && !values.isEmpty()) {
final Iterator<DistributionSetIdName> iterator = values.iterator();
protected DistributionSet findEntityByTableValue(final DistributionSetIdName lastSelectedId) {
return distributionSetManagement.findDistributionSetByIdWithDetails(lastSelectedId.getId());
}
while (iterator.hasNext()) {
value = iterator.next();
}
if (null != value) {
managementUIState.setSelectedDsIdName(values);
managementUIState.setLastSelectedDsIdName(value);
final DistributionSet lastSelectedDistSet = distributionSetManagement
.findDistributionSetByIdWithDetails(value.getId());
eventBus.publish(this,
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet));
}
} else {
managementUIState.setSelectedDsIdName(null);
managementUIState.setLastSelectedDsIdName(null);
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, null));
}
@Override
protected void publishEntityAfterValueChange(final DistributionSet selectedLastEntity) {
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
}
@Override
protected ManagementUIState getManagmentEntityState() {
return managementUIState;
}
@Override
@@ -306,7 +259,17 @@ public class DistributionTable extends AbstractTable {
@Override
protected List<TableColumn> getTableVisibleColumns() {
return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), true, i18n);
final List<TableColumn> columnList = super.getTableVisibleColumns();
if (isMaximized()) {
return columnList;
}
columnList.add(new TableColumn(SPUILabelDefinitions.PIN_COLUMN, StringUtils.EMPTY, 0.1F));
return columnList;
}
@Override
protected float getColumnNameMinimizedSize() {
return 0.7F;
}
@Override
@@ -345,7 +308,7 @@ public class DistributionTable extends AbstractTable {
private void assignDsTag(final DragAndDropEvent event) {
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
final Table distTable = (Table) taregtDet.getTarget();
final Set<DistributionSetIdName> distsSelected = HawkbitCommonUtil.getSelectedDSDetails(distTable);
final Set<DistributionSetIdName> distsSelected = getTableValue(distTable);
final Set<Long> distList = new HashSet<>();
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
@@ -363,7 +326,7 @@ public class DistributionTable extends AbstractTable {
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distList,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getAssigned() >= 1 && managementUIState.getDistributionTableFilters().isNoTagSelected()) {
refreshFilter();
}
@@ -390,7 +353,7 @@ public class DistributionTable extends AbstractTable {
private void assignTargetToDs(final DragAndDropEvent event) {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final Table source = transferable.getSourceComponent();
final Set<TargetIdName> targetsSelected = HawkbitCommonUtil.getSelectedTargetDetails(source);
final Set<TargetIdName> targetsSelected = getTableValue(source);
final Set<TargetIdName> targetDetailsList = new HashSet<>();
if (!targetsSelected.contains(transferable.getData("itemId"))) {
@@ -502,17 +465,7 @@ public class DistributionTable extends AbstractTable {
private void updateDistributionInTable(final DistributionSet editedDs) {
final Item item = getContainerDataSource()
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(editedDs.getName());
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(editedDs.getVersion());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
.setValue(HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(editedDs.getDescription());
updateEntity(editedDs, item);
}
private void restoreDistributionTableStyle() {
@@ -703,12 +656,10 @@ public class DistributionTable extends AbstractTable {
this.distributinPinnedBtn = distributinPinnedBtn;
}
private void setNoDataAvailable() {
final int size = getContainerDataSource().size();
if (size == 0) {
managementUIState.setNoDataAvailableDistribution(true);
} else {
managementUIState.setNoDataAvailableDistribution(false);
}
@Override
protected void setDataAvailable(final boolean available) {
managementUIState.setNoDataAvailableDistribution(!available);
}
}

View File

@@ -8,21 +8,15 @@
*/
package org.eclipse.hawkbit.ui.management.dstable;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -43,33 +37,12 @@ import com.vaadin.ui.Window;
public class DistributionTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = 7597766804650170127L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManagementUIState managementUIState;
@Autowired
private DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout;
@Override
@PostConstruct
protected void init() {
super.init();
eventbus.subscribe(this);
}
@PreDestroy
void destroy() {
eventbus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT) {
@@ -154,13 +127,13 @@ public class DistributionTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
managementUIState.setDsTableMaximized(Boolean.TRUE);
eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MAXIMIZED, null));
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED, null));
}
@Override
public void minimizeTable() {
managementUIState.setDsTableMaximized(Boolean.FALSE);
eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MINIMIZED, null));
eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED, null));
}
@Override

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
@@ -31,7 +29,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -51,9 +48,6 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private static final long serialVersionUID = -8151483237450892057L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private DistributionTagDropEvent spDistTagDropEvent;
@@ -64,12 +58,6 @@ public class DistributionTagButtons extends AbstractFilterButtons {
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
addNewTag(new DistributionSetTag("NO TAG"));
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.management.dstag;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -38,12 +36,6 @@ public class DistributionTagHeader extends AbstractFilterHeader {
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private ManagementUIState managementUIState;
@@ -90,7 +82,7 @@ public class DistributionTagHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
managementUIState.setDistTagFilterClosed(true);
eventbus.publish(this, ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT);
eventBus.publish(this, ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT);
}
@Override

View File

@@ -9,50 +9,26 @@
package org.eclipse.hawkbit.ui.management.event;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class DistributionTableEvent {
public class DistributionTableEvent extends BaseEntityEvent<DistributionSet> {
/**
*
*
* Constructor.
*
* @param eventType
* the event type
* @param entity
* the distribution set
*/
public enum DistributionComponentEvent {
ADD_DISTRIBUTION, EDIT_DISTRIBUTION, DELETE_DISTRIBUTION, ON_VALUE_CHANGE, MAXIMIZED, MINIMIZED
}
private DistributionComponentEvent distributionComponentEvent;
private DistributionSet distributionSet;
/**
* @param distributionComponentEvent
* @param distributionSet
*/
public DistributionTableEvent(final DistributionComponentEvent distributionComponentEvent,
final DistributionSet distributionSet) {
this.distributionComponentEvent = distributionComponentEvent;
this.distributionSet = distributionSet;
}
public DistributionComponentEvent getDistributionComponentEvent() {
return distributionComponentEvent;
}
public void setDistributionComponentEvent(final DistributionComponentEvent distributionComponentEvent) {
this.distributionComponentEvent = distributionComponentEvent;
}
public DistributionSet getDistributionSet() {
return distributionSet;
}
public void setDistributionSet(final DistributionSet distributionSet) {
this.distributionSet = distributionSet;
public DistributionTableEvent(final BaseEntityEventType eventType, final DistributionSet entity) {
super(eventType, entity);
}
}

View File

@@ -150,7 +150,7 @@ public class DistributionTagDropEvent implements DropHandler {
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG);
}

View File

@@ -16,10 +16,6 @@ import java.util.Map;
import org.eclipse.hawkbit.ui.common.AbstractAcceptCriteria;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -41,29 +37,6 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
private static final Map<String, Object> DROP_HINTS_CONFIGS = createDropHintConfigurations();
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Override
protected void analyseDragComponent(final Component compsource) {
final String sourceID = getComponentId(compsource);
final Object event = DROP_HINTS_CONFIGS.get(sourceID);
eventBus.publish(this, event);
}
@Override
protected void hideDropHints() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
}
@Override
protected void invalidDrop() {
uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED);
}
@Override
protected String getComponentId(final Component component) {
String id = component.getId();
@@ -80,11 +53,6 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria {
return DROP_HINTS_CONFIGS;
}
@Override
protected void publishDragStartEvent(final Object event) {
eventBus.publish(this, event);
}
@Override
protected Map<String, List<String>> getDropConfigurations() {
return DROP_CONFIGS;

View File

@@ -9,7 +9,8 @@
package org.eclipse.hawkbit.ui.management.event;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
@@ -17,34 +18,18 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentE
*
*
*/
public class TargetAddUpdateWindowEvent {
private final TargetComponentEvent targetComponentEvent;
private final Target target;
public class TargetAddUpdateWindowEvent extends BaseEntityEvent<Target> {
/**
* Constructor.
*
* @param eventType
* the event type
* @param target
* the target which has been created or modified
* @param entity
* the entity
*/
public TargetAddUpdateWindowEvent(final TargetComponentEvent eventType, final Target target) {
this.targetComponentEvent = eventType;
this.target = target;
public TargetAddUpdateWindowEvent(final BaseEntityEventType eventType, final Target entity) {
super(eventType, entity);
}
/**
* @return the targetComponentEvent
*/
public TargetComponentEvent getTargetComponentEvent() {
return targetComponentEvent;
}
/**
* @return the target
*/
public Target getTarget() {
return target;
}
}

View File

@@ -9,77 +9,51 @@
package org.eclipse.hawkbit.ui.management.event;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
/**
*
*
*
*/
public class TargetTableEvent {
public class TargetTableEvent extends BaseEntityEvent<Target> {
/**
* Target table components events.
*
*/
public enum TargetComponentEvent {
REFRESH_TARGETS, EDIT_TARGET, DELETE_TARGET, SELECTED_TARGET, MAXIMIZED, MINIMIZED, SELLECT_ALL, BULK_TARGET_CREATED, BULK_UPLOAD_COMPLETED, BULK_TARGET_UPLOAD_STARTED, BULK_UPLOAD_PROCESS_STARTED
REFRESH_TARGETS, SELLECT_ALL, BULK_TARGET_CREATED, BULK_UPLOAD_COMPLETED, BULK_TARGET_UPLOAD_STARTED, BULK_UPLOAD_PROCESS_STARTED
}
private TargetComponentEvent targetComponentEvent;
private Target target;
private TargetIdName targetIdName;
/**
* Constructor.
*
* @param eventType
* the event type.
* @param entity
* the entity
*/
public TargetTableEvent(final BaseEntityEventType eventType, final Target entity) {
super(eventType, entity);
}
/**
* The component event.
*
* @param targetComponentEvent
* the target component event.
*/
public TargetTableEvent(final TargetComponentEvent targetComponentEvent) {
super();
super(null, null);
this.targetComponentEvent = targetComponentEvent;
}
/**
* @param targetComponentEvent
* @param target
*/
public TargetTableEvent(final TargetComponentEvent targetComponentEvent, final Target target) {
this(targetComponentEvent);
this.target = target;
}
/**
* @param targetComponentEvent
* @param targetIdName
*/
public TargetTableEvent(final TargetComponentEvent targetComponentEvent, final TargetIdName targetIdName) {
this(targetComponentEvent);
this.targetIdName = targetIdName;
}
public TargetComponentEvent getTargetComponentEvent() {
return targetComponentEvent;
}
public void setTargetComponentEvent(final TargetComponentEvent targetComponentEvent) {
this.targetComponentEvent = targetComponentEvent;
}
public Target getTarget() {
return target;
}
public void setTarget(final Target target) {
this.target = target;
}
public TargetIdName getTargetIdName() {
return targetIdName;
}
public void setTargetIdName(final TargetIdName targetIdName) {
this.targetIdName = targetIdName;
}
}

View File

@@ -95,8 +95,8 @@ public class CountMessageLabel extends Label {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent event) {
if (event.getTargetComponentEvent() == TargetTableEvent.TargetComponentEvent.SELLECT_ALL
|| event.getTargetComponentEvent() == TargetComponentEvent.REFRESH_TARGETS) {
if (TargetTableEvent.TargetComponentEvent.SELLECT_ALL == event.getTargetComponentEvent()
|| TargetComponentEvent.REFRESH_TARGETS == event.getTargetComponentEvent()) {
displayTargetCountStatus();
}

View File

@@ -11,14 +11,11 @@ package org.eclipse.hawkbit.ui.management.footer;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
@@ -28,12 +25,9 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -56,17 +50,6 @@ import com.vaadin.ui.UI;
public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
private static final long serialVersionUID = -8112907467821886253L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient UINotification notification;
@Autowired
private transient TagManagement tagManagementService;
@@ -83,18 +66,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Autowired
private CountMessageLabel countMessageLabel;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.UPDATE_COUNT) {
@@ -226,26 +197,11 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
return true;
}
@Override
protected String getNoActionsButtonLabel() {
return i18n.get("button.no.actions");
}
@Override
protected String getActionsButtonLabel() {
return i18n.get("button.actions");
}
@Override
protected void restoreActionCount() {
updateActionCount();
}
@Override
protected String getUnsavedActionsWindowCaption() {
return i18n.get("caption.save.window");
}
@Override
protected void unsavedActionsWindowClosed() {
final String message = manangementConfirmationWindowLayout.getConsolidatedMessage();
@@ -256,7 +212,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
@Override
protected Component getUnsavedActionsWindowContent() {
manangementConfirmationWindowLayout.init();
manangementConfirmationWindowLayout.initialize();
return manangementConfirmationWindowLayout;
}
@@ -302,7 +258,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) {
final Set<DistributionSetIdName> distSelected = HawkbitCommonUtil.getSelectedDSDetails(sourceTable);
final Set<DistributionSetIdName> distSelected = AbstractTable.getTableValue(sourceTable);
final Set<DistributionSetIdName> distributionIdNameSet = new HashSet<>();
if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
@@ -356,7 +312,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout {
}
private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) {
final Set<TargetIdName> targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(sourceTable);
final Set<TargetIdName> targetSelected = AbstractTable.getTableValue(sourceTable);
final Set<TargetIdName> targetIdNameSet = new HashSet<>();
if (!targetSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {

View File

@@ -19,8 +19,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
@@ -31,20 +29,15 @@ import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout;
import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent;
import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
@@ -52,8 +45,8 @@ import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table.Align;
import com.vaadin.ui.themes.ValoTheme;
/**
* Confirmation window for target/ds delete and assignment.
@@ -79,12 +72,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
@Autowired
private ManagementUIState managementUIState;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient TargetManagement targetManagement;
@@ -99,14 +86,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
private ConfirmationTab assignmnetTab;
/**
* Initialze the component.
*/
@PostConstruct
public void init() {
super.inittialize();
}
@Override
protected Map<String, ConfirmationTab> getConfimrationTabs() {
final Map<String, ConfirmationTab> tabs = new HashMap<>();
@@ -130,6 +109,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE);
assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all"));
assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab));
assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
assignmnetTab.getDiscardAll().setId(SPUIComponetIdProvider.DISCARD_ASSIGNMENT);
assignmnetTab.getDiscardAll().addClickListener(event -> discardAllAssignments(assignmnetTab));
@@ -139,35 +119,17 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
// Add the discard action column
assignmnetTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
style.append(' ');
style.append(SPUIStyleDefinitions.REDICON);
final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class);
deleteIcon.setData(itemId);
deleteIcon.setImmediate(true);
deleteIcon.addClickListener(event -> discardAssignment(
(TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab));
return deleteIcon;
final ClickListener clickListener = event -> discardAssignment(
(TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab);
return createDiscardButton(itemId, clickListener);
});
// set the visible columns
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(TARGET_NAME);
visibleColumnIds.add(DISTRIBUTION_NAME);
visibleColumnIds.add(DISCARD_CHANGES);
visibleColumnLabels.add(i18n.get("header.first.assignment.table"));
visibleColumnLabels.add(i18n.get("header.second.assignment.table"));
visibleColumnLabels.add(i18n.get("header.third.assignment.table"));
}
assignmnetTab.getTable().setColumnExpandRatio(TARGET_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, 2);
assignmnetTab.getTable().setColumnExpandRatio(DISCARD_CHANGES, 1);
assignmnetTab.getTable().setVisibleColumns(visibleColumnIds.toArray());
assignmnetTab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
assignmnetTab.getTable().setVisibleColumns(TARGET_NAME, DISTRIBUTION_NAME, DISCARD_CHANGES);
assignmnetTab.getTable().setColumnHeaders(i18n.get("header.first.assignment.table"),
i18n.get("header.second.assignment.table"), i18n.get("header.third.assignment.table"));
assignmnetTab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER);
actionTypeOptionGroupLayout.selectDefaultOption();
@@ -326,27 +288,15 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
/* Add the discard action column */
tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final Button deletestargetIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deletestargetIcon.setData(itemId);
deletestargetIcon.setImmediate(true);
deletestargetIcon.addClickListener(event -> discardTargetDelete(
(TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab));
return deletestargetIcon;
final ClickListener clickListener = event -> discardTargetDelete(
(TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab);
return createDiscardButton(itemId, clickListener);
});
/* set the visible columns */
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(TARGET_NAME);
visibleColumnIds.add(DISCARD_CHANGES);
visibleColumnLabels.add(i18n.get("header.first.deletetarget.table"));
visibleColumnLabels.add(i18n.get("header.second.deletetarget.table"));
}
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(TARGET_NAME, DISCARD_CHANGES);
tab.getTable().setColumnHeaders(i18n.get("header.first.deletetarget.table"),
i18n.get("header.second.deletetarget.table"));
tab.getTable().setColumnExpandRatio(TARGET_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH);
tab.getTable().setColumnExpandRatio(DISCARD_CHANGES, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
@@ -371,30 +321,17 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
/* Add the discard action column */
tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> {
final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
SPUIButtonStyleSmallNoBorder.class);
deletesDsIcon.setData(itemId);
deletesDsIcon.setImmediate(true);
deletesDsIcon.addClickListener(event -> discardDSDelete(
(DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab));
return deletesDsIcon;
});
final ClickListener clickListener = event -> discardDSDelete(
(DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab);
return createDiscardButton(itemId, clickListener);
/* set the visible columns */
final List<Object> visibleColumnIds = new ArrayList<>();
final List<String> visibleColumnLabels = new ArrayList<>();
if (visibleColumnIds.isEmpty() && visibleColumnLabels.isEmpty()) {
visibleColumnIds.add(DISTRIBUTION_NAME);
visibleColumnIds.add(DISCARD_CHANGES);
visibleColumnLabels.add(i18n.get("header.one.deletedist.table"));
visibleColumnLabels.add(i18n.get("header.second.deletedist.table"));
}
});
tab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH);
tab.getTable().setColumnExpandRatio(DISCARD_CHANGES, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
tab.getTable().setVisibleColumns(visibleColumnIds.toArray());
tab.getTable().setColumnHeaders(visibleColumnLabels.toArray(new String[0]));
tab.getTable().setVisibleColumns(DISTRIBUTION_NAME, DISCARD_CHANGES);
tab.getTable().setColumnHeaders(i18n.get("header.one.deletedist.table"),
i18n.get("header.second.deletedist.table"));
tab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER);
return tab;
}

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -31,7 +32,7 @@ import com.vaadin.spring.annotation.VaadinSessionScope;
*/
@VaadinSessionScope
@SpringComponent
public class ManagementUIState implements Serializable {
public class ManagementUIState implements ManagmentEntityState<DistributionSetIdName>, Serializable {
private static final long serialVersionUID = 7301409196969723794L;
@@ -170,7 +171,7 @@ public class ManagementUIState implements Serializable {
}
public Optional<Set<TargetIdName>> getSelectedTargetIdName() {
return selectedTargetIdName == null ? Optional.empty() : Optional.of(selectedTargetIdName);
return Optional.ofNullable(selectedTargetIdName);
}
public void setSelectedTargetIdName(final Set<TargetIdName> selectedTargetIdName) {
@@ -266,16 +267,19 @@ public class ManagementUIState implements Serializable {
return lastSelectedDsIdName;
}
public void setLastSelectedDsIdName(final DistributionSetIdName lastSelectedDsIdName) {
this.lastSelectedDsIdName = lastSelectedDsIdName;
@Override
public void setLastSelectedEntity(final DistributionSetIdName value) {
this.lastSelectedDsIdName = value;
}
public void setSelectedDsIdName(final Set<DistributionSetIdName> selectedDsIdName) {
this.selectedDsIdName = selectedDsIdName;
@Override
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
this.selectedDsIdName = values;
}
public Optional<Set<DistributionSetIdName>> getSelectedDsIdName() {
return selectedDsIdName == null ? Optional.empty() : Optional.of(selectedDsIdName);
return Optional.ofNullable(selectedDsIdName);
}
/**

View File

@@ -63,14 +63,10 @@ import com.vaadin.ui.Upload.SucceededListener;
/**
* Bulk target upload handler.
*
*/
public class BulkUploadHandler extends CustomComponent
implements SucceededListener, FailedListener, Receiver, StartedListener {
/**
*
*/
private static final long serialVersionUID = -1273494705754674501L;
private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class);
@@ -149,12 +145,6 @@ public class BulkUploadHandler extends CustomComponent
setCompositionRoot(horizontalLayout);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String,
* java.lang.String)
*/
@Override
public OutputStream receiveUpload(final String filename, final String mimeType) {
try {
@@ -170,25 +160,11 @@ public class BulkUploadHandler extends CustomComponent
return new NullOutputStream();
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.FailedListener#uploadFailed(com.vaadin.ui.Upload.
* FailedEvent)
*/
@Override
public void uploadFailed(final FailedEvent event) {
LOG.info("Upload failed for file :{} due to {}", event.getFilename(), event.getReason());
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.SucceededListener#uploadSucceeded(com.vaadin.ui.
* Upload.SucceededEvent)
*/
@Override
public void uploadSucceeded(final SucceededEvent event) {
executor.execute(new UploadAsync(event));
@@ -252,6 +228,61 @@ public class BulkUploadHandler extends CustomComponent
}
}
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload()
.getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload()
.setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void doAssignments() {
final StringBuilder errorMessage = new StringBuilder();
String dsAssignmentFailedMsg = null;
@@ -267,6 +298,41 @@ public class BulkUploadHandler extends CustomComponent
displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg);
}
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
}
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (deletedTags.isEmpty()) {
return null;
}
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
}
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
private boolean ifTagsSelected() {
return targetBulkTokenTags.getTokenField().getValue() != null;
}
@@ -307,59 +373,6 @@ public class BulkUploadHandler extends CustomComponent
}
}
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void addNewTarget(final String controllerId, final String name) {
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) {
@@ -405,43 +418,6 @@ public class BulkUploadHandler extends CustomComponent
}
}
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
} else {
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (!deletedTags.isEmpty()) {
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
} else {
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
}
return null;
}
private static class NullOutputStream extends OutputStream {
/**
* null output stream.
@@ -462,13 +438,6 @@ public class BulkUploadHandler extends CustomComponent
return upload;
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.StartedListener#uploadStarted(com.vaadin.ui.Upload
* .StartedEvent)
*/
@Override
public void uploadStarted(final StartedEvent event) {
if (!event.getFilename().endsWith(".csv")) {

View File

@@ -14,11 +14,11 @@ import java.util.Set;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
@@ -56,6 +56,8 @@ import com.vaadin.ui.themes.ValoTheme;
@SpringComponent
@VaadinSessionScope
public class TargetAddUpdateWindowLayout extends CustomComponent {
private static final long serialVersionUID = -6659290471705262389L;
@Autowired
private I18N i18n;
@@ -68,7 +70,6 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
@Autowired
private transient UINotification uINotification;
private static final long serialVersionUID = -6659290471705262389L;
private TextField controllerIDTextField;
private TextField nameTextField;
private TextArea descTextArea;
@@ -218,7 +219,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
/* display success msg */
uINotification.displaySuccess(i18n.get("message.update.success", new Object[] { latestTarget.getName() }));
// publishing through event bus
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.EDIT_TARGET, latestTarget));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, latestTarget));
/* close the window */
closeThisWindow();

View File

@@ -10,11 +10,7 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.net.URI;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
@@ -22,15 +18,12 @@ import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.tagdetails.TargetTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -50,25 +43,13 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Target details layout.
*
*
*
*/
@SpringComponent
@ViewScope
public class TargetDetails extends AbstractTableDetailsLayout {
public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private static final long serialVersionUID = 4571732743399605843L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private ManagementUIState managementUIState;
@@ -78,36 +59,29 @@ public class TargetDetails extends AbstractTableDetailsLayout {
@Autowired
private TargetTagToken targetTagToken;
private Target selectedTarget = null;
private VerticalLayout assignedDistLayout;
private VerticalLayout installedDistLayout;
/**
* Initialize the Target details.
*/
@Override
@PostConstruct
public void init() {
super.init();
targetAddUpdateWindowLayout.init();
eventBus.subscribe(this);
}
@Override
protected String getDefaultCaption() {
return i18n.get("target.details.header");
return getI18n().get("target.details.header");
}
@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(createAttributesLayout(), i18n.get("caption.attributes.tab"), null);
detailsTab.addTab(createAssignedDistLayout(), i18n.get("header.target.assigned"), null);
detailsTab.addTab(createInstalledDistLayout(), i18n.get("header.target.installed"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null);
detailsTab.addTab(createAttributesLayout(), getI18n().get("caption.attributes.tab"), null);
detailsTab.addTab(createAssignedDistLayout(), getI18n().get("header.target.assigned"), null);
detailsTab.addTab(createInstalledDistLayout(), getI18n().get("header.target.installed"), null);
detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null);
}
@@ -129,13 +103,14 @@ public class TargetDetails extends AbstractTableDetailsLayout {
@Override
protected void onEdit(final ClickEvent event) {
if (selectedTarget != null) {
final Window newDistWindow = targetAddUpdateWindowLayout.getWindow();
targetAddUpdateWindowLayout.populateValuesOfTarget(selectedTarget.getControllerId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
if (getSelectedBaseEntity() == null) {
return;
}
final Window newDistWindow = targetAddUpdateWindowLayout.getWindow();
targetAddUpdateWindowLayout.populateValuesOfTarget(getSelectedBaseEntity().getControllerId());
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@Override
@@ -155,50 +130,24 @@ public class TargetDetails extends AbstractTableDetailsLayout {
@Override
protected void populateDetailsWidget() {
if (selectedTarget != null) {
setName(getDefaultCaption(), selectedTarget.getName());
}
populateDetailsWidget(selectedTarget);
}
private void populateDetailsWidget(final Target target) {
if (target != null) {
setName(getDefaultCaption(), target.getName());
updateDetailsLayout(target.getControllerId(), target.getTargetInfo().getAddress(),
target.getSecurityToken(),
SPDateTimeUtil.getFormattedDate(target.getTargetInfo().getLastTargetQuery()));
populateDescription(target);
populateDistributionDtls(installedDistLayout, target.getTargetInfo().getInstalledDistributionSet());
populateDistributionDtls(assignedDistLayout, target.getAssignedDistributionSet());
updateLogLayout(getLogLayout(), target.getLastModifiedAt(), target.getLastModifiedBy(),
target.getCreatedAt(), target.getCreatedBy(), i18n);
populateAttributes(target);
if (getSelectedBaseEntity() != null) {
updateDetailsLayout(getSelectedBaseEntity().getControllerId(),
getSelectedBaseEntity().getTargetInfo().getAddress(), getSelectedBaseEntity().getSecurityToken(),
SPDateTimeUtil.getFormattedDate(getSelectedBaseEntity().getTargetInfo().getLastTargetQuery()));
populateDistributionDtls(installedDistLayout,
getSelectedBaseEntity().getTargetInfo().getInstalledDistributionSet());
populateDistributionDtls(assignedDistLayout, getSelectedBaseEntity().getAssignedDistributionSet());
} else {
setName(getDefaultCaption(), HawkbitCommonUtil.SP_STRING_EMPTY);
updateDetailsLayout(null, null, null, null);
populateDescription(null);
populateDistributionDtls(installedDistLayout, null);
populateDistributionDtls(assignedDistLayout, null);
updateLogLayout(getLogLayout(), null, HawkbitCommonUtil.SP_STRING_EMPTY, null, null, i18n);
populateAttributes(null);
}
updateAttributesLayout(getSelectedBaseEntity());
}
private void populateAttributes(final Target target) {
if (target != null) {
updateAttributesLayout(target);
} else {
updateAttributesLayout(null);
}
}
private void populateDescription(final Target target) {
if (target != null) {
updateDescriptionLayout(i18n.get("label.description"), target.getDescription());
} else {
updateDescriptionLayout(i18n.get("label.description"), null);
}
@Override
protected String getName() {
return getSelectedBaseEntity().getName();
}
private void updateDetailsLayout(final String controllerId, final URI address, final String securityToken,
@@ -206,17 +155,18 @@ public class TargetDetails extends AbstractTableDetailsLayout {
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.target.id"),
final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.target.id"),
HawkbitCommonUtil.trimAndNullIfEmpty(controllerId) == null ? "" : controllerId);
controllerLabel.setId(SPUIComponetIdProvider.TARGET_CONTROLLER_ID);
detailsTabLayout.addComponent(controllerLabel);
final Label lastPollDtLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.target.lastpolldate"),
final Label lastPollDtLabel = SPUIComponentProvider.createNameValueLabel(
getI18n().get("label.target.lastpolldate"),
HawkbitCommonUtil.trimAndNullIfEmpty(lastQueryDate) == null ? "" : lastQueryDate);
lastPollDtLabel.setId(SPUIComponetIdProvider.TARGET_LAST_QUERY_DT);
detailsTabLayout.addComponent(lastPollDtLabel);
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.ip"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.ip"),
address == null ? StringUtils.EMPTY : address.toString());
typeLabel.setId(SPUIComponetIdProvider.TARGET_IP_ADDRESS);
detailsTabLayout.addComponent(typeLabel);
@@ -232,7 +182,7 @@ public class TargetDetails extends AbstractTableDetailsLayout {
final HorizontalLayout securityTokenLayout = new HorizontalLayout();
final Label securityTableLbl = new Label(
SPUIComponentProvider.getBoldHTMLText(i18n.get("label.target.security.token")), ContentMode.HTML);
SPUIComponentProvider.getBoldHTMLText(getI18n().get("label.target.security.token")), ContentMode.HTML);
securityTableLbl.addStyleName(SPUIDefinitions.TEXT_STYLE);
securityTableLbl.addStyleName("label-style");
@@ -252,18 +202,17 @@ public class TargetDetails extends AbstractTableDetailsLayout {
private void populateDistributionDtls(final VerticalLayout layout, final DistributionSet distributionSet) {
layout.removeAllComponents();
if (distributionSet != null) {
// Display distribution set name
layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.name"),
distributionSet.getName()));
layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.version"),
distributionSet.getVersion()));
/* Module info */
distributionSet.getModules()
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
if (distributionSet == null) {
return;
}
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.name"),
distributionSet.getName()));
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.version"),
distributionSet.getVersion()));
distributionSet.getModules()
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
}
/**
@@ -279,42 +228,14 @@ public class TargetDetails extends AbstractTableDetailsLayout {
return SPUIComponentProvider.createNameValueLabel(labelName + " : ", swModule.getName(), swModule.getVersion());
}
@Override
protected void clearDetails() {
populateDetailsWidget(null);
}
@Override
protected Boolean hasEditPermission() {
return permChecker.hasUpdateTargetPermission();
return getPermissionChecker().hasUpdateTargetPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent targetTableEvent) {
// Get the event type
final TargetComponentEvent event = targetTableEvent.getTargetComponentEvent();
if (event == TargetComponentEvent.SELECTED_TARGET || event == TargetComponentEvent.EDIT_TARGET) {
UI.getCurrent().access(() -> {
// If selected or edited, populate the fresh details.
if (targetTableEvent.getTarget() != null) {
selectedTarget = targetTableEvent.getTarget();
} else {
selectedTarget = null;
}
populateData(selectedTarget != null);
});
} else if (event == TargetComponentEvent.MINIMIZED) {
UI.getCurrent().access(() -> showLayout());
} else if (event == TargetComponentEvent.MAXIMIZED) {
UI.getCurrent().access(() -> hideLayout());
}
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
onBaseEntityEvent(targetTableEvent);
}
@Override

View File

@@ -18,9 +18,6 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
@@ -34,7 +31,9 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.filter.FilterExpression;
import org.eclipse.hawkbit.ui.filter.Filters;
import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter;
@@ -53,7 +52,6 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentE
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.state.TargetTableFilters;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -69,7 +67,6 @@ import org.springframework.data.domain.Sort;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -102,7 +99,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
@SpringComponent
@ViewScope
public class TargetTable extends AbstractTable implements Handler {
public class TargetTable extends AbstractTable<Target, TargetIdName> implements Handler {
private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class);
private static final String TARGET_PINNED = "targetPinned";
@@ -116,9 +113,6 @@ public class TargetTable extends AbstractTable implements Handler {
@Autowired
private transient TargetManagement targetManagement;
@Autowired
private I18N i18n;
@Autowired
private ManagementUIState managementUIState;
@@ -128,9 +122,6 @@ public class TargetTable extends AbstractTable implements Handler {
@Autowired
private UINotification notification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
@@ -141,19 +132,11 @@ public class TargetTable extends AbstractTable implements Handler {
private ShortcutAction actionUnSelectAll;
@Override
@PostConstruct
protected void init() {
super.init();
addActionHandler(this);
actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall"));
actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear"));
eventBus.subscribe(this);
setNoDataAvailable();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
/**
@@ -199,9 +182,10 @@ public class TargetTable extends AbstractTable implements Handler {
@EventBusListenerMethod(scope = EventScope.SESSION)
void addOrEditEvent(final TargetAddUpdateWindowEvent targetUIEvent) {
if (targetUIEvent.getTargetComponentEvent() == TargetComponentEvent.EDIT_TARGET) {
UI.getCurrent().access(() -> updateTarget(targetUIEvent.getTarget()));
if (BaseEntityEventType.UPDATED_ENTITY != targetUIEvent.getEventType()) {
return;
}
UI.getCurrent().access(() -> updateTarget(targetUIEvent.getEntity()));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -239,33 +223,14 @@ public class TargetTable extends AbstractTable implements Handler {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final TargetTableEvent event) {
if (event.getTargetComponentEvent() == TargetComponentEvent.MINIMIZED) {
UI.getCurrent().access(() -> applyMinTableSettings());
} else if (event.getTargetComponentEvent() == TargetComponentEvent.MAXIMIZED) {
UI.getCurrent().access(() -> applyMaxTableSettings());
} else if (event.getTargetComponentEvent() == TargetComponentEvent.EDIT_TARGET) {
UI.getCurrent().access(() -> updateTarget(event.getTarget()));
}
onBaseEntityEvent(event);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#getTableId()
*/
@Override
protected String getTableId() {
return SPUIComponetIdProvider.TARGET_TABLE_ID;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.common.table.AbstractTable#createContainer(
* )
*/
@Override
protected Container createContainer() {
// ADD all the filters to the query config
@@ -311,12 +276,6 @@ public class TargetTable extends AbstractTable implements Handler {
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable#
* addCustomGeneratedColumns ()
*/
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON,
@@ -340,22 +299,24 @@ public class TargetTable extends AbstractTable implements Handler {
}
@Override
protected void onValueChange() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
@SuppressWarnings("unchecked")
final Set<TargetIdName> values = HawkbitCommonUtil.getSelectedTargetDetails(this);
if (values != null && !values.isEmpty()) {
final TargetIdName lastSelectedItem = getLastSelectedItem(values);
managementUIState.setSelectedTargetIdName(values);
managementUIState.setLastSelectedTargetIdName(lastSelectedItem);
final Target target = targetManagement
.findTargetByControllerIDWithDetails(lastSelectedItem.getControllerId());
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, target));
} else {
managementUIState.setSelectedTargetIdName(null);
managementUIState.setLastSelectedTargetIdName(null);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, (Target) null));
}
protected void publishEntityAfterValueChange(final Target selectedLastEntity) {
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
}
@Override
protected Target findEntityByTableValue(final TargetIdName lastSelectedId) {
return targetManagement.findTargetByControllerIDWithDetails(lastSelectedId.getControllerId());
}
@Override
protected void setManagementEntitiyStateValues(final Set<TargetIdName> values, final TargetIdName lastId) {
managementUIState.setSelectedTargetIdName(values);
managementUIState.setLastSelectedTargetIdName(lastId);
}
@Override
protected ManagmentEntityState<TargetIdName> getManagmentEntityState() {
return null;
}
@Override
@@ -365,30 +326,15 @@ public class TargetTable extends AbstractTable implements Handler {
@Override
protected List<TableColumn> getTableVisibleColumns() {
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_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f));
} else {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8f));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0f));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0f));
final List<TableColumn> columnList = super.getTableVisibleColumns();
if (!isMaximized()) {
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
}
return columnList;
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.table.AbstractTable#getTableDropHandler()
*/
@Override
protected DropHandler getTableDropHandler() {
return new DropHandler() {
@@ -630,7 +576,7 @@ public class TargetTable extends AbstractTable implements Handler {
private void tagAssignment(final DragAndDropEvent event) {
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
final Table targetTable = (Table) taregtDet.getTarget();
final Set<TargetIdName> targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(targetTable);
final Set<TargetIdName> targetSelected = getTableValue(targetTable);
final Set<String> targetList = new HashSet<>();
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
final Object targetItemId = dropData.getItemIdOver();
@@ -644,7 +590,7 @@ public class TargetTable extends AbstractTable implements Handler {
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
refreshFilter();
}
@@ -688,7 +634,7 @@ public class TargetTable extends AbstractTable implements Handler {
private static Set<DistributionSetIdName> getDraggedDistributionSet(final TableTransferable transferable,
final Table source) {
final Set<DistributionSetIdName> distSelected = HawkbitCommonUtil.getSelectedDSDetails(source);
final Set<DistributionSetIdName> distSelected = getTableValue(source);
final Set<DistributionSetIdName> distributionIdSet = new HashSet<>();
if (!distSelected.contains(transferable.getData(ITEMID))) {
distributionIdSet.add((DistributionSetIdName) transferable.getData(ITEMID));
@@ -962,7 +908,7 @@ public class TargetTable extends AbstractTable implements Handler {
refreshTargets();
}
if (lastSelectedTarget != null) {
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, lastSelectedTarget));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, lastSelectedTarget));
}
}
@@ -1042,13 +988,9 @@ public class TargetTable extends AbstractTable implements Handler {
setValue(null);
}
private void setNoDataAvailable() {
final int tableSize = getContainerDataSource().size();
if (tableSize == 0) {
managementUIState.setNoDataAvilableTarget(true);
} else {
managementUIState.setNoDataAvilableTarget(false);
}
@Override
protected void setDataAvailable(final boolean available) {
managementUIState.setNoDataAvilableTarget(!available);
}
/**

View File

@@ -11,12 +11,10 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent;
@@ -29,7 +27,6 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUITargetDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -63,12 +60,6 @@ public class TargetTableHeader extends AbstractTableHeader {
private static final long serialVersionUID = -8647521126666320022L;
@Autowired
private I18N i18n;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private UINotification notification;
@@ -90,21 +81,14 @@ public class TargetTableHeader extends AbstractTableHeader {
private Boolean isComplexFilterViewDisplayed = Boolean.FALSE;
@Override
@PostConstruct
protected void init() {
super.init();
// creating add window for adding new target
targetAddUpdateWindow.init();
targetBulkUpdateWindow.init();
eventBus.subscribe(this);
onLoadRestoreState();
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT) {
@@ -272,13 +256,13 @@ public class TargetTableHeader extends AbstractTableHeader {
@Override
public void maximizeTable() {
managementUIState.setTargetTableMaximized(Boolean.TRUE);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.MAXIMIZED));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.MAXIMIZED,null));
}
@Override
public void minimizeTable() {
managementUIState.setTargetTableMaximized(Boolean.FALSE);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.MINIMIZED));
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.MINIMIZED,null));
}
@Override
@@ -395,8 +379,7 @@ public class TargetTableHeader extends AbstractTableHeader {
}
private Set<DistributionSetIdName> getDropppedDistributionDetails(final TableTransferable transferable) {
final Set<DistributionSetIdName> distSelected = HawkbitCommonUtil
.getSelectedDSDetails(transferable.getSourceComponent());
final Set<DistributionSetIdName> distSelected = AbstractTable.getTableValue(transferable.getSourceComponent());
final Set<DistributionSetIdName> distributionIdSet = new HashSet<>();
if (!distSelected.contains(transferable.getData("itemId"))) {
distributionIdSet.add((DistributionSetIdName) transferable.getData("itemId"));

View File

@@ -13,8 +13,6 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
@@ -24,6 +22,7 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
@@ -38,7 +37,6 @@ import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -63,9 +61,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 5049554600376508073L;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private ManagementUIState managementUIState;
@@ -99,12 +94,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
super.init(filterButtonClickBehaviour);
addNewTargetTag(new TargetTag("NO TAG"));
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -229,7 +218,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final Table source = transferable.getSourceComponent();
final Set<TargetIdName> targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(source);
final Set<TargetIdName> targetSelected = AbstractTable.getTableValue(source);
final Set<String> targetList = new HashSet<>();
if (transferable.getData(ITEMID) != null) {
if (!targetSelected.contains(transferable.getData(ITEMID))) {
@@ -244,7 +233,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n));
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(targTagName, result, i18n));
if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) {
eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG);

View File

@@ -10,14 +10,12 @@ package org.eclipse.hawkbit.ui.management.targettag;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
@@ -32,15 +30,9 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
private static final long serialVersionUID = 3046367045669148009L;
@Autowired
private SpPermissionChecker permChecker;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventbus;
@Autowired
private CreateUpdateTargetTagLayout createUpdateTargetTagLayout;
@@ -58,7 +50,6 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
@Override
protected String getHideButtonId() {
return SPUIComponetIdProvider.HIDE_TARGET_TAGS;
}
@@ -87,7 +78,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
@Override
protected void hideFilterButtonLayout() {
managementUIState.setTargetTagFilterClosed(true);
eventbus.publish(this, ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT);
eventBus.publish(this, ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT);
}
@Override

View File

@@ -15,9 +15,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
@@ -34,7 +31,6 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -47,7 +43,6 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.peter.contextmenu.ContextMenu;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItem;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItemClickEvent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -59,7 +54,6 @@ import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
@@ -84,11 +78,7 @@ public class RolloutListGrid extends AbstractGrid {
private static final String START_OPTION = "Start";
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
private static final String customObject = "customObject";
@Autowired
private transient RolloutManagement rolloutManagement;
@@ -107,18 +97,6 @@ public class RolloutListGrid extends AbstractGrid {
private transient Map<RolloutStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutStatus.class);
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
switch (event) {
@@ -154,12 +132,7 @@ public class RolloutListGrid extends AbstractGrid {
}
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus);
item.getItemProperty("customObject").setValue(new CustomObject(rollout.getName(), rollout.getStatus().toString()));
final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue();
/*if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS)
.setValue(Long.valueOf(rollout.getRolloutGroups().size()));
}*/
final int groupsCreated = rollout.getRolloutGroupsCreated();
if (groupsCreated != 0) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated));
@@ -167,7 +140,9 @@ public class RolloutListGrid extends AbstractGrid {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS)
.setValue(Long.valueOf(rollout.getRolloutGroups().size()));
}
item.getItemProperty(customObject)
.setValue(new CustomObject(rollout.getName(), rollout.getStatus().toString()));
}
@Override
@@ -180,16 +155,8 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void addContainerProperties() {
final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, false, false);
// rolloutGridContainer.addContainerProperty("yes", Boolean.class, null,
// false, false);
// rolloutGridContainer.addContainerProperty("custom",
// CustomValue.class,
// null, false, false);
// rolloutGridContainer.addContainerProperty("buttonText", String.class,
// "", false, false);
rolloutGridContainer.addContainerProperty("customObject", CustomObject.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGridContainer.addContainerProperty(customObject, CustomObject.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false);
@@ -218,8 +185,9 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setColumnExpandRatio() {
getColumn("customObject").setMinimumWidth(40);
getColumn("customObject").setMaximumWidth(150);
getColumn(customObject).setMinimumWidth(40);
getColumn(customObject).setMaximumWidth(150);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150);
@@ -243,8 +211,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setColumnHeaderNames() {
// getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption("name");
getColumn("customObject").setHeaderCaption("Name");
getColumn(customObject).setHeaderCaption(i18n.get("header.name"));
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
@@ -266,10 +233,8 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
// columnList.add("yes");
columnList.add("customObject");
// columnList.add(SPUILabelDefinitions.VAR_NAME);
final List<Object> columnList = new ArrayList<>();
columnList.add(customObject);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
@@ -288,14 +253,14 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setHiddenColumns() {
List<Object> columnsToBeHidden = new ArrayList<>();
final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
for (Object propertyId : columnsToBeHidden) {
for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true);
}
@@ -318,18 +283,10 @@ public class RolloutListGrid extends AbstractGrid {
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event)));
///////////////
// getColumn("customObject").setRenderer(new CustomObjectRenderer(event
// -> onClickOfRolloutName(event)));
CustomObjectRenderer cor = new CustomObjectRenderer(CustomObject.class);
cor.addClickListener(event -> onClickOfRolloutName(event));
getColumn("customObject").setRenderer(cor);
CustomObjectRenderer customObjectRenderer = new CustomObjectRenderer(CustomObject.class);
customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event));
getColumn(customObject).setRenderer(customObjectRenderer);
///////////////////////
// getColumn("custom").setRenderer(new CheckboxRenderer());
// getColumn("buttonText").setRenderer(new
// MyButtonRenderer(event->x()));
}
private void createRolloutStatusToFontMap() {
@@ -356,7 +313,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override
public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign";
}
@@ -365,20 +322,18 @@ public class RolloutListGrid extends AbstractGrid {
});
}
private void onClickOfRolloutName(RendererClickEvent event) {
private void onClickOfRolloutName(final RendererClickEvent event) {
rolloutUIState.setRolloutId((long) event.getItemId());
// final String rolloutName =
CustomObject customObject = (CustomObject) getContainerDataSource().getItem(event.getItemId())
.getItemProperty("customObject").getValue();
rolloutUIState.setRolloutName(customObject.getName());
String ds = (String) getContainerDataSource().getItem(event.getItemId())
final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
rolloutUIState.setRolloutName(rolloutName);
final String ds = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue();
rolloutUIState.setRolloutDistributionSet(ds);
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
}
private void onClickOfActionBtn(RendererClickEvent event) {
private void onClickOfActionBtn(final RendererClickEvent event) {
final ContextMenu contextMenu = createContextMenu((Long) event.getItemId());
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
contextMenu.open(event.getClientX(), event.getClientY());
@@ -426,17 +381,6 @@ public class RolloutListGrid extends AbstractGrid {
cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE));
}
private String convertRolloutStatusToString(final RolloutStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
private void menuItemClicked(final ContextMenuItemClickEvent event) {
final ContextMenuItem item = (ContextMenuItem) event.getSource();
final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
@@ -480,12 +424,12 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = 2544026030795375748L;
private final FontAwesome fontIcon;
public FontIconGenerator(FontAwesome icon) {
public FontIconGenerator(final FontAwesome icon) {
this.fontIcon = icon;
}
@Override
public String getValue(Item item, Object itemId, Object propertyId) {
public String getValue(final Item item, final Object itemId, final Object propertyId) {
return fontIcon.getHtml();
}
@@ -495,12 +439,12 @@ public class RolloutListGrid extends AbstractGrid {
}
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
return SPUILabelDefinitions.ACTION.toLowerCase();
} else if ("customObject".equals(cell.getPropertyId())) {
} else if (customObject.equals(cell.getPropertyId())) {
return ((CustomObject) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper
@@ -597,6 +541,13 @@ public class RolloutListGrid extends AbstractGrid {
public Class<String> getPresentationType() {
return String.class;
}
private String convertRolloutStatusToString(final RolloutStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
}
/**
@@ -609,14 +560,16 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = -5794528427855153924L;
@Override
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@@ -630,7 +583,7 @@ public class RolloutListGrid extends AbstractGrid {
return String.class;
}
}
/**
*
* Converter to convert 0 to empty , if total target groups is zero.

View File

@@ -15,9 +15,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
@@ -29,12 +26,12 @@ import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.CustomObject;
import org.eclipse.hawkbit.ui.customrenderers.renderers.CustomObjectRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -43,13 +40,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.GeneratedPropertyContainer;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
@@ -67,11 +62,7 @@ import com.vaadin.ui.renderers.HtmlRenderer;
public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = 4060904914954370524L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
private static final String customObject = "customObject";
@Autowired
private transient RolloutGroupManagement rolloutGroupManagement;
@@ -87,26 +78,12 @@ public class RolloutGroupListGrid extends AbstractGrid {
private transient Map<RolloutGroupStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutGroupStatus.class);
private final String name = "name";
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
if (RolloutEvent.SHOW_ROLLOUT_GROUPS != event) {
return;
}
getLazyQueryContainer().refresh();
((LazyQueryContainer) getContainerDataSource()).refresh();
}
/**
@@ -126,7 +103,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
}
final RolloutGroup rolloutGroup = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(rolloutGroupChangeEvent.getRolloutGroupId());
final LazyQueryContainer rolloutContainer = getLazyQueryContainer();
final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource();
final Item item = rolloutContainer.getItem(rolloutGroup.getId());
if (item == null) {
return;
@@ -146,15 +123,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
protected Container createContainer() {
final BeanQueryFactory<RolloutGroupBeanQuery> rolloutQf = new BeanQueryFactory<>(RolloutGroupBeanQuery.class);
return new GeneratedPropertyContainer(new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf));
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf);
}
@Override
protected void addContainerProperties() {
final LazyQueryContainer rolloutGroupGridContainer = getLazyQueryContainer();
rolloutGroupGridContainer.addContainerProperty("customObject", CustomObject.class, null, false, false);
final LazyQueryContainer rolloutGroupGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGroupGridContainer.addContainerProperty(customObject, CustomObject.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutGroupStatus.class, null,
false, false);
@@ -179,36 +157,14 @@ public class RolloutGroupListGrid extends AbstractGrid {
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
TotalTargetCountStatus.class, null, false, false);
// addGeneratedProperties();
}
/*
* private void addGeneratedProperties() { GeneratedPropertyContainer
* generatedPropertyContainer = (GeneratedPropertyContainer)
* getContainerDataSource(); //
* generatedPropertyContainer.addGeneratedProperty(SPUILabelDefinitions.
* VAR_NAME, // new PropertyValueGenerator<CustomRollOutDetails>() { //
* private static final long serialVersionUID = -9203261132281441831L; //
* // @Override // public CustomRollOutDetails getValue(Item item, Object
* itemId, Object // propertyId) { // CustomRollOutDetails
* customRollOutDetails = new // CustomRollOutDetails(); //
* customRollOutDetails.setRolloutName( // (String) //
* item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue().toString()
* ); // return customRollOutDetails; // } // // @Override // public
* Class<CustomRollOutDetails> getType() { // return
* CustomRollOutDetails.class; // } // });
*
* }
*/
}
@Override
protected void setColumnExpandRatio() {
/*getColumn(SPUILabelDefinitions.VAR_NAME).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_NAME).setMaximumWidth(200);*/
getColumn("customObject").setMinimumWidth(40);
getColumn("customObject").setMaximumWidth(200);
getColumn(customObject).setMinimumWidth(40);
getColumn(customObject).setMaximumWidth(200);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100);
@@ -231,8 +187,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
protected void setColumnHeaderNames() {
//getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.get("header.name"));
getColumn("customObject").setHeaderCaption(i18n.get("header.name"));
getColumn(customObject).setHeaderCaption(i18n.get("header.name"));
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setHeaderCaption(i18n.get("header.detail.status"));
@@ -257,9 +212,8 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
columnList.add("customObject");
//columnList.add(SPUILabelDefinitions.VAR_NAME);
final List<Object> columnList = new ArrayList<>();
columnList.add(customObject);
columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
@@ -284,27 +238,20 @@ public class RolloutGroupListGrid extends AbstractGrid {
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter());
if (permissionChecker.hasRolloutTargetsReadPermission()) {
/*
* getColumn(SPUILabelDefinitions.VAR_NAME) .setRenderer(new
* LinkRenderer(event -> onClickOfRolloutGroupName(event)));
*/
CustomObjectRenderer cor = new CustomObjectRenderer(CustomObject.class);
cor.addClickListener(event -> onClickOfRolloutGroupName(event));
getColumn("customObject").setRenderer(cor);
getColumn(customObject).setRenderer(new CustomObjectRenderer(event -> onClickOfRolloutGroupName(event)));
}
}
@Override
protected void setHiddenColumns() {
List<Object> columnsToBeHidden = new ArrayList<>();
final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
for (Object propertyId : columnsToBeHidden) {
for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true);
}
}
@@ -314,24 +261,12 @@ public class RolloutGroupListGrid extends AbstractGrid {
return cell -> getDescription(cell);
}
private void onClickOfRolloutGroupName(RendererClickEvent event) {
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
rolloutUIState
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
private void createRolloutGroupStatusToFontMap() {
statusIconMap.put(RolloutGroupStatus.FINISHED,
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
@@ -345,14 +280,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
return SPUILabelDefinitions.ACTION.toLowerCase();
} else if ("customObject".equals(cell.getPropertyId())) {
} else if (customObject.equals(cell.getPropertyId())) {
return ((CustomObject) cell.getProperty().getValue()).getName();
// getNameToolTip(cell.getProperty().getValue().toString());
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
@@ -360,21 +294,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
return null;
}
private String getNameToolTip(final String text) {
String[] nameList = text.split(":");
if (nameList[0].equalsIgnoreCase(name)) {
return nameList[1];
}
return "";
}
private void alignColumns() {
setCellStyleGenerator(new CellStyleGenerator() {
private static final long serialVersionUID = 5573570647129792429L;
@Override
public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign";
@@ -384,10 +310,6 @@ public class RolloutGroupListGrid extends AbstractGrid {
});
}
private LazyQueryContainer getLazyQueryContainer() {
return ((LazyQueryContainer) (((GeneratedPropertyContainer) getContainerDataSource()).getWrappedContainer()));
}
/**
*
* Converts {@link TotalTargetCountStatus} into formatted string with status
@@ -399,14 +321,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = -9205943894818450807L;
@Override
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@@ -452,5 +376,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
return String.class;
}
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
}
}

View File

@@ -14,9 +14,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
@@ -26,7 +23,6 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -35,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -55,29 +50,12 @@ import com.vaadin.spring.annotation.ViewScope;
public class RolloutGroupTargetsListGrid extends AbstractGrid {
private static final long serialVersionUID = -2244756637458984597L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutUIState rolloutUIState;
private transient Map<Status, StatusFontIcon> statusIconMap = new EnumMap<>(Status.class);
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
@@ -158,7 +136,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
@Override
protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>();
final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnList.add(SPUILabelDefinitions.VAR_CREATED_BY);
@@ -218,11 +196,9 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
public String convertToPresentation(final Status status, final Class<? extends String> targetType,
final Locale locale) {
if (status == null) {
// Actions are not created for targets when
// rollout's status
// is READY and when duplicate assignment is done.
// In these cases display a appropriate status with
// description
// Actions are not created for targets when rollout's status is
// READY and when duplicate assignment is done. In these cases
// display a appropriate status with description
return getStatus();
}
return processActionStatus(status);
@@ -238,16 +214,27 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
return String.class;
}
}
private String processActionStatus(final Status status) {
StatusFontIcon statusFontIcon = statusIconMap.get(status);
if (statusFontIcon == null) {
return null;
private String processActionStatus(final Status status) {
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
private String getStatus() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
}
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private void createRolloutStatusToFontMap() {
@@ -271,22 +258,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
}
private String getStatus() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
} else {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private String getDescription(CellReference cell) {
private String getDescription(final CellReference cell) {
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return null;
}
@@ -296,7 +268,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
}
return cell.getProperty().getValue().toString().toLowerCase();
}
private String getDescriptionWhenNoAction() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
@@ -304,7 +275,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return RolloutGroupStatus.READY.toString().toLowerCase();
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
final String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
? rolloutUIState.getRolloutDistributionSet().get() : "";
return i18n.get("message.dist.already.assigned", new Object[] { ds });
}

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AnonymousDownloadAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.GatewaySecurityTokenAuthenticationConfigurationItem;
@@ -30,9 +31,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* View to configure the authentication mode.
*
*
*
*/
@SpringComponent
@ViewScope
@@ -55,12 +53,17 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
@Autowired
private GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem;
@Autowired
private AnonymousDownloadAuthenticationConfigurationItem anonymousDownloadAuthenticationConfigurationItem;
private CheckBox gatewaySecTokenCheckBox;
private CheckBox targetSecTokenCheckBox;
private CheckBox certificateAuthCheckbox;
private CheckBox downloadAnonymousCheckBox;
/**
* Initialize Authentication Configuration layout.
*/
@@ -80,7 +83,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
headerDisSetType.addStyleName("config-panel-header");
vLayout.addComponent(headerDisSetType);
final GridLayout gridLayout = new GridLayout(2, 3);
final GridLayout gridLayout = new GridLayout(2, 4);
gridLayout.setSpacing(true);
gridLayout.setImmediate(true);
gridLayout.setColumnExpandRatio(1, 1.0F);
@@ -108,6 +111,14 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
gridLayout.addComponent(gatewaySecTokenCheckBox, 0, 2);
gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, 2);
downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
downloadAnonymousCheckBox.setId("downloadanonymouscheckbox");
downloadAnonymousCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
downloadAnonymousCheckBox.addValueChangeListener(this);
anonymousDownloadAuthenticationConfigurationItem.addChangeListener(this);
gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3);
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3);
vLayout.addComponent(gridLayout);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
@@ -118,6 +129,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
certificateAuthenticationConfigurationItem.save();
targetSecurityTokenAuthenticationConfigurationItem.save();
gatewaySecurityTokenAuthenticationConfigurationItem.save();
anonymousDownloadAuthenticationConfigurationItem.save();
}
@Override
@@ -125,9 +137,11 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
certificateAuthenticationConfigurationItem.undo();
targetSecurityTokenAuthenticationConfigurationItem.undo();
gatewaySecurityTokenAuthenticationConfigurationItem.undo();
anonymousDownloadAuthenticationConfigurationItem.undo();
certificateAuthCheckbox.setValue(certificateAuthenticationConfigurationItem.isConfigEnabled());
targetSecTokenCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
gatewaySecTokenCheckBox.setValue(gatewaySecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
downloadAnonymousCheckBox.setValue(anonymousDownloadAuthenticationConfigurationItem.isConfigEnabled());
}
@Override
@@ -153,6 +167,8 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
} else if (checkBox == certificateAuthCheckbox) {
configurationItem = certificateAuthenticationConfigurationItem;
} else if (checkBox == downloadAnonymousCheckBox) {
configurationItem = anonymousDownloadAuthenticationConfigurationItem;
} else {
return;
}

View File

@@ -14,8 +14,8 @@ import java.util.List;
import com.vaadin.ui.CustomComponent;
/**
* base class for all configuration views. This class implements the logic for
* the handling of the
* Base class for all configuration views. This class implements the logic for
* the handling of the configurations in a consistent way.
*
*/
public abstract class BaseConfigurationView extends CustomComponent implements ConfigurationGroup {

View File

@@ -11,9 +11,8 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import com.vaadin.ui.Component;
/**
*
*
*
* Interface that all system configurations have to implement to save and undo
* their customized changes.
*/
public interface ConfigurationGroup extends Component, ConfigurationItem {

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.io.Serializable;
/**
* represents an configurationItem, which can be modified by the user
* Represents an configurationItem, which can be modified by the user
*/
public interface ConfigurationItem {

View File

@@ -33,9 +33,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* Default DistributionSet Panel.
*
*
*
*/
@SpringComponent
@ViewScope

View File

@@ -29,8 +29,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* View to configure the polling interval and the overdue time.
*
*
*/
@SpringComponent
@ViewScope

View File

@@ -38,9 +38,6 @@ import com.vaadin.ui.VerticalLayout;
/**
* Main UI for the system configuration view.
*
*
*
*/
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
@ViewScope
@@ -73,7 +70,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
private final List<ConfigurationGroup> configurationViews = new ArrayList<>();
/**
* init method adds all Configuration Views to the list of Views.
* Init method adds all Configuration Views to the list of Views.
*/
@PostConstruct
public void init() {
@@ -154,13 +151,6 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
undoConfigurationBtn.setEnabled(false);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup.
* ConfigurationGroupChangeListener #configurationChanged()
*/
@Override
public void configurationHasChanged() {
saveConfigurationBtn.setEnabled(true);

View File

@@ -21,9 +21,6 @@ import com.vaadin.server.Resource;
/**
* Menu item for system configuration view.
*
*
*
*/
@Component
@Order(700)

View File

@@ -14,7 +14,9 @@ import java.util.List;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.ui.VerticalLayout;
@@ -30,6 +32,9 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
private static final long serialVersionUID = 1L;
@Autowired
private I18N i18n;
private final TenantConfigurationKey configurationKey;
private final transient TenantConfigurationManagement tenantConfigurationManagement;
@@ -53,7 +58,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
*/
protected void init(final String labelText) {
setImmediate(true);
addComponent(SPUIComponentProvider.getLabel(labelText, SPUILabelDefinitions.SP_LABEL_SIMPLE));
addComponent(SPUIComponentProvider.getLabel(i18n.get(labelText), SPUILabelDefinitions.SP_LABEL_SIMPLE));
}
@Override

View File

@@ -0,0 +1,72 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/**
* This class represents the UI item for the anonymous download by in the
* authentication configuration view.
*/
@SpringComponent
@ViewScope
public class AnonymousDownloadAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
private static final long serialVersionUID = 1L;
private boolean configurationEnabled = false;
private boolean configurationEnabledChange = false;
@Autowired
public AnonymousDownloadAuthenticationConfigurationItem(
final TenantConfigurationManagement tenantConfigurationManagement) {
super(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, tenantConfigurationManagement);
}
@PostConstruct
public void init() {
super.init("label.configuration.anonymous.download");
configurationEnabled = isConfigEnabled();
}
@Override
public void configEnable() {
configurationEnabledChange = !configurationEnabled;
configurationEnabled = true;
}
@Override
public void configDisable() {
configurationEnabledChange = configurationEnabled;
configurationEnabled = false;
}
@Override
public void save() {
if (!configurationEnabledChange) {
return;
}
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
}
@Override
public void undo() {
configurationEnabledChange = false;
configurationEnabled = getTenantConfigurationManagement()
.getConfigurationValue(getConfigurationKey(), Boolean.class).getValue();
}
}

View File

@@ -13,7 +13,6 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,21 +25,15 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
*
*
* This class represents the UI item for the certificate authenticated by an
* reverse proxy in the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class CertificateAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
private I18N i18n;
private boolean configurationEnabled = false;
private boolean configurationEnabledChange = false;
private boolean configurationCaRootAuthorityChanged = false;
@@ -59,11 +52,11 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
super.init(i18n.get("label.configuration.auth.header"));
super.init("label.configuration.auth.header");
configurationEnabled = isConfigEnabled();
detailLayout = new VerticalLayout();
@@ -94,12 +87,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {
@@ -110,12 +97,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
setDetailVisible(true);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configDisable()
*/
@Override
public void configDisable() {
if (configurationEnabled) {
@@ -125,11 +106,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
setDetailVisible(false);
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem#save()
*/
@Override
public void save() {
if (configurationEnabledChange) {
@@ -142,11 +118,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
}
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem#undo()
*/
@Override
public void undo() {
configurationEnabledChange = false;

View File

@@ -15,7 +15,6 @@ import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,22 +29,17 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
*
*
* This class represents the UI item for the gateway security token section in
* the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class GatewaySecurityTokenAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
private transient SecurityTokenGenerator securityTokenGenerator;
@Autowired
private I18N i18n;
private TextField gatewayTokenNameTextField;
@@ -70,12 +64,12 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
super.init(i18n.get("label.configuration.auth.gatewaytoken"));
super.init("label.configuration.auth.gatewaytoken");
configurationEnabled = isConfigEnabled();
detailLayout = new VerticalLayout();
@@ -135,12 +129,6 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
notifyConfigurationChanged();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {

View File

@@ -12,29 +12,21 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
/**
*
*
*
* This class represents the UI item for the target security token section in
* the authentication configuration view.
*/
@SpringComponent
@ViewScope
public class TargetSecurityTokenAuthenticationConfigurationItem extends AbstractAuthenticationTenantConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
private I18N i18n;
private boolean configurationEnabled = false;
private boolean configurationEnabledChange = false;
@@ -49,20 +41,14 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
}
/**
* init mehotd called by spring.
* Init mehotd called by spring.
*/
@PostConstruct
public void init() {
super.init(i18n.get("label.configuration.auth.targettoken"));
super.init("label.configuration.auth.targettoken");
configurationEnabled = isConfigEnabled();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configEnable()
*/
@Override
public void configEnable() {
if (!configurationEnabled) {
@@ -71,12 +57,6 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
configurationEnabled = true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# configDisable()
*/
@Override
public void configDisable() {
if (configurationEnabled) {

View File

@@ -14,8 +14,6 @@ import java.util.List;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout;
@@ -50,8 +48,8 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
this.addComponent(durationField, 1, 0);
this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT);
checkBox.addValueChangeListener(event->checkBoxChange());
durationField.addValueChangeListener(event->notifyConfigurationChanged());
checkBox.addValueChangeListener(event -> checkBoxChange());
durationField.addValueChangeListener(event -> notifyConfigurationChanged());
}
private void checkBoxChange() {

View File

@@ -14,29 +14,24 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.management.dstable.DistributionTable;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UserDetails;
@@ -95,8 +90,6 @@ public final class HawkbitCommonUtil {
private static final String COUNT_STYLE = " countStyle = document.createElement('style'); ";
private static final String COUNT_STYLE_ID = " countStyle.id=\"sp-drag-count\"; ";
private static final String APPEND_CHILD = " document.head.appendChild(countStyle);";
private static final String HEADER_VERSION = "header.version";
private static final String HEADER_NAME = "header.name";
private static final String SM_HIGHLIGHT_CREATE_SCRIPT = "smHighlight = document.createElement('style'); smHighlight.id=\"sm-table-highlight\"; document.head.appendChild(smHighlight); ";
private static final String SM_HIGHLIGHT_REMOVE_SCRIPT = "var y = document.getElementById('sm-table-highlight'); if(y) { document.head.removeChild(y); } ";
private static final String SM_HIGHLIGHT_RESET_SCRIPT = SM_HIGHLIGHT_REMOVE_SCRIPT + SM_HIGHLIGHT_CREATE_SCRIPT
@@ -809,7 +802,7 @@ public final class HawkbitCommonUtil {
public static boolean isDuplicate(final String name, final String version, final String type) {
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
swMgmtService.findSoftwareModuleTypeByKey(type));
swMgmtService.findSoftwareModuleTypeByName(type));
boolean duplicate = false;
if (swModule != null) {
duplicate = true;
@@ -868,7 +861,7 @@ public final class HawkbitCommonUtil {
/**
* Display Target Tag action message.
*
* @param targTagName
* @param tagName
* as tag name
* @param result
* as TargetTagAssigmentResult
@@ -878,8 +871,8 @@ public final class HawkbitCommonUtil {
* I18N
* @return message
*/
public static String getTargetTagAssigmentMsg(final String targTagName, final TargetTagAssignmentResult result,
final I18N i18n) {
public static String createAssignmentMessage(final String tagName,
final AssignmentResult<? extends NamedEntity> result, final I18N i18n) {
final StringBuilder formMsg = new StringBuilder();
final int assignedCount = result.getAssigned();
final int alreadyAssignedCount = result.getAlreadyAssigned();
@@ -887,10 +880,10 @@ public final class HawkbitCommonUtil {
if (assignedCount == 1) {
formMsg.append(i18n.get("message.target.assigned.one",
new Object[] { result.getAssignedTargets().get(0).getName(), targTagName })).append("<br>");
new Object[] { result.getAssignedEntity().get(0).getName(), tagName })).append("<br>");
} else if (assignedCount > 1) {
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName }))
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, tagName }))
.append("<br>");
if (alreadyAssignedCount > 0) {
@@ -902,55 +895,10 @@ public final class HawkbitCommonUtil {
if (unassignedCount == 1) {
formMsg.append(i18n.get("message.target.unassigned.one",
new Object[] { result.getUnassignedTargets().get(0).getName(), targTagName })).append("<br>");
new Object[] { result.getUnassignedEntity().get(0).getName(), tagName })).append("<br>");
} else if (unassignedCount > 1) {
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName }))
.append("<br>");
}
return formMsg.toString();
}
/**
* Get message to be displayed after distribution tag assignment.
*
* @param targTagName
* tag name
* @param result
* DistributionSetTagAssigmentResult
* @param tagsClickedList
* list of clicked tags
* @param i18n
* I18N
* @return message
*/
public static String getDistributionTagAssignmentMsg(final String targTagName,
final DistributionSetTagAssignmentResult result, final I18N i18n) {
final StringBuilder formMsg = new StringBuilder();
final int assignedCount = result.getAssigned();
final int alreadyAssignedCount = result.getAlreadyAssigned();
final int unassignedCount = result.getUnassigned();
if (assignedCount == 1) {
formMsg.append(i18n.get("message.target.assigned.one",
new Object[] { result.getAssignedDs().get(0).getName(), targTagName })).append("<br>");
} else if (assignedCount > 1) {
formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName }))
.append("<br>");
if (alreadyAssignedCount > 0) {
final String alreadyAssigned = i18n.get("message.target.alreadyAssigned",
new Object[] { alreadyAssignedCount });
formMsg.append(alreadyAssigned).append("<br>");
}
}
if (unassignedCount == 1) {
formMsg.append(i18n.get("message.target.unassigned.one",
new Object[] { result.getUnassignedDs().get(0).getName(), targTagName })).append("<br>");
} else if (unassignedCount > 1) {
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName }))
formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, tagName }))
.append("<br>");
}
return formMsg.toString();
@@ -1004,43 +952,6 @@ public final class HawkbitCommonUtil {
lqc.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
}
/**
* Get visible columns in table.
*
* @param isMaximized
* true if table is maximized
* @param isShowPinColumn
* if true pin column will be displayed.
* @param i18n
* I18N
* @return List<TableColumn> list of columns to be displayed.
*/
public static List<TableColumn> getTableVisibleColumns(final Boolean isMaximized, final Boolean isShowPinColumn,
final I18N i18n) {
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));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f));
} else if (isShowPinColumn) {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.7f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get(HEADER_VERSION), 0.2f));
columnList.add(new TableColumn(SPUILabelDefinitions.PIN_COLUMN, SP_STRING_EMPTY, 0.1f));
} else {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.8f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get(HEADER_VERSION), 0.2f));
}
return columnList;
}
/**
* Reset the software module table rows highlight css.
*
@@ -1147,36 +1058,6 @@ public final class HawkbitCommonUtil {
return DELETE_TAG_DROP_REMOVE_SCRIPT;
}
/**
* Get the details of selected rows of {@link TargetTable}.
*
* @param sourceTable
* @return set of {@link TargetIdName}
*/
public static Set<TargetIdName> getSelectedTargetDetails(final Table sourceTable) {
Set<TargetIdName> targetSelected = null;
if (sourceTable.getValue() != null) {
targetSelected = new LinkedHashSet<>((Set) sourceTable.getValue());
targetSelected.remove(null);
}
return targetSelected;
}
/**
* Get the details of selected rows of {@link DistributionTable}.
*
* @param sourceTable
* @return set of {@link DistributionSetIdName}
*/
public static Set<DistributionSetIdName> getSelectedDSDetails(final Table sourceTable) {
Set<DistributionSetIdName> distSelected = null;
if (sourceTable.getValue() != null) {
distSelected = new LinkedHashSet<>((Set) sourceTable.getValue());
distSelected.remove(null);
}
return distSelected;
}
/**
*
* Add target table container properties.
@@ -1397,4 +1278,19 @@ public final class HawkbitCommonUtil {
return val.toString();
}
/**
* Receive the code point of a given StatusFontIcon.
*
* @param statusFontIcon
* the status font icon
* @return the code point of the StatusFontIcon
*/
public static String getCodePoint(final StatusFontIcon statusFontIcon) {
if (statusFontIcon == null) {
return null;
}
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
: null;
}
}

View File

@@ -501,6 +501,11 @@ public final class SPUIComponetIdProvider {
*/
public static final String SYSTEM_CONFIGURATION_CANCEL = "system.configuration.cancel";
/**
* Id of the anonymous download checkbox.
*/
public static final String SYSTEM_CONFIGURATION_ANONYMOUS_DOWNLOAD_CHECKBOX = "system.configuration.anonymous.download.checkbox";
/**
* Id of maximize/minimize icon of table - Software module table.
*/
@@ -827,7 +832,7 @@ public final class SPUIComponetIdProvider {
* Rollout status label id.
*/
public static final String ROLLOUT_STATUS_LABEL_ID = "rollout.status.id";
/**
* Rollout group status label id.
*/
@@ -867,12 +872,12 @@ public final class SPUIComponetIdProvider {
* Rollout group targets count message label.
*/
public static final String ROLLOUT_GROUP_TARGET_LABEL = "rollout.group.target.label";
/**
* Action confirmation popup id.
*/
public static final String CONFIRMATION_POPUP_ID = "action.confirmation.popup.id";
/**
* Validation status icon .
*/

View File

@@ -161,6 +161,7 @@ label.tag.name = Tag name
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy
label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token
label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token
label.configuration.anonymous.download = Allow targets to download artifacts without security credentials
label.unsupported.browser.ie=Sorry! current browser is not supported. Please use Internet Explorer 11 and above
# Checkbox label prefix with - checkbox

View File

@@ -159,6 +159,7 @@ label.tag.name = Tag name
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy
label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token
label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token
label.configuration.anonymous.download = Allow targets to download artifacts without security credentials
label.unsupported.browser.ie=Sorry! current browser is not supported. Please use Internet Explorer 11 and above
# Checkbox label prefix with - checkbox
@@ -389,6 +390,7 @@ configuration.defaultdistributionset.select.label=Wahl des default Distribution
configuration.savebutton.tooltip=Konfigurationen speichern
configuration.cancellbutton.tooltip=Konfigurationen zur<75>cksetzen
configuration.authentication.title=Authentifikationseinstellungen
#Calendar
calendar.year=Jahr
calendar.years=Jahre

View File

@@ -160,6 +160,7 @@ label.tag.name = Tag name
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy
label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token
label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token
label.configuration.anonymous.download = Allow targets to download artifacts without security credentials
label.unsupported.browser.ie=Sorry! current browser is not supported. Please use Internet Explorer 11 and above
# Checkbox label prefix with - checkbox