Merge branch 'master' into
fix_dialog_window_must_not_close_after_save_if_duplicate_exists Conflicts: hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
@@ -8,9 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.simulator;
|
package org.eclipse.hawkbit.simulator;
|
||||||
|
|
||||||
|
import static java.util.concurrent.Executors.newScheduledThreadPool;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.security.DigestOutputStream;
|
import java.security.DigestOutputStream;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
@@ -20,7 +23,6 @@ import java.security.SecureRandom;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -56,9 +58,10 @@ import com.google.common.io.ByteStreams;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceSimulatorUpdater {
|
public class DeviceSimulatorUpdater {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceSimulatorUpdater.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceSimulatorUpdater.class);
|
||||||
|
|
||||||
private static final ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(8);
|
private static final ScheduledExecutorService threadPool = newScheduledThreadPool(8);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpSenderService spSenderService;
|
private SpSenderService spSenderService;
|
||||||
@@ -118,14 +121,9 @@ public class DeviceSimulatorUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class DeviceSimulatorUpdateThread implements Runnable {
|
private static final class DeviceSimulatorUpdateThread implements Runnable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final String BUT_GOT_LOG_MESSAGE = " but got: ";
|
private static final String BUT_GOT_LOG_MESSAGE = " but got: ";
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final String DOWNLOAD_LOG_MESSAGE = "Download ";
|
private static final String DOWNLOAD_LOG_MESSAGE = "Download ";
|
||||||
|
|
||||||
private static final int MINIMUM_TOKENLENGTH_FOR_HINT = 6;
|
private static final int MINIMUM_TOKENLENGTH_FOR_HINT = 6;
|
||||||
@@ -279,13 +277,17 @@ public class DeviceSimulatorUpdater {
|
|||||||
|
|
||||||
private static long getOverallRead(final CloseableHttpResponse response, final MessageDigest md)
|
private static long getOverallRead(final CloseableHttpResponse response, final MessageDigest md)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
long overallread;
|
long overallread;
|
||||||
try (final BufferedOutputStream bdos = new BufferedOutputStream(
|
|
||||||
new DigestOutputStream(ByteStreams.nullOutputStream(), md))) {
|
try (final OutputStream os = ByteStreams.nullOutputStream();
|
||||||
|
final BufferedOutputStream bos = new BufferedOutputStream(new DigestOutputStream(os, md))) {
|
||||||
|
|
||||||
try (BufferedInputStream bis = new BufferedInputStream(response.getEntity().getContent())) {
|
try (BufferedInputStream bis = new BufferedInputStream(response.getEntity().getContent())) {
|
||||||
overallread = ByteStreams.copy(bis, bdos);
|
overallread = ByteStreams.copy(bis, bos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return overallread;
|
return overallread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ import java.util.Map;
|
|||||||
* An interface for declaring the name of the field described in the database
|
* An interface for declaring the name of the field described in the database
|
||||||
* which is used as string representation of the field, e.g. for sorting the
|
* which is used as string representation of the field, e.g. for sorting the
|
||||||
* fields over REST.
|
* fields over REST.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface FieldNameProvider {
|
public interface FieldNameProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separator for the sub attributes
|
* Separator for the sub attributes
|
||||||
*/
|
*/
|
||||||
@@ -38,11 +39,25 @@ public interface FieldNameProvider {
|
|||||||
* @return <true> contains <false> contains not
|
* @return <true> contains <false> contains not
|
||||||
*/
|
*/
|
||||||
default boolean containsSubEntityAttribute(final String propertyField) {
|
default boolean containsSubEntityAttribute(final String propertyField) {
|
||||||
return FieldNameProvider.containsSubEntityAttribute(propertyField, getSubEntityAttributes());
|
|
||||||
|
final List<String> subEntityAttributes = getSubEntityAttributes();
|
||||||
|
if (subEntityAttributes.contains(propertyField)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (final String attribute : subEntityAttributes) {
|
||||||
|
final String[] graph = attribute.split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||||
|
|
||||||
|
for (final String subAttribute : graph) {
|
||||||
|
if (subAttribute.equalsIgnoreCase(propertyField)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return all sub entities attributes.
|
* @return all sub entities attributes.
|
||||||
*/
|
*/
|
||||||
default List<String> getSubEntityAttributes() {
|
default List<String> getSubEntityAttributes() {
|
||||||
@@ -50,7 +65,7 @@ public interface FieldNameProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the database column for the key
|
* The database column for the key
|
||||||
*
|
*
|
||||||
* @return key fieldname
|
* @return key fieldname
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +74,7 @@ public interface FieldNameProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the database column for the value
|
* The database column for the value
|
||||||
*
|
*
|
||||||
* @return key fieldname
|
* @return key fieldname
|
||||||
*/
|
*/
|
||||||
@@ -75,31 +90,4 @@ public interface FieldNameProvider {
|
|||||||
default boolean isMap() {
|
default boolean isMap() {
|
||||||
return getKeyFieldName() != null;
|
return getKeyFieldName() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a sub attribute exists.
|
|
||||||
*
|
|
||||||
* @param propertyField
|
|
||||||
* the sub property field.
|
|
||||||
* @param subEntityAttribues
|
|
||||||
* the list of available properties
|
|
||||||
* @return <true> property exists <false> not exists
|
|
||||||
*/
|
|
||||||
static boolean containsSubEntityAttribute(final String propertyField, final List<String> subEntityAttribues) {
|
|
||||||
if (subEntityAttribues.contains(propertyField)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (final String attribute : subEntityAttribues) {
|
|
||||||
final String[] graph = attribute.split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
|
||||||
|
|
||||||
for (final String subAttribute : graph) {
|
|
||||||
if (subAttribute.equalsIgnoreCase(propertyField)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Map} with attributes of SP Target.
|
* {@link Map} with attributes of SP Target.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MgmtTargetAttributes extends HashMap<String, String> {
|
public class MgmtTargetAttributes extends HashMap<String, String> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
|||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.eclipse.hawkbit.util.IpUtil;
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
@@ -80,7 +78,6 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
|||||||
|
|
||||||
private static final String TARGET_DESCRIPTION_TEST = "created in test";
|
private static final String TARGET_DESCRIPTION_TEST = "created in test";
|
||||||
|
|
||||||
// json paths
|
|
||||||
private static final String JSON_PATH_ROOT = "$";
|
private static final String JSON_PATH_ROOT = "$";
|
||||||
|
|
||||||
// fields, attributes
|
// fields, attributes
|
||||||
@@ -633,69 +630,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
|||||||
final String knownName = "someName";
|
final String knownName = "someName";
|
||||||
createSingleTarget(knownControllerId, knownName);
|
createSingleTarget(knownControllerId, knownName);
|
||||||
|
|
||||||
// test
|
|
||||||
|
|
||||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS"))
|
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS"))
|
||||||
.andExpect(status().isNoContent()).andExpect(content().string(""));
|
.andExpect(status().isNoContent()).andExpect(content().string(""));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getInstalledDistributionSetOfTarget() throws JSONException, Exception {
|
|
||||||
// create first a target which can be retrieved by rest interface
|
|
||||||
final String knownControllerId = "1";
|
|
||||||
final String knownName = "someName";
|
|
||||||
createSingleTarget(knownControllerId, knownName);
|
|
||||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
|
||||||
// assign ds to target
|
|
||||||
final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId).getActions()
|
|
||||||
.get(0);
|
|
||||||
// give feedback, so installedDS is in SNYC
|
|
||||||
feedbackToByInSync(actionId);
|
|
||||||
// test
|
|
||||||
|
|
||||||
final SoftwareModule os = ds.findFirstModuleByType(osType);
|
|
||||||
final SoftwareModule jvm = ds.findFirstModuleByType(runtimeType);
|
|
||||||
final SoftwareModule bApp = ds.findFirstModuleByType(appType);
|
|
||||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS"))
|
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
|
||||||
.andExpect(jsonPath(JSON_PATH_ID, equalTo(ds.getId().intValue())))
|
|
||||||
.andExpect(jsonPath(JSON_PATH_NAME, equalTo(ds.getName())))
|
|
||||||
.andExpect(jsonPath(JSON_PATH_DESCRIPTION, equalTo(ds.getDescription())))
|
|
||||||
// os
|
|
||||||
.andExpect(
|
|
||||||
jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(os.getId().intValue())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].name", equalTo(os.getName())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].description",
|
|
||||||
equalTo(os.getDescription())))
|
|
||||||
.andExpect(
|
|
||||||
jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].version", equalTo(os.getVersion())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].vendor", equalTo(os.getVendor())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].type", equalTo("os")))
|
|
||||||
// jvm
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].id",
|
|
||||||
equalTo(jvm.getId().intValue())))
|
|
||||||
.andExpect(
|
|
||||||
jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].name", equalTo(jvm.getName())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].description",
|
|
||||||
equalTo(jvm.getDescription())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].version",
|
|
||||||
equalTo(jvm.getVersion())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].vendor",
|
|
||||||
equalTo(jvm.getVendor())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].type", equalTo("runtime")))
|
|
||||||
// baseApp
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].id",
|
|
||||||
equalTo(bApp.getId().intValue())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].name", equalTo(bApp.getName())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].description",
|
|
||||||
equalTo(bApp.getDescription())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].version",
|
|
||||||
equalTo(bApp.getVersion())))
|
|
||||||
.andExpect(
|
|
||||||
jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].vendor", equalTo(bApp.getVendor())))
|
|
||||||
.andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].type", equalTo("application")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
|||||||
public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extends AbstractBaseEntityEvent<E> {
|
public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extends AbstractBaseEntityEvent<E> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3671601415138242311L;
|
private static final long serialVersionUID = -3671601415138242311L;
|
||||||
private final transient Map<String, Values> changeSet;
|
private final transient Map<String, PropertyChange> changeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize base entity and property changed with old and new value.
|
* Initialize base entity and property changed with old and new value.
|
||||||
@@ -31,7 +31,7 @@ public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extend
|
|||||||
* details of properties changed and old value and new value of
|
* details of properties changed and old value and new value of
|
||||||
* the changed properties
|
* the changed properties
|
||||||
*/
|
*/
|
||||||
public AbstractPropertyChangeEvent(final E baseEntity, final Map<String, Values> changeSetValues) {
|
public AbstractPropertyChangeEvent(final E baseEntity, final Map<String, PropertyChange> changeSetValues) {
|
||||||
super(baseEntity);
|
super(baseEntity);
|
||||||
this.changeSet = changeSetValues;
|
this.changeSet = changeSetValues;
|
||||||
}
|
}
|
||||||
@@ -39,15 +39,15 @@ public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extend
|
|||||||
/**
|
/**
|
||||||
* @return the changeSet
|
* @return the changeSet
|
||||||
*/
|
*/
|
||||||
public Map<String, Values> getChangeSet() {
|
public Map<String, PropertyChange> getChangeSet() {
|
||||||
return changeSet;
|
return changeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Carries old value and new value of a property .
|
* Carries old value and new value of a property .
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Values {
|
public static class PropertyChange {
|
||||||
|
|
||||||
private final Object oldValue;
|
private final Object oldValue;
|
||||||
private final Object newValue;
|
private final Object newValue;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extend
|
|||||||
* @param newValue
|
* @param newValue
|
||||||
* new value after change
|
* new value after change
|
||||||
*/
|
*/
|
||||||
public Values(final Object oldValue, final Object newValue) {
|
public PropertyChange(final Object oldValue, final Object newValue) {
|
||||||
super();
|
super();
|
||||||
this.oldValue = oldValue;
|
this.oldValue = oldValue;
|
||||||
this.newValue = newValue;
|
this.newValue = newValue;
|
||||||
@@ -78,6 +78,5 @@ public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extend
|
|||||||
public Object getNewValue() {
|
public Object getNewValue() {
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ public class ActionPropertyChangeEvent extends AbstractPropertyChangeEvent<Actio
|
|||||||
* @param action
|
* @param action
|
||||||
* @param changeSetValues
|
* @param changeSetValues
|
||||||
*/
|
*/
|
||||||
public ActionPropertyChangeEvent(final Action action,
|
public ActionPropertyChangeEvent(final Action action, final Map<String, PropertyChange> changeSetValues) {
|
||||||
final Map<String, AbstractPropertyChangeEvent<Action>.Values> changeSetValues) {
|
|
||||||
super(action, changeSetValues);
|
super(action, changeSetValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class RolloutGroupPropertyChangeEvent extends AbstractPropertyChangeEvent
|
|||||||
* @param changeSetValues
|
* @param changeSetValues
|
||||||
*/
|
*/
|
||||||
public RolloutGroupPropertyChangeEvent(final RolloutGroup rolloutGroup,
|
public RolloutGroupPropertyChangeEvent(final RolloutGroup rolloutGroup,
|
||||||
final Map<String, AbstractPropertyChangeEvent<RolloutGroup>.Values> changeSetValues) {
|
final Map<String, PropertyChange> changeSetValues) {
|
||||||
super(rolloutGroup, changeSetValues);
|
super(rolloutGroup, changeSetValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ public class RolloutPropertyChangeEvent extends AbstractPropertyChangeEvent<Roll
|
|||||||
* @param rollout
|
* @param rollout
|
||||||
* @param changeSetValues
|
* @param changeSetValues
|
||||||
*/
|
*/
|
||||||
public RolloutPropertyChangeEvent(final Rollout rollout,
|
public RolloutPropertyChangeEvent(final Rollout rollout, final Map<String, PropertyChange> changeSetValues) {
|
||||||
final Map<String, AbstractPropertyChangeEvent<Rollout>.Values> changeSetValues) {
|
|
||||||
super(rollout, changeSetValues);
|
super(rollout, changeSetValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,16 +12,9 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract report series.
|
* An abstract report series.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AbstractReportSeries implements Serializable {
|
public class AbstractReportSeries implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|||||||
@@ -14,13 +14,11 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple list report series which just contains a list of values of a report.
|
* A simple list report series which just contains a list of values of a report.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ListReportSeries extends AbstractReportSeries {
|
public class ListReportSeries extends AbstractReportSeries {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final List<Number> data = new ArrayList<>();
|
private final List<Number> data = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,8 +48,8 @@ public class ListReportSeries extends AbstractReportSeries {
|
|||||||
* @param values
|
* @param values
|
||||||
*/
|
*/
|
||||||
private void setData(final Number... values) {
|
private void setData(final Number... values) {
|
||||||
this.data.clear();
|
data.clear();
|
||||||
Collections.addAll(this.data, values);
|
Collections.addAll(data, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -599,11 +598,16 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Action> findActionsByTarget(final String rsqlParam, final Target target, final Pageable pageable) {
|
public Page<Action> findActionsByTarget(final String rsqlParam, final Target target, final Pageable pageable) {
|
||||||
final Specification<JpaAction> specification = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
|
||||||
|
|
||||||
return convertAcPage(actionRepository.findAll((Specification<JpaAction>) (root, query, cb) -> cb
|
final Specification<JpaAction> byTargetSpec = createSpecificationFor(target, rsqlParam);
|
||||||
.and(specification.toPredicate(root, query, cb), cb.equal(root.get(JpaAction_.target), target)),
|
final Page<JpaAction> actions = actionRepository.findAll(byTargetSpec, pageable);
|
||||||
pageable), pageable);
|
return convertAcPage(actions, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Specification<JpaAction> createSpecificationFor(final Target target, final String rsqlParam) {
|
||||||
|
final Specification<JpaAction> spec = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
||||||
|
return (root, query, cb) -> cb.and(spec.toPredicate(root, query, cb),
|
||||||
|
cb.equal(root.get(JpaAction_.target), target));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Page<Action> convertAcPage(final Page<JpaAction> findAll, final Pageable pageable) {
|
private static Page<Action> convertAcPage(final Page<JpaAction> findAll, final Pageable pageable) {
|
||||||
@@ -642,10 +646,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countActionsByTarget(final String rsqlParam, final Target target) {
|
public Long countActionsByTarget(final String rsqlParam, final Target target) {
|
||||||
final Specification<JpaAction> spec = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
return actionRepository.count(createSpecificationFor(target, rsqlParam));
|
||||||
|
|
||||||
return actionRepository.count((root, query, cb) -> cb.and(spec.toPredicate(root, query, cb),
|
|
||||||
cb.equal(root.get(JpaAction_.target), target)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
findOne(metadata.getDistributionSet(), metadata.getKey());
|
findOne(metadata.getDistributionSet(), metadata.getKey());
|
||||||
// touch it to update the lock revision because we are modifying the
|
// touch it to update the lock revision because we are modifying the
|
||||||
// DS indirectly
|
// DS indirectly
|
||||||
touch(metadata.getDistributionSet());;
|
touch(metadata.getDistributionSet());
|
||||||
return distributionSetMetadataRepository.save(metadata);
|
return distributionSetMetadataRepository.save(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,8 +528,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to get the latest distribution set based on ds ID after the metadata changes for that distribution set.
|
* Method to get the latest distribution set based on ds ID after the
|
||||||
* @param distributionSet Distribution set
|
* metadata changes for that distribution set.
|
||||||
|
*
|
||||||
|
* @param distributionSet
|
||||||
|
* Distribution set
|
||||||
*/
|
*/
|
||||||
private void touch(final DistributionSet distributionSet) {
|
private void touch(final DistributionSet distributionSet) {
|
||||||
final DistributionSet latestDistributionSet = findDistributionSetById(distributionSet.getId());
|
final DistributionSet latestDistributionSet = findDistributionSetById(distributionSet.getId());
|
||||||
@@ -552,7 +555,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId) {
|
public List<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId) {
|
||||||
return new ArrayList<DistributionSetMetadata>(distributionSetMetadataRepository
|
return new ArrayList<>(distributionSetMetadataRepository
|
||||||
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
||||||
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
||||||
distributionSetId)));
|
distributionSetId)));
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
/**
|
/**
|
||||||
* Get count of targets in different status in rollout.
|
* Get count of targets in different status in rollout.
|
||||||
*
|
*
|
||||||
* @param page
|
* @param pageable
|
||||||
* the page request to sort and limit the result
|
* the page request to sort and limit the result
|
||||||
* @return a list of rollouts with details of targets count for different
|
* @return a list of rollouts with details of targets count for different
|
||||||
* statuses
|
* statuses
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.domain.Specifications;
|
import org.springframework.data.jpa.domain.Specifications;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.springframework.transaction.TransactionSystemException;
|
|||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
public class ExceptionMappingAspectHandler implements Ordered {
|
public class ExceptionMappingAspectHandler implements Ordered {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ExceptionMappingAspectHandler.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ExceptionMappingAspectHandler.class);
|
||||||
|
|
||||||
private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>();
|
private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>();
|
||||||
@@ -63,6 +64,7 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
private final SQLStateSQLExceptionTranslator sqlStateExceptionTranslator = new SQLStateSQLExceptionTranslator();
|
private final SQLStateSQLExceptionTranslator sqlStateExceptionTranslator = new SQLStateSQLExceptionTranslator();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class);
|
MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class);
|
||||||
MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class);
|
MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class);
|
||||||
MAPPED_EXCEPTION_ORDER.add(ConcurrencyFailureException.class);
|
MAPPED_EXCEPTION_ORDER.add(ConcurrencyFailureException.class);
|
||||||
@@ -90,9 +92,11 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
+ " || execution( * org.eclipse.hawkbit.controller.*.*(..)) "
|
+ " || execution( * org.eclipse.hawkbit.controller.*.*(..)) "
|
||||||
+ " || execution( * org.eclipse.hawkbit.rest.resource.*.*(..)) "
|
+ " || execution( * org.eclipse.hawkbit.rest.resource.*.*(..)) "
|
||||||
+ " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex")
|
+ " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex")
|
||||||
// Exception squid:S00112 - Is aspectJ proxy
|
// Exception for squid:S00112, squid:S1162
|
||||||
@SuppressWarnings({ "squid:S00112" })
|
// It is a AspectJ proxy which deals with exceptions.
|
||||||
|
@SuppressWarnings({ "squid:S00112", "squid:S1162" })
|
||||||
public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {
|
public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {
|
||||||
|
|
||||||
LOG.trace("exception occured", ex);
|
LOG.trace("exception occured", ex);
|
||||||
Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex);
|
Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex);
|
||||||
|
|
||||||
@@ -122,6 +126,7 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.trace("mapped exception {} to {}", translatedAccessException.getClass(), mappingException.getClass());
|
LOG.trace("mapped exception {} to {}", translatedAccessException.getClass(), mappingException.getClass());
|
||||||
throw mappingException;
|
throw mappingException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEventAwareEntity(final Object object) {
|
private static boolean isEventAwareEntity(final Object object) {
|
||||||
return object instanceof EventAwareEntity;
|
return object instanceof EventAwareEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doNotifiy(final Runnable runnable) {
|
private static void doNotifiy(final Runnable runnable) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(runnable);
|
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
|||||||
* the status for this action status
|
* the status for this action status
|
||||||
* @param occurredAt
|
* @param occurredAt
|
||||||
* the occurred timestamp
|
* the occurred timestamp
|
||||||
* @param messages
|
* @param message
|
||||||
* the messages which should be added to this action status
|
* the message which should be added to this action status
|
||||||
*/
|
*/
|
||||||
public JpaActionStatus(final JpaAction action, final Status status, final Long occurredAt, final String message) {
|
public JpaActionStatus(final JpaAction action, final Status status, final Long occurredAt, final String message) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import javax.persistence.OneToMany;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent.PropertyChange;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||||
@@ -299,8 +299,8 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
|
||||||
final Map<String, AbstractPropertyChangeEvent<JpaDistributionSet>.Values> changeSet = EntityPropertyChangeHelper
|
final Map<String, PropertyChange> changeSet = EntityPropertyChangeHelper.getChangeSet(JpaDistributionSet.class,
|
||||||
.getChangeSet(JpaDistributionSet.class, descriptorEvent);
|
descriptorEvent);
|
||||||
EventBusHolder.getInstance().getEventBus().post(new DistributionSetUpdateEvent(this));
|
EventBusHolder.getInstance().getEventBus().post(new DistributionSetUpdateEvent(this));
|
||||||
|
|
||||||
if (changeSet.containsKey(DELETED_PROPERTY)) {
|
if (changeSet.containsKey(DELETED_PROPERTY)) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import org.springframework.data.domain.Persistable;
|
|||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Long>, Target, EventAwareEntity {
|
public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Long>, Target, EventAwareEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "controller_id", length = 64)
|
@Column(name = "controller_id", length = 64)
|
||||||
@@ -185,7 +186,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isNew
|
* @param entityNew
|
||||||
* the isNew to set
|
* the isNew to set
|
||||||
*/
|
*/
|
||||||
public void setNew(final boolean entityNew) {
|
public void setNew(final boolean entityNew) {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
|
|||||||
private boolean requestControllerAttributes = true;
|
private boolean requestControllerAttributes = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for {@link TargetStatus}.
|
* Constructor for {@link JpaTargetInfo}.
|
||||||
*
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* related to this status.
|
* related to this status.
|
||||||
@@ -149,7 +149,7 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isNew
|
* @param entityNew
|
||||||
* the isNew to set
|
* the isNew to set
|
||||||
*/
|
*/
|
||||||
public void setNew(final boolean entityNew) {
|
public void setNew(final boolean entityNew) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.model.helper;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent.PropertyChange;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||||
import org.eclipse.persistence.internal.sessions.ObjectChangeSet;
|
import org.eclipse.persistence.internal.sessions.ObjectChangeSet;
|
||||||
@@ -32,15 +32,14 @@ public class EntityPropertyChangeHelper<T extends TenantAwareBaseEntity> {
|
|||||||
* @param event
|
* @param event
|
||||||
* @return the map of the changeSet
|
* @return the map of the changeSet
|
||||||
*/
|
*/
|
||||||
public static <T extends TenantAwareBaseEntity> Map<String, AbstractPropertyChangeEvent<T>.Values> getChangeSet(
|
public static <T extends TenantAwareBaseEntity> Map<String, PropertyChange> getChangeSet(final Class<T> clazz,
|
||||||
final Class<T> clazz, final DescriptorEvent event) {
|
final DescriptorEvent event) {
|
||||||
final T rolloutGroup = clazz.cast(event.getObject());
|
final T rolloutGroup = clazz.cast(event.getObject());
|
||||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||||
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||||
.map(record -> (DirectToFieldChangeRecord) record)
|
.map(record -> (DirectToFieldChangeRecord) record)
|
||||||
.collect(Collectors.toMap(record -> record.getAttribute(),
|
.collect(Collectors.toMap(record -> record.getAttribute(),
|
||||||
record -> new AbstractPropertyChangeEvent<T>(rolloutGroup, null).new Values(
|
record -> new PropertyChange(record.getOldValue(), record.getNewValue())));
|
||||||
record.getOldValue(), record.getNewValue())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.repository.FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -15,7 +17,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Expression;
|
import javax.persistence.criteria.Expression;
|
||||||
@@ -89,8 +90,6 @@ public final class RSQLUtility {
|
|||||||
* @param fieldNameProvider
|
* @param fieldNameProvider
|
||||||
* the enum class type which implements the
|
* the enum class type which implements the
|
||||||
* {@link FieldNameProvider}
|
* {@link FieldNameProvider}
|
||||||
* @param entityManager
|
|
||||||
* {@link EntityManager}
|
|
||||||
* @return an specification which can be used with JPA
|
* @return an specification which can be used with JPA
|
||||||
* @throws RSQLParameterUnsupportedFieldException
|
* @throws RSQLParameterUnsupportedFieldException
|
||||||
* if a field in the RSQL string is used but not provided by the
|
* if a field in the RSQL string is used but not provided by the
|
||||||
@@ -205,7 +204,7 @@ public final class RSQLUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getAndValidatePropertyFieldName(final A propertyEnum, final ComparisonNode node) {
|
private String getAndValidatePropertyFieldName(final A propertyEnum, final ComparisonNode node) {
|
||||||
String finalProperty = propertyEnum.getFieldName();
|
|
||||||
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||||
|
|
||||||
validateMapParamter(propertyEnum, node, graph);
|
validateMapParamter(propertyEnum, node, graph);
|
||||||
@@ -215,9 +214,12 @@ public final class RSQLUtility {
|
|||||||
throw createRSQLParameterUnsupportedException(node);
|
throw createRSQLParameterUnsupportedException(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final StringBuilder fieldNameBuilder = new StringBuilder(propertyEnum.getFieldName());
|
||||||
|
|
||||||
for (int i = 1; i < graph.length; i++) {
|
for (int i = 1; i < graph.length; i++) {
|
||||||
|
|
||||||
final String propertyField = graph[i];
|
final String propertyField = graph[i];
|
||||||
finalProperty += FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + propertyField;
|
fieldNameBuilder.append(SUB_ATTRIBUTE_SEPERATOR).append(propertyField);
|
||||||
|
|
||||||
// the key of map is not in the graph
|
// the key of map is not in the graph
|
||||||
if (propertyEnum.isMap() && graph.length == (i + 1)) {
|
if (propertyEnum.isMap() && graph.length == (i + 1)) {
|
||||||
@@ -229,7 +231,7 @@ public final class RSQLUtility {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return finalProperty;
|
return fieldNameBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMapParamter(final A propertyEnum, final ComparisonNode node, final String[] graph) {
|
private void validateMapParamter(final A propertyEnum, final ComparisonNode node, final String[] graph) {
|
||||||
|
|||||||
@@ -9,11 +9,24 @@
|
|||||||
package org.eclipse.hawkbit.rest.util;
|
package org.eclipse.hawkbit.rest.util;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.net.HttpHeaders.ACCEPT_RANGES;
|
||||||
|
import static com.google.common.net.HttpHeaders.CONTENT_DISPOSITION;
|
||||||
|
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||||
|
import static com.google.common.net.HttpHeaders.CONTENT_RANGE;
|
||||||
|
import static com.google.common.net.HttpHeaders.ETAG;
|
||||||
|
import static com.google.common.net.HttpHeaders.IF_RANGE;
|
||||||
|
import static com.google.common.net.HttpHeaders.LAST_MODIFIED;
|
||||||
|
import static java.math.RoundingMode.DOWN;
|
||||||
|
import static javax.servlet.http.HttpServletResponse.SC_PARTIAL_CONTENT;
|
||||||
|
import static org.eclipse.hawkbit.rest.util.ByteRange.MULTIPART_BOUNDARY;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.springframework.http.HttpStatus.PARTIAL_CONTENT;
|
||||||
|
import static org.springframework.http.HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE;
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,23 +40,19 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
|
|||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
import com.google.common.math.DoubleMath;
|
import com.google.common.math.DoubleMath;
|
||||||
import com.google.common.net.HttpHeaders;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for the Rest Source API.
|
* Utility class for the Rest Source API.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class RestResourceConversionHelper {
|
public final class RestResourceConversionHelper {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(RestResourceConversionHelper.class);
|
private static final Logger LOG = LoggerFactory.getLogger(RestResourceConversionHelper.class);
|
||||||
|
|
||||||
private static final int BUFFER_SIZE = 4096;
|
private static final int BUFFER_SIZE = 4096;
|
||||||
|
|
||||||
// utility class, private constructor.
|
|
||||||
private RestResourceConversionHelper() {
|
private RestResourceConversionHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -92,7 +101,8 @@ public final class RestResourceConversionHelper {
|
|||||||
*
|
*
|
||||||
* @return http code
|
* @return http code
|
||||||
*
|
*
|
||||||
* @see https://tools.ietf.org/html/rfc7233
|
* @see <a href="https://tools.ietf.org/html/rfc7233">https://tools.ietf.org
|
||||||
|
* /html/rfc7233</a>
|
||||||
*/
|
*/
|
||||||
public static ResponseEntity<InputStream> writeFileResponse(final LocalArtifact artifact,
|
public static ResponseEntity<InputStream> writeFileResponse(final LocalArtifact artifact,
|
||||||
final HttpServletResponse response, final HttpServletRequest request, final DbArtifact file,
|
final HttpServletResponse response, final HttpServletRequest request, final DbArtifact file,
|
||||||
@@ -107,11 +117,11 @@ public final class RestResourceConversionHelper {
|
|||||||
|
|
||||||
response.reset();
|
response.reset();
|
||||||
response.setBufferSize(BUFFER_SIZE);
|
response.setBufferSize(BUFFER_SIZE);
|
||||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + artifact.getFilename());
|
response.setHeader(CONTENT_DISPOSITION, "attachment;filename=" + artifact.getFilename());
|
||||||
response.setHeader(HttpHeaders.ETAG, etag);
|
response.setHeader(ETAG, etag);
|
||||||
response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
|
response.setHeader(ACCEPT_RANGES, "bytes");
|
||||||
response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified);
|
response.setDateHeader(LAST_MODIFIED, lastModified);
|
||||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
response.setContentType(APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
|
||||||
final ByteRange full = new ByteRange(0, length - 1, length);
|
final ByteRange full = new ByteRange(0, length - 1, length);
|
||||||
final List<ByteRange> ranges = new ArrayList<>();
|
final List<ByteRange> ranges = new ArrayList<>();
|
||||||
@@ -123,9 +133,9 @@ public final class RestResourceConversionHelper {
|
|||||||
|
|
||||||
// Range header matches"bytes=n-n,n-n,n-n..."
|
// Range header matches"bytes=n-n,n-n,n-n..."
|
||||||
if (!range.matches("^bytes=\\d*-\\d*(,\\d*-\\d*)*$")) {
|
if (!range.matches("^bytes=\\d*-\\d*(,\\d*-\\d*)*$")) {
|
||||||
response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes */" + length);
|
response.setHeader(CONTENT_RANGE, "bytes */" + length);
|
||||||
LOG.debug("range header for filename ({}) is not satisfiable: ", artifact.getFilename());
|
LOG.debug("range header for filename ({}) is not satisfiable: ", artifact.getFilename());
|
||||||
return new ResponseEntity<>(HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE);
|
return new ResponseEntity<>(REQUESTED_RANGE_NOT_SATISFIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC: if the representation is unchanged, send me the part(s) that
|
// RFC: if the representation is unchanged, send me the part(s) that
|
||||||
@@ -144,32 +154,31 @@ public final class RestResourceConversionHelper {
|
|||||||
// full request - no range
|
// full request - no range
|
||||||
if (ranges.isEmpty() || ranges.get(0).equals(full)) {
|
if (ranges.isEmpty() || ranges.get(0).equals(full)) {
|
||||||
LOG.debug("filename ({}) results into a full request: ", artifact.getFilename());
|
LOG.debug("filename ({}) results into a full request: ", artifact.getFilename());
|
||||||
fullfileRequest(artifact, response, file, controllerManagement, statusId, full);
|
handleFullFileRequest(artifact, response, file, controllerManagement, statusId, full);
|
||||||
result = new ResponseEntity<>(HttpStatus.OK);
|
result = new ResponseEntity<>(OK);
|
||||||
}
|
}
|
||||||
// standard range request
|
// standard range request
|
||||||
else if (ranges.size() == 1) {
|
else if (ranges.size() == 1) {
|
||||||
LOG.debug("filename ({}) results into a standard range request: ", artifact.getFilename());
|
LOG.debug("filename ({}) results into a standard range request: ", artifact.getFilename());
|
||||||
standardRangeRequest(artifact, response, file, controllerManagement, statusId, ranges);
|
handleStandardRangeRequest(artifact, response, file, controllerManagement, statusId, ranges);
|
||||||
result = new ResponseEntity<>(HttpStatus.PARTIAL_CONTENT);
|
result = new ResponseEntity<>(PARTIAL_CONTENT);
|
||||||
}
|
}
|
||||||
// multipart range request
|
// multipart range request
|
||||||
else {
|
else {
|
||||||
LOG.debug("filename ({}) results into a multipart range request: ", artifact.getFilename());
|
LOG.debug("filename ({}) results into a multipart range request: ", artifact.getFilename());
|
||||||
multipartRangeRequest(artifact, response, file, controllerManagement, statusId, ranges);
|
handleMultipartRangeRequest(artifact, response, file, controllerManagement, statusId, ranges);
|
||||||
result = new ResponseEntity<>(HttpStatus.PARTIAL_CONTENT);
|
result = new ResponseEntity<>(PARTIAL_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fullfileRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
private static void handleFullFileRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
||||||
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
||||||
final ByteRange full) {
|
final ByteRange full) {
|
||||||
final ByteRange r = full;
|
final ByteRange r = full;
|
||||||
response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
response.setHeader(CONTENT_RANGE, "bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
||||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(r.getLength()));
|
response.setHeader(CONTENT_LENGTH, String.valueOf(r.getLength()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
copyStreams(file.getFileInputStream(), response.getOutputStream(), controllerManagement, statusId,
|
copyStreams(file.getFileInputStream(), response.getOutputStream(), controllerManagement, statusId,
|
||||||
@@ -182,7 +191,7 @@ public final class RestResourceConversionHelper {
|
|||||||
|
|
||||||
private static ResponseEntity<InputStream> extractRange(final HttpServletResponse response, final long length,
|
private static ResponseEntity<InputStream> extractRange(final HttpServletResponse response, final long length,
|
||||||
final List<ByteRange> ranges, final String range) {
|
final List<ByteRange> ranges, final String range) {
|
||||||
ResponseEntity<InputStream> result = null;
|
|
||||||
if (ranges.isEmpty()) {
|
if (ranges.isEmpty()) {
|
||||||
for (final String part : range.substring(6).split(",")) {
|
for (final String part : range.substring(6).split(",")) {
|
||||||
long start = sublong(part, 0, part.indexOf('-'));
|
long start = sublong(part, 0, part.indexOf('-'));
|
||||||
@@ -198,9 +207,8 @@ public final class RestResourceConversionHelper {
|
|||||||
// Check if Range is syntactically valid. If not, then return
|
// Check if Range is syntactically valid. If not, then return
|
||||||
// 416.
|
// 416.
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes */" + length);
|
response.setHeader(CONTENT_RANGE, "bytes */" + length);
|
||||||
result = new ResponseEntity<>(HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE);
|
return new ResponseEntity<>(REQUESTED_RANGE_NOT_SATISFIABLE);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add range.
|
// Add range.
|
||||||
@@ -218,10 +226,10 @@ public final class RestResourceConversionHelper {
|
|||||||
|
|
||||||
private static void checkForShortcut(final HttpServletRequest request, final String etag, final long lastModified,
|
private static void checkForShortcut(final HttpServletRequest request, final String etag, final long lastModified,
|
||||||
final ByteRange full, final List<ByteRange> ranges) {
|
final ByteRange full, final List<ByteRange> ranges) {
|
||||||
final String ifRange = request.getHeader(HttpHeaders.IF_RANGE);
|
final String ifRange = request.getHeader(IF_RANGE);
|
||||||
if (ifRange != null && !ifRange.equals(etag)) {
|
if (ifRange != null && !ifRange.equals(etag)) {
|
||||||
try {
|
try {
|
||||||
final long ifRangeTime = request.getDateHeader(HttpHeaders.IF_RANGE);
|
final long ifRangeTime = request.getDateHeader(IF_RANGE);
|
||||||
if (ifRangeTime != -1 && ifRangeTime + 1000 < lastModified) {
|
if (ifRangeTime != -1 && ifRangeTime + 1000 < lastModified) {
|
||||||
ranges.add(full);
|
ranges.add(full);
|
||||||
}
|
}
|
||||||
@@ -232,17 +240,17 @@ public final class RestResourceConversionHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void multipartRangeRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
private static void handleMultipartRangeRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
||||||
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
||||||
final List<ByteRange> ranges) {
|
final List<ByteRange> ranges) {
|
||||||
response.setContentType("multipart/byteranges; boundary=" + ByteRange.MULTIPART_BOUNDARY);
|
response.setContentType("multipart/byteranges; boundary=" + MULTIPART_BOUNDARY);
|
||||||
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
|
response.setStatus(SC_PARTIAL_CONTENT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (final ByteRange r : ranges) {
|
for (final ByteRange r : ranges) {
|
||||||
// Add multipart boundary and header fields for every range.
|
// Add multipart boundary and header fields for every range.
|
||||||
response.getOutputStream().println();
|
response.getOutputStream().println();
|
||||||
response.getOutputStream().println("--" + ByteRange.MULTIPART_BOUNDARY);
|
response.getOutputStream().println("--" + MULTIPART_BOUNDARY);
|
||||||
response.getOutputStream()
|
response.getOutputStream()
|
||||||
.println("Content-Range: bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
.println("Content-Range: bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
||||||
|
|
||||||
@@ -253,20 +261,20 @@ public final class RestResourceConversionHelper {
|
|||||||
|
|
||||||
// End with final multipart boundary.
|
// End with final multipart boundary.
|
||||||
response.getOutputStream().println();
|
response.getOutputStream().println();
|
||||||
response.getOutputStream().print("--" + ByteRange.MULTIPART_BOUNDARY + "--");
|
response.getOutputStream().print("--" + MULTIPART_BOUNDARY + "--");
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
LOG.error("multipartRangeRequest of file ({}) failed!", artifact.getFilename(), e);
|
LOG.error("multipartRangeRequest of file ({}) failed!", artifact.getFilename(), e);
|
||||||
throw new FileSteamingFailedException(artifact.getFilename());
|
throw new FileSteamingFailedException(artifact.getFilename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void standardRangeRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
private static void handleStandardRangeRequest(final LocalArtifact artifact, final HttpServletResponse response,
|
||||||
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
final DbArtifact file, final ControllerManagement controllerManagement, final Long statusId,
|
||||||
final List<ByteRange> ranges) {
|
final List<ByteRange> ranges) {
|
||||||
final ByteRange r = ranges.get(0);
|
final ByteRange r = ranges.get(0);
|
||||||
response.setHeader(HttpHeaders.CONTENT_RANGE, "bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
response.setHeader(CONTENT_RANGE, "bytes " + r.getStart() + "-" + r.getEnd() + "/" + r.getTotal());
|
||||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(r.getLength()));
|
response.setHeader(CONTENT_LENGTH, String.valueOf(r.getLength()));
|
||||||
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
|
response.setStatus(SC_PARTIAL_CONTENT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
copyStreams(file.getFileInputStream(), response.getOutputStream(), controllerManagement, statusId,
|
copyStreams(file.getFileInputStream(), response.getOutputStream(), controllerManagement, statusId,
|
||||||
@@ -315,7 +323,7 @@ public final class RestResourceConversionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (controllerManagement != null) {
|
if (controllerManagement != null) {
|
||||||
final int newPercent = DoubleMath.roundToInt(total * 100.0 / length, RoundingMode.DOWN);
|
final int newPercent = DoubleMath.roundToInt(total * 100.0 / length, DOWN);
|
||||||
|
|
||||||
// every 10 percent an event
|
// every 10 percent an event
|
||||||
if (newPercent == 100 || newPercent > progressPercent + 10) {
|
if (newPercent == 100 || newPercent > progressPercent + 10) {
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ public class DosFilter extends OncePerRequestFilter {
|
|||||||
|
|
||||||
boolean processChain;
|
boolean processChain;
|
||||||
|
|
||||||
final String ip = IpUtil.getClientIpFromRequest(request, forwardHeader, true).getHost();
|
final String ip = IpUtil.getClientIpFromRequest(request, forwardHeader).getHost();
|
||||||
|
|
||||||
if (checkIpFails(ip)) {
|
if (checkIpFails(ip)) {
|
||||||
processChain = handleMissingIpAddress(response);
|
processChain = handleMissingIpAddress(response);
|
||||||
} else {
|
} else {
|
||||||
@@ -121,7 +122,6 @@ public class DosFilter extends OncePerRequestFilter {
|
|||||||
if (processChain) {
|
if (processChain) {
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -72,14 +72,16 @@ public final class IpUtil {
|
|||||||
* @param forwardHeader
|
* @param forwardHeader
|
||||||
* the header name containing the IP address e.g. forwarded by a
|
* the header name containing the IP address e.g. forwarded by a
|
||||||
* proxy {@code x-forwarded-for}
|
* proxy {@code x-forwarded-for}
|
||||||
*
|
|
||||||
* @param trackRemoteIp
|
|
||||||
* to <code>true</code> if remote IP should be tracked.
|
|
||||||
* @return the {@link URI} based IP address from the client which sent the
|
* @return the {@link URI} based IP address from the client which sent the
|
||||||
* request
|
* request
|
||||||
*/
|
*/
|
||||||
public static URI getClientIpFromRequest(final HttpServletRequest request, final String forwardHeader,
|
public static URI getClientIpFromRequest(final HttpServletRequest request, final String forwardHeader) {
|
||||||
|
return getClientIpFromRequest(request, forwardHeader, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static URI getClientIpFromRequest(final HttpServletRequest request, final String forwardHeader,
|
||||||
final boolean trackRemoteIp) {
|
final boolean trackRemoteIp) {
|
||||||
|
|
||||||
String ip;
|
String ip;
|
||||||
|
|
||||||
if (trackRemoteIp) {
|
if (trackRemoteIp) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.util;
|
package org.eclipse.hawkbit.util;
|
||||||
|
|
||||||
|
import static com.google.common.net.HttpHeaders.X_FORWARDED_FOR;
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -21,13 +22,13 @@ import java.net.URI;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||||
|
import org.eclipse.hawkbit.security.HawkbitSecurityProperties.Clients;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import com.google.common.net.HttpHeaders;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
@@ -37,69 +38,73 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
@Stories("IP Util Test")
|
@Stories("IP Util Test")
|
||||||
public class IpUtilTest {
|
public class IpUtilTest {
|
||||||
|
|
||||||
|
private static final String KNOWN_REQUEST_HEADER = "bumlux";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private HttpServletRequest requestMock;
|
private HttpServletRequest requestMock;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Clients clientMock;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private HawkbitSecurityProperties securityPropertyMock;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests create uri from request")
|
@Description("Tests create uri from request")
|
||||||
public void getRemoteAddrFromRequestIfForwaredHeaderNotPresent() {
|
public void getRemoteAddrFromRequestIfForwaredHeaderNotPresent() {
|
||||||
// known values
|
|
||||||
final URI knownRemoteClientIP = IpUtil.createHttpUri("127.0.0.1");
|
final URI knownRemoteClientIP = IpUtil.createHttpUri("127.0.0.1");
|
||||||
// mock
|
when(requestMock.getHeader(X_FORWARDED_FOR)).thenReturn(null);
|
||||||
when(requestMock.getHeader(HttpHeaders.X_FORWARDED_FOR)).thenReturn(null);
|
|
||||||
when(requestMock.getRemoteAddr()).thenReturn(knownRemoteClientIP.getHost());
|
when(requestMock.getRemoteAddr()).thenReturn(knownRemoteClientIP.getHost());
|
||||||
|
|
||||||
// test
|
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, KNOWN_REQUEST_HEADER);
|
||||||
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "bumlux", true);
|
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
||||||
.isEqualTo(knownRemoteClientIP);
|
.isEqualTo(knownRemoteClientIP);
|
||||||
verify(requestMock, times(1)).getHeader("bumlux");
|
verify(requestMock, times(1)).getHeader(KNOWN_REQUEST_HEADER);
|
||||||
verify(requestMock, times(1)).getRemoteAddr();
|
verify(requestMock, times(1)).getRemoteAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests create uri from request with masked IP when IP tracking is disabled")
|
@Description("Tests create uri from request with masked IP when IP tracking is disabled")
|
||||||
public void maskRemoteAddrIfDisabled() {
|
public void maskRemoteAddrIfDisabled() {
|
||||||
// known values
|
|
||||||
final URI knownRemoteClientIP = IpUtil.createHttpUri("***");
|
final URI knownRemoteClientIP = IpUtil.createHttpUri("***");
|
||||||
// mock
|
when(requestMock.getHeader(X_FORWARDED_FOR)).thenReturn(null);
|
||||||
when(requestMock.getHeader(HttpHeaders.X_FORWARDED_FOR)).thenReturn(null);
|
|
||||||
when(requestMock.getRemoteAddr()).thenReturn(knownRemoteClientIP.getHost());
|
when(requestMock.getRemoteAddr()).thenReturn(knownRemoteClientIP.getHost());
|
||||||
|
when(securityPropertyMock.getClients()).thenReturn(clientMock);
|
||||||
|
when(clientMock.getRemoteIpHeader()).thenReturn(KNOWN_REQUEST_HEADER);
|
||||||
|
when(clientMock.isTrackRemoteIp()).thenReturn(false);
|
||||||
|
|
||||||
// test
|
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, securityPropertyMock);
|
||||||
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "bumlux", false);
|
|
||||||
|
|
||||||
// verify
|
|
||||||
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
||||||
.isEqualTo(knownRemoteClientIP);
|
.isEqualTo(knownRemoteClientIP);
|
||||||
verify(requestMock, times(0)).getHeader("bumlux");
|
verify(requestMock, times(0)).getHeader(KNOWN_REQUEST_HEADER);
|
||||||
verify(requestMock, times(0)).getRemoteAddr();
|
verify(requestMock, times(0)).getRemoteAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests create uri from x forward header")
|
@Description("Tests create uri from x forward header")
|
||||||
public void getRemoteAddrFromXForwardedForHeader() {
|
public void getRemoteAddrFromXForwardedForHeader() {
|
||||||
// known values
|
|
||||||
final URI knownRemoteClientIP = IpUtil.createHttpUri("10.99.99.1");
|
final URI knownRemoteClientIP = IpUtil.createHttpUri("10.99.99.1");
|
||||||
// mock
|
when(requestMock.getHeader(X_FORWARDED_FOR)).thenReturn(knownRemoteClientIP.getHost());
|
||||||
when(requestMock.getHeader(HttpHeaders.X_FORWARDED_FOR)).thenReturn(knownRemoteClientIP.getHost());
|
|
||||||
when(requestMock.getRemoteAddr()).thenReturn(null);
|
when(requestMock.getRemoteAddr()).thenReturn(null);
|
||||||
|
|
||||||
// test
|
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "X-Forwarded-For");
|
||||||
final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "X-Forwarded-For", true);
|
|
||||||
|
|
||||||
// verify
|
|
||||||
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
assertThat(remoteAddr).as("The remote address should be as the known client IP address")
|
||||||
.isEqualTo(knownRemoteClientIP);
|
.isEqualTo(knownRemoteClientIP);
|
||||||
verify(requestMock, times(1)).getHeader(HttpHeaders.X_FORWARDED_FOR);
|
verify(requestMock, times(1)).getHeader(X_FORWARDED_FOR);
|
||||||
verify(requestMock, times(0)).getRemoteAddr();
|
verify(requestMock, times(0)).getRemoteAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests create http uri ipv4 and ipv6")
|
@Description("Tests create http uri ipv4 and ipv6")
|
||||||
public void testCreateHttpUri() {
|
public void testCreateHttpUri() {
|
||||||
|
|
||||||
final String ipv4 = "10.99.99.1";
|
final String ipv4 = "10.99.99.1";
|
||||||
URI httpUri = IpUtil.createHttpUri(ipv4);
|
URI httpUri = IpUtil.createHttpUri(ipv4);
|
||||||
assertHttpUri(ipv4, httpUri);
|
assertHttpUri(ipv4, httpUri);
|
||||||
@@ -111,7 +116,6 @@ public class IpUtilTest {
|
|||||||
final String ipv6 = "0:0:0:0:0:0:0:1";
|
final String ipv6 = "0:0:0:0:0:0:0:1";
|
||||||
httpUri = IpUtil.createHttpUri(ipv6);
|
httpUri = IpUtil.createHttpUri(ipv6);
|
||||||
assertHttpUri("[" + ipv6 + "]", httpUri);
|
assertHttpUri("[" + ipv6 + "]", httpUri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertHttpUri(final String host, final URI httpUri) {
|
private void assertHttpUri(final String host, final URI httpUri) {
|
||||||
@@ -124,6 +128,7 @@ public class IpUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests create amqp uri ipv4 and ipv6")
|
@Description("Tests create amqp uri ipv4 and ipv6")
|
||||||
public void testCreateAmqpUri() {
|
public void testCreateAmqpUri() {
|
||||||
|
|
||||||
final String ipv4 = "10.99.99.1";
|
final String ipv4 = "10.99.99.1";
|
||||||
URI amqpUri = IpUtil.createAmqpUri(ipv4, "path");
|
URI amqpUri = IpUtil.createAmqpUri(ipv4, "path");
|
||||||
assertAmqpUri(ipv4, amqpUri);
|
assertAmqpUri(ipv4, amqpUri);
|
||||||
@@ -138,6 +143,7 @@ public class IpUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertAmqpUri(final String host, final URI amqpUri) {
|
private void assertAmqpUri(final String host, final URI amqpUri) {
|
||||||
|
|
||||||
assertTrue("The given URI is an AMQP scheme", IpUtil.isAmqpUri(amqpUri));
|
assertTrue("The given URI is an AMQP scheme", IpUtil.isAmqpUri(amqpUri));
|
||||||
assertFalse("The given URI is not an HTTP scheme", IpUtil.isHttpUri(amqpUri));
|
assertFalse("The given URI is not an HTTP scheme", IpUtil.isHttpUri(amqpUri));
|
||||||
assertEquals("The given host matches the URI host", host, amqpUri.getHost());
|
assertEquals("The given host matches the URI host", host, amqpUri.getHost());
|
||||||
@@ -148,17 +154,19 @@ public class IpUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests create invalid uri")
|
@Description("Tests create invalid uri")
|
||||||
public void testCreateInvalidUri() {
|
public void testCreateInvalidUri() {
|
||||||
|
|
||||||
final String host = "10.99.99.1";
|
final String host = "10.99.99.1";
|
||||||
final URI testUri = IpUtil.createUri("test", host);
|
final URI testUri = IpUtil.createUri("test", host);
|
||||||
|
|
||||||
assertFalse("The given URI is not an AMQP address", IpUtil.isAmqpUri(testUri));
|
assertFalse("The given URI is not an AMQP address", IpUtil.isAmqpUri(testUri));
|
||||||
assertFalse("The given URI is not an HTTP address", IpUtil.isHttpUri(testUri));
|
assertFalse("The given URI is not an HTTP address", IpUtil.isHttpUri(testUri));
|
||||||
assertEquals("The given host matches the URI host", host, testUri.getHost());
|
assertEquals("The given host matches the URI host", host, testUri.getHost());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IpUtil.createUri(":/", host);
|
IpUtil.createUri(":/", host);
|
||||||
fail("Missing expected IllegalArgumentException due invalid URI");
|
fail("Missing expected IllegalArgumentException due invalid URI");
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.artifacts.details;
|
package org.eclipse.hawkbit.ui.artifacts.details;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.ASC;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -15,7 +20,6 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
|||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -51,18 +55,18 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
|||||||
*/
|
*/
|
||||||
public ArtifactBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public ArtifactBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortIds, final boolean[] sortStates) {
|
final Object[] sortIds, final boolean[] sortStates) {
|
||||||
|
|
||||||
super(definition, queryConfig, sortIds, sortStates);
|
super(definition, queryConfig, sortIds, sortStates);
|
||||||
|
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (isNotNullOrEmpty(queryConfig)) {
|
||||||
baseSwModuleId = (Long) queryConfig.get(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE);
|
baseSwModuleId = (Long) queryConfig.get(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
if (!isEmpty(sortStates)) {
|
||||||
// Initalize Sor
|
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
|
||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
|
||||||
// Add sort.
|
|
||||||
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
||||||
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
|
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.event.SoftwareModuleEvent.SoftwareModuleEventType;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
@@ -149,8 +150,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
final SoftwareModule softwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
final SoftwareModule softwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||||
labelStr = HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion());
|
labelStr = HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion());
|
||||||
}
|
}
|
||||||
titleOfArtifactDetails = SPUIComponentProvider.getLabel(
|
titleOfArtifactDetails = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr))
|
||||||
HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
.buildCaptionLabel();
|
||||||
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
|
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
|
||||||
titleOfArtifactDetails.setSizeFull();
|
titleOfArtifactDetails.setSizeFull();
|
||||||
titleOfArtifactDetails.setImmediate(true);
|
titleOfArtifactDetails.setImmediate(true);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
|||||||
public BaseSwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public BaseSwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortIds, final boolean[] sortStates) {
|
final Object[] sortIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortIds, sortStates);
|
super(definition, queryConfig, sortIds, sortStates);
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||||
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
||||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
|||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
@@ -118,26 +120,17 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
/* name textfield */
|
|
||||||
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
|
||||||
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
|
|
||||||
|
|
||||||
/* version text field */
|
nameTextField = createTextField("textfield.name", SPUIComponentIdProvider.SOFT_MODULE_NAME);
|
||||||
versionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
|
||||||
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
|
|
||||||
|
|
||||||
/* Vendor text field */
|
versionTextField = createTextField("textfield.version", SPUIComponentIdProvider.SOFT_MODULE_VERSION);
|
||||||
vendorTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.vendor"), "", ValoTheme.TEXTFIELD_TINY,
|
|
||||||
false, null, i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
|
|
||||||
|
|
||||||
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
vendorTextField = createTextField("textfield.vendor", SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
|
||||||
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
vendorTextField.setRequired(false);
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
|
||||||
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
|
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
|
||||||
|
.prompt(i18n.get("textfield.description")).id(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION)
|
||||||
|
.buildTextComponent();
|
||||||
|
|
||||||
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", "", null, null, true,
|
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", "", null, null, true,
|
||||||
null, i18n.get("upload.swmodule.type"));
|
null, i18n.get("upload.swmodule.type"));
|
||||||
@@ -148,6 +141,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
populateTypeNameCombo();
|
populateTypeNameCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextField createTextField(final String in18Key, final String id) {
|
||||||
|
return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key))
|
||||||
|
.immediate(true).id(id).buildTextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
private void populateTypeNameCombo() {
|
private void populateTypeNameCombo() {
|
||||||
typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||||
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
||||||
@@ -181,8 +179,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
|||||||
|
|
||||||
setCompositionRoot(formLayout);
|
setCompositionRoot(formLayout);
|
||||||
|
|
||||||
window = SPUIWindowDecorator.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
|
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
|
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this)
|
||||||
|
.layout(formLayout).i18n(i18n)
|
||||||
|
.buildCommonDialogWindow();
|
||||||
|
|
||||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ import com.vaadin.ui.UI;
|
|||||||
/**
|
/**
|
||||||
* Header of Software module table.
|
* Header of Software module table.
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
|
||||||
@ViewScope
|
@ViewScope
|
||||||
|
@SpringComponent
|
||||||
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
|
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6469417305487144809L;
|
private static final long serialVersionUID = 6469417305487144809L;
|
||||||
@@ -162,7 +162,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final UploadArtifactUIEvent event) {
|
void onEvent(final UploadArtifactUIEvent event) {
|
||||||
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
|
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
|
||||||
UI.getCurrent().access(() -> refreshFilter());
|
UI.getCurrent().access(this::refreshFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||||
final String nameVersionStr = getNameAndVerion(itemId);
|
final String nameVersionStr = getNameAndVerion(itemId);
|
||||||
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
||||||
manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId, nameVersionStr));
|
manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId));
|
||||||
return manageMetaDataBtn;
|
return manageMetaDataBtn;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -237,8 +237,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
|
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Button createManageMetadataButton(final String nameVersionStr) {
|
||||||
private Button createManageMetadataButton(String nameVersionStr) {
|
|
||||||
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
||||||
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
||||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||||
@@ -254,8 +253,8 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
return name + "." + version;
|
return name + "." + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMetadataDetails(Long itemId, String nameVersionStr) {
|
private void showMetadataDetails(final Long itemId) {
|
||||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
||||||
/* display the window */
|
/* display the window */
|
||||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
|
|||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
|
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
|
||||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
@@ -34,6 +36,7 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.OptionGroup;
|
import com.vaadin.ui.OptionGroup;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -73,29 +76,28 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
|
|||||||
|
|
||||||
singleAssignStr = i18n.get("label.singleAssign.type");
|
singleAssignStr = i18n.get("label.singleAssign.type");
|
||||||
multiAssignStr = i18n.get("label.multiAssign.type");
|
multiAssignStr = i18n.get("label.multiAssign.type");
|
||||||
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
singleAssign = new LabelBuilder().name(singleAssignStr).buildLabel();
|
||||||
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
|
||||||
|
|
||||||
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
multiAssign = new LabelBuilder().name(multiAssignStr).buildLabel();
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME, true, "", i18n.get("textfield.name"), true,
|
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
tagName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
|
||||||
|
|
||||||
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
|
tagName = createTextField("textfield.name", SPUIDefinitions.TYPE_NAME, SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY, true, "", i18n.get("textfield.key"), true,
|
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
typeKey.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
|
|
||||||
|
|
||||||
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
typeKey = createTextField("textfield.key", SPUIDefinitions.TYPE_KEY, SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC, false, "",
|
|
||||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
|
||||||
tagDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
|
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC)
|
||||||
tagDesc.setImmediate(true);
|
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC)
|
||||||
|
.buildTextComponent();
|
||||||
tagDesc.setNullRepresentation("");
|
tagDesc.setNullRepresentation("");
|
||||||
|
|
||||||
singleMultiOptionGroup();
|
singleMultiOptionGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextField createTextField(final String in18Key, final String styleName, final String id) {
|
||||||
|
return new TextFieldBuilder().caption(i18n.get(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
|
||||||
|
.required(true).prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildLayout() {
|
protected void buildLayout() {
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.artifacts.upload;
|
package org.eclipse.hawkbit.ui.artifacts.upload;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.FAILED;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.SUCCESS;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -23,6 +26,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
|
||||||
@@ -58,11 +62,11 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
* Artifact upload confirmation popup.
|
* Artifact upload confirmation popup.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UploadConfirmationwindow implements Button.ClickListener {
|
public class UploadConfirmationWindow implements Button.ClickListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1679035890140031740L;
|
private static final long serialVersionUID = -1679035890140031740L;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UploadConfirmationwindow.class);
|
private static final Logger LOG = LoggerFactory.getLogger(UploadConfirmationWindow.class);
|
||||||
|
|
||||||
private static final String MD5_CHECKSUM = "md5Checksum";
|
private static final String MD5_CHECKSUM = "md5Checksum";
|
||||||
|
|
||||||
@@ -120,7 +124,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
* @param artifactUploadState
|
* @param artifactUploadState
|
||||||
* reference of session variable {@link ArtifactUploadState}.
|
* reference of session variable {@link ArtifactUploadState}.
|
||||||
*/
|
*/
|
||||||
public UploadConfirmationwindow(final UploadLayout artifactUploadView,
|
public UploadConfirmationWindow(final UploadLayout artifactUploadView,
|
||||||
final ArtifactUploadState artifactUploadState) {
|
final ArtifactUploadState artifactUploadState) {
|
||||||
this.uploadLayout = artifactUploadView;
|
this.uploadLayout = artifactUploadView;
|
||||||
this.artifactUploadState = artifactUploadState;
|
this.artifactUploadState = artifactUploadState;
|
||||||
@@ -245,29 +249,27 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
deleteIcon.setData(itemId);
|
deleteIcon.setData(itemId);
|
||||||
newItem.getItemProperty(ACTION).setValue(deleteIcon);
|
newItem.getItemProperty(ACTION).setValue(deleteIcon);
|
||||||
|
|
||||||
final TextField sha1 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
final TextField sha1 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/sha1");
|
||||||
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
sha1.setId(swNameVersion + "/" + customFile.getFileName() + "/sha1");
|
|
||||||
|
|
||||||
final TextField md5 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
final TextField md5 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/md5");
|
||||||
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
md5.setId(swNameVersion + "/" + customFile.getFileName() + "/md5");
|
createTextField(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
|
||||||
|
|
||||||
final TextField customFileName = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
|
||||||
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
customFileName.setId(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
|
|
||||||
newItem.getItemProperty(SHA1_CHECKSUM).setValue(sha1);
|
newItem.getItemProperty(SHA1_CHECKSUM).setValue(sha1);
|
||||||
newItem.getItemProperty(MD5_CHECKSUM).setValue(md5);
|
newItem.getItemProperty(MD5_CHECKSUM).setValue(md5);
|
||||||
newItem.getItemProperty(CUSTOM_FILE).setValue(customFile);
|
newItem.getItemProperty(CUSTOM_FILE).setValue(customFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static TextField createTextField(final String id) {
|
||||||
|
return new TextFieldBuilder().immediate(true).id(id).buildTextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
|
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
|
||||||
final String customFileName, final String itemId) {
|
final String customFileName, final String itemId) {
|
||||||
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
||||||
final TextField fileNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
final TextField fileNameTextField = createTextField(
|
||||||
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
|
||||||
fileNameTextField.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
|
|
||||||
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
|
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
|
||||||
fileNameTextField.setValue(customFileName);
|
fileNameTextField.setValue(customFileName);
|
||||||
|
|
||||||
@@ -615,6 +617,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
|
|
||||||
private void createLocalArtifact(final String itemId, final String filePath,
|
private void createLocalArtifact(final String itemId, final String filePath,
|
||||||
final ArtifactManagement artifactManagement, final SoftwareModule baseSw) {
|
final ArtifactManagement artifactManagement, final SoftwareModule baseSw) {
|
||||||
|
|
||||||
final File newFile = new File(filePath);
|
final File newFile = new File(filePath);
|
||||||
final Item item = tabelContainer.getItem(itemId);
|
final Item item = tabelContainer.getItem(itemId);
|
||||||
final String sha1Checksum = ((TextField) item.getItemProperty(SHA1_CHECKSUM).getValue()).getValue();
|
final String sha1Checksum = ((TextField) item.getItemProperty(SHA1_CHECKSUM).getValue()).getValue();
|
||||||
@@ -624,27 +627,25 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
final String[] itemDet = itemId.split("/");
|
final String[] itemDet = itemId.split("/");
|
||||||
final String swModuleNameVersion = itemDet[0];
|
final String swModuleNameVersion = itemDet[0];
|
||||||
|
|
||||||
FileInputStream fis = null;
|
try (FileInputStream fis = new FileInputStream(newFile)) {
|
||||||
try {
|
|
||||||
fis = new FileInputStream(newFile);
|
|
||||||
artifactManagement.createLocalArtifact(fis, baseSw.getId(), providedFileName,
|
artifactManagement.createLocalArtifact(fis, baseSw.getId(), providedFileName,
|
||||||
HawkbitCommonUtil.trimAndNullIfEmpty(md5Checksum),
|
HawkbitCommonUtil.trimAndNullIfEmpty(md5Checksum),
|
||||||
HawkbitCommonUtil.trimAndNullIfEmpty(sha1Checksum), true, customFile.getMimeType());
|
HawkbitCommonUtil.trimAndNullIfEmpty(sha1Checksum), true, customFile.getMimeType());
|
||||||
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.SUCCESS, "");
|
saveUploadStatus(providedFileName, swModuleNameVersion, SUCCESS, "");
|
||||||
} catch (final FileNotFoundException e) {
|
|
||||||
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
|
} catch (final ArtifactUploadFailedException | InvalidSHA1HashException | InvalidMD5HashException
|
||||||
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
| FileNotFoundException e) {
|
||||||
} catch (final ArtifactUploadFailedException e) {
|
|
||||||
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
|
saveUploadStatus(providedFileName, swModuleNameVersion, FAILED, e.getMessage());
|
||||||
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
|
||||||
} catch (final InvalidSHA1HashException e) {
|
|
||||||
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
|
|
||||||
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
|
||||||
} catch (final InvalidMD5HashException e) {
|
|
||||||
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
|
|
||||||
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
||||||
|
|
||||||
|
} catch (final IOException ex) {
|
||||||
|
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, ex);
|
||||||
} finally {
|
} finally {
|
||||||
closeFileStream(fis, newFile);
|
if (newFile.exists() && !newFile.delete()) {
|
||||||
|
LOG.error("Could not delete temporary file: {}", newFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,21 +660,6 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void closeFileStream(final FileInputStream fis, final File newFile) {
|
|
||||||
|
|
||||||
if (fis != null) {
|
|
||||||
try {
|
|
||||||
fis.close();
|
|
||||||
} catch (final IOException e) {
|
|
||||||
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newFile.exists() && !newFile.delete()) {
|
|
||||||
LOG.error("Could not delete temporary file: {}", newFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Table getUploadDetailsTable() {
|
public Table getUploadDetailsTable() {
|
||||||
return uploadDetailsTable;
|
return uploadDetailsTable;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
|
|
||||||
private Button discardBtn;
|
private Button discardBtn;
|
||||||
|
|
||||||
private UploadConfirmationwindow currentUploadConfirmationwindow;
|
private UploadConfirmationWindow currentUploadConfirmationwindow;
|
||||||
|
|
||||||
private VerticalLayout dropAreaLayout;
|
private VerticalLayout dropAreaLayout;
|
||||||
|
|
||||||
@@ -639,7 +639,7 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
if (artifactUploadState.getFileSelected().isEmpty()) {
|
if (artifactUploadState.getFileSelected().isEmpty()) {
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
|
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
|
||||||
} else {
|
} else {
|
||||||
currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState);
|
currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState);
|
||||||
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
|
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
|
||||||
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
|
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
|
||||||
Page.getCurrent().getBrowserWindowHeight());
|
Page.getCurrent().getBrowserWindowHeight());
|
||||||
@@ -661,7 +661,7 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
return spInfo;
|
return spInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) {
|
void setCurrentUploadConfirmationwindow(final UploadConfirmationWindow currentUploadConfirmationwindow) {
|
||||||
this.currentUploadConfirmationwindow = currentUploadConfirmationwindow;
|
this.currentUploadConfirmationwindow = currentUploadConfirmationwindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,11 +57,7 @@ import elemental.json.JsonValue;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows upload status during upload.
|
* Shows upload status during upload.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ViewScope
|
@ViewScope
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
public class UploadStatusInfoWindow extends Window {
|
public class UploadStatusInfoWindow extends Window {
|
||||||
@@ -444,7 +440,7 @@ public class UploadStatusInfoWindow extends Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resizeWindow(final ClickEvent event) {
|
private void resizeWindow(final ClickEvent event) {
|
||||||
if (event.getButton().getIcon() == FontAwesome.EXPAND) {
|
if (FontAwesome.EXPAND.equals(event.getButton().getIcon())) {
|
||||||
event.getButton().setIcon(FontAwesome.COMPRESS);
|
event.getButton().setIcon(FontAwesome.COMPRESS);
|
||||||
setWindowMode(WindowMode.MAXIMIZED);
|
setWindowMode(WindowMode.MAXIMIZED);
|
||||||
resetColumnWidth();
|
resetColumnWidth();
|
||||||
|
|||||||
@@ -16,15 +16,18 @@ import javax.annotation.PostConstruct;
|
|||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||||
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
|
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -48,7 +51,6 @@ import com.vaadin.ui.TextField;
|
|||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -115,10 +117,24 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
|||||||
public CommonDialogWindow getWindow(final E entity, final M metaData) {
|
public CommonDialogWindow getWindow(final E entity, final M metaData) {
|
||||||
selectedEntity = entity;
|
selectedEntity = entity;
|
||||||
final String nameVersion = HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
final String nameVersion = HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
|
||||||
metadataWindow = SPUIWindowDecorator.getWindow(getMetadataCaption(nameVersion), null,
|
|
||||||
SPUIDefinitions.CUSTOM_METADATA_WINDOW, this, event -> onSave(), event -> onCancel(), null, mainLayout,
|
metadataWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||||
i18n);
|
.caption(getMetadataCaption(nameVersion)).content(this).cancelButtonClickListener(event -> onCancel())
|
||||||
metadataWindow.setId(SPUIComponentIdProvider.METADATA_POPUP_ID);
|
.id(SPUIComponentIdProvider.METADATA_POPUP_ID).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
|
||||||
|
|
||||||
|
metadataWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveOrUpdate() {
|
||||||
|
onSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canWindowClose() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
metadataWindow.setHeight(550, Unit.PIXELS);
|
metadataWindow.setHeight(550, Unit.PIXELS);
|
||||||
metadataWindow.setWidth(800, Unit.PIXELS);
|
metadataWindow.setWidth(800, Unit.PIXELS);
|
||||||
metadataWindow.getMainLayout().setSizeFull();
|
metadataWindow.getMainLayout().setSizeFull();
|
||||||
@@ -204,9 +220,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createKeyTextField() {
|
private TextField createKeyTextField() {
|
||||||
final TextField keyField = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
|
final TextField keyField = new TextFieldBuilder().caption(i18n.get("textfield.key")).required(true)
|
||||||
ValoTheme.TEXTFIELD_TINY, true, "", i18n.get("textfield.key"), true, 128);
|
.prompt(i18n.get("textfield.key")).immediate(true).id(SPUIComponentIdProvider.METADATA_KEY_FIELD_ID)
|
||||||
keyField.setId(SPUIComponentIdProvider.METADATA_KEY_FIELD_ID);
|
.maxLengthAllowed(128).buildTextComponent();
|
||||||
keyField.addTextChangeListener(event -> onKeyChange(event));
|
keyField.addTextChangeListener(event -> onKeyChange(event));
|
||||||
keyField.setTextChangeEventMode(TextChangeEventMode.EAGER);
|
keyField.setTextChangeEventMode(TextChangeEventMode.EAGER);
|
||||||
keyField.setWidth("100%");
|
keyField.setWidth("100%");
|
||||||
@@ -214,9 +230,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea createValueTextField() {
|
private TextArea createValueTextField() {
|
||||||
valueTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.value"), null, ValoTheme.TEXTAREA_TINY,
|
valueTextArea = new TextAreaBuilder().caption(i18n.get("textfield.value")).required(true)
|
||||||
true, null, i18n.get("textfield.value"), 4000);
|
.prompt(i18n.get("textfield.value")).immediate(true).id(SPUIComponentIdProvider.METADATA_VALUE_ID)
|
||||||
valueTextArea.setId(SPUIComponentIdProvider.METADATA_VALUE_ID);
|
.maxLengthAllowed(4000).buildTextComponent();
|
||||||
valueTextArea.setNullRepresentation("");
|
valueTextArea.setNullRepresentation("");
|
||||||
valueTextArea.setSizeFull();
|
valueTextArea.setSizeFull();
|
||||||
valueTextArea.setHeight(100, Unit.PERCENTAGE);
|
valueTextArea.setHeight(100, Unit.PERCENTAGE);
|
||||||
@@ -301,7 +317,7 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
return SPUIComponentProvider.getLabel(i18n.get("caption.metadata"), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
return new LabelBuilder().name(i18n.get("caption.metadata")).buildCaptionLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IndexedContainer getMetadataContainer() {
|
private static IndexedContainer getMetadataContainer() {
|
||||||
@@ -407,9 +423,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
|||||||
|
|
||||||
private String getMetadataCaption(final String nameVersionStr) {
|
private String getMetadataCaption(final String nameVersionStr) {
|
||||||
final StringBuilder caption = new StringBuilder();
|
final StringBuilder caption = new StringBuilder();
|
||||||
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION + i18n.get("caption.metadata.popup") + " "
|
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_START + i18n.get("caption.metadata.popup") + " "
|
||||||
+ HawkbitCommonUtil.getBoldHTMLText(nameVersionStr));
|
+ HawkbitCommonUtil.getBoldHTMLText(nameVersionStr));
|
||||||
caption.append(HawkbitCommonUtil.DIV_CLOSE);
|
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_END);
|
||||||
return caption.toString();
|
return caption.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts 2d-coordinates to a Color.
|
* Converts 2d-coordinates to a Color.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CoordinatesToColor implements Coordinates2Color {
|
public class CoordinatesToColor implements Coordinates2Color {
|
||||||
|
|
||||||
@@ -30,32 +26,31 @@ public class CoordinatesToColor implements Coordinates2Color {
|
|||||||
@Override
|
@Override
|
||||||
public int[] calculate(final Color color) {
|
public int[] calculate(final Color color) {
|
||||||
final float[] hsv = color.getHSV();
|
final float[] hsv = color.getHSV();
|
||||||
final int x = Math.round(hsv[0] * 220f);
|
final int x = Math.round(hsv[0] * 220F);
|
||||||
int y = 0;
|
final int y = calculateYCoordinateOfColor(hsv);
|
||||||
y = calculateYCoordinateOfColor(hsv);
|
|
||||||
return new int[] { x, y };
|
return new int[] { x, y };
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color calculateHSVColor(final int x, final int y) {
|
private static Color calculateHSVColor(final int x, final int y) {
|
||||||
final float h = x / 220f;
|
final float h = x / 220F;
|
||||||
float s = 1f;
|
float s = 1F;
|
||||||
float v = 1f;
|
float v = 1F;
|
||||||
if (y < 110) {
|
if (y < 110) {
|
||||||
s = y / 110f;
|
s = y / 110F;
|
||||||
} else if (y > 110) {
|
} else if (y > 110) {
|
||||||
v = 1f - (y - 110f) / 110f;
|
v = 1F - (y - 110F) / 110F;
|
||||||
}
|
}
|
||||||
return new Color(Color.HSVtoRGB(h, s, v));
|
return new Color(Color.HSVtoRGB(h, s, v));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateYCoordinateOfColor(final float[] hsv) {
|
private static int calculateYCoordinateOfColor(final float[] hsv) {
|
||||||
int y;
|
int y;
|
||||||
// lower half
|
// lower half
|
||||||
/* Assuming hsv[] array value will have in the range of 0 to 1 */
|
/* Assuming hsv[] array value will have in the range of 0 to 1 */
|
||||||
if (hsv[1] < 1f) {
|
if (hsv[1] < 1F) {
|
||||||
y = Math.round(hsv[1] * 110f);
|
y = Math.round(hsv[1] * 110F);
|
||||||
} else {
|
} else {
|
||||||
y = Math.round(110f - (hsv[1] + hsv[2]) * 110f);
|
y = Math.round(110F - (hsv[1] + hsv[2]) * 110F);
|
||||||
}
|
}
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.ui.common.builder;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.vaadin.ui.AbstractTextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Text field builder.
|
||||||
|
*
|
||||||
|
* @param <E>
|
||||||
|
* the concrete text component
|
||||||
|
*/
|
||||||
|
public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
|
||||||
|
|
||||||
|
private String caption;
|
||||||
|
private String style;
|
||||||
|
private String styleName;
|
||||||
|
private String prompt;
|
||||||
|
private String id;
|
||||||
|
private boolean immediate;
|
||||||
|
private boolean required;
|
||||||
|
private int maxLengthAllowed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param caption
|
||||||
|
* the caption to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> caption(final String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param style
|
||||||
|
* the style to set * @return the builder
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> style(final String style) {
|
||||||
|
this.style = style;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param styleName
|
||||||
|
* the styleName to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> styleName(final String styleName) {
|
||||||
|
this.styleName = styleName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param required
|
||||||
|
* the required to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> required(final boolean required) {
|
||||||
|
this.required = required;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param prompt
|
||||||
|
* the prompt to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> prompt(final String prompt) {
|
||||||
|
this.prompt = prompt;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param immediate
|
||||||
|
* the immediate to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> immediate(final boolean immediate) {
|
||||||
|
this.immediate = immediate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param maxLengthAllowed
|
||||||
|
* the maxLengthAllowed to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> maxLengthAllowed(final int maxLengthAllowed) {
|
||||||
|
this.maxLengthAllowed = maxLengthAllowed;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* the id to set
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public AbstractTextFieldBuilder<E> id(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a textfield
|
||||||
|
*
|
||||||
|
* @return textfield
|
||||||
|
*/
|
||||||
|
public E buildTextComponent() {
|
||||||
|
final E textComponent = createTextComponent();
|
||||||
|
|
||||||
|
textComponent.setRequired(required);
|
||||||
|
textComponent.setImmediate(immediate);
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(caption)) {
|
||||||
|
textComponent.setCaption(caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(style)) {
|
||||||
|
textComponent.setStyleName(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(styleName)) {
|
||||||
|
textComponent.addStyleName(styleName);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(prompt)) {
|
||||||
|
textComponent.setInputPrompt(prompt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxLengthAllowed > 0) {
|
||||||
|
textComponent.setMaxLength(maxLengthAllowed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(id)) {
|
||||||
|
textComponent.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return textComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract E createTextComponent();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* 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.builder;
|
||||||
|
|
||||||
|
import com.vaadin.ui.Label;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label Builder.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LabelBuilder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private boolean visible = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name to set
|
||||||
|
* @return builder
|
||||||
|
*/
|
||||||
|
public LabelBuilder name(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* the id to set
|
||||||
|
* @return builder
|
||||||
|
*/
|
||||||
|
public LabelBuilder id(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param visible
|
||||||
|
* the visible to set
|
||||||
|
* @return builder
|
||||||
|
*/
|
||||||
|
public LabelBuilder visible(final boolean visible) {
|
||||||
|
this.visible = visible;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build caption label.
|
||||||
|
*
|
||||||
|
* @return Label
|
||||||
|
*/
|
||||||
|
public Label buildCaptionLabel() {
|
||||||
|
final Label label = createLabel();
|
||||||
|
label.setValue(name);
|
||||||
|
label.addStyleName("header-caption");
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build label.
|
||||||
|
*
|
||||||
|
* @return Label
|
||||||
|
*/
|
||||||
|
public Label buildLabel() {
|
||||||
|
final Label label = createLabel();
|
||||||
|
label.setImmediate(false);
|
||||||
|
label.setWidth("-1px");
|
||||||
|
label.setHeight("-1px");
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Label createLabel() {
|
||||||
|
final Label label = new Label(name);
|
||||||
|
label.setVisible(visible);
|
||||||
|
final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
|
||||||
|
style.append(' ');
|
||||||
|
style.append(ValoTheme.LABEL_BOLD);
|
||||||
|
label.addStyleName(style.toString());
|
||||||
|
if (id != null) {
|
||||||
|
label.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* 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.builder;
|
||||||
|
|
||||||
|
import com.vaadin.ui.TextArea;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TextArea builder.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TextAreaBuilder extends AbstractTextFieldBuilder<TextArea> {
|
||||||
|
|
||||||
|
private static final int TEXT_AREA_DEFAULT_MAX_LENGTH = 512;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public TextAreaBuilder() {
|
||||||
|
maxLengthAllowed(TEXT_AREA_DEFAULT_MAX_LENGTH);
|
||||||
|
styleName(ValoTheme.TEXTAREA_TINY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TextArea createTextComponent() {
|
||||||
|
final TextArea textArea = new TextArea();
|
||||||
|
textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
|
||||||
|
return textArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* 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.builder;
|
||||||
|
|
||||||
|
import com.vaadin.event.FieldEvents.TextChangeListener;
|
||||||
|
import com.vaadin.server.Sizeable.Unit;
|
||||||
|
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Textfield builder.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TextFieldBuilder extends AbstractTextFieldBuilder<TextField> {
|
||||||
|
|
||||||
|
private static final int TEXT_FIELD_DEFAULT_MAX_LENGTH = 64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public TextFieldBuilder() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* the id
|
||||||
|
*/
|
||||||
|
public TextFieldBuilder(final String id) {
|
||||||
|
maxLengthAllowed(TEXT_FIELD_DEFAULT_MAX_LENGTH);
|
||||||
|
styleName(ValoTheme.TEXTAREA_TINY);
|
||||||
|
id(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a search text field.
|
||||||
|
*
|
||||||
|
* @param textChangeListener
|
||||||
|
* listener when text is changed.
|
||||||
|
* @return the textfield
|
||||||
|
*/
|
||||||
|
public TextField createSearchField(final TextChangeListener textChangeListener) {
|
||||||
|
final TextField textField = style("filter-box").styleName("text-style filter-box-hide").buildTextComponent();
|
||||||
|
textField.setWidth(100.0F, Unit.PERCENTAGE);
|
||||||
|
textField.addTextChangeListener(textChangeListener);
|
||||||
|
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
||||||
|
// 1 seconds timeout.
|
||||||
|
textField.setTextChangeTimeout(1000);
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TextField createTextComponent() {
|
||||||
|
final TextField textField = new TextField();
|
||||||
|
textField.addStyleName(ValoTheme.TEXTFIELD_SMALL);
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/**
|
||||||
|
* 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.builder;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
|
|
||||||
|
import com.vaadin.ui.AbstractLayout;
|
||||||
|
import com.vaadin.ui.Button.ClickListener;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
|
import com.vaadin.ui.Window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder for Window.
|
||||||
|
*/
|
||||||
|
public class WindowBuilder {
|
||||||
|
|
||||||
|
private String caption;
|
||||||
|
private Component content;
|
||||||
|
private ClickListener cancelButtonClickListener;
|
||||||
|
private String helpLink;
|
||||||
|
private AbstractLayout layout;
|
||||||
|
private I18N i18n;
|
||||||
|
private final String type;
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private SaveDialogCloseListener saveDialogCloseListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* window type
|
||||||
|
*/
|
||||||
|
public WindowBuilder(final String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the SaveDialogCloseListener.
|
||||||
|
*
|
||||||
|
* @param saveDialogCloseListener
|
||||||
|
* the saveDialogCloseListener
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder saveDialogCloseListener(final SaveDialogCloseListener saveDialogCloseListener) {
|
||||||
|
this.saveDialogCloseListener = saveDialogCloseListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the caption.
|
||||||
|
*
|
||||||
|
* @param caption
|
||||||
|
* the caption
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder caption(final String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the content.
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* the content
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder content(final Component content) {
|
||||||
|
this.content = content;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the cancelButtonClickListener.
|
||||||
|
*
|
||||||
|
* @param cancelButtonClickListener
|
||||||
|
* the cancelButtonClickListener
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder cancelButtonClickListener(final ClickListener cancelButtonClickListener) {
|
||||||
|
this.cancelButtonClickListener = cancelButtonClickListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the helpLink.
|
||||||
|
*
|
||||||
|
* @param helpLink
|
||||||
|
* the helpLink
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder helpLink(final String helpLink) {
|
||||||
|
this.helpLink = helpLink;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the layout.
|
||||||
|
*
|
||||||
|
* @param layout
|
||||||
|
* the layout
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder layout(final AbstractLayout layout) {
|
||||||
|
this.layout = layout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the i18n.
|
||||||
|
*
|
||||||
|
* @param i18n
|
||||||
|
* the i18n
|
||||||
|
* @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder i18n(final I18N i18n) {
|
||||||
|
this.i18n = i18n;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* the id to set * @return the window builder
|
||||||
|
*/
|
||||||
|
public WindowBuilder id(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the common dialog window.
|
||||||
|
*
|
||||||
|
* @return the window.
|
||||||
|
*/
|
||||||
|
public CommonDialogWindow buildCommonDialogWindow() {
|
||||||
|
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
|
||||||
|
layout, i18n);
|
||||||
|
window.setSaveDialogCloseListener(saveDialogCloseListener);
|
||||||
|
decorateWindow(window);
|
||||||
|
return window;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the common dialog window.
|
||||||
|
*
|
||||||
|
* @return the window.
|
||||||
|
*/
|
||||||
|
public CommonDialogWindow buildConfirmationWindow() {
|
||||||
|
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
|
||||||
|
layout, i18n);
|
||||||
|
window.setSaveDialogCloseListener(saveDialogCloseListener);
|
||||||
|
decorateWindow(window);
|
||||||
|
return window;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decorateWindow(final Window window) {
|
||||||
|
if (id != null) {
|
||||||
|
window.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
|
||||||
|
window.setDraggable(false);
|
||||||
|
window.setClosable(true);
|
||||||
|
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
|
||||||
|
|
||||||
|
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
|
||||||
|
window.setDraggable(true);
|
||||||
|
window.setClosable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build window based on type.
|
||||||
|
*
|
||||||
|
* @return Window
|
||||||
|
*/
|
||||||
|
public Window buildWindow() {
|
||||||
|
final Window window = new Window(caption);
|
||||||
|
window.setContent(content);
|
||||||
|
window.setSizeUndefined();
|
||||||
|
window.setModal(true);
|
||||||
|
window.setResizable(false);
|
||||||
|
|
||||||
|
decorateWindow(window);
|
||||||
|
|
||||||
|
if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
|
||||||
|
window.setClosable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
@@ -51,6 +52,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected transient EventBus.SessionEventBus eventBus;
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PostConstruct.
|
||||||
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
removeAllComponents();
|
removeAllComponents();
|
||||||
@@ -65,10 +69,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createActionMessgaeLabel() {
|
private void createActionMessgaeLabel() {
|
||||||
actionMessage = SPUIComponentProvider.getLabel("", null);
|
actionMessage = new LabelBuilder().name("").id(SPUIComponentIdProvider.ACTION_LABEL).visible(false)
|
||||||
|
.buildLabel();
|
||||||
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
|
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
|
||||||
actionMessage.setId(SPUIComponentIdProvider.ACTION_LABEL);
|
|
||||||
actionMessage.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAccordian() {
|
private void createAccordian() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
@@ -25,7 +26,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
@@ -183,7 +183,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
return new LabelBuilder().name(getDefaultCaption()).buildCaptionLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VerticalLayout getTabLayout() {
|
protected VerticalLayout getTabLayout() {
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ public class DistributionSetMetadatadetailslayout extends Table {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 2913758299611837718L;
|
private static final long serialVersionUID = 2913758299611837718L;
|
||||||
|
|
||||||
private DistributionSetManagement distributionSetManagement;
|
|
||||||
|
|
||||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
|
||||||
|
|
||||||
private static final String METADATA_KEY = "Key";
|
private static final String METADATA_KEY = "Key";
|
||||||
|
|
||||||
private static final String VIEW = "view";
|
private static final String VIEW = "view";
|
||||||
|
|
||||||
|
private transient DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
|
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||||
|
|
||||||
private SpPermissionChecker permissionChecker;
|
private SpPermissionChecker permissionChecker;
|
||||||
|
|
||||||
private transient EntityFactory entityFactory;
|
private transient EntityFactory entityFactory;
|
||||||
@@ -61,7 +61,7 @@ public class DistributionSetMetadatadetailslayout extends Table {
|
|||||||
private Long selectedDistSetId;
|
private Long selectedDistSetId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the component.
|
*
|
||||||
* @param i18n
|
* @param i18n
|
||||||
* @param permissionChecker
|
* @param permissionChecker
|
||||||
* @param distributionSetManagement
|
* @param distributionSetManagement
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.common.filterlayout;
|
package org.eclipse.hawkbit.ui.common.filterlayout;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.NO_TAG_BUTTON_ID;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -95,16 +97,12 @@ public abstract class AbstractFilterButtons extends Table {
|
|||||||
container.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, true, true);
|
container.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
protected void addColumn() {
|
protected void addColumn() {
|
||||||
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
|
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private DragAndDropWrapper addGeneratedCell(final Object itemId) {
|
private DragAndDropWrapper addGeneratedCell(final Object itemId) {
|
||||||
|
|
||||||
final Item item = getItem(itemId);
|
final Item item = getItem(itemId);
|
||||||
final Long id = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_ID).getValue();
|
final Long id = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_ID).getValue();
|
||||||
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||||
@@ -116,16 +114,18 @@ public abstract class AbstractFilterButtons extends Table {
|
|||||||
? item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).getValue().toString() : DEFAULT_GREEN;
|
? item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).getValue().toString() : DEFAULT_GREEN;
|
||||||
final Button typeButton = createFilterButton(id, name, desc, color, itemId);
|
final Button typeButton = createFilterButton(id, name, desc, color, itemId);
|
||||||
typeButton.addClickListener(event -> filterButtonClickBehaviour.processFilterButtonClick(event));
|
typeButton.addClickListener(event -> filterButtonClickBehaviour.processFilterButtonClick(event));
|
||||||
if (typeButton.getData().equals(SPUIDefinitions.NO_TAG_BUTTON_ID) && isNoTagSateSelected()) {
|
|
||||||
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
if ((NO_TAG_BUTTON_ID.equals(typeButton.getData()) && isNoTagStateSelected())
|
||||||
} else if (id != null && isClickedByDefault(name)) {
|
|| (id != null && isClickedByDefault(name))) {
|
||||||
|
|
||||||
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
return createDragAndDropWrapper(typeButton, name, id);
|
return createDragAndDropWrapper(typeButton, name, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isNoTagSateSelected() {
|
protected boolean isNoTagStateSelected() {
|
||||||
return Boolean.FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DragAndDropWrapper createDragAndDropWrapper(final Button tagButton, final String name, final Long id) {
|
private DragAndDropWrapper createDragAndDropWrapper(final Button tagButton, final String name, final Long id) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.ui.common.filterlayout;
|
package org.eclipse.hawkbit.ui.common.filterlayout;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
@@ -91,7 +92,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
return SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
return new LabelBuilder().name(getTitle()).buildCaptionLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
@@ -215,11 +216,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
if (!hasUnsavedActions()) {
|
if (!hasUnsavedActions()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
|
unsavedActionsWindow = new WindowBuilder(SPUIDefinitions.CONFIRMATION_WINDOW)
|
||||||
SPUIComponentIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
|
.caption(getUnsavedActionsWindowCaption()).id(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID)
|
||||||
|
.content(getUnsavedActionsWindowContent()).buildWindow();
|
||||||
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
|
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
|
||||||
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
|
|
||||||
unsavedActionsWindow.setId(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID);
|
|
||||||
UI.getCurrent().addWindow(unsavedActionsWindow);
|
UI.getCurrent().addWindow(unsavedActionsWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.common.grid;
|
package org.eclipse.hawkbit.ui.common.grid;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
@@ -61,7 +60,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
|||||||
private void createComponents() {
|
private void createComponents() {
|
||||||
headerCaptionLayout = getHeaderCaptionLayout();
|
headerCaptionLayout = getHeaderCaptionLayout();
|
||||||
if (isRollout()) {
|
if (isRollout()) {
|
||||||
searchField = createSearchField();
|
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText()));
|
||||||
searchResetIcon = createSearchResetIcon();
|
searchResetIcon = createSearchResetIcon();
|
||||||
addButton = createAddButton();
|
addButton = createAddButton();
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
|||||||
addStyleName("no-border-bottom");
|
addStyleName("no-border-bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createHeaderFilterIconLayout() {
|
private static HorizontalLayout createHeaderFilterIconLayout() {
|
||||||
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
|
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
|
||||||
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
|
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
|
||||||
titleFilterIconsLayout.setSpacing(false);
|
titleFilterIconsLayout.setSpacing(false);
|
||||||
@@ -101,17 +100,6 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
|||||||
return titleFilterIconsLayout;
|
return titleFilterIconsLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
|
||||||
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
|
||||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
textField.setId(getSearchBoxId());
|
|
||||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
|
||||||
textField.addTextChangeListener(event -> searchBy(event.getText()));
|
|
||||||
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
|
||||||
textField.setTextChangeTimeout(1000);
|
|
||||||
return textField;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SPUIButton createSearchResetIcon() {
|
private SPUIButton createSearchResetIcon() {
|
||||||
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton(getSearchRestIconId(), "", "", null,
|
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton(getSearchRestIconId(), "", "", null,
|
||||||
false, FontAwesome.SEARCH, SPUIButtonStyleSmallNoBorder.class);
|
false, FontAwesome.SEARCH, SPUIButtonStyleSmallNoBorder.class);
|
||||||
|
|||||||
@@ -12,20 +12,20 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.vaadin.event.dd.DropHandler;
|
import com.vaadin.event.dd.DropHandler;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
@@ -86,7 +86,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
|||||||
|
|
||||||
private void createComponents() {
|
private void createComponents() {
|
||||||
headerCaption = createHeaderCaption();
|
headerCaption = createHeaderCaption();
|
||||||
searchField = createSearchField();
|
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText()));
|
||||||
|
|
||||||
searchResetIcon = createSearchResetIcon();
|
searchResetIcon = createSearchResetIcon();
|
||||||
|
|
||||||
@@ -203,21 +203,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
final Label captionLabel = SPUIComponentProvider.getLabel(getHeaderCaption(),
|
return new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel();
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
|
||||||
return captionLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextField createSearchField() {
|
|
||||||
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
|
||||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
textField.setId(getSearchBoxId());
|
|
||||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
|
||||||
textField.addTextChangeListener(event -> searchBy(event.getText()));
|
|
||||||
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
|
||||||
// 1 seconds timeout.
|
|
||||||
textField.setTextChangeTimeout(1000);
|
|
||||||
return textField;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SPUIButton createSearchResetIcon() {
|
private SPUIButton createSearchResetIcon() {
|
||||||
@@ -322,7 +308,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
|||||||
maxMinIcon.setData(Boolean.FALSE);
|
maxMinIcon.setData(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createHeaderFilterIconLayout() {
|
private static HorizontalLayout createHeaderFilterIconLayout() {
|
||||||
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
|
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
|
||||||
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
|
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
|
||||||
titleFilterIconsLayout.setSpacing(false);
|
titleFilterIconsLayout.setSpacing(false);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class SPTargetAttributesLayout {
|
|||||||
final Label title = new Label(i18n.get("label.target.controller.attrs"), ContentMode.HTML);
|
final Label title = new Label(i18n.get("label.target.controller.attrs"), ContentMode.HTML);
|
||||||
title.addStyleName(SPUIDefinitions.TEXT_STYLE);
|
title.addStyleName(SPUIDefinitions.TEXT_STYLE);
|
||||||
targetAttributesLayout.addComponent(title);
|
targetAttributesLayout.addComponent(title);
|
||||||
if (HawkbitCommonUtil.mapCheckStrings(controllerAttibs)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(controllerAttibs)) {
|
||||||
for (final Map.Entry<String, String> entry : controllerAttibs.entrySet()) {
|
for (final Map.Entry<String, String> entry : controllerAttibs.entrySet()) {
|
||||||
targetAttributesLayout.addComponent(
|
targetAttributesLayout.addComponent(
|
||||||
SPUIComponentProvider.createNameValueLabel(entry.getKey() + ": ", entry.getValue()));
|
SPUIComponentProvider.createNameValueLabel(entry.getKey() + ": ", entry.getValue()));
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
|
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
|
||||||
import org.eclipse.hawkbit.ui.decorators.HeaderLayoutDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -34,15 +29,11 @@ import com.vaadin.shared.ui.label.ContentMode;
|
|||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.CheckBox;
|
import com.vaadin.ui.CheckBox;
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Link;
|
import com.vaadin.ui.Link;
|
||||||
import com.vaadin.ui.Panel;
|
import com.vaadin.ui.Panel;
|
||||||
import com.vaadin.ui.TabSheet;
|
import com.vaadin.ui.TabSheet;
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,149 +52,6 @@ public final class SPUIComponentProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param className
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static HorizontalLayout getHorizontalLayout(final Class<? extends HorizontalLayout> className) {
|
|
||||||
HorizontalLayout hLayout = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
hLayout = className.newInstance();
|
|
||||||
} catch (final InstantiationException exception) {
|
|
||||||
LOG.error("Error occured while creating HorizontalLayout-" + className, exception);
|
|
||||||
} catch (final IllegalAccessException exception) {
|
|
||||||
LOG.error("Error occured while acessing HorizontalLayout-" + className, exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get HorizontalLayout UI component.
|
|
||||||
*
|
|
||||||
* @param className
|
|
||||||
* as Layout
|
|
||||||
* @return HorizontalLayout as UI
|
|
||||||
*/
|
|
||||||
public static HorizontalLayout getHorizontalLayout() {
|
|
||||||
HorizontalLayout hLayout = null;
|
|
||||||
try {
|
|
||||||
hLayout = HorizontalLayout.class.newInstance();
|
|
||||||
} catch (final InstantiationException exception) {
|
|
||||||
LOG.error("Error occured while creating HorizontalLayout-", exception);
|
|
||||||
} catch (final IllegalAccessException exception) {
|
|
||||||
LOG.error("Error occured while acessing HorizontalLayout-", exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tableHeaderLayoutDecorator
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static HorizontalLayout getHeaderLayout(
|
|
||||||
final Class<? extends HeaderLayoutDecorator> tableHeaderLayoutDecorator) {
|
|
||||||
// Do we really need this???
|
|
||||||
HorizontalLayout hLayout = getHorizontalLayout(new SPUIHorizontalLayout().getUiHorizontalLayout().getClass());
|
|
||||||
|
|
||||||
if (tableHeaderLayoutDecorator == null) {
|
|
||||||
return hLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final HeaderLayoutDecorator layoutDecorator = tableHeaderLayoutDecorator.newInstance();
|
|
||||||
hLayout = layoutDecorator.decorate(hLayout);
|
|
||||||
|
|
||||||
} catch (final InstantiationException | IllegalAccessException exception) {
|
|
||||||
LOG.error("Error occured while creating horizontal decorator " + HeaderLayoutDecorator.class,
|
|
||||||
exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Label UI component.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* label caption
|
|
||||||
* @param type
|
|
||||||
* string simple|Confirm|Message
|
|
||||||
* @return Label
|
|
||||||
*/
|
|
||||||
public static Label getLabel(final String name, final String type) {
|
|
||||||
return SPUILabelDecorator.getDeocratedLabel(name, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get window component.
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* window caption
|
|
||||||
* @param id
|
|
||||||
* window id
|
|
||||||
* @param type
|
|
||||||
* type of window
|
|
||||||
* @return Window
|
|
||||||
*/
|
|
||||||
public static Window getWindow(final String caption, final String id, final String type) {
|
|
||||||
return SPUIWindowDecorator.getDeocratedWindow(caption, id, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Label UI component.
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* set the caption of the textfield
|
|
||||||
* @param style
|
|
||||||
* set style
|
|
||||||
* @param styleName
|
|
||||||
* add style
|
|
||||||
* @param required
|
|
||||||
* to set field as mandatory
|
|
||||||
* @param data
|
|
||||||
* component data
|
|
||||||
* @param prompt
|
|
||||||
* prompt user for input
|
|
||||||
* @param immediate
|
|
||||||
* set component's immediate mode specified mode
|
|
||||||
* @param maxLengthAllowed
|
|
||||||
* maximum characters allowed
|
|
||||||
* @return TextField text field
|
|
||||||
*/
|
|
||||||
public static TextField getTextField(final String caption, final String style, final String styleName,
|
|
||||||
final boolean required, final String data, final String prompt, final boolean immediate,
|
|
||||||
final int maxLengthAllowed) {
|
|
||||||
return SPUITextFieldDecorator.decorate(caption, style, styleName, required, data, prompt, immediate,
|
|
||||||
maxLengthAllowed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Label UI component. *
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* set the caption of the textArea
|
|
||||||
* @param style
|
|
||||||
* set style
|
|
||||||
* @param styleName
|
|
||||||
* add style
|
|
||||||
* @param required
|
|
||||||
* to set field as mandatory
|
|
||||||
* @param data
|
|
||||||
* component data
|
|
||||||
* @param promt
|
|
||||||
* prompt user for input
|
|
||||||
* @param maxLength
|
|
||||||
* maximum characters allowed
|
|
||||||
* @return TextArea text area
|
|
||||||
*/
|
|
||||||
public static TextArea getTextArea(final String caption, final String style, final String styleName,
|
|
||||||
final boolean required, final String data, final String promt, final int maxLength) {
|
|
||||||
return SPUITextAreaDecorator.decorate(caption, style, styleName, required, data, promt, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Label UI component.
|
* Get Label UI component.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.components;
|
|
||||||
|
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plain Horizontal Layout.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SPUIHorizontalLayout {
|
|
||||||
private final HorizontalLayout uiHorizontalLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
public SPUIHorizontalLayout() {
|
|
||||||
uiHorizontalLayout = new HorizontalLayout();
|
|
||||||
decorate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorate.
|
|
||||||
*/
|
|
||||||
private void decorate() {
|
|
||||||
uiHorizontalLayout.setImmediate(false);
|
|
||||||
uiHorizontalLayout.setMargin(false);
|
|
||||||
uiHorizontalLayout.setSpacing(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get HorizontalLayout.
|
|
||||||
*
|
|
||||||
* @return HorizontalLayout as UI
|
|
||||||
*/
|
|
||||||
public HorizontalLayout getUiHorizontalLayout() {
|
|
||||||
return uiHorizontalLayout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,7 @@ import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler;
|
|||||||
import com.vaadin.shared.ui.Connect;
|
import com.vaadin.shared.ui.Connect;
|
||||||
|
|
||||||
import elemental.json.JsonObject;
|
import elemental.json.JsonObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A connector for {@link CustomObjectRenderer }.
|
* A connector for {@link CustomObjectRenderer }.
|
||||||
*
|
*
|
||||||
@@ -25,13 +26,13 @@ import elemental.json.JsonObject;
|
|||||||
public class RolloutRendererConnector extends ClickableRendererConnector<RolloutRendererData> {
|
public class RolloutRendererConnector extends ClickableRendererConnector<RolloutRendererData> {
|
||||||
private static final long serialVersionUID = 7734682321931830566L;
|
private static final long serialVersionUID = 7734682321931830566L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
|
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
|
||||||
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
|
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HandlerRegistration addClickHandler(
|
protected HandlerRegistration addClickHandler(final RendererClickHandler<JsonObject> handler) {
|
||||||
RendererClickHandler<JsonObject> handler) {
|
|
||||||
return getRenderer().addClickHandler(handler);
|
return getRenderer().addClickHandler(handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,11 +11,10 @@ package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RendererData class with Name and Status.
|
* RendererData class with name and status.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RolloutRendererData implements Serializable {
|
public class RolloutRendererData implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5018181529953620263L;
|
private static final long serialVersionUID = -5018181529953620263L;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@@ -23,10 +22,10 @@ public class RolloutRendererData implements Serializable {
|
|||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the RendererData.
|
* Initialize the RendererData empty.
|
||||||
*/
|
*/
|
||||||
public RolloutRendererData() {
|
public RolloutRendererData() {
|
||||||
|
// Needed by Vaadin for compiling the widget set.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,8 +36,7 @@ public class RolloutRendererData implements Serializable {
|
|||||||
* @param status
|
* @param status
|
||||||
* Status of Rollout.
|
* Status of Rollout.
|
||||||
*/
|
*/
|
||||||
public RolloutRendererData(String name, String status) {
|
public RolloutRendererData(final String name, final String status) {
|
||||||
super();
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
@@ -47,7 +45,7 @@ public class RolloutRendererData implements Serializable {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +53,7 @@ public class RolloutRendererData implements Serializable {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(String status) {
|
public void setStatus(final String status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,8 @@ import com.vaadin.ui.renderers.ClickableRenderer;
|
|||||||
import elemental.json.JsonValue;
|
import elemental.json.JsonValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders button with provided CustomObject.
|
* Renders button with provided CustomObject. Used to display button with link.
|
||||||
* Used to display button with link.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
|
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8754180585906263554L;
|
private static final long serialVersionUID = -8754180585906263554L;
|
||||||
@@ -33,29 +30,30 @@ public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize custom object renderer with {@link Class<CustomObject>}
|
* Initialize custom object renderer with the given type.
|
||||||
*
|
*
|
||||||
* @param presentationType
|
* @param presentationType
|
||||||
* Class<CustomObject>
|
* Class<CustomObject>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public RolloutRenderer(Class<RolloutRendererData> presentationType) {
|
public RolloutRenderer(final Class<RolloutRendererData> presentationType) {
|
||||||
super(presentationType);
|
super(presentationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new custom object renderer and adds the given click listener to it.
|
* Creates a new custom object renderer and adds the given click listener to
|
||||||
|
* it.
|
||||||
*
|
*
|
||||||
* @param listener
|
* @param listener
|
||||||
* the click listener to register
|
* the click listener to register
|
||||||
*/
|
*/
|
||||||
public RolloutRenderer(RendererClickListener listener) {
|
public RolloutRenderer(final RendererClickListener listener) {
|
||||||
this();
|
this();
|
||||||
addClickListener(listener);
|
addClickListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonValue encode(RolloutRendererData resource) {
|
public JsonValue encode(final RolloutRendererData resource) {
|
||||||
return super.encode(resource, RolloutRendererData.class);
|
return super.encode(resource, RolloutRendererData.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
|
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
|
||||||
import com.vaadin.ui.Label;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Decorator for the label.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class SPUILabelDecorator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private Constructor.
|
|
||||||
*/
|
|
||||||
private SPUILabelDecorator() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple decorator.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* as String
|
|
||||||
* @param type
|
|
||||||
* as String
|
|
||||||
* @return Label
|
|
||||||
*/
|
|
||||||
public static Label getDeocratedLabel(final String name, final String type) {
|
|
||||||
final Label spUILabel = new Label(name);
|
|
||||||
// Set style.
|
|
||||||
final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
|
|
||||||
style.append(' ');
|
|
||||||
style.append(ValoTheme.LABEL_BOLD);
|
|
||||||
spUILabel.addStyleName(style.toString());
|
|
||||||
if (SPUILabelDefinitions.SP_WIDGET_CAPTION.equalsIgnoreCase(type)) {
|
|
||||||
spUILabel.setValue(name);
|
|
||||||
spUILabel.addStyleName("header-caption");
|
|
||||||
} else if (SPUILabelDefinitions.SP_LABEL_MESSAGE.equalsIgnoreCase(type)) {
|
|
||||||
spUILabel.setContentMode(ContentMode.HTML);
|
|
||||||
spUILabel.addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
|
|
||||||
} else {
|
|
||||||
spUILabel.setImmediate(false);
|
|
||||||
spUILabel.setWidth("-1px");
|
|
||||||
spUILabel.setHeight("-1px");
|
|
||||||
}
|
|
||||||
|
|
||||||
return spUILabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TextArea with required style.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class SPUITextAreaDecorator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private Constrcutor.
|
|
||||||
*/
|
|
||||||
private SPUITextAreaDecorator() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorate.
|
|
||||||
*
|
|
||||||
* @param style
|
|
||||||
* set style
|
|
||||||
* @param styleName
|
|
||||||
* add style
|
|
||||||
* @param required
|
|
||||||
* to set field as mandatory
|
|
||||||
* @param data
|
|
||||||
* component data
|
|
||||||
* @param prompt
|
|
||||||
* as user for input
|
|
||||||
* @param maxLength
|
|
||||||
* maximum characters allowed
|
|
||||||
* @return TextArea as comp
|
|
||||||
*/
|
|
||||||
public static TextArea decorate(final String caption, final String style, final String styleName,
|
|
||||||
final boolean required, final String data, final String prompt, final int maxLength) {
|
|
||||||
final TextArea spUITxtArea = new TextArea();
|
|
||||||
// Default settings
|
|
||||||
spUITxtArea.setRequired(false);
|
|
||||||
spUITxtArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
|
|
||||||
if (StringUtils.isNotEmpty(caption)) {
|
|
||||||
spUITxtArea.setCaption(caption);
|
|
||||||
}
|
|
||||||
if (required) {
|
|
||||||
spUITxtArea.setRequired(true);
|
|
||||||
}
|
|
||||||
// Add style
|
|
||||||
if (StringUtils.isNotEmpty(style)) {
|
|
||||||
spUITxtArea.setStyleName(style);
|
|
||||||
}
|
|
||||||
// Add style Name
|
|
||||||
if (StringUtils.isNotEmpty(styleName)) {
|
|
||||||
spUITxtArea.addStyleName(styleName);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(prompt)) {
|
|
||||||
spUITxtArea.setInputPrompt(prompt);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(data)) {
|
|
||||||
spUITxtArea.setData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxLength > 0) {
|
|
||||||
spUITxtArea.setMaxLength(maxLength);
|
|
||||||
}
|
|
||||||
return spUITxtArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorate TextField with required style.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class SPUITextFieldDecorator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
private SPUITextFieldDecorator() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* set the caption of the textfield
|
|
||||||
* @param style
|
|
||||||
* set style
|
|
||||||
* @param styleName
|
|
||||||
* add style
|
|
||||||
* @param required
|
|
||||||
* to set field as mandatory
|
|
||||||
* @param data
|
|
||||||
* component data
|
|
||||||
* @param prompt
|
|
||||||
* prompt user for input
|
|
||||||
* @param immediate
|
|
||||||
* as for display
|
|
||||||
* @param maxLengthAllowed
|
|
||||||
* maximum characters allowed
|
|
||||||
* @return Text field as decorated
|
|
||||||
*/
|
|
||||||
public static TextField decorate(final String caption, final String style, final String styleName,
|
|
||||||
final boolean required, final String data, final String prompt, final boolean immediate,
|
|
||||||
final int maxLengthAllowed) {
|
|
||||||
final TextField spUITxtFld = new TextField();
|
|
||||||
if (StringUtils.isNotEmpty(caption)) {
|
|
||||||
spUITxtFld.setCaption(caption);
|
|
||||||
}
|
|
||||||
// Default settings
|
|
||||||
spUITxtFld.setRequired(false);
|
|
||||||
spUITxtFld.addStyleName(ValoTheme.TEXTFIELD_SMALL);
|
|
||||||
if (required) {
|
|
||||||
spUITxtFld.setRequired(true);
|
|
||||||
}
|
|
||||||
if (immediate) {
|
|
||||||
spUITxtFld.setImmediate(true);
|
|
||||||
}
|
|
||||||
// Add style
|
|
||||||
if (StringUtils.isNotEmpty(style)) {
|
|
||||||
spUITxtFld.setStyleName(style);
|
|
||||||
}
|
|
||||||
// Add style Name
|
|
||||||
if (StringUtils.isNotEmpty(styleName)) {
|
|
||||||
spUITxtFld.addStyleName(styleName);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(prompt)) {
|
|
||||||
spUITxtFld.setInputPrompt(prompt);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(data)) {
|
|
||||||
spUITxtFld.setData(data);
|
|
||||||
}
|
|
||||||
if (maxLengthAllowed > 0) {
|
|
||||||
spUITxtFld.setMaxLength(maxLengthAllowed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return spUITxtFld;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
|
||||||
|
|
||||||
import com.vaadin.ui.AbstractLayout;
|
|
||||||
import com.vaadin.ui.Button.ClickListener;
|
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorator for Window.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class SPUIWindowDecorator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private Constructor.
|
|
||||||
*/
|
|
||||||
private SPUIWindowDecorator() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorates window based on type.
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* window caption
|
|
||||||
* @param id
|
|
||||||
* window id
|
|
||||||
* @param type
|
|
||||||
* window type
|
|
||||||
* @param content
|
|
||||||
* content in the window
|
|
||||||
* @param cancelButtonClickListener
|
|
||||||
* cancel button
|
|
||||||
* @param helpLink
|
|
||||||
* help link
|
|
||||||
* @param layout
|
|
||||||
* layout in the window
|
|
||||||
* @param i18n
|
|
||||||
* i18n for internationalization
|
|
||||||
* @return Window
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static CommonDialogWindow getWindow(final String caption, final String id, final String type,
|
|
||||||
final Component content, final ClickListener cancelButtonClickListener, final String helpLink,
|
|
||||||
final AbstractLayout layout, final I18N i18n) {
|
|
||||||
return getWindow(caption, id, type, content, null, cancelButtonClickListener, helpLink, layout, i18n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param caption
|
|
||||||
* window caption
|
|
||||||
* @param id
|
|
||||||
* window id
|
|
||||||
* @param type
|
|
||||||
* window type
|
|
||||||
* @param content
|
|
||||||
* content in the window
|
|
||||||
* @param saveButtonClickListener
|
|
||||||
* save button
|
|
||||||
* @param cancelButtonClickListener
|
|
||||||
* cancel button
|
|
||||||
* @param helpLink
|
|
||||||
* help link
|
|
||||||
* @param layout
|
|
||||||
* layout in the window
|
|
||||||
* @param i18n
|
|
||||||
* i18n for internationalization
|
|
||||||
* @return window
|
|
||||||
*/
|
|
||||||
public static CommonDialogWindow getWindow(final String caption, final String id, final String type,
|
|
||||||
final Component content, final ClickListener saveButtonClickListener,
|
|
||||||
final ClickListener cancelButtonClickListener, final String helpLink, final AbstractLayout layout,
|
|
||||||
final I18N i18n) {
|
|
||||||
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
|
|
||||||
layout, i18n);
|
|
||||||
|
|
||||||
if (SPUIDefinitions.CUSTOM_METADATA_WINDOW.equals(type)) {
|
|
||||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveOrUpdate() {
|
|
||||||
saveButtonClickListener.buttonClick(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canWindowClose() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
window.setDraggable(true);
|
|
||||||
window.setClosable(true);
|
|
||||||
} else {
|
|
||||||
if (null != id) {
|
|
||||||
window.setId(id);
|
|
||||||
}
|
|
||||||
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
|
|
||||||
window.setDraggable(false);
|
|
||||||
window.setClosable(true);
|
|
||||||
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
|
|
||||||
|
|
||||||
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
|
|
||||||
window.setDraggable(true);
|
|
||||||
window.setClosable(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decorates window based on type.
|
|
||||||
*
|
|
||||||
* @param caption
|
|
||||||
* window caption
|
|
||||||
* @param id
|
|
||||||
* window id
|
|
||||||
* @param type
|
|
||||||
* window type
|
|
||||||
* @return Window
|
|
||||||
*/
|
|
||||||
public static Window getDeocratedWindow(final String caption, final String id, final String type) {
|
|
||||||
final Window window = new Window(caption);
|
|
||||||
window.setSizeUndefined();
|
|
||||||
window.setModal(true);
|
|
||||||
window.setResizable(false);
|
|
||||||
if (null != id) {
|
|
||||||
window.setId(id);
|
|
||||||
}
|
|
||||||
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
|
|
||||||
window.setDraggable(false);
|
|
||||||
window.setClosable(true);
|
|
||||||
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
|
|
||||||
|
|
||||||
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
|
|
||||||
window.setDraggable(true);
|
|
||||||
window.setClosable(false);
|
|
||||||
}
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
|||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
|
||||||
@@ -44,6 +46,7 @@ import com.vaadin.ui.CheckBox;
|
|||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -83,24 +86,24 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
|
|||||||
|
|
||||||
super.createRequiredComponents();
|
super.createRequiredComponents();
|
||||||
|
|
||||||
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
tagName = createTextField("textfield.name", SPUIDefinitions.DIST_SET_TYPE_NAME,
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_NAME, true, "",
|
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
|
||||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
tagName.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
|
|
||||||
|
|
||||||
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
|
typeKey = createTextField("textfield.key", SPUIDefinitions.DIST_SET_TYPE_KEY,
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"),
|
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
|
||||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
typeKey.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
|
|
||||||
|
|
||||||
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC, false, "",
|
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC)
|
||||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
.prompt(i18n.get("textfield.description")).immediate(true)
|
||||||
tagDesc.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC);
|
.id(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC).buildTextComponent();
|
||||||
tagDesc.setImmediate(true);
|
|
||||||
tagDesc.setNullRepresentation("");
|
tagDesc.setNullRepresentation("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextField createTextField(final String in18Key, final String styleName, final String id) {
|
||||||
|
return new TextFieldBuilder().caption(i18n.get(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
|
||||||
|
.required(true).prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildLayout() {
|
protected void buildLayout() {
|
||||||
|
|
||||||
|
|||||||
@@ -117,5 +117,4 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
private void refreshTypeTable() {
|
private void refreshTypeTable() {
|
||||||
setContainerDataSource(createButtonsLazyQueryContainer());
|
setContainerDataSource(createButtonsLazyQueryContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
|||||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||||
|
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
searchText = String.format("%%%s%%", searchText);
|
searchText = String.format("%%%s%%", searchText);
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
|
|||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
|
||||||
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
|
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
|
||||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -27,7 +25,6 @@ import com.vaadin.spring.annotation.ViewScope;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Pop up layout to display software module metadata.
|
* Pop up layout to display software module metadata.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
@@ -39,39 +36,35 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
|
|||||||
private transient SoftwareManagement softwareManagement;
|
private transient SoftwareManagement softwareManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArtifactUploadState artifactUploadState;
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityFactory entityFactory;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ManageDistUIState manageDistUIState;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SpPermissionChecker permChecker;
|
protected SpPermissionChecker permChecker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkForDuplicate(SoftwareModule entity, String value) {
|
protected void checkForDuplicate(final SoftwareModule entity, final String value) {
|
||||||
softwareManagement.findSoftwareModuleMetadata(entity, value);
|
softwareManagement.findSoftwareModuleMetadata(entity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create metadata for SWModule.
|
* Create metadata for SWModule.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected SoftwareModuleMetadata createMetadata(SoftwareModule entity, String key, String value) {
|
protected SoftwareModuleMetadata createMetadata(final SoftwareModule entity, final String key, final String value) {
|
||||||
SoftwareModuleMetadata swMetadata = softwareManagement.createSoftwareModuleMetadata(entityFactory
|
final SoftwareModuleMetadata swMetadata = softwareManagement
|
||||||
.generateSoftwareModuleMetadata(entity, key, value));
|
.createSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
|
||||||
setSelectedEntity(swMetadata.getSoftwareModule());
|
setSelectedEntity(swMetadata.getSoftwareModule());
|
||||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata));
|
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata));
|
||||||
return swMetadata;
|
return swMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update metadata for SWModule.
|
* Update metadata for SWModule.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected SoftwareModuleMetadata updateMetadata(SoftwareModule entity, String key, String value) {
|
protected SoftwareModuleMetadata updateMetadata(final SoftwareModule entity, final String key, final String value) {
|
||||||
SoftwareModuleMetadata swMetadata = softwareManagement.updateSoftwareModuleMetadata(entityFactory
|
final SoftwareModuleMetadata swMetadata = softwareManagement
|
||||||
.generateSoftwareModuleMetadata(entity, key, value));
|
.updateSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
|
||||||
setSelectedEntity(swMetadata.getSoftwareModule());
|
setSelectedEntity(swMetadata.getSoftwareModule());
|
||||||
return swMetadata;
|
return swMetadata;
|
||||||
}
|
}
|
||||||
@@ -85,8 +78,8 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
|
|||||||
* delete metadata for SWModule.
|
* delete metadata for SWModule.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void deleteMetadata(SoftwareModule entity, String key, String value) {
|
protected void deleteMetadata(final SoftwareModule entity, final String key, final String value) {
|
||||||
SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
|
final SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
|
||||||
softwareManagement.deleteSoftwareModuleMetadata(entity, key);
|
softwareManagement.deleteSoftwareModuleMetadata(entity, key);
|
||||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata));
|
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata));
|
||||||
}
|
}
|
||||||
@@ -100,5 +93,4 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
|
|||||||
protected boolean hasUpdatePermission() {
|
protected boolean hasUpdatePermission() {
|
||||||
return permChecker.hasUpdateDistributionPermission();
|
return permChecker.hasUpdateDistributionPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
|||||||
public SwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public SwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortIds, final boolean[] sortStates) {
|
final Object[] sortIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortIds, sortStates);
|
super(definition, queryConfig, sortIds, sortStates);
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||||
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
||||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.distributions.smtype;
|
package org.eclipse.hawkbit.ui.distributions.smtype;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE;
|
||||||
|
import static org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_NAME;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -19,7 +24,6 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
|
|||||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||||
@@ -35,10 +39,9 @@ import com.vaadin.spring.annotation.ViewScope;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Software Module Type filter buttons.
|
* Software Module Type filter buttons.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
|
||||||
@ViewScope
|
@ViewScope
|
||||||
|
@SpringComponent
|
||||||
public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6804534533362387433L;
|
private static final long serialVersionUID = 6804534533362387433L;
|
||||||
@@ -51,7 +54,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getButtonsTableId() {
|
protected String getButtonsTableId() {
|
||||||
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
|
return SW_MODULE_TYPE_TABLE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,7 +63,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
final BeanQueryFactory<SoftwareModuleTypeBeanQuery> typeQF = new BeanQueryFactory<>(
|
final BeanQueryFactory<SoftwareModuleTypeBeanQuery> typeQF = new BeanQueryFactory<>(
|
||||||
SoftwareModuleTypeBeanQuery.class);
|
SoftwareModuleTypeBeanQuery.class);
|
||||||
typeQF.setQueryConfiguration(queryConfig);
|
typeQF.setQueryConfiguration(queryConfig);
|
||||||
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), typeQF);
|
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, VAR_NAME), typeQF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,8 +73,8 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isClickedByDefault(final String typeName) {
|
protected boolean isClickedByDefault(final String typeName) {
|
||||||
return manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
return manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && manageDistUIState
|
||||||
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName().equals(typeName);
|
.getSoftwareModuleFilters().getSoftwareModuleType().get().getName().equals(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,13 +107,16 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final SoftwareModuleTypeEvent event) {
|
void onEvent(final SoftwareModuleTypeEvent event) {
|
||||||
if (event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE
|
if (isCreateOrUpdate(event) && event.getSoftwareModuleType() != null) {
|
||||||
|| event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE
|
|
||||||
&& event.getSoftwareModuleType() != null) {
|
|
||||||
refreshTypeTable();
|
refreshTypeTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isCreateOrUpdate(final SoftwareModuleTypeEvent event) {
|
||||||
|
return event.getSoftwareModuleTypeEnum() == ADD_SOFTWARE_MODULE_TYPE
|
||||||
|
|| event.getSoftwareModuleTypeEnum() == UPDATE_SOFTWARE_MODULE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final SaveActionWindowEvent event) {
|
void onEvent(final SaveActionWindowEvent event) {
|
||||||
if (event == SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES) {
|
if (event == SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES) {
|
||||||
@@ -121,6 +127,4 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
|
|||||||
private void refreshTypeTable() {
|
private void refreshTypeTable() {
|
||||||
setContainerDataSource(createButtonsLazyQueryContainer());
|
setContainerDataSource(createButtonsLazyQueryContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.distributions.state;
|
package org.eclipse.hawkbit.ui.distributions.state;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptySet;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -49,7 +50,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
|
|
||||||
private DistributionSetIdName lastSelectedDistribution;
|
private DistributionSetIdName lastSelectedDistribution;
|
||||||
|
|
||||||
private Set<Long> selectedSoftwareModules = Collections.emptySet();
|
private Set<Long> selectedSoftwareModules = emptySet();
|
||||||
|
|
||||||
private Set<String> selectedDeleteDistSetTypes = new HashSet<>();
|
private Set<String> selectedDeleteDistSetTypes = new HashSet<>();
|
||||||
|
|
||||||
@@ -57,23 +58,23 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
|
|
||||||
private Long selectedBaseSwModuleId;
|
private Long selectedBaseSwModuleId;
|
||||||
|
|
||||||
private boolean distTypeFilterClosed = Boolean.FALSE;
|
private boolean distTypeFilterClosed;
|
||||||
|
|
||||||
private boolean swTypeFilterClosed = Boolean.FALSE;
|
private boolean swTypeFilterClosed;
|
||||||
|
|
||||||
private final Map<Long, String> deleteSofwareModulesList = new HashMap<>();
|
private final Map<Long, String> deleteSofwareModulesList = new HashMap<>();
|
||||||
|
|
||||||
private boolean swModuleTableMaximized = Boolean.FALSE;
|
private boolean swModuleTableMaximized;
|
||||||
|
|
||||||
private boolean dsTableMaximized = Boolean.FALSE;
|
private boolean dsTableMaximized;
|
||||||
|
|
||||||
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
|
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
|
||||||
|
|
||||||
private final Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<>();
|
private final Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<>();
|
||||||
|
|
||||||
private boolean noDataAvilableSwModule = Boolean.FALSE;
|
private boolean noDataAvilableSwModule;
|
||||||
|
|
||||||
private boolean noDataAvailableDist = Boolean.FALSE;
|
private boolean noDataAvailableDist;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the manageDistFilters
|
* @return the manageDistFilters
|
||||||
@@ -117,6 +118,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
this.lastSelectedDistribution = value;
|
this.lastSelectedDistribution = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
|
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
|
||||||
selectedDistributions = values;
|
selectedDistributions = values;
|
||||||
}
|
}
|
||||||
@@ -223,7 +225,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
/***
|
/***
|
||||||
* Set isDsModuleTableMaximized.
|
* Set isDsModuleTableMaximized.
|
||||||
*
|
*
|
||||||
* @param isDsModuleTableMaximized
|
* @param dsModuleTableMaximized
|
||||||
*/
|
*/
|
||||||
public void setDsTableMaximized(final boolean dsModuleTableMaximized) {
|
public void setDsTableMaximized(final boolean dsModuleTableMaximized) {
|
||||||
dsTableMaximized = dsModuleTableMaximized;
|
dsTableMaximized = dsModuleTableMaximized;
|
||||||
@@ -241,7 +243,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isSwModuleTableMaximized
|
* @param swModuleTableMaximized
|
||||||
* the isSwModuleTableMaximized to set
|
* the isSwModuleTableMaximized to set
|
||||||
*/
|
*/
|
||||||
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
|
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
|
||||||
@@ -271,8 +273,8 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param noDilableDist
|
* @param noDataAvailableDist
|
||||||
* the noDataAvailableDist to set
|
* the isNoDataAvailableDist to set
|
||||||
*/
|
*/
|
||||||
public void setNoDataAvailableDist(final boolean noDataAvailableDist) {
|
public void setNoDataAvailableDist(final boolean noDataAvailableDist) {
|
||||||
this.noDataAvailableDist = noDataAvailableDist;
|
this.noDataAvailableDist = noDataAvailableDist;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
|||||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||||
import org.eclipse.hawkbit.ui.UiProperties;
|
import org.eclipse.hawkbit.ui.UiProperties;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -217,10 +219,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
breadcrumbButton = createBreadcrumbButton();
|
breadcrumbButton = createBreadcrumbButton();
|
||||||
|
|
||||||
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
|
headerCaption = new LabelBuilder().name(SPUILabelDefinitions.VAR_CREATE_FILTER).buildCaptionLabel();
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
|
||||||
|
|
||||||
nameLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
nameLabel = new LabelBuilder().name("").buildLabel();
|
||||||
nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
|
nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
|
||||||
|
|
||||||
nameTextField = createNameTextField();
|
nameTextField = createNameTextField();
|
||||||
@@ -249,10 +250,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createNameTextField() {
|
private TextField createNameTextField() {
|
||||||
final TextField nameField = SPUIComponentProvider.getTextField(i18n.get("textfield.customfiltername"), "",
|
final TextField nameField = new TextFieldBuilder().caption(i18n.get("textfield.customfiltername"))
|
||||||
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.customfiltername"), true,
|
.prompt(i18n.get("textfield.customfiltername")).immediate(true)
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
.id(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME).buildTextComponent();
|
||||||
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
|
|
||||||
nameField.setPropertyDataSource(nameLabel);
|
nameField.setPropertyDataSource(nameLabel);
|
||||||
nameField.addTextChangeListener(this::onFilterNameChange);
|
nameField.addTextChangeListener(this::onFilterNameChange);
|
||||||
return nameField;
|
return nameField;
|
||||||
@@ -307,7 +307,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
breadcrumbLayout = new HorizontalLayout();
|
breadcrumbLayout = new HorizontalLayout();
|
||||||
breadcrumbLayout.addComponent(breadcrumbButton);
|
breadcrumbLayout.addComponent(breadcrumbButton);
|
||||||
breadcrumbLayout.addComponent(new Label(">"));
|
breadcrumbLayout.addComponent(new Label(">"));
|
||||||
breadcrumbName = SPUIComponentProvider.getLabel(null, SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
breadcrumbName = new LabelBuilder().buildCaptionLabel();
|
||||||
breadcrumbLayout.addComponent(breadcrumbName);
|
breadcrumbLayout.addComponent(breadcrumbName);
|
||||||
breadcrumbName.addStyleName("breadcrumbPaddingLeft");
|
breadcrumbName.addStyleName("breadcrumbPaddingLeft");
|
||||||
|
|
||||||
@@ -450,10 +450,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private static TextField createSearchField() {
|
||||||
final TextField textField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, "",
|
final TextField textField = new TextFieldBuilder().immediate(true).id("custom.query.text.Id")
|
||||||
"", true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
|
||||||
textField.setId("custom.query.text.Id");
|
|
||||||
textField.addStyleName("target-filter-textfield");
|
textField.addStyleName("target-filter-textfield");
|
||||||
textField.setWidth(900.0F, Unit.PIXELS);
|
textField.setWidth(900.0F, Unit.PIXELS);
|
||||||
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import javax.annotation.PreDestroy;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
|
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
|
||||||
@@ -209,7 +209,7 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
final Item row1 = getItem(itemId);
|
final Item row1 = getItem(itemId);
|
||||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
|
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
|
||||||
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label label = new LabelBuilder().name("").buildLabel();
|
||||||
label.setContentMode(ContentMode.HTML);
|
label.setContentMode(ContentMode.HTML);
|
||||||
if (targetStatus == TargetUpdateStatus.PENDING) {
|
if (targetStatus == TargetUpdateStatus.PENDING) {
|
||||||
label.setDescription("Pending");
|
label.setDescription("Pending");
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.FILTER_BY_QUERY;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.ASC;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -61,38 +67,25 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
final Object[] sortIds, final boolean[] sortStates) {
|
final Object[] sortIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortIds, sortStates);
|
super(definition, queryConfig, sortIds, sortStates);
|
||||||
|
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (isNotNullOrEmpty(queryConfig)) {
|
||||||
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
|
filterQuery = (String) queryConfig.get(FILTER_BY_QUERY);
|
||||||
}
|
}
|
||||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
|
||||||
// Initalize Sor
|
if (!isEmpty(sortStates)) {
|
||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
|
||||||
// Add sort.
|
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
|
||||||
|
|
||||||
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
||||||
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
|
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#constructBean()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected ProxyTarget constructBean() {
|
protected ProxyTarget constructBean() {
|
||||||
|
|
||||||
return new ProxyTarget();
|
return new ProxyTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
|
|
||||||
* int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected List<ProxyTarget> loadBeans(final int startIndex, final int count) {
|
protected List<ProxyTarget> loadBeans(final int startIndex, final int count) {
|
||||||
Slice<Target> targetBeans;
|
Slice<Target> targetBeans;
|
||||||
@@ -131,23 +124,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
return proxyTargetBeans;
|
return proxyTargetBeans;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
|
|
||||||
* .util.List, java.util.List, java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveBeans(final List<ProxyTarget> arg0, final List<ProxyTarget> arg1, final List<ProxyTarget> arg2) {
|
protected void saveBeans(final List<ProxyTarget> arg0, final List<ProxyTarget> arg1, final List<ProxyTarget> arg2) {
|
||||||
// CRUD operations on Target will be done through repository methods
|
// CRUD operations on Target will be done through repository methods
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
long size = 0;
|
long size = 0;
|
||||||
@@ -184,5 +165,4 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
}
|
}
|
||||||
return i18N;
|
return i18N;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
|
|||||||
public TargetFilterBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public TargetFilterBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
searchText = String.format("%%%s%%", searchText);
|
searchText = String.format("%%%s%%", searchText);
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ package org.eclipse.hawkbit.ui.filtermanagement;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -18,7 +20,6 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
|||||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
@@ -26,7 +27,6 @@ import org.vaadin.spring.events.EventBus;
|
|||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
@@ -78,8 +78,7 @@ public class TargetFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION,
|
return new LabelBuilder().name(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION).buildCaptionLabel();
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
private void buildLayout() {
|
||||||
@@ -121,14 +120,9 @@ public class TargetFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private TextField createSearchField() {
|
||||||
final TextField campSearchTextField = SPUIComponentProvider.getTextField(null, "filter-box",
|
final TextField campSearchTextField = new TextFieldBuilder("target.filter.search.text.Id")
|
||||||
"text-style filter-box-hide", false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
.createSearchField(event -> searchBy(event.getText()));
|
||||||
campSearchTextField.setId("target.filter.search.text.Id");
|
campSearchTextField.setWidth(500.0F, Unit.PIXELS);
|
||||||
campSearchTextField.setWidth(500.0f, Unit.PIXELS);
|
|
||||||
campSearchTextField.addTextChangeListener(event -> searchBy(event.getText()));
|
|
||||||
campSearchTextField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
|
||||||
// 1 seconds timeout.
|
|
||||||
campSearchTextField.setTextChangeTimeout(1000);
|
|
||||||
return campSearchTextField;
|
return campSearchTextField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +150,6 @@ public class TargetFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openSearchTextField() {
|
private void openSearchTextField() {
|
||||||
//
|
|
||||||
searchResetIcon.addStyleName(SPUIDefinitions.FILTER_RESET_ICON);
|
searchResetIcon.addStyleName(SPUIDefinitions.FILTER_RESET_ICON);
|
||||||
searchResetIcon.togleIcon(FontAwesome.TIMES);
|
searchResetIcon.togleIcon(FontAwesome.TIMES);
|
||||||
searchResetIcon.setData(Boolean.TRUE);
|
searchResetIcon.setData(Boolean.TRUE);
|
||||||
|
|||||||
@@ -21,13 +21,15 @@ import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
|||||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
@@ -113,10 +115,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Discard the changes and close the popup.
|
* Discard the changes and close the popup.
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
*/
|
||||||
protected void discard(final Button.ClickEvent event) {
|
protected void discard() {
|
||||||
UI.getCurrent().removeWindow(window);
|
UI.getCurrent().removeWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,20 +148,20 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
|
|||||||
|
|
||||||
createTagStr = i18n.get("label.create.tag");
|
createTagStr = i18n.get("label.create.tag");
|
||||||
updateTagStr = i18n.get("label.update.tag");
|
updateTagStr = i18n.get("label.update.tag");
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
comboLabel = new LabelBuilder().name(i18n.get("label.choose.tag")).buildLabel();
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
colorLabel = new LabelBuilder().name(i18n.get("label.choose.tag.color")).buildLabel();
|
||||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||||
|
|
||||||
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
tagName = new TextFieldBuilder().caption(i18n.get("textfield.name"))
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME, true, "", i18n.get("textfield.name"), true,
|
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true)
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
.prompt(i18n.get("textfield.name")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_NAME)
|
||||||
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
.buildTextComponent();
|
||||||
|
|
||||||
|
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
|
||||||
|
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC)
|
||||||
|
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_DESC)
|
||||||
|
.buildTextComponent();
|
||||||
|
|
||||||
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
|
||||||
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC, false, "", i18n.get("textfield.description"),
|
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
|
||||||
tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
|
|
||||||
tagDesc.setImmediate(true);
|
|
||||||
tagDesc.setNullRepresentation("");
|
tagDesc.setNullRepresentation("");
|
||||||
|
|
||||||
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", "", null, null, false, "",
|
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", "", null, null, false, "",
|
||||||
@@ -461,8 +461,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
|
|||||||
|
|
||||||
public CommonDialogWindow getWindow() {
|
public CommonDialogWindow getWindow() {
|
||||||
reset();
|
reset();
|
||||||
window = SPUIWindowDecorator.getWindow(getWindowCaption(), null, SPUIDefinitions.CREATE_UPDATE_WINDOW, this,
|
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(getWindowCaption()).content(this)
|
||||||
this::discard, null, mainLayout, i18n);
|
.cancelButtonClickListener(event -> discard()).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
|
||||||
|
|
||||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
@@ -475,7 +475,6 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
|
|||||||
} else {
|
} else {
|
||||||
updateEntity(findEntityByName());
|
updateEntity(findEntityByName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.layouts;
|
|||||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
@@ -51,8 +52,8 @@ public abstract class CreateUpdateTypeLayout<E extends NamedEntity> extends Abst
|
|||||||
|
|
||||||
createTagStr = i18n.get("label.create.type");
|
createTagStr = i18n.get("label.create.type");
|
||||||
updateTagStr = i18n.get("label.update.type");
|
updateTagStr = i18n.get("label.update.type");
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
comboLabel = new LabelBuilder().name(i18n.get("label.choose.type")).buildLabel();
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
colorLabel = new LabelBuilder().name(i18n.get("label.choose.type.color")).buildLabel();
|
||||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||||
|
|
||||||
tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false,
|
tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.management.actionhistory;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
import org.eclipse.hawkbit.ui.components.SPUIButton;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -17,7 +18,6 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
|||||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
@@ -63,8 +63,9 @@ public class ActionHistoryHeader extends VerticalLayout {
|
|||||||
private void buildComponent() {
|
private void buildComponent() {
|
||||||
// create default title - it will be shown even when no data is
|
// create default title - it will be shown even when no data is
|
||||||
// available
|
// available
|
||||||
titleOfActionHistory = SPUIComponentProvider.getLabel(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""),
|
titleOfActionHistory = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""))
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
.buildCaptionLabel();
|
||||||
|
|
||||||
titleOfActionHistory.setImmediate(true);
|
titleOfActionHistory.setImmediate(true);
|
||||||
titleOfActionHistory.setContentMode(ContentMode.HTML);
|
titleOfActionHistory.setContentMode(ContentMode.HTML);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
|
|||||||
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
|
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -36,7 +37,6 @@ import org.eclipse.hawkbit.ui.utils.I18N;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -357,7 +357,7 @@ public class ActionHistoryTable extends TreeTable {
|
|||||||
private Component getForcedColumn(final Object itemId) {
|
private Component getForcedColumn(final Object itemId) {
|
||||||
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
|
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
|
||||||
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
|
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
|
||||||
final Label actionLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label actionLabel = new LabelBuilder().name("").buildCaptionLabel();
|
||||||
actionLabel.setContentMode(ContentMode.HTML);
|
actionLabel.setContentMode(ContentMode.HTML);
|
||||||
actionLabel.setStyleName("action-history-table-col-forced-label");
|
actionLabel.setStyleName("action-history-table-col-forced-label");
|
||||||
if (actionWithActiveStatus != null && actionWithActiveStatus.getActionType() == ActionType.FORCED) {
|
if (actionWithActiveStatus != null && actionWithActiveStatus.getActionType() == ActionType.FORCED) {
|
||||||
@@ -522,7 +522,7 @@ public class ActionHistoryTable extends TreeTable {
|
|||||||
* @return Label as UI
|
* @return Label as UI
|
||||||
*/
|
*/
|
||||||
private Label getStatusIcon(final Action.Status status) {
|
private Label getStatusIcon(final Action.Status status) {
|
||||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label label = new LabelBuilder().name("").buildLabel();
|
||||||
final String statusIconPending = "statusIconPending";
|
final String statusIconPending = "statusIconPending";
|
||||||
label.setContentMode(ContentMode.HTML);
|
label.setContentMode(ContentMode.HTML);
|
||||||
if (Action.Status.FINISHED == status) {
|
if (Action.Status.FINISHED == status) {
|
||||||
@@ -576,13 +576,11 @@ public class ActionHistoryTable extends TreeTable {
|
|||||||
final long currentTimeMillis = System.currentTimeMillis();
|
final long currentTimeMillis = System.currentTimeMillis();
|
||||||
|
|
||||||
final HorizontalLayout hLayout = new HorizontalLayout();
|
final HorizontalLayout hLayout = new HorizontalLayout();
|
||||||
final Label autoForceLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label autoForceLabel = new LabelBuilder().name("").id("action.history.table.timedforceId").buildLabel();
|
||||||
|
|
||||||
actionLabel.setValue(FontAwesome.BOLT.getHtml());
|
actionLabel.setValue(FontAwesome.BOLT.getHtml());
|
||||||
autoForceLabel.setContentMode(ContentMode.HTML);
|
autoForceLabel.setContentMode(ContentMode.HTML);
|
||||||
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
|
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
|
||||||
// setted Id for TimedForced.
|
|
||||||
autoForceLabel.setId("action.history.table.timedforceId");
|
|
||||||
|
|
||||||
hLayout.addComponent(actionLabel);
|
hLayout.addComponent(actionLabel);
|
||||||
hLayout.addComponent(autoForceLabel);
|
hLayout.addComponent(autoForceLabel);
|
||||||
@@ -608,8 +606,8 @@ public class ActionHistoryTable extends TreeTable {
|
|||||||
* as String
|
* as String
|
||||||
* @return Labeal as UI
|
* @return Labeal as UI
|
||||||
*/
|
*/
|
||||||
private Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) {
|
private static Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) {
|
||||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label label = new LabelBuilder().name("").buildLabel();
|
||||||
label.setContentMode(ContentMode.HTML);
|
label.setContentMode(ContentMode.HTML);
|
||||||
if (SPUIDefinitions.SCHEDULED.equals(activeValue)) {
|
if (SPUIDefinitions.SCHEDULED.equals(activeValue)) {
|
||||||
label.setDescription("Scheduled");
|
label.setDescription("Scheduled");
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
|||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
|
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
|
||||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||||
@@ -126,16 +128,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
|||||||
* Create required UI components.
|
* Create required UI components.
|
||||||
*/
|
*/
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
distNameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
distNameTextField = createTextField("textfield.name", SPUIComponentIdProvider.DIST_ADD_NAME);
|
||||||
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
distVersionTextField = createTextField("textfield.version", SPUIComponentIdProvider.DIST_ADD_VERSION);
|
||||||
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
|
|
||||||
distNameTextField.setNullRepresentation("");
|
|
||||||
|
|
||||||
distVersionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
|
||||||
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
|
|
||||||
distVersionTextField.setNullRepresentation("");
|
|
||||||
|
|
||||||
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, "",
|
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, "",
|
||||||
false, "", i18n.get("label.combobox.type"));
|
false, "", i18n.get("label.combobox.type"));
|
||||||
@@ -144,10 +138,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
|||||||
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
||||||
populateDistSetTypeNameCombo();
|
populateDistSetTypeNameCombo();
|
||||||
|
|
||||||
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
|
||||||
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIComponentIdProvider.DIST_ADD_DESC)
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
.buildTextComponent();
|
||||||
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
|
|
||||||
descTextArea.setNullRepresentation("");
|
descTextArea.setNullRepresentation("");
|
||||||
|
|
||||||
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
|
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
|
||||||
@@ -156,6 +149,13 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
|||||||
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
|
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextField createTextField(final String in18Key, final String id) {
|
||||||
|
final TextField buildTextField = new TextFieldBuilder().caption(i18n.get(in18Key)).required(true)
|
||||||
|
.prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
|
||||||
|
buildTextField.setNullRepresentation("");
|
||||||
|
return buildTextField;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the LazyQueryContainer instance for DistributionSetTypes.
|
* Get the LazyQueryContainer instance for DistributionSetTypes.
|
||||||
*
|
*
|
||||||
@@ -335,8 +335,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
|||||||
resetComponents();
|
resetComponents();
|
||||||
populateDistSetTypeNameCombo();
|
populateDistSetTypeNameCombo();
|
||||||
populateValuesOfDistribution(editDistId);
|
populateValuesOfDistribution(editDistId);
|
||||||
window = SPUIWindowDecorator.getWindow(i18n.get("caption.add.new.dist"), null,
|
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.dist"))
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
|
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
|
||||||
|
|
||||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
|||||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||||
|
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||||
distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
||||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||||
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
||||||
|
|||||||
@@ -120,12 +120,10 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* RESET.
|
* RESET.
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void discard(final ClickEvent event) {
|
public void discard() {
|
||||||
super.discard(event);
|
super.discard();
|
||||||
resetDistTagValues();
|
resetDistTagValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isNoTagSateSelected() {
|
protected boolean isNoTagStateSelected() {
|
||||||
return managementUIState.getDistributionTableFilters().isNoTagSelected();
|
return managementUIState.getDistributionTableFilters().isNoTagSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.vaadin.spring.events.EventBus;
|
|||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
import com.vaadin.shared.ui.label.ContentMode;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -250,7 +251,7 @@ public class CountMessageLabel extends Label {
|
|||||||
* @return String as msg.
|
* @return String as msg.
|
||||||
*/
|
*/
|
||||||
private static String getSerachMsg(final String searchTxt, final String param) {
|
private static String getSerachMsg(final String searchTxt, final String param) {
|
||||||
return HawkbitCommonUtil.checkValidString(searchTxt) ? param : HawkbitCommonUtil.SP_STRING_SPACE;
|
return Strings.isNullOrEmpty(searchTxt) ? HawkbitCommonUtil.SP_STRING_SPACE : param;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -390,7 +390,6 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString()));
|
eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void addNewTarget(final String controllerId, final String name) {
|
private void addNewTarget(final String controllerId, final String name) {
|
||||||
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
|
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
|
||||||
@@ -407,6 +406,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void setTargetValues(final Target target, final String name, final String description) {
|
private static void setTargetValues(final Target target, final String name, final String description) {
|
||||||
if (null == name) {
|
if (null == name) {
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ import org.eclipse.hawkbit.repository.model.Target;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||||
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
|
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
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.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
@@ -39,8 +39,8 @@ import com.vaadin.ui.CustomComponent;
|
|||||||
import com.vaadin.ui.FormLayout;
|
import com.vaadin.ui.FormLayout;
|
||||||
import com.vaadin.ui.TextArea;
|
import com.vaadin.ui.TextArea;
|
||||||
import com.vaadin.ui.TextField;
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add and Update Target.
|
* Add and Update Target.
|
||||||
@@ -83,30 +83,22 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
/* Textfield for controller Id */
|
controllerIDTextField = createTextField("prompt.target.id", SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
|
||||||
controllerIDTextField = SPUIComponentProvider.getTextField(i18n.get("prompt.target.id"), "",
|
nameTextField = createTextField("textfield.name", SPUIComponentIdProvider.TARGET_ADD_NAME);
|
||||||
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("prompt.target.id"), true,
|
nameTextField.setRequired(false);
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
controllerIDTextField.setId(SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
|
|
||||||
/* Textfield for target name */
|
|
||||||
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
|
||||||
false, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
nameTextField.setId(SPUIComponentIdProvider.TARGET_ADD_NAME);
|
|
||||||
|
|
||||||
/* Textarea for target description */
|
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
|
||||||
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIComponentIdProvider.TARGET_ADD_DESC)
|
||||||
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
|
.buildTextComponent();
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
|
||||||
descTextArea.setId(SPUIComponentIdProvider.TARGET_ADD_DESC);
|
|
||||||
descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
private TextField createTextField(final String in18Key, final String id) {
|
||||||
|
return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key))
|
||||||
|
.immediate(true).id(id).buildTextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
private void buildLayout() {
|
||||||
* The main layout of the window contains mandatory info, textboxes
|
|
||||||
* (controller Id, name & description) and action buttons layout
|
|
||||||
*/
|
|
||||||
setSizeUndefined();
|
setSizeUndefined();
|
||||||
formLayout = new FormLayout();
|
formLayout = new FormLayout();
|
||||||
formLayout.addComponent(controllerIDTextField);
|
formLayout.addComponent(controllerIDTextField);
|
||||||
@@ -160,8 +152,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
|
|
||||||
public Window getWindow() {
|
public Window getWindow() {
|
||||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||||
window = SPUIWindowDecorator.getWindow(i18n.get("caption.add.new.target"), null,
|
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.target"))
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
|
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
|
||||||
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -169,9 +161,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
if (editTarget) {
|
if (editTarget) {
|
||||||
updateTarget();
|
updateTarget();
|
||||||
} else {
|
} else {
|
||||||
addNewTarget();
|
UI.getCurrent().access(() -> addNewTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.targettable;
|
package org.eclipse.hawkbit.ui.management.targettable;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.ASC;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,7 +36,6 @@ import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
|
||||||
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
||||||
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||||
|
|
||||||
@@ -39,11 +44,12 @@ import com.google.common.base.Strings;
|
|||||||
/**
|
/**
|
||||||
* Simple implementation of generics bean query which dynamically loads a batch
|
* Simple implementation of generics bean query which dynamically loads a batch
|
||||||
* of beans.
|
* of beans.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5645680058303167558L;
|
private static final long serialVersionUID = -5645680058303167558L;
|
||||||
private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
|
|
||||||
|
private Sort sort = new Sort(TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
|
||||||
private transient Collection<TargetUpdateStatus> status = null;
|
private transient Collection<TargetUpdateStatus> status = null;
|
||||||
private String[] targetTags = null;
|
private String[] targetTags = null;
|
||||||
private Long distributionId = null;
|
private Long distributionId = null;
|
||||||
@@ -69,9 +75,10 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
*/
|
*/
|
||||||
public TargetBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public TargetBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortIds, final boolean[] sortStates) {
|
final Object[] sortIds, final boolean[] sortStates) {
|
||||||
|
|
||||||
super(definition, queryConfig, sortIds, sortStates);
|
super(definition, queryConfig, sortIds, sortStates);
|
||||||
|
|
||||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
if (isNotNullOrEmpty(queryConfig)) {
|
||||||
status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS);
|
status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS);
|
||||||
targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
||||||
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
||||||
@@ -84,12 +91,12 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION);
|
pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
if (!isEmpty(sortStates)) {
|
||||||
// Initalize Sor
|
|
||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
|
||||||
// Add sort.
|
|
||||||
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
||||||
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
|
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,5 +227,4 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
}
|
}
|
||||||
return i18N;
|
return i18N;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import org.eclipse.hawkbit.repository.DeploymentManagement;
|
|||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.ui.UiProperties;
|
import org.eclipse.hawkbit.ui.UiProperties;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery;
|
import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery;
|
||||||
@@ -192,10 +194,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea getDescriptionTextArea() {
|
private TextArea getDescriptionTextArea() {
|
||||||
final TextArea description = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"),
|
final TextArea description = new TextAreaBuilder().caption(i18n.get("textfield.description"))
|
||||||
"text-area-style", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
|
.style("text-area-style").prompt(i18n.get("textfield.description")).immediate(true)
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
.id(SPUIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent();
|
||||||
description.setId(SPUIComponentIdProvider.BULK_UPLOAD_DESC);
|
|
||||||
description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
description.setWidth("100%");
|
description.setWidth("100%");
|
||||||
return description;
|
return description;
|
||||||
@@ -358,10 +359,11 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
*/
|
*/
|
||||||
public Window getWindow() {
|
public Window getWindow() {
|
||||||
managementUIState.setBulkUploadWindowMinimised(false);
|
managementUIState.setBulkUploadWindowMinimised(false);
|
||||||
bulkUploadWindow = SPUIComponentProvider.getWindow("", null, SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
|
||||||
|
bulkUploadWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption("").content(this)
|
||||||
|
.buildWindow();
|
||||||
bulkUploadWindow.addStyleName("bulk-upload-window");
|
bulkUploadWindow.addStyleName("bulk-upload-window");
|
||||||
bulkUploadWindow.setImmediate(true);
|
bulkUploadWindow.setImmediate(true);
|
||||||
bulkUploadWindow.setContent(this);
|
|
||||||
if (isNoBulkUploadInProgress()) {
|
if (isNoBulkUploadInProgress()) {
|
||||||
bulkUploader.getUpload().setEnabled(true);
|
bulkUploader.getUpload().setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.targettable;
|
package org.eclipse.hawkbit.ui.management.targettable;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_DISTRIBUTION;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TAG;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TEXT;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TAG;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||||
|
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TEXT;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -239,12 +248,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
return targetTableContainer;
|
return targetTableContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties
|
|
||||||
* (com.vaadin.data.Container )
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void addContainerProperties(final Container container) {
|
protected void addContainerProperties(final Container container) {
|
||||||
HawkbitCommonUtil.addTargetTableContainerProperties(container);
|
HawkbitCommonUtil.addTargetTableContainerProperties(container);
|
||||||
@@ -266,10 +269,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object getItemIdToSelect() {
|
protected Object getItemIdToSelect() {
|
||||||
if (managementUIState.getSelectedTargetIdName().isPresent()) {
|
return managementUIState.getSelectedTargetIdName().orElse(null);
|
||||||
return managementUIState.getSelectedTargetIdName().get();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -306,7 +306,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
|
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
|
||||||
}
|
}
|
||||||
return columnList;
|
return columnList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -440,14 +439,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPinned(final String targetId) {
|
private boolean isPinned(final String targetId) {
|
||||||
boolean result;
|
return managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
||||||
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
|
||||||
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) {
|
|
||||||
result = true;
|
|
||||||
} else {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -464,7 +457,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
} else {
|
} else {
|
||||||
unPinTarget(event.getButton());
|
unPinTarget(event.getButton());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -519,9 +511,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set style of target table.
|
* Set style of target table.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
|
||||||
private void styleTargetTable() {
|
private void styleTargetTable() {
|
||||||
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
||||||
}
|
}
|
||||||
@@ -533,7 +523,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
&& isNoTagAssigned(event)) {
|
&& isNoTagAssigned(event)) {
|
||||||
tagAssignment(event);
|
tagAssignment(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
|
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
|
||||||
@@ -730,24 +719,22 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkFilterEvent(final TargetFilterEvent filterEvent) {
|
private static boolean checkFilterEvent(final TargetFilterEvent filterEvent) {
|
||||||
boolean isFilterEvent;
|
return isNormalFilter(filterEvent) || isRemoveFilterEvent(filterEvent) || isStatusFilterEvent(filterEvent);
|
||||||
boolean isFilter;
|
}
|
||||||
boolean isRemoveFilters;
|
|
||||||
boolean isStatusFilter;
|
|
||||||
isFilter = filterEvent == TargetFilterEvent.FILTER_BY_TEXT || filterEvent == TargetFilterEvent.FILTER_BY_TAG
|
|
||||||
|| filterEvent == TargetFilterEvent.FILTER_BY_DISTRIBUTION
|
|
||||||
|| filterEvent == TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
|
|
||||||
|
|
||||||
isRemoveFilters = filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TEXT
|
private static boolean isStatusFilterEvent(final TargetFilterEvent filterEvent) {
|
||||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TAG
|
return filterEvent == TargetFilterEvent.FILTER_BY_STATUS
|
||||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION
|
|
||||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
|
||||||
isStatusFilter = filterEvent == TargetFilterEvent.FILTER_BY_STATUS
|
|
||||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_STATUS;
|
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
isFilterEvent = isFilter || isRemoveFilters || isStatusFilter;
|
private static boolean isRemoveFilterEvent(final TargetFilterEvent filterEvent) {
|
||||||
|
return filterEvent == REMOVE_FILTER_BY_TEXT || filterEvent == REMOVE_FILTER_BY_TAG
|
||||||
|
|| filterEvent == REMOVE_FILTER_BY_DISTRIBUTION || filterEvent == REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||||
|
}
|
||||||
|
|
||||||
return isFilterEvent;
|
private static boolean isNormalFilter(final TargetFilterEvent filterEvent) {
|
||||||
|
return filterEvent == FILTER_BY_TEXT || filterEvent == FILTER_BY_TAG || filterEvent == FILTER_BY_DISTRIBUTION
|
||||||
|
|| filterEvent == FILTER_BY_TARGET_FILTER_QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) {
|
private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) {
|
||||||
@@ -760,14 +747,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
|
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemId
|
|
||||||
* @param propertyId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String createTargetTableStyle(final Object itemId, final Object propertyId) {
|
private String createTargetTableStyle(final Object itemId, final Object propertyId) {
|
||||||
if (null == propertyId) {
|
if (null == propertyId) {
|
||||||
final Item item = getItem(itemId);
|
final Item item = getItem(itemId);
|
||||||
@@ -778,7 +759,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
return getTargetTableStyle(assignedDistributionSetId, installedDistributionSetId);
|
return getTargetTableStyle(assignedDistributionSetId, installedDistributionSetId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void styleTargetTableOnPinning() {
|
private void styleTargetTableOnPinning() {
|
||||||
@@ -803,12 +783,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To add new target to the table on Top.
|
|
||||||
*
|
|
||||||
* @param newTarget
|
|
||||||
* as reference
|
|
||||||
*/
|
|
||||||
private void refreshTargets() {
|
private void refreshTargets() {
|
||||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||||
final int size = targetContainer.size();
|
final int size = targetContainer.size();
|
||||||
@@ -834,8 +808,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
final Item item = targetContainer.getItem(targetIdName);
|
final Item item = targetContainer.getItem(targetIdName);
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName());
|
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName());
|
||||||
if (targetInfo != null) {
|
if (targetInfo != null) {
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP)
|
||||||
HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
|
.setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
|
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -869,9 +843,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// workaround until push is available for action history, re-select
|
// workaround until push is available for action history, re-select
|
||||||
// the
|
// the updated target so the action history gets refreshed.
|
||||||
// updated target so
|
|
||||||
// the action history gets refreshed.
|
|
||||||
if (isLastSelectedTarget(targetIdName)) {
|
if (isLastSelectedTarget(targetIdName)) {
|
||||||
lastSelectedTarget = target;
|
lastSelectedTarget = target;
|
||||||
}
|
}
|
||||||
@@ -884,13 +856,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onTargetUpdateEvents(final List<TargetUpdatedEvent> events) {
|
||||||
private void onTargetUpdateEvents(List<TargetUpdatedEvent> events) {
|
|
||||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||||
boolean shoulTargetsUpdated = false;
|
boolean shoulTargetsUpdated = false;
|
||||||
Target lastSelectedTarget = null;
|
Target lastSelectedTarget = null;
|
||||||
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
|
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
|
||||||
Target target = targetUpdatedEvent.getEntity();
|
final Target target = targetUpdatedEvent.getEntity();
|
||||||
final TargetIdName targetIdName = target.getTargetIdName();
|
final TargetIdName targetIdName = target.getTargetIdName();
|
||||||
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
||||||
shoulTargetsUpdated = true;
|
shoulTargetsUpdated = true;
|
||||||
@@ -911,8 +882,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onTargetCreatedEvents() {
|
private void onTargetCreatedEvents() {
|
||||||
refreshTargets();
|
refreshTargets();
|
||||||
}
|
}
|
||||||
@@ -935,7 +904,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
|
|
||||||
// As Vaadin Table only returns the current ItemIds which are visible
|
// As Vaadin Table only returns the current ItemIds which are visible
|
||||||
// you don't need to search explicit for them.
|
// you don't need to search explicit for them.
|
||||||
setValue(getItemIds());
|
setValue(getItemIds());
|
||||||
@@ -957,7 +925,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
* Set total target count and count of targets truncated in target table.
|
* Set total target count and count of targets truncated in target table.
|
||||||
*/
|
*/
|
||||||
private void resetTargetCountDetails() {
|
private void resetTargetCountDetails() {
|
||||||
final long size;
|
|
||||||
final long totalTargetsCount = getTotalTargetsCount();
|
final long totalTargetsCount = getTotalTargetsCount();
|
||||||
managementUIState.setTargetsCountAll(totalTargetsCount);
|
managementUIState.setTargetsCountAll(totalTargetsCount);
|
||||||
|
|
||||||
@@ -965,11 +932,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
String[] targetTags = null;
|
String[] targetTags = null;
|
||||||
Long distributionId = null;
|
Long distributionId = null;
|
||||||
String searchText = null;
|
String searchText = null;
|
||||||
Boolean noTagClicked;
|
|
||||||
Long pinnedDistId = null;
|
Long pinnedDistId = null;
|
||||||
|
|
||||||
if (isFilteredByTags()) {
|
if (isFilteredByTags()) {
|
||||||
targetTags = (String[]) managementUIState.getTargetTableFilters().getClickedTargetTags().toArray();
|
targetTags = managementUIState.getTargetTableFilters().getClickedTargetTags().toArray(new String[0]);
|
||||||
}
|
}
|
||||||
if (isFilteredByStatus()) {
|
if (isFilteredByStatus()) {
|
||||||
status = managementUIState.getTargetTableFilters().getClickedStatusTargetTags();
|
status = managementUIState.getTargetTableFilters().getClickedStatusTargetTags();
|
||||||
@@ -980,12 +946,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
if (isFilteredByText()) {
|
if (isFilteredByText()) {
|
||||||
searchText = String.format("%%%s%%", managementUIState.getTargetTableFilters().getSearchText().get());
|
searchText = String.format("%%%s%%", managementUIState.getTargetTableFilters().getSearchText().get());
|
||||||
}
|
}
|
||||||
noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
|
final boolean noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
|
||||||
if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
|
if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
|
||||||
pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
|
pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
final long size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
||||||
noTagClicked, pinnedDistId);
|
noTagClicked, pinnedDistId);
|
||||||
|
|
||||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
|
||||||
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
|
||||||
@@ -20,7 +21,6 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
|||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
@@ -84,8 +84,8 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
|
|||||||
addStyleName("target-status-filters");
|
addStyleName("target-status-filters");
|
||||||
setMargin(false);
|
setMargin(false);
|
||||||
|
|
||||||
final Label targetFilterStatusLabel = SPUIComponentProvider.getLabel(i18n.get("label.filter.by.status"),
|
final Label targetFilterStatusLabel = new LabelBuilder().name(i18n.get("label.filter.by.status")).buildLabel();
|
||||||
SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
|
||||||
targetFilterStatusLabel.addStyleName("target-status-filters-title");
|
targetFilterStatusLabel.addStyleName("target-status-filters-title");
|
||||||
|
|
||||||
addComponent(targetFilterStatusLabel);
|
addComponent(targetFilterStatusLabel);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isNoTagSateSelected() {
|
protected boolean isNoTagStateSelected() {
|
||||||
return managementUIState.getTargetTableFilters().isNoTagSelected();
|
return managementUIState.getTargetTableFilters().isNoTagSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.UIScope;
|
import com.vaadin.spring.annotation.UIScope;
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.Button.ClickListener;
|
import com.vaadin.ui.Button.ClickListener;
|
||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.CustomComponent;
|
import com.vaadin.ui.CustomComponent;
|
||||||
@@ -52,14 +53,11 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
* A responsive menu component providing user information and the controls for
|
* A responsive menu component providing user information and the controls for
|
||||||
* primary navigation between the views.
|
* primary navigation between the views.
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
|
||||||
@UIScope
|
@UIScope
|
||||||
|
@SpringComponent
|
||||||
public final class DashboardMenu extends CustomComponent {
|
public final class DashboardMenu extends CustomComponent {
|
||||||
|
|
||||||
private static final String STYLE_VISIBLE = "valo-menu-visible";
|
private static final String ID = "dashboard-menu";
|
||||||
public static final String ID = "dashboard-menu";
|
|
||||||
public static final String REPORTS_BADGE_ID = "dashboard-menu-reports-badge";
|
|
||||||
public static final String NOTIFICATIONS_BADGE_ID = "dashboard-menu-notifications-badge";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
@@ -208,13 +206,7 @@ public final class DashboardMenu extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Component buildToggleButton() {
|
private Component buildToggleButton() {
|
||||||
final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> {
|
final Button valoMenuToggleButton = new Button("Menu", new MenuToggleClickListenerMyClickListener());
|
||||||
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
|
|
||||||
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
|
|
||||||
} else {
|
|
||||||
getCompositionRoot().addStyleName(STYLE_VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
valoMenuToggleButton.setIcon(FontAwesome.LIST);
|
valoMenuToggleButton.setIcon(FontAwesome.LIST);
|
||||||
valoMenuToggleButton.addStyleName("valo-menu-toggle");
|
valoMenuToggleButton.addStyleName("valo-menu-toggle");
|
||||||
valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
||||||
@@ -329,15 +321,28 @@ public final class DashboardMenu extends CustomComponent {
|
|||||||
return accessDeined;
|
return accessDeined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MenuToggleClickListenerMyClickListener implements ClickListener {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final String STYLE_VISIBLE = "valo-menu-visible";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buttonClick(final ClickEvent event) {
|
||||||
|
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
|
||||||
|
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
|
||||||
|
} else {
|
||||||
|
getCompositionRoot().addStyleName(STYLE_VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An menu item button wrapper for the dashboard menu item.
|
* An menu item button wrapper for the dashboard menu item.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final class ValoMenuItemButton extends Button {
|
public static final class ValoMenuItemButton extends Button {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final String STYLE_SELECTED = "selected";
|
private static final String STYLE_SELECTED = "selected";
|
||||||
|
|
||||||
private final DashboardMenuItem view;
|
private final DashboardMenuItem view;
|
||||||
@@ -358,7 +363,6 @@ public final class DashboardMenu extends CustomComponent {
|
|||||||
/* Avoid double click */
|
/* Avoid double click */
|
||||||
setDisableOnClick(true);
|
setDisableOnClick(true);
|
||||||
addClickListener(event -> event.getComponent().getUI().getNavigator().navigateTo(view.getViewName()));
|
addClickListener(event -> event.getComponent().getUI().getNavigator().navigateTo(view.getViewName()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class DistributionBarHelper {
|
public final class DistributionBarHelper {
|
||||||
|
private static final String HTML_DIV_END = "</div>";
|
||||||
private static final int PARENT_SIZE_IN_PCT = 100;
|
private static final int PARENT_SIZE_IN_PCT = 100;
|
||||||
private static final double MINIMUM_PART_SIZE = 10;
|
private static final double MINIMUM_PART_SIZE = 10;
|
||||||
private static final String DISTRIBUTION_BAR_PART_MAIN_STYLE = GwtDistributionBar.CLASSNAME + "-part";
|
private static final String DISTRIBUTION_BAR_PART_MAIN_STYLE = GwtDistributionBar.CLASSNAME + "-part";
|
||||||
@@ -38,23 +39,23 @@ public final class DistributionBarHelper {
|
|||||||
*
|
*
|
||||||
* @return string of format "status1:count,status2:count"
|
* @return string of format "status1:count,status2:count"
|
||||||
*/
|
*/
|
||||||
public static String getDistributionBarAsHTMLString(Map<Status, Long> statusTotalCountMap) {
|
public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap) {
|
||||||
StringBuilder htmlString = new StringBuilder();
|
final StringBuilder htmlString = new StringBuilder();
|
||||||
Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
|
final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
|
||||||
Long totalValue = getTotalSizes(statusTotalCountMap);
|
final Long totalValue = getTotalSizes(statusTotalCountMap);
|
||||||
if (statusMapWithNonZeroValues.size() <= 0) {
|
if (statusMapWithNonZeroValues.size() <= 0) {
|
||||||
return getUnintialisedBar();
|
return getUnintialisedBar();
|
||||||
}
|
}
|
||||||
int partIndex = 1;
|
int partIndex = 1;
|
||||||
htmlString.append(getParentDivStart());
|
htmlString.append(getParentDivStart());
|
||||||
for (Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
|
for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
|
||||||
if (entry.getValue() > 0) {
|
if (entry.getValue() > 0) {
|
||||||
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
|
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
|
||||||
statusMapWithNonZeroValues.size()));
|
statusMapWithNonZeroValues.size()));
|
||||||
partIndex++;
|
partIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
htmlString.append(getParentDivEnd());
|
htmlString.append(HTML_DIV_END);
|
||||||
return htmlString.toString();
|
return htmlString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ public final class DistributionBarHelper {
|
|||||||
* map with status and count
|
* map with status and count
|
||||||
* @return map with non zero values
|
* @return map with non zero values
|
||||||
*/
|
*/
|
||||||
public static Map<Status, Long> getStatusMapWithNonZeroValues(Map<Status, Long> statusTotalCountMap) {
|
public static Map<Status, Long> getStatusMapWithNonZeroValues(final Map<Status, Long> statusTotalCountMap) {
|
||||||
return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0)
|
return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0)
|
||||||
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
|
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
|
||||||
}
|
}
|
||||||
@@ -77,19 +78,20 @@ public final class DistributionBarHelper {
|
|||||||
* map with status and count details
|
* map with status and count details
|
||||||
* @return tool tip
|
* @return tool tip
|
||||||
*/
|
*/
|
||||||
public static String getTooltip(Map<Status, Long> statusCountMap) {
|
public static String getTooltip(final Map<Status, Long> statusCountMap) {
|
||||||
Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper.getStatusMapWithNonZeroValues(statusCountMap);
|
final Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper
|
||||||
StringBuilder tooltip = new StringBuilder();
|
.getStatusMapWithNonZeroValues(statusCountMap);
|
||||||
for (Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
|
final StringBuilder tooltip = new StringBuilder();
|
||||||
|
for (final Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
|
||||||
tooltip.append(entry.getKey().toString().toLowerCase()).append(" : ").append(entry.getValue())
|
tooltip.append(entry.getKey().toString().toLowerCase()).append(" : ").append(entry.getValue())
|
||||||
.append("<br>");
|
.append("<br>");
|
||||||
}
|
}
|
||||||
return tooltip.toString();
|
return tooltip.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPartStyle(int partIndex, int noOfParts, String customStyle) {
|
private static String getPartStyle(final int partIndex, final int noOfParts, final String customStyle) {
|
||||||
StringBuilder mainStyle = new StringBuilder();
|
final StringBuilder mainStyle = new StringBuilder();
|
||||||
StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
|
final StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
|
||||||
if (noOfParts == 1) {
|
if (noOfParts == 1) {
|
||||||
styleName.append("-only");
|
styleName.append("-only");
|
||||||
} else if (partIndex == 1) {
|
} else if (partIndex == 1) {
|
||||||
@@ -108,15 +110,16 @@ public final class DistributionBarHelper {
|
|||||||
return mainStyle.toString();
|
return mainStyle.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPartWidth(Long value, Long totalValue, int noOfParts) {
|
private static String getPartWidth(final Long value, final Long totalValue, final int noOfParts) {
|
||||||
final double minTotalSize = MINIMUM_PART_SIZE * noOfParts;
|
final double minTotalSize = MINIMUM_PART_SIZE * noOfParts;
|
||||||
final double availableSize = PARENT_SIZE_IN_PCT - minTotalSize;
|
final double availableSize = PARENT_SIZE_IN_PCT - minTotalSize;
|
||||||
double val = MINIMUM_PART_SIZE + (double) value / totalValue * availableSize;
|
final double val = MINIMUM_PART_SIZE + (double) value / totalValue * availableSize;
|
||||||
return String.format("%.3f", val) + "%";
|
return String.format("%.3f", val) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPart(int partIndex, Status status, Long value, Long totalValue, int noOfParts) {
|
private static String getPart(final int partIndex, final Status status, final Long value, final Long totalValue,
|
||||||
String partValue = status.toString().toLowerCase();
|
final int noOfParts) {
|
||||||
|
final String partValue = status.toString().toLowerCase();
|
||||||
return "<div class=\"" + getPartStyle(partIndex, noOfParts, partValue) + "\" style=\"width: "
|
return "<div class=\"" + getPartStyle(partIndex, noOfParts, partValue) + "\" style=\"width: "
|
||||||
+ getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\""
|
+ getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\""
|
||||||
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>";
|
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>";
|
||||||
@@ -127,9 +130,9 @@ public final class DistributionBarHelper {
|
|||||||
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">uninitialized</span></div>";
|
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">uninitialized</span></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Long getTotalSizes(Map<Status, Long> statusTotalCountMap) {
|
private static Long getTotalSizes(final Map<Status, Long> statusTotalCountMap) {
|
||||||
Long total = 0L;
|
Long total = 0L;
|
||||||
for (Long value : statusTotalCountMap.values()) {
|
for (final Long value : statusTotalCountMap.values()) {
|
||||||
total = total + value;
|
total = total + value;
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
@@ -139,8 +142,4 @@ public final class DistributionBarHelper {
|
|||||||
return "<div class=\"" + GwtDistributionBar.CLASSNAME
|
return "<div class=\"" + GwtDistributionBar.CLASSNAME
|
||||||
+ "\" style=\"width: 100%; height: 100%;\" id=\"rollout.status.progress.bar.id\">";
|
+ "\" style=\"width: 100%; height: 100%;\" id=\"rollout.status.progress.bar.id\">";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getParentDivEnd() {
|
|
||||||
return "</div>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ import org.eclipse.hawkbit.ui.UiProperties;
|
|||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
|
||||||
import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery;
|
import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery;
|
||||||
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout;
|
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout;
|
||||||
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
|
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
|
||||||
@@ -166,9 +169,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
|
|
||||||
public CommonDialogWindow getWindow() {
|
public CommonDialogWindow getWindow() {
|
||||||
resetComponents();
|
resetComponents();
|
||||||
final CommonDialogWindow commonDialogWindow = SPUIWindowDecorator.getWindow(
|
final CommonDialogWindow commonDialogWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||||
i18n.get("caption.configure.rollout"), null, SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null,
|
.caption(i18n.get("caption.configure.rollout")).content(this).layout(this).i18n(i18n)
|
||||||
uiProperties.getLinks().getDocumentation().getRolloutView(), this, i18n);
|
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView()).buildCommonDialogWindow();
|
||||||
commonDialogWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
commonDialogWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -280,15 +283,23 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label getLabel(final String key) {
|
private Label getLabel(final String key) {
|
||||||
return SPUIComponentProvider.getLabel(i18n.get(key), SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
return new LabelBuilder().name(i18n.get(key)).buildLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField getTextfield(final String key) {
|
private TextField createTextField(final String in18Key, final String id) {
|
||||||
return SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get(key), true,
|
return new TextFieldBuilder().prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label getPercentHintLabel() {
|
private TextField createIntegerTextField(final String in18Key, final String id) {
|
||||||
|
final TextField textField = createTextField(in18Key, id);
|
||||||
|
textField.setNullRepresentation("");
|
||||||
|
textField.setConverter(new StringToIntegerConverter());
|
||||||
|
textField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
|
||||||
|
textField.setSizeUndefined();
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Label getPercentHintLabel() {
|
||||||
final Label percentSymbol = new Label("%");
|
final Label percentSymbol = new Label("%");
|
||||||
percentSymbol.addStyleName(ValoTheme.LABEL_TINY + " " + ValoTheme.LABEL_BOLD);
|
percentSymbol.addStyleName(ValoTheme.LABEL_TINY + " " + ValoTheme.LABEL_BOLD);
|
||||||
percentSymbol.setSizeUndefined();
|
percentSymbol.setSizeUndefined();
|
||||||
@@ -304,31 +315,31 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
populateTargetFilterQuery();
|
populateTargetFilterQuery();
|
||||||
|
|
||||||
noOfGroups = createNoOfGroupsField();
|
noOfGroups = createNoOfGroupsField();
|
||||||
groupSizeLabel = createGroupSizeLabel();
|
groupSizeLabel = createCountLabel();
|
||||||
triggerThreshold = createTriggerThreshold();
|
triggerThreshold = createTriggerThreshold();
|
||||||
errorThreshold = createErrorThreshold();
|
errorThreshold = createErrorThreshold();
|
||||||
description = createDescription();
|
description = createDescription();
|
||||||
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
|
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
|
||||||
setDefaultSaveStartGroupOption();
|
setDefaultSaveStartGroupOption();
|
||||||
actionTypeOptionGroupLayout.selectDefaultOption();
|
actionTypeOptionGroupLayout.selectDefaultOption();
|
||||||
totalTargetsLabel = createTotalTargetsLabel();
|
totalTargetsLabel = createCountLabel();
|
||||||
targetFilterQuery = createTargetFilterQuery();
|
targetFilterQuery = createTargetFilterQuery();
|
||||||
actionTypeOptionGroupLayout.addStyleName(SPUIStyleDefinitions.ROLLOUT_ACTION_TYPE_LAYOUT);
|
actionTypeOptionGroupLayout.addStyleName(SPUIStyleDefinitions.ROLLOUT_ACTION_TYPE_LAYOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label createGroupSizeLabel() {
|
private static Label createCountLabel() {
|
||||||
final Label groupSize = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label groupSize = new LabelBuilder().visible(false).name("").buildLabel();
|
||||||
groupSize.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message");
|
groupSize.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message");
|
||||||
groupSize.setImmediate(true);
|
groupSize.setImmediate(true);
|
||||||
groupSize.setVisible(false);
|
|
||||||
groupSize.setSizeUndefined();
|
groupSize.setSizeUndefined();
|
||||||
return groupSize;
|
return groupSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextArea createTargetFilterQuery() {
|
private static TextArea createTargetFilterQuery() {
|
||||||
final TextArea filterField = SPUIComponentProvider.getTextArea(null, "text-area-style",
|
final TextArea filterField = new TextAreaBuilder().style("text-area-style")
|
||||||
ValoTheme.TEXTFIELD_TINY, false, null, null,
|
.id(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD)
|
||||||
SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
|
||||||
|
|
||||||
filterField.setId(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
|
filterField.setId(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
|
||||||
filterField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
filterField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
filterField.setEnabled(false);
|
filterField.setEnabled(false);
|
||||||
@@ -336,15 +347,6 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
return filterField;
|
return filterField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label createTotalTargetsLabel() {
|
|
||||||
final Label targetCountLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
|
||||||
targetCountLabel.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message");
|
|
||||||
targetCountLabel.setImmediate(true);
|
|
||||||
targetCountLabel.setVisible(false);
|
|
||||||
targetCountLabel.setSizeUndefined();
|
|
||||||
return targetCountLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OptionGroup createErrorThresholdOptionGroup() {
|
private OptionGroup createErrorThresholdOptionGroup() {
|
||||||
final OptionGroup errorThresoldOptions = new OptionGroup();
|
final OptionGroup errorThresoldOptions = new OptionGroup();
|
||||||
for (final ERRORTHRESOLDOPTIONS option : ERRORTHRESOLDOPTIONS.values()) {
|
for (final ERRORTHRESOLDOPTIONS option : ERRORTHRESOLDOPTIONS.values()) {
|
||||||
@@ -527,49 +529,35 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea createDescription() {
|
private TextArea createDescription() {
|
||||||
final TextArea descriptionField = SPUIComponentProvider.getTextArea(null, "text-area-style",
|
final TextArea descriptionField = new TextAreaBuilder().style("text-area-style")
|
||||||
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
.prompt(i18n.get("textfield.description")).id(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID)
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
.buildTextComponent();
|
||||||
descriptionField.setId(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID);
|
|
||||||
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
descriptionField.setSizeUndefined();
|
descriptionField.setSizeUndefined();
|
||||||
return descriptionField;
|
return descriptionField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createErrorThreshold() {
|
private TextField createErrorThreshold() {
|
||||||
final TextField errorField = getTextfield("prompt.error.threshold");
|
final TextField errorField = createIntegerTextField("prompt.error.threshold",
|
||||||
errorField.setNullRepresentation("");
|
SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
|
||||||
errorField.addValidator(new ThresholdFieldValidator());
|
errorField.addValidator(new ThresholdFieldValidator());
|
||||||
errorField.setConverter(new StringToIntegerConverter());
|
|
||||||
errorField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
|
|
||||||
errorField.setId(SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
|
|
||||||
errorField.setMaxLength(7);
|
errorField.setMaxLength(7);
|
||||||
errorField.setSizeUndefined();
|
|
||||||
return errorField;
|
return errorField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createTriggerThreshold() {
|
private TextField createTriggerThreshold() {
|
||||||
final TextField thresholdField = getTextfield("prompt.tigger.threshold");
|
final TextField thresholdField = createIntegerTextField("prompt.tigger.threshold",
|
||||||
thresholdField.setId(SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
|
SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
|
||||||
thresholdField.setNullRepresentation("");
|
|
||||||
thresholdField.addValidator(new ThresholdFieldValidator());
|
thresholdField.addValidator(new ThresholdFieldValidator());
|
||||||
thresholdField.setConverter(new StringToIntegerConverter());
|
|
||||||
thresholdField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
|
|
||||||
thresholdField.setSizeUndefined();
|
|
||||||
thresholdField.setMaxLength(3);
|
|
||||||
return thresholdField;
|
return thresholdField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createNoOfGroupsField() {
|
private TextField createNoOfGroupsField() {
|
||||||
final TextField noOfGroupsField = getTextfield("prompt.number.of.groups");
|
final TextField noOfGroupsField = createIntegerTextField("prompt.number.of.groups",
|
||||||
noOfGroupsField.setId(SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
|
SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
|
||||||
noOfGroupsField.addValidator(new GroupNumberValidator());
|
noOfGroupsField.addValidator(new GroupNumberValidator());
|
||||||
noOfGroupsField.setSizeUndefined();
|
|
||||||
noOfGroupsField.setMaxLength(3);
|
noOfGroupsField.setMaxLength(3);
|
||||||
noOfGroupsField.setConverter(new StringToIntegerConverter());
|
|
||||||
noOfGroupsField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
|
|
||||||
noOfGroupsField.addValueChangeListener(this::onGroupNumberChange);
|
noOfGroupsField.addValueChangeListener(this::onGroupNumberChange);
|
||||||
noOfGroupsField.setNullRepresentation("");
|
|
||||||
return noOfGroupsField;
|
return noOfGroupsField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,8 +595,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createRolloutNameField() {
|
private TextField createRolloutNameField() {
|
||||||
final TextField rolloutNameField = getTextfield("textfield.name");
|
final TextField rolloutNameField = createTextField("textfield.name",
|
||||||
rolloutNameField.setId(SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
|
SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
|
||||||
rolloutNameField.setSizeUndefined();
|
rolloutNameField.setSizeUndefined();
|
||||||
return rolloutNameField;
|
return rolloutNameField;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.rollout.rollout;
|
package org.eclipse.hawkbit.ui.rollout.rollout;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -71,10 +73,10 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
|||||||
|
|
||||||
searchText = getSearchText();
|
searchText = getSearchText();
|
||||||
|
|
||||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
if (!isEmpty(sortStates)) {
|
||||||
// Initalize Sor
|
|
||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
||||||
// Add sort.
|
|
||||||
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
for (int targetId = 1; targetId < sortIds.length; targetId++) {
|
||||||
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
|
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.rollout.rollout;
|
package org.eclipse.hawkbit.ui.rollout.rollout;
|
||||||
|
|
||||||
|
import static org.eclipse.hawkbit.ui.rollout.DistributionBarHelper.getTooltip;
|
||||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
|
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_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_CLOSE_TAG;
|
||||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
|
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.ACTION;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_DIST_NAME_VERSION;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_STATUS;
|
||||||
|
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -428,19 +433,22 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDescription(final CellReference cell) {
|
private String getDescription(final CellReference cell) {
|
||||||
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
|
||||||
return cell.getProperty().getValue().toString().toLowerCase();
|
String description = null;
|
||||||
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
|
||||||
return SPUILabelDefinitions.ACTION.toLowerCase();
|
if (VAR_STATUS.equals(cell.getPropertyId())) {
|
||||||
|
description = cell.getProperty().getValue().toString().toLowerCase();
|
||||||
|
} else if (ACTION.equals(cell.getPropertyId())) {
|
||||||
|
description = ACTION.toLowerCase();
|
||||||
} else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) {
|
} else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) {
|
||||||
return ((RolloutRendererData) cell.getProperty().getValue()).getName();
|
description = ((RolloutRendererData) cell.getProperty().getValue()).getName();
|
||||||
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
|
} else if (VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
|
||||||
return DistributionBarHelper
|
description = getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
|
||||||
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
|
} else if (VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
|
||||||
} else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
|
description = getDSDetails(cell.getItem());
|
||||||
return getDSDetails(cell.getItem());
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDSDetails(final Item rolloutItem) {
|
private static String getDSDetails(final Item rolloutItem) {
|
||||||
|
|||||||
@@ -11,13 +11,12 @@ package org.eclipse.hawkbit.ui.rollout.rollout;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
|
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
|
||||||
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
@@ -134,8 +133,7 @@ public class RolloutListHeader extends AbstractGridHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HorizontalLayout getHeaderCaptionLayout() {
|
protected HorizontalLayout getHeaderCaptionLayout() {
|
||||||
final Label headerCaption = SPUIComponentProvider.getLabel(getHeaderCaption(),
|
final Label headerCaption = new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel();
|
||||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
|
||||||
final HorizontalLayout headerCaptionLayout = new HorizontalLayout();
|
final HorizontalLayout headerCaptionLayout = new HorizontalLayout();
|
||||||
headerCaptionLayout.addComponent(headerCaption);
|
headerCaptionLayout.addComponent(headerCaption);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
|
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.ASC;
|
||||||
|
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -64,24 +68,21 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
|
|||||||
*/
|
*/
|
||||||
public RolloutGroupBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
public RolloutGroupBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||||
|
|
||||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||||
|
|
||||||
rolloutId = getRolloutId();
|
rolloutId = getRolloutId();
|
||||||
|
|
||||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
if (!isEmpty(sortStates)) {
|
||||||
// Initalize Sor
|
|
||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
|
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortPropertyIds[0]);
|
||||||
// Add sort.
|
|
||||||
for (int targetId = 1; targetId < sortPropertyIds.length; targetId++) {
|
for (int targetId = 1; targetId < sortPropertyIds.length; targetId++) {
|
||||||
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC,
|
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortPropertyIds[targetId]));
|
||||||
(String) sortPropertyIds[targetId]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Long getRolloutId() {
|
private Long getRolloutId() {
|
||||||
return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null;
|
return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import com.vaadin.server.FontAwesome;
|
|||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
||||||
|
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickListener;
|
||||||
import com.vaadin.ui.renderers.HtmlRenderer;
|
import com.vaadin.ui.renderers.HtmlRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,7 +239,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
||||||
new TotalTargetCountStatusConverter());
|
new TotalTargetCountStatusConverter());
|
||||||
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
||||||
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(this::onClickOfRolloutGroupName));
|
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(new RolloutGroupClickListener()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,12 +262,6 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
return this::getDescription;
|
return this::getDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
|
||||||
rolloutUIState
|
|
||||||
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
|
||||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRolloutGroupStatusToFontMap() {
|
private void createRolloutGroupStatusToFontMap() {
|
||||||
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
||||||
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
|
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
|
||||||
@@ -310,11 +305,22 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RolloutGroupClickListener implements RendererClickListener {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(final RendererClickEvent event) {
|
||||||
|
rolloutUIState.setRolloutGroup(
|
||||||
|
rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
||||||
|
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Converts {@link TotalTargetCountStatus} into formatted string with status
|
* Converts {@link TotalTargetCountStatus} into formatted string with status
|
||||||
* and count details.
|
* and count details.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class TotalTargetCountStatusConverter implements Converter<String, TotalTargetCountStatus> {
|
class TotalTargetCountStatusConverter implements Converter<String, TotalTargetCountStatus> {
|
||||||
|
|
||||||
@@ -322,15 +328,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TotalTargetCountStatus convertToModel(final String value,
|
public TotalTargetCountStatus convertToModel(final String value,
|
||||||
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
|
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale) {
|
||||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertToPresentation(final TotalTargetCountStatus value,
|
public String convertToPresentation(final TotalTargetCountStatus value,
|
||||||
final Class<? extends String> targetType, final Locale locale)
|
final Class<? extends String> targetType, final Locale locale) {
|
||||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
|
||||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,9 +350,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Converts {@link RolloutGroupStatus} to string.
|
* Converts {@link RolloutGroupStatus} to string.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class RolloutGroupStatusConverter implements Converter<String, RolloutGroupStatus> {
|
class RolloutGroupStatusConverter implements Converter<String, RolloutGroupStatus> {
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -18,7 +19,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
|
|||||||
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
@@ -149,8 +149,8 @@ public class RolloutGroupsListHeader extends AbstractGridHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HorizontalLayout getHeaderCaptionLayout() {
|
protected HorizontalLayout getHeaderCaptionLayout() {
|
||||||
headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
headerCaption = new LabelBuilder().id(SPUIComponentIdProvider.ROLLOUT_GROUP_HEADER_CAPTION).name("")
|
||||||
headerCaption.setId(SPUIComponentIdProvider.ROLLOUT_GROUP_HEADER_CAPTION);
|
.buildCaptionLabel();
|
||||||
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
rolloutsListViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
|
rolloutsListViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
|
|||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||||
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -19,7 +20,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
|
|||||||
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
@@ -164,7 +164,7 @@ public class RolloutGroupTargetsListHeader extends AbstractGridHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HorizontalLayout getHeaderCaptionLayout() {
|
protected HorizontalLayout getHeaderCaptionLayout() {
|
||||||
headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
headerCaption = new LabelBuilder().name("").buildCaptionLabel();
|
||||||
headerCaption.setStyleName(ValoTheme.LABEL_BOLD + " " + ValoTheme.LABEL_SMALL);
|
headerCaption.setStyleName(ValoTheme.LABEL_BOLD + " " + ValoTheme.LABEL_SMALL);
|
||||||
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
|||||||
final CheckBox checkBox = (CheckBox) event.getProperty();
|
final CheckBox checkBox = (CheckBox) event.getProperty();
|
||||||
AuthenticationConfigurationItem configurationItem;
|
AuthenticationConfigurationItem configurationItem;
|
||||||
|
|
||||||
if (checkBox == gatewaySecTokenCheckBox) {
|
if (gatewaySecTokenCheckBox.equals(checkBox)) {
|
||||||
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
||||||
} else if (checkBox == targetSecTokenCheckBox) {
|
} else if (targetSecTokenCheckBox.equals(checkBox)) {
|
||||||
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
|
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
|
||||||
} else if (checkBox == certificateAuthCheckbox) {
|
} else if (certificateAuthCheckbox.equals(checkBox)) {
|
||||||
configurationItem = certificateAuthenticationConfigurationItem;
|
configurationItem = certificateAuthenticationConfigurationItem;
|
||||||
} else if (checkBox == downloadAnonymousCheckBox) {
|
} else if (downloadAnonymousCheckBox.equals(checkBox)) {
|
||||||
configurationItem = anonymousDownloadAuthenticationConfigurationItem;
|
configurationItem = anonymousDownloadAuthenticationConfigurationItem;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
@@ -58,7 +57,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
|
|||||||
*/
|
*/
|
||||||
protected void init(final String labelText) {
|
protected void init(final String labelText) {
|
||||||
setImmediate(true);
|
setImmediate(true);
|
||||||
addComponent(SPUIComponentProvider.getLabel(i18n.get(labelText), SPUILabelDefinitions.SP_LABEL_SIMPLE));
|
addComponent(new LabelBuilder().name(i18n.get(labelText)).buildLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user