Add new abstract table to reduce the visible columns and add entity code
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
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.SPUIComponetIdProvider;
|
||||
@@ -48,7 +48,7 @@ import com.vaadin.ui.UI;
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class SoftwareModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
|
||||
|
||||
private static final long serialVersionUID = 6469417305487144809L;
|
||||
|
||||
@@ -165,7 +165,7 @@ public class SoftwareModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(),
|
||||
baseEntity.getVersion());
|
||||
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
|
||||
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
|
||||
artifactUploadState.getSelectedSoftwareModules().stream().forEach(this::unselect);
|
||||
@@ -178,12 +178,10 @@ public class SoftwareModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
||||
if (isMaximized()) {
|
||||
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));
|
||||
} else {
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F));
|
||||
if (!isMaximized()) {
|
||||
return columnList;
|
||||
}
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F));
|
||||
return columnList;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -293,7 +293,8 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
final List<TableColumn> columnList = new ArrayList<>();
|
||||
if (!isMaximized()) {
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F));
|
||||
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));
|
||||
@@ -306,6 +307,10 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
||||
return columnList;
|
||||
}
|
||||
|
||||
protected float getColumnNameMinimizedSize() {
|
||||
return 0.8F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get drop handler for the table.
|
||||
*
|
||||
|
||||
@@ -28,7 +28,7 @@ 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;
|
||||
@@ -70,7 +70,7 @@ import com.vaadin.ui.UI;
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class DistributionSetTable extends AbstractTable<DistributionSet, DistributionSetIdName> {
|
||||
public class DistributionSetTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
|
||||
|
||||
private static final long serialVersionUID = -7731776093470487988L;
|
||||
|
||||
@@ -475,11 +475,10 @@ public class DistributionSetTable extends AbstractTable<DistributionSet, Distrib
|
||||
protected Item addEntity(final DistributionSet baseEntity) {
|
||||
final Item item = super.addEntity(baseEntity);
|
||||
item.getItemProperty(SPUILabelDefinitions.DIST_ID).setValue(baseEntity.getId());
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(baseEntity.isComplete());
|
||||
|
||||
if (manageDistUIState.getSelectedDistributions().isPresent()) {
|
||||
manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
|
||||
manageDistUIState.getSelectedDistributions().get().stream().forEach(this::unselect);
|
||||
}
|
||||
select(baseEntity.getDistributionSetIdName());
|
||||
return item;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.distributions.smtable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -20,7 +19,7 @@ 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.common.ManagmentEntityState;
|
||||
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.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
@@ -63,7 +62,7 @@ import com.vaadin.ui.Window;
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class SwModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
|
||||
|
||||
private static final long serialVersionUID = 6785314784507424750L;
|
||||
|
||||
@@ -228,19 +227,20 @@ public class SwModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
final List<TableColumn> columnList = new ArrayList<>();
|
||||
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
||||
if (isMaximized()) {
|
||||
columnList.addAll(super.getTableVisibleColumns());
|
||||
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));
|
||||
} 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() {
|
||||
@@ -332,12 +332,11 @@ public class SwModuleTable extends AbstractTable<SoftwareModule, Long> {
|
||||
baseEntity.getVersion());
|
||||
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion);
|
||||
item.getItemProperty("swId").setValue(baseEntity.getId());
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor());
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour());
|
||||
|
||||
if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
|
||||
manageDistUIState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
|
||||
manageDistUIState.getSelectedSoftwareModules().stream().forEach(this::unselect);
|
||||
}
|
||||
select(baseEntity.getId());
|
||||
return item;
|
||||
|
||||
@@ -25,7 +25,7 @@ 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;
|
||||
@@ -70,7 +70,7 @@ import com.vaadin.ui.UI;
|
||||
*/
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class DistributionTable extends AbstractTable<DistributionSet, DistributionSetIdName> {
|
||||
public class DistributionTable extends AbstractNamedVersionTable<DistributionSet, DistributionSetIdName> {
|
||||
|
||||
private static final long serialVersionUID = -1928335256399519494L;
|
||||
|
||||
@@ -272,18 +272,19 @@ public class DistributionTable extends AbstractTable<DistributionSet, Distributi
|
||||
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
final List<TableColumn> columnList = new ArrayList<>();
|
||||
final List<TableColumn> columnList = super.getTableVisibleColumns();
|
||||
if (isMaximized()) {
|
||||
columnList.addAll(super.getTableVisibleColumns());
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 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.PIN_COLUMN, StringUtils.EMPTY, 0.1f));
|
||||
return columnList;
|
||||
}
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.PIN_COLUMN, StringUtils.EMPTY, 0.1f));
|
||||
return columnList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getColumnNameMinimizedSize() {
|
||||
return 0.7F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DropHandler getTableDropHandler() {
|
||||
return new DropHandler() {
|
||||
@@ -478,13 +479,6 @@ public class DistributionTable extends AbstractTable<DistributionSet, Distributi
|
||||
final Item item = getContainerDataSource()
|
||||
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
|
||||
updateEntity(editedDs, item);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEntity(final DistributionSet baseEntity, final Item item) {
|
||||
super.updateEntity(baseEntity, item);
|
||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||
}
|
||||
|
||||
private void restoreDistributionTableStyle() {
|
||||
|
||||
Reference in New Issue
Block a user