use constants for html tags used often

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-04-28 16:20:13 +02:00
parent d8d026e9a1
commit f203e31d00
4 changed files with 72 additions and 52 deletions

View File

@@ -8,6 +8,11 @@
*/ */
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -263,7 +268,7 @@ public class CreateOrUpdateFilterTable extends Table {
private static final long serialVersionUID = 688730421728162456L; private static final long serialVersionUID = 688730421728162456L;
@Override @Override
public String generateDescription(Component source, Object itemId, Object propertyId) { public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
final DistributionSet distributionSet; final DistributionSet distributionSet;
final Item item = getItem(itemId); final Item item = getItem(itemId);
if (propertyId != null) { if (propertyId != null) {
@@ -279,35 +284,35 @@ public class CreateOrUpdateFilterTable extends Table {
} }
private String getDSDetails(final DistributionSet distributionSet) { private String getDSDetails(final DistributionSet distributionSet) {
StringBuilder swModuleNames = new StringBuilder(); final StringBuilder swModuleNames = new StringBuilder();
StringBuilder swModuleVendors = new StringBuilder(); final StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>) distributionSet.getModules(); final Set<SoftwareModule> swModules = distributionSet.getModules();
swModules.forEach(swModule -> { swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName()); swModuleNames.append(swModule.getName());
swModuleNames.append(" , "); swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , "); swModuleVendors.append(" , ");
}); });
StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<ul>"); stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" Required Migration step : ") stringBuilder.append(" Required Migration step : ")
.append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No");
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("</ul>"); stringBuilder.append(HTML_UL_CLOSE_TAG);
return stringBuilder.toString(); return stringBuilder.toString();
} }

View File

@@ -8,6 +8,11 @@
*/ */
package org.eclipse.hawkbit.ui.management.targettable; package org.eclipse.hawkbit.ui.management.targettable;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -1089,7 +1094,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
private static final long serialVersionUID = 688730421728162456L; private static final long serialVersionUID = 688730421728162456L;
@Override @Override
public String generateDescription(Component source, Object itemId, Object propertyId) { public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
final DistributionSet distributionSet; final DistributionSet distributionSet;
final Item item = getItem(itemId); final Item item = getItem(itemId);
if (propertyId != null) { if (propertyId != null) {
@@ -1105,34 +1110,34 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
} }
private String getDSDetails(final DistributionSet distributionSet) { private String getDSDetails(final DistributionSet distributionSet) {
StringBuilder swModuleNames = new StringBuilder(); final StringBuilder swModuleNames = new StringBuilder();
StringBuilder swModuleVendors = new StringBuilder(); final StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>) distributionSet.getModules(); final Set<SoftwareModule> swModules = distributionSet.getModules();
swModules.forEach(swModule -> { swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName()); swModuleNames.append(swModule.getName());
swModuleNames.append(" , "); swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , "); swModuleVendors.append(" , ");
}); });
StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<ul>"); stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" Required Migration step : ") stringBuilder.append(" Required Migration step : ")
.append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No");
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("</ul>"); stringBuilder.append(HTML_UL_CLOSE_TAG);
return stringBuilder.toString(); return stringBuilder.toString();
} }
} }

View File

@@ -8,6 +8,11 @@
*/ */
package org.eclipse.hawkbit.ui.rollout.rollout; package org.eclipse.hawkbit.ui.rollout.rollout;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumMap; import java.util.EnumMap;
@@ -477,14 +482,14 @@ public class RolloutListGrid extends AbstractGrid {
return DistributionBarHelper return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
return getDSDetails((Item) cell.getItem()); return getDSDetails(cell.getItem());
} }
return null; return null;
} }
private String getDSDetails(final Item rolloutItem) { private String getDSDetails(final Item rolloutItem) {
StringBuilder swModuleNames = new StringBuilder(); final StringBuilder swModuleNames = new StringBuilder();
StringBuilder swModuleVendors = new StringBuilder(); final StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>) rolloutItem.getItemProperty(SW_MODULES).getValue(); final Set<SoftwareModule> swModules = (Set<SoftwareModule>) rolloutItem.getItemProperty(SW_MODULES).getValue();
swModules.forEach(swModule -> { swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName()); swModuleNames.append(swModule.getName());
@@ -492,30 +497,30 @@ public class RolloutListGrid extends AbstractGrid {
swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , "); swModuleVendors.append(" , ");
}); });
StringBuilder stringBuilder = new StringBuilder(); final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<ul>"); stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ") stringBuilder.append(" DistributionSet Description : ")
.append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue()); .append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ") stringBuilder.append(" DistributionSet Type : ")
.append((String) rolloutItem.getItemProperty(DS_TYPE).getValue()); .append((String) rolloutItem.getItemProperty(DS_TYPE).getValue());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Required Migration step : ") stringBuilder.append("Required Migration step : ")
.append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No"); .append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No");
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("<li>"); stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append("</li>"); stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append("</ul>"); stringBuilder.append(HTML_UL_CLOSE_TAG);
return stringBuilder.toString(); return stringBuilder.toString();
} }

View File

@@ -73,6 +73,11 @@ public final class HawkbitCommonUtil {
*/ */
public static final String SPAN_CLOSE = "</span>"; public static final String SPAN_CLOSE = "</span>";
public static final String HTML_LI_CLOSE_TAG = "</li>";
public static final String HTML_LI_OPEN_TAG = "<li>";
public static final String HTML_UL_CLOSE_TAG = "</ul>";
public static final String HTML_UL_OPEN_TAG = "<ul>";
private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class); private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class);
private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } "; private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } ";