Merge branch 'master' into feature_configurable_mgmt_sim_scenario
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.simulator.amqp;
|
package org.eclipse.hawkbit.simulator.amqp;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ import org.springframework.amqp.core.Binding;
|
|||||||
import org.springframework.amqp.core.BindingBuilder;
|
import org.springframework.amqp.core.BindingBuilder;
|
||||||
import org.springframework.amqp.core.FanoutExchange;
|
import org.springframework.amqp.core.FanoutExchange;
|
||||||
import org.springframework.amqp.core.Queue;
|
import org.springframework.amqp.core.Queue;
|
||||||
|
import org.springframework.amqp.core.QueueBuilder;
|
||||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
@@ -65,9 +67,12 @@ public class AmqpConfiguration {
|
|||||||
* @return the queue
|
* @return the queue
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Queue receiverConnectorQueueFromSp() {
|
public Queue receiverConnectorQueueFromHawkBit() {
|
||||||
return new Queue(amqpProperties.getReceiverConnectorQueueFromSp(), true, false, false,
|
final Map<String, Object> arguments = getDeadLetterExchangeArgs();
|
||||||
getDeadLetterExchangeArgs());
|
arguments.putAll(getTTLMaxArgs());
|
||||||
|
|
||||||
|
return QueueBuilder.nonDurable(amqpProperties.getReceiverConnectorQueueFromSp()).withArguments(arguments)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +94,7 @@ public class AmqpConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Binding bindReceiverQueueToSpExchange() {
|
public Binding bindReceiverQueueToSpExchange() {
|
||||||
return BindingBuilder.bind(receiverConnectorQueueFromSp()).to(exchangeQueueToConnector());
|
return BindingBuilder.bind(receiverConnectorQueueFromHawkBit()).to(exchangeQueueToConnector());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +104,7 @@ public class AmqpConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Queue deadLetterQueue() {
|
public Queue deadLetterQueue() {
|
||||||
return new Queue(amqpProperties.getDeadLetterQueue(), true, false, true);
|
return QueueBuilder.nonDurable(amqpProperties.getDeadLetterQueue()).withArguments(getTTLMaxArgs()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,4 +150,11 @@ public class AmqpConfiguration {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, Object> getTTLMaxArgs() {
|
||||||
|
final Map<String, Object> args = new HashMap<>();
|
||||||
|
args.put("x-message-ttl", Duration.ofDays(1).toMillis());
|
||||||
|
args.put("x-max-length", 100_000);
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,21 +82,4 @@ public class MessageService {
|
|||||||
clazz.getTypeName());
|
clazz.getTypeName());
|
||||||
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to verify if lwm2m header is set.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
* the message with the header
|
|
||||||
* @param header
|
|
||||||
* the header to verify
|
|
||||||
*/
|
|
||||||
public void checkIfLwm2mHeaderEmpty(final Message message, final String header) {
|
|
||||||
final Object headerObject = message.getMessageProperties().getHeaders().get(header);
|
|
||||||
if (null == headerObject) {
|
|
||||||
logAndThrowMessageError(message, "Header of " + header + "empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN" />
|
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN" />
|
||||||
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN" />
|
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN" />
|
||||||
<Logger name="org.apache.tomcat.jdbc.pool.ConnectionPool" level="DEBUG" />
|
|
||||||
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
|
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
|
||||||
|
|
||||||
<!-- Security Log with hints on potential attacks -->
|
<!-- Security Log with hints on potential attacks -->
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@ConditionalOnMissingBean(AsyncConfigurer.class)
|
@ConditionalOnMissingBean(AsyncConfigurer.class)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class AsyncConfigurerThreadpoolProperties {
|
|||||||
/**
|
/**
|
||||||
* Max queue size for central event executor.
|
* Max queue size for central event executor.
|
||||||
*/
|
*/
|
||||||
private Integer queuesize = 250;
|
private Integer queuesize = 5_000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core processing threads for central event executor.
|
* Core processing threads for central event executor.
|
||||||
@@ -30,7 +30,7 @@ public class AsyncConfigurerThreadpoolProperties {
|
|||||||
/**
|
/**
|
||||||
* Maximum thread pool size for central event executor.
|
* Maximum thread pool size for central event executor.
|
||||||
*/
|
*/
|
||||||
private Integer maxthreads = 50;
|
private Integer maxthreads = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the number of threads is greater than the core, this is the maximum
|
* When the number of threads is greater than the core, this is the maximum
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.autoconfigure.scheduling;
|
|||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -21,6 +22,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.task.TaskExecutor;
|
||||||
|
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
|
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
@@ -39,11 +43,21 @@ public class ExecutorAutoConfiguration {
|
|||||||
private AsyncConfigurerThreadpoolProperties asyncConfigurerProperties;
|
private AsyncConfigurerThreadpoolProperties asyncConfigurerProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ExecutorService for general purpose multi threaded operations
|
* @return ExecutorService with security context availability in thread
|
||||||
|
* execution..
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public Executor asyncExecutor() {
|
public Executor asyncExecutor() {
|
||||||
|
return new DelegatingSecurityContextExecutor(threadPoolExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return central ThreadPoolExecutor for general purpose multi threaded
|
||||||
|
* operations. Tries an orderly shutdown when destroyed.
|
||||||
|
*/
|
||||||
|
@Bean(destroyMethod = "shutdown")
|
||||||
|
public ThreadPoolExecutor threadPoolExecutor() {
|
||||||
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(
|
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(
|
||||||
asyncConfigurerProperties.getQueuesize());
|
asyncConfigurerProperties.getQueuesize());
|
||||||
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(),
|
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(),
|
||||||
@@ -53,7 +67,8 @@ public class ExecutorAutoConfiguration {
|
|||||||
threadPoolExecutor.setRejectedExecutionHandler((r, executor) -> LOGGER.warn(
|
threadPoolExecutor.setRejectedExecutionHandler((r, executor) -> LOGGER.warn(
|
||||||
"Reject runnable for centralExecutorService, reached limit of queue size {}",
|
"Reject runnable for centralExecutorService, reached limit of queue size {}",
|
||||||
executor.getQueue().size()));
|
executor.getQueue().size()));
|
||||||
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
|
||||||
|
return threadPoolExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,4 +84,32 @@ public class ExecutorAutoConfiguration {
|
|||||||
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link TaskExecutor} for task execution
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public TaskExecutor taskExecutor() {
|
||||||
|
return new ConcurrentTaskExecutor(asyncExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link ScheduledExecutorService} based on
|
||||||
|
* {@link #threadPoolTaskScheduler()}.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public ScheduledExecutorService scheduledExecutorService() {
|
||||||
|
return threadPoolTaskScheduler().getScheduledExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link ThreadPoolTaskScheduler} for scheduled operations.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
|
||||||
|
return new ThreadPoolTaskScheduler();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ vaadin.servlet.urlMapping=/UI/*
|
|||||||
vaadin.servlet.heartbeatInterval=60
|
vaadin.servlet.heartbeatInterval=60
|
||||||
vaadin.servlet.closeIdleSessions=false
|
vaadin.servlet.closeIdleSessions=false
|
||||||
|
|
||||||
# Defines the thread pool executor
|
|
||||||
hawkbit.threadpool.corethreads=5
|
|
||||||
hawkbit.threadpool.maxthreads=20
|
|
||||||
hawkbit.threadpool.idletimeout=10000
|
|
||||||
hawkbit.threadpool.queuesize=20000
|
|
||||||
|
|
||||||
# Defines the polling time for the controllers in HH:MM:SS notation
|
# Defines the polling time for the controllers in HH:MM:SS notation
|
||||||
hawkbit.controller.pollingTime=00:05:00
|
hawkbit.controller.pollingTime=00:05:00
|
||||||
hawkbit.controller.pollingOverdueTime=00:05:00
|
hawkbit.controller.pollingOverdueTime=00:05:00
|
||||||
|
|||||||
@@ -8,21 +8,32 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
|
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.amqp.core.Binding;
|
import org.springframework.amqp.core.Binding;
|
||||||
import org.springframework.amqp.core.BindingBuilder;
|
import org.springframework.amqp.core.BindingBuilder;
|
||||||
import org.springframework.amqp.core.FanoutExchange;
|
import org.springframework.amqp.core.FanoutExchange;
|
||||||
import org.springframework.amqp.core.Queue;
|
import org.springframework.amqp.core.Queue;
|
||||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||||
|
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
|
||||||
|
import org.springframework.retry.support.RetryTemplate;;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The spring AMQP configuration which is enabled by using the profile
|
* The spring AMQP configuration which is enabled by using the profile
|
||||||
@@ -32,14 +43,68 @@ import org.springframework.context.annotation.Bean;
|
|||||||
@EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class })
|
@EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class })
|
||||||
public class AmqpConfiguration {
|
public class AmqpConfiguration {
|
||||||
|
|
||||||
@Autowired
|
private static final Logger LOGGER = LoggerFactory.getLogger(AmqpConfiguration.class);
|
||||||
protected AmqpProperties amqpProperties;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected AmqpDeadletterProperties amqpDeadletterProperties;
|
private AmqpProperties amqpProperties;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConnectionFactory connectionFactory;
|
private AmqpDeadletterProperties amqpDeadletterProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("threadPoolExecutor")
|
||||||
|
private ThreadPoolExecutor threadPoolExecutor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConnectionFactory rabbitConnectionFactory;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
protected static class RabbitConnectionFactoryCreator {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmqpProperties amqpProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("threadPoolExecutor")
|
||||||
|
private ThreadPoolExecutor threadPoolExecutor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ConnectionFactory} with enabled publisher confirms and
|
||||||
|
* heartbeat.
|
||||||
|
*
|
||||||
|
* @param config
|
||||||
|
* with standard {@link RabbitProperties}
|
||||||
|
* @return {@link ConnectionFactory}
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ConnectionFactory rabbitConnectionFactory(final RabbitProperties config) {
|
||||||
|
final CachingConnectionFactory factory = new CachingConnectionFactory();
|
||||||
|
factory.setRequestedHeartBeat(amqpProperties.getRequestedHeartBeat());
|
||||||
|
factory.setExecutor(threadPoolExecutor);
|
||||||
|
factory.getRabbitConnectionFactory().setHeartbeatExecutor(scheduledExecutorService);
|
||||||
|
factory.setPublisherConfirms(true);
|
||||||
|
|
||||||
|
final String addresses = config.getAddresses();
|
||||||
|
factory.setAddresses(addresses);
|
||||||
|
if (config.getHost() != null) {
|
||||||
|
factory.setHost(config.getHost());
|
||||||
|
factory.setPort(config.getPort());
|
||||||
|
}
|
||||||
|
if (config.getUsername() != null) {
|
||||||
|
factory.setUsername(config.getUsername());
|
||||||
|
}
|
||||||
|
if (config.getPassword() != null) {
|
||||||
|
factory.setPassword(config.getPassword());
|
||||||
|
}
|
||||||
|
if (config.getVirtualHost() != null) {
|
||||||
|
factory.setVirtualHost(config.getVirtualHost());
|
||||||
|
}
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link RabbitAdmin} and ignore declaration exceptions.
|
* Create a {@link RabbitAdmin} and ignore declaration exceptions.
|
||||||
@@ -49,20 +114,34 @@ public class AmqpConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RabbitAdmin rabbitAdmin() {
|
public RabbitAdmin rabbitAdmin() {
|
||||||
final RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
final RabbitAdmin rabbitAdmin = new RabbitAdmin(rabbitConnectionFactory);
|
||||||
rabbitAdmin.setIgnoreDeclarationExceptions(true);
|
rabbitAdmin.setIgnoreDeclarationExceptions(true);
|
||||||
return rabbitAdmin;
|
return rabbitAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to set the Jackson2JsonMessageConverter.
|
* @return {@link RabbitTemplate} with automatic retry, published confirms
|
||||||
*
|
* and {@link Jackson2JsonMessageConverter}.
|
||||||
* @return the Jackson2JsonMessageConverter
|
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RabbitTemplate rabbitTemplate() {
|
public RabbitTemplate rabbitTemplate() {
|
||||||
final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
|
final RabbitTemplate rabbitTemplate = new RabbitTemplate(rabbitConnectionFactory);
|
||||||
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
|
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||||
|
|
||||||
|
final RetryTemplate retryTemplate = new RetryTemplate();
|
||||||
|
retryTemplate.setBackOffPolicy(new ExponentialBackOffPolicy());
|
||||||
|
rabbitTemplate.setRetryTemplate(retryTemplate);
|
||||||
|
|
||||||
|
rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
|
||||||
|
if (ack) {
|
||||||
|
LOGGER.debug("Message with correlation ID {} confirmed by broker.", correlationData.getId());
|
||||||
|
} else {
|
||||||
|
LOGGER.error("Broker is unable to handle message with correlation ID {} : {}", correlationData.getId(),
|
||||||
|
cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
return rabbitTemplate;
|
return rabbitTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +238,7 @@ public class AmqpConfiguration {
|
|||||||
public SimpleRabbitListenerContainerFactory listenerContainerFactory() {
|
public SimpleRabbitListenerContainerFactory listenerContainerFactory() {
|
||||||
final SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
|
final SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
|
||||||
containerFactory.setDefaultRequeueRejected(false);
|
containerFactory.setDefaultRequeueRejected(false);
|
||||||
containerFactory.setConnectionFactory(connectionFactory);
|
containerFactory.setConnectionFactory(rabbitConnectionFactory);
|
||||||
containerFactory.setMissingQueuesFatal(amqpProperties.isMissingQueuesFatal());
|
containerFactory.setMissingQueuesFatal(amqpProperties.isMissingQueuesFatal());
|
||||||
return containerFactory;
|
return containerFactory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
@@ -38,6 +40,11 @@ public class AmqpProperties {
|
|||||||
*/
|
*/
|
||||||
private boolean missingQueuesFatal = false;
|
private boolean missingQueuesFatal = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requested heartbeat interval from broker in {@link TimeUnit#SECONDS}.
|
||||||
|
*/
|
||||||
|
private int requestedHeartBeat = (int) TimeUnit.SECONDS.toSeconds(60);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is missingQueuesFatal enabled
|
* Is missingQueuesFatal enabled
|
||||||
*
|
*
|
||||||
@@ -102,4 +109,13 @@ public class AmqpProperties {
|
|||||||
public void setReceiverQueue(final String receiverQueue) {
|
public void setReceiverQueue(final String receiverQueue) {
|
||||||
this.receiverQueue = receiverQueue;
|
this.receiverQueue = receiverQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRequestedHeartBeat() {
|
||||||
|
return requestedHeartBeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestedHeartBeat(final int requestedHeartBeat) {
|
||||||
|
this.requestedHeartBeat = requestedHeartBeat;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class BaseAmqpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final void logAndThrowMessageError(final Message message, final String error) {
|
protected final void logAndThrowMessageError(final Message message, final String error) {
|
||||||
LOGGER.warn("Error \"{}\" reported by message: {}", error, message);
|
LOGGER.warn("Warning! \"{}\" reported by message: {}", error, message);
|
||||||
throw new IllegalArgumentException(error);
|
throw new IllegalArgumentException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,14 @@
|
|||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.util.IpUtil;
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.amqp.rabbit.support.CorrelationData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A default implementation for the sender service. The service sends all amqp
|
* A default implementation for the sender service. The service sends all amqp
|
||||||
@@ -20,6 +24,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|||||||
* extracted from the uri.
|
* extracted from the uri.
|
||||||
*/
|
*/
|
||||||
public class DefaultAmqpSenderService implements AmqpSenderService {
|
public class DefaultAmqpSenderService implements AmqpSenderService {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAmqpSenderService.class);
|
||||||
|
|
||||||
private final RabbitTemplate internalAmqpTemplate;
|
private final RabbitTemplate internalAmqpTemplate;
|
||||||
|
|
||||||
@@ -39,7 +44,16 @@ public class DefaultAmqpSenderService implements AmqpSenderService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
internalAmqpTemplate.send(extractExchange(replyTo), null, message);
|
final String correlationId = UUID.randomUUID().toString();
|
||||||
|
final String exchange = extractExchange(replyTo);
|
||||||
|
|
||||||
|
if (LOGGER.isTraceEnabled()) {
|
||||||
|
LOGGER.trace("Sending message {} to exchange {} with correlationId {}", message, exchange, correlationId);
|
||||||
|
} else {
|
||||||
|
LOGGER.debug("Sending message to exchange {} with correlationId {}", exchange, correlationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
internalAmqpTemplate.send(exchange, null, message, new CorrelationData(correlationId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit;
|
package org.eclipse.hawkbit;
|
||||||
|
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.amqp.AmqpProperties;
|
||||||
import org.eclipse.hawkbit.amqp.AmqpSenderService;
|
import org.eclipse.hawkbit.amqp.AmqpSenderService;
|
||||||
import org.eclipse.hawkbit.amqp.DefaultAmqpSenderService;
|
import org.eclipse.hawkbit.amqp.DefaultAmqpSenderService;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder;
|
||||||
@@ -16,13 +24,22 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
import org.springframework.amqp.support.converter.MessageConverter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.task.TaskExecutor;
|
||||||
|
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({ AmqpProperties.class })
|
||||||
public class AmqpTestConfiguration {
|
public class AmqpTestConfiguration {
|
||||||
/**
|
/**
|
||||||
* @return the {@link SystemSecurityContext} singleton bean which make it
|
* @return the {@link SystemSecurityContext} singleton bean which make it
|
||||||
@@ -56,4 +73,55 @@ public class AmqpTestConfiguration {
|
|||||||
public AmqpSenderService amqpSenderServiceBean(final RabbitTemplate rabbitTemplate) {
|
public AmqpSenderService amqpSenderServiceBean(final RabbitTemplate rabbitTemplate) {
|
||||||
return new DefaultAmqpSenderService(rabbitTemplate);
|
return new DefaultAmqpSenderService(rabbitTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ExecutorService with security context availability in thread
|
||||||
|
* execution..
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public Executor asyncExecutor() {
|
||||||
|
return new DelegatingSecurityContextExecutor(threadPoolExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return central ThreadPoolExecutor for general purpose multi threaded
|
||||||
|
* operations. Tries an orderly shutdown when destroyed.
|
||||||
|
*/
|
||||||
|
@Bean(destroyMethod = "shutdown")
|
||||||
|
public ThreadPoolExecutor threadPoolExecutor() {
|
||||||
|
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(10);
|
||||||
|
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 10, 1000, TimeUnit.MILLISECONDS,
|
||||||
|
blockingQueue, new ThreadFactoryBuilder().setNameFormat("central-executor-pool-%d").build());
|
||||||
|
|
||||||
|
return threadPoolExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link TaskExecutor} for task execution
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public TaskExecutor taskExecutor() {
|
||||||
|
return new ConcurrentTaskExecutor(asyncExecutor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link ScheduledExecutorService} based on
|
||||||
|
* {@link #threadPoolTaskScheduler()}.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public ScheduledExecutorService scheduledExecutorService() {
|
||||||
|
return threadPoolTaskScheduler().getScheduledExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link ThreadPoolTaskScheduler} for scheduled operations.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
|
||||||
|
return new ThreadPoolTaskScheduler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
@Stories("Test to generate the artifact download URL")
|
@Stories("Test to generate the artifact download URL")
|
||||||
@SpringApplicationConfiguration(classes = { AmqpTestConfiguration.class,
|
@SpringApplicationConfiguration(classes = { AmqpTestConfiguration.class,
|
||||||
org.eclipse.hawkbit.RepositoryApplicationConfiguration.class })
|
org.eclipse.hawkbit.RepositoryApplicationConfiguration.class })
|
||||||
|
|
||||||
public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTestWithMongoDB {
|
public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTestWithMongoDB {
|
||||||
|
|
||||||
private static final String HTTPS_LOCALHOST = "https://localhost:8080/";
|
private static final String HTTPS_LOCALHOST = "https://localhost:8080/";
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public final class Constants {
|
|||||||
* generated by repository for every new account for "Firmware/Operating
|
* generated by repository for every new account for "Firmware/Operating
|
||||||
* System" .
|
* System" .
|
||||||
*/
|
*/
|
||||||
public static final String SMT_DEFAULT_OS_NAME = "Firmware";
|
public static final String SMT_DEFAULT_OS_NAME = "OS";
|
||||||
/**
|
/**
|
||||||
* {@link SoftwareModuleType#getName()} of a {@link SoftwareModuleType}
|
* {@link SoftwareModuleType#getName()} of a {@link SoftwareModuleType}
|
||||||
* generated by repository for every new account for "applications/apps".
|
* generated by repository for every new account for "applications/apps".
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Tag;
|
import org.eclipse.hawkbit.repository.model.Tag;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
@@ -82,15 +84,26 @@ public interface DistributionSetRepository
|
|||||||
List<DistributionSet> findByModules(JpaSoftwareModule module);
|
List<DistributionSet> findByModules(JpaSoftwareModule module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds {@link DistributionSet}s based on given ID if they are not assigned
|
* Finds {@link DistributionSet}s based on given ID that are assigned yet to
|
||||||
* yet to an {@link UpdateAction}, i.e. unused.
|
* an {@link Action}, i.e. in use.
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* to search for
|
* to search for
|
||||||
* @return
|
* @return list of {@link DistributionSet#getId()}
|
||||||
*/
|
*/
|
||||||
@Query("select ac.distributionSet.id from JpaAction ac where ac.distributionSet.id in :ids")
|
@Query("select ac.distributionSet.id from JpaAction ac where ac.distributionSet.id in :ids")
|
||||||
List<Long> findAssignedDistributionSetsById(@Param("ids") Long... ids);
|
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Long... ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds {@link DistributionSet}s based on given ID that are assigned yet to
|
||||||
|
* an {@link Rollout}, i.e. in use.
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* to search for
|
||||||
|
* @return list of {@link DistributionSet#getId()}
|
||||||
|
*/
|
||||||
|
@Query("select ra.distributionSet.id from JpaRollout ra where ra.distributionSet.id in :ids")
|
||||||
|
List<Long> findAssignedToRolloutDistributionSetsById(@Param("ids") Long... ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves all given {@link DistributionSet}s.
|
* Saves all given {@link DistributionSet}s.
|
||||||
|
|||||||
@@ -173,7 +173,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
public void deleteDistributionSet(final Long... distributionSetIDs) {
|
public void deleteDistributionSet(final Long... distributionSetIDs) {
|
||||||
final List<Long> toHardDelete = new ArrayList<>();
|
final List<Long> toHardDelete = new ArrayList<>();
|
||||||
|
|
||||||
final List<Long> assigned = distributionSetRepository.findAssignedDistributionSetsById(distributionSetIDs);
|
final List<Long> assigned = distributionSetRepository
|
||||||
|
.findAssignedToTargetDistributionSetsById(distributionSetIDs);
|
||||||
|
assigned.addAll(distributionSetRepository.findAssignedToRolloutDistributionSetsById(distributionSetIDs));
|
||||||
|
|
||||||
// soft delete assigned
|
// soft delete assigned
|
||||||
if (!assigned.isEmpty()) {
|
if (!assigned.isEmpty()) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
@@ -34,12 +35,18 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
|||||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
|
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||||
|
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||||
|
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||||
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||||
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||||
import org.fest.assertions.core.Condition;
|
import org.fest.assertions.core.Condition;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -777,36 +784,55 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Deltes a DS that is no in use. Expected behaviour is a soft delete on the database, i.e. only marked as "
|
@Description("Deletes a DS that is in use by either target assignment or rollout. Expected behaviour is a soft delete on the database, i.e. only marked as "
|
||||||
+ "deleted, kept eas refernce and unavailable for future use..")
|
+ "deleted, kept as reference but unavailable for future use..")
|
||||||
public void deleteAssignedDistributionSet() {
|
public void deleteAssignedDistributionSet() {
|
||||||
DistributionSet ds1 = testdataFactory.createDistributionSet("ds-1");
|
DistributionSet ds1 = testdataFactory.createDistributionSet("ds-1");
|
||||||
DistributionSet ds2 = testdataFactory.createDistributionSet("ds-2");
|
DistributionSet ds2 = testdataFactory.createDistributionSet("ds-2");
|
||||||
DistributionSet dsAssigned = testdataFactory.createDistributionSet("ds-3");
|
DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
|
||||||
|
final DistributionSet dsToRolloutAssigned = testdataFactory.createDistributionSet("ds-4");
|
||||||
|
|
||||||
ds1 = distributionSetManagement.findDistributionSetByNameAndVersion(ds1.getName(), ds1.getVersion());
|
ds1 = distributionSetManagement.findDistributionSetByNameAndVersion(ds1.getName(), ds1.getVersion());
|
||||||
ds2 = distributionSetManagement.findDistributionSetByNameAndVersion(ds2.getName(), ds2.getVersion());
|
ds2 = distributionSetManagement.findDistributionSetByNameAndVersion(ds2.getName(), ds2.getVersion());
|
||||||
|
|
||||||
// create assigned DS
|
// create assigned DS
|
||||||
dsAssigned = distributionSetManagement.findDistributionSetByNameAndVersion(dsAssigned.getName(),
|
dsToTargetAssigned = distributionSetManagement.findDistributionSetByNameAndVersion(dsToTargetAssigned.getName(),
|
||||||
dsAssigned.getVersion());
|
dsToTargetAssigned.getVersion());
|
||||||
final Target target = new JpaTarget("4712");
|
final Target target = new JpaTarget("4712");
|
||||||
final Target savedTarget = targetManagement.createTarget(target);
|
final Target savedTarget = targetManagement.createTarget(target);
|
||||||
final List<Target> toAssign = new ArrayList<>();
|
final List<Target> toAssign = new ArrayList<>();
|
||||||
toAssign.add(savedTarget);
|
toAssign.add(savedTarget);
|
||||||
deploymentManagement.assignDistributionSet(dsAssigned, toAssign);
|
deploymentManagement.assignDistributionSet(dsToTargetAssigned, toAssign);
|
||||||
|
|
||||||
// delete a ds
|
// create assigned rollout
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(3);
|
createRolloutByVariables("test", "test", 5, "name==*", dsToRolloutAssigned, "50", "5");
|
||||||
distributionSetManagement.deleteDistributionSet(dsAssigned.getId());
|
|
||||||
|
// delete assigned ds
|
||||||
|
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||||
|
distributionSetManagement.deleteDistributionSet(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId());
|
||||||
|
|
||||||
// not assigned so not marked as deleted
|
// not assigned so not marked as deleted
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(3);
|
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
.findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
.findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
||||||
.isEqualTo(2);
|
.isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
|
||||||
|
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
|
||||||
|
final String successCondition, final String errorCondition) {
|
||||||
|
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder()
|
||||||
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, successCondition)
|
||||||
|
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition)
|
||||||
|
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
|
||||||
|
final Rollout rolloutToCreate = new JpaRollout();
|
||||||
|
rolloutToCreate.setName(rolloutName);
|
||||||
|
rolloutToCreate.setDescription(rolloutDescription);
|
||||||
|
rolloutToCreate.setTargetFilterQuery(filterQuery);
|
||||||
|
rolloutToCreate.setDistributionSet(distributionSet);
|
||||||
|
return rolloutManagement.createRollout(rolloutToCreate, groupSize, conditions);
|
||||||
|
}
|
||||||
|
|
||||||
private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t,
|
private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t,
|
||||||
final String... msgs) {
|
final String... msgs) {
|
||||||
updActA.setStatus(status);
|
updActA.setStatus(status);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
|||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.Constants;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
||||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
@@ -34,7 +35,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Test filter software module test type by name")
|
@Description("Test filter software module test type by name")
|
||||||
public void testFilterByParameterName() {
|
public void testFilterByParameterName() {
|
||||||
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==Firmware", 1);
|
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==" + Constants.SMT_DEFAULT_OS_NAME, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import org.eclipse.hawkbit.repository.EntityFactory;
|
|||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||||
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.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;
|
||||||
@@ -29,29 +29,25 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||||
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.Alignment;
|
|
||||||
import com.vaadin.ui.Button;
|
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.CustomComponent;
|
||||||
|
import com.vaadin.ui.FormLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
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.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates window for Software module add or update.
|
* Generates window for Software module add or update.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class SoftwareModuleAddUpdateWindow implements Serializable {
|
public class SoftwareModuleAddUpdateWindow extends CustomComponent implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5217675246477211483L;
|
private static final long serialVersionUID = -5217675246477211483L;
|
||||||
|
|
||||||
@@ -70,7 +66,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient EntityFactory entityFactory;
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
private Label madatoryLabel;
|
private Label mandatoryLabel;
|
||||||
|
|
||||||
private TextField nameTextField;
|
private TextField nameTextField;
|
||||||
|
|
||||||
@@ -78,15 +74,11 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
|
|
||||||
private TextField vendorTextField;
|
private TextField vendorTextField;
|
||||||
|
|
||||||
private Button saveSoftware;
|
|
||||||
|
|
||||||
private Button closeWindow;
|
|
||||||
|
|
||||||
private ComboBox typeComboBox;
|
private ComboBox typeComboBox;
|
||||||
|
|
||||||
private TextArea descTextArea;
|
private TextArea descTextArea;
|
||||||
|
|
||||||
private Window window;
|
private CommonDialogWindow window;
|
||||||
|
|
||||||
private String oldDescriptionValue;
|
private String oldDescriptionValue;
|
||||||
|
|
||||||
@@ -102,7 +94,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
* @return reference of {@link com.vaadin.ui.Window} to add new software
|
* @return reference of {@link com.vaadin.ui.Window} to add new software
|
||||||
* module.
|
* module.
|
||||||
*/
|
*/
|
||||||
public Window createAddSoftwareModuleWindow() {
|
public CommonDialogWindow createAddSoftwareModuleWindow() {
|
||||||
|
|
||||||
editSwModule = Boolean.FALSE;
|
editSwModule = Boolean.FALSE;
|
||||||
createRequiredComponents();
|
createRequiredComponents();
|
||||||
createWindow();
|
createWindow();
|
||||||
@@ -118,6 +111,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
* module.
|
* module.
|
||||||
*/
|
*/
|
||||||
public Window createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
public Window createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
|
||||||
|
|
||||||
editSwModule = Boolean.TRUE;
|
editSwModule = Boolean.TRUE;
|
||||||
this.baseSwModuleId = baseSwModuleId;
|
this.baseSwModuleId = baseSwModuleId;
|
||||||
createRequiredComponents();
|
createRequiredComponents();
|
||||||
@@ -132,33 +126,35 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
/* name textfield */
|
/* name textfield */
|
||||||
nameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
||||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
|
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
|
||||||
|
|
||||||
/* version text field */
|
/* version text field */
|
||||||
versionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
versionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
||||||
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
||||||
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
|
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
|
||||||
|
|
||||||
/* Vendor text field */
|
/* Vendor text field */
|
||||||
vendorTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
vendorTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.vendor"), "", ValoTheme.TEXTFIELD_TINY,
|
||||||
i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
false, null, i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
|
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
|
||||||
|
|
||||||
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
|
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
||||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
||||||
|
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
|
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
|
||||||
addDescriptionTextChangeListener();
|
addDescriptionTextChangeListener();
|
||||||
addVendorTextChangeListener();
|
addVendorTextChangeListener();
|
||||||
|
|
||||||
/* Label for mandatory symbol */
|
/* Label for mandatory symbol */
|
||||||
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
mandatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
||||||
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
mandatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||||
madatoryLabel.addStyleName(ValoTheme.LABEL_SMALL);
|
mandatoryLabel.addStyleName(ValoTheme.LABEL_SMALL);
|
||||||
|
|
||||||
typeComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, null,
|
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", "", null, null, true,
|
||||||
i18n.get("upload.swmodule.type"));
|
null, i18n.get("upload.swmodule.type"));
|
||||||
typeComboBox.setId(SPUIComponentIdProvider.SW_MODULE_TYPE);
|
typeComboBox.setId(SPUIComponentIdProvider.SW_MODULE_TYPE);
|
||||||
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
|
typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
|
||||||
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
|
typeComboBox.setNewItemsAllowed(Boolean.FALSE);
|
||||||
@@ -166,24 +162,6 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
|
|
||||||
populateTypeNameCombo();
|
populateTypeNameCombo();
|
||||||
|
|
||||||
/* save or update button */
|
|
||||||
saveSoftware = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SOFT_MODULE_SAVE, "", "", "", true,
|
|
||||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveSoftware.addClickListener(event -> {
|
|
||||||
if (editSwModule) {
|
|
||||||
updateSwModule();
|
|
||||||
} else {
|
|
||||||
/* add new or update software module */
|
|
||||||
addNewBaseSoftware();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* close button */
|
|
||||||
closeWindow = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SOFT_MODULE_DISCARD, "", "", "", true,
|
|
||||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
/* Just close this window when this button is clicked */
|
|
||||||
closeWindow.addClickListener(event -> closeThisWindow());
|
|
||||||
|
|
||||||
resetOldValues();
|
resetOldValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,68 +181,44 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep UI components on Layout.
|
* Build the window content and get an instance of customDialogWindow
|
||||||
*
|
*
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private void createWindow() {
|
private void createWindow() {
|
||||||
/* action button layout (save & dicard) */
|
|
||||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
|
||||||
buttonsLayout.setSizeFull();
|
|
||||||
buttonsLayout.addComponents(saveSoftware, closeWindow);
|
|
||||||
buttonsLayout.setComponentAlignment(saveSoftware, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonsLayout.setComponentAlignment(closeWindow, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonsLayout.addStyleName("window-style");
|
|
||||||
|
|
||||||
final Label madatoryStarLabel = new Label("*");
|
final Label madatoryStarLabel = new Label("*");
|
||||||
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
|
madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
|
||||||
madatoryStarLabel.setWidth(null);
|
madatoryStarLabel.setWidth(null);
|
||||||
final HorizontalLayout hLayout = new HorizontalLayout();
|
|
||||||
hLayout.setSizeFull();
|
|
||||||
hLayout.addComponents(typeComboBox, madatoryStarLabel);
|
|
||||||
hLayout.setComponentAlignment(typeComboBox, Alignment.TOP_LEFT);
|
|
||||||
hLayout.setComponentAlignment(madatoryStarLabel, Alignment.TOP_RIGHT);
|
|
||||||
hLayout.setExpandRatio(typeComboBox, 0.8f);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The main layout of the window contains mandatory info, textboxes
|
* The main layout of the window contains mandatory info, textboxes
|
||||||
* (controller Id, name & description) and action buttons layout
|
* (controller Id, name & description) and action buttons layout
|
||||||
*/
|
*/
|
||||||
final VerticalLayout mainLayout = new VerticalLayout();
|
addStyleName("lay-color");
|
||||||
mainLayout.setSpacing(Boolean.TRUE);
|
|
||||||
mainLayout.addStyleName("lay-color");
|
final FormLayout formLayout = new FormLayout();
|
||||||
mainLayout.addComponent(madatoryLabel);
|
formLayout.addComponent(mandatoryLabel);
|
||||||
mainLayout.setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
|
formLayout.addComponent(typeComboBox);
|
||||||
mainLayout.addComponent(hLayout);
|
formLayout.addComponent(nameTextField);
|
||||||
mainLayout.setComponentAlignment(hLayout, Alignment.MIDDLE_LEFT);
|
formLayout.addComponent(versionTextField);
|
||||||
mainLayout.addComponents(nameTextField, versionTextField, vendorTextField, descTextArea, buttonsLayout);
|
formLayout.addComponent(vendorTextField);
|
||||||
|
formLayout.addComponent(descTextArea);
|
||||||
|
|
||||||
|
setCompositionRoot(formLayout);
|
||||||
|
|
||||||
/* add main layout to the window */
|
/* add main layout to the window */
|
||||||
window = SPUIComponentProvider.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
|
window = SPUIComponentProvider.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> saveOrUpdate(), event -> closeThisWindow(), null);
|
||||||
window.setContent(mainLayout);
|
window.getButtonsLayout().removeStyleName("actionButtonsMargin");
|
||||||
window.setModal(true);
|
|
||||||
nameTextField.focus();
|
nameTextField.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDescriptionTextChangeListener() {
|
private void addDescriptionTextChangeListener() {
|
||||||
descTextArea.addTextChangeListener(event -> {
|
descTextArea.addTextChangeListener(event -> window.setSaveButtonEnabled(hasDescriptionChanged(event)));
|
||||||
if (event.getText().equals(oldDescriptionValue) && vendorTextField.getValue().equals(oldVendorValue)) {
|
|
||||||
saveSoftware.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
saveSoftware.setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addVendorTextChangeListener() {
|
private void addVendorTextChangeListener() {
|
||||||
vendorTextField.addTextChangeListener(event -> {
|
vendorTextField.addTextChangeListener(event -> window.setSaveButtonEnabled(hasVendorChanged(event)));
|
||||||
if (event.getText().equals(oldVendorValue) && descTextArea.getValue().equals(oldDescriptionValue)) {
|
|
||||||
saveSoftware.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
saveSoftware.setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,26 +230,31 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
final String vendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
final String vendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
||||||
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||||
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
|
||||||
if (mandatoryCheck(name, version, type)) {
|
|
||||||
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
if (!mandatoryCheck(name, version, type)) {
|
||||||
uiNotifcation.displayValidationError(
|
return;
|
||||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
}
|
||||||
} else {
|
|
||||||
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
|
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
||||||
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
|
uiNotifcation.displayValidationError(
|
||||||
if (newBaseSoftwareModule != null) {
|
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||||
/* display success message */
|
} else {
|
||||||
uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] {
|
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
|
||||||
newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() }));
|
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
|
||||||
eventBus.publish(this,
|
if (newBaseSoftwareModule != null) {
|
||||||
new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule));
|
/* display success message */
|
||||||
}
|
uiNotifcation.displaySuccess(i18n.get("message.save.success",
|
||||||
// close the window
|
new Object[] { newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() }));
|
||||||
closeThisWindow();
|
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule));
|
||||||
}
|
}
|
||||||
|
// close the window
|
||||||
|
closeThisWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates a softwareModule
|
||||||
|
*/
|
||||||
private void updateSwModule() {
|
private void updateSwModule() {
|
||||||
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
|
||||||
final String newVendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
final String newVendor = HawkbitCommonUtil.trimAndNullIfEmpty(vendorTextField.getValue());
|
||||||
@@ -312,6 +271,9 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
closeThisWindow();
|
closeThisWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill the data of a softwareModule in the content of the window
|
||||||
|
*/
|
||||||
private void populateValuesOfSwModule() {
|
private void populateValuesOfSwModule() {
|
||||||
final SoftwareModule swModle = softwareManagement.findSoftwareModuleById(baseSwModuleId);
|
final SoftwareModule swModle = softwareManagement.findSoftwareModuleById(baseSwModuleId);
|
||||||
nameTextField.setValue(swModle.getName());
|
nameTextField.setValue(swModle.getName());
|
||||||
@@ -326,7 +288,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
typeComboBox.addItem(swModle.getType().getName());
|
typeComboBox.addItem(swModle.getType().getName());
|
||||||
}
|
}
|
||||||
typeComboBox.setValue(swModle.getType().getName());
|
typeComboBox.setValue(swModle.getType().getName());
|
||||||
saveSoftware.setEnabled(Boolean.FALSE);
|
window.setSaveButtonEnabled(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,4 +326,21 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
|
|||||||
}
|
}
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveOrUpdate() {
|
||||||
|
if (editSwModule) {
|
||||||
|
updateSwModule();
|
||||||
|
} else {
|
||||||
|
addNewBaseSoftware();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasDescriptionChanged(final TextChangeEvent event) {
|
||||||
|
return !(event.getText().equals(oldDescriptionValue) && vendorTextField.getValue().equals(oldVendorValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasVendorChanged(final TextChangeEvent event) {
|
||||||
|
return !(event.getText().equals(oldVendorValue) && descTextArea.getValue().equals(oldDescriptionValue));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,279 +9,114 @@
|
|||||||
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
package org.eclipse.hawkbit.ui.artifacts.smtype;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
|
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.common.CoordinatesToColor;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
|
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.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
|
||||||
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.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.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
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.spring.events.EventBus;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
import com.vaadin.data.Property.ValueChangeListener;
|
|
||||||
import com.vaadin.server.FontAwesome;
|
|
||||||
import com.vaadin.server.Page;
|
|
||||||
import com.vaadin.shared.ui.colorpicker.Color;
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
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.AbstractColorPicker.Coordinates2Color;
|
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.ComboBox;
|
|
||||||
import com.vaadin.ui.CustomComponent;
|
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.OptionGroup;
|
import com.vaadin.ui.OptionGroup;
|
||||||
import com.vaadin.ui.Slider;
|
|
||||||
import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.UI;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||||
import com.vaadin.ui.components.colorpicker.ColorPickerGradient;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Layout for the create or update software module type.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
|
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout
|
||||||
|
implements ColorChangeListener, ColorSelector {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5169398523815919367L;
|
private static final long serialVersionUID = -5169398523815919367L;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateSoftwareTypeLayout.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SpPermissionChecker permChecker;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private I18N i18n;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instance of ColorPickerPreview.
|
|
||||||
*/
|
|
||||||
private SpColorPickerPreview selPreview;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private transient UINotification uiNotification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient SoftwareManagement swTypeManagementService;
|
private transient SoftwareManagement swTypeManagementService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient EntityFactory entityFactory;
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private transient EventBus.SessionEventBus eventBus;
|
|
||||||
|
|
||||||
private String createTypeStr;
|
|
||||||
private String updateTypeStr;
|
|
||||||
private String singleAssignStr;
|
private String singleAssignStr;
|
||||||
private String multiAssignStr;
|
private String multiAssignStr;
|
||||||
private Label createType;
|
|
||||||
private Label updateType;
|
|
||||||
private Label singleAssign;
|
private Label singleAssign;
|
||||||
private Label multiAssign;
|
private Label multiAssign;
|
||||||
private Label comboLabel;
|
|
||||||
private Label colorLabel;
|
|
||||||
private Label madatoryLabel;
|
|
||||||
private TextField typeName;
|
|
||||||
private TextField typeKey;
|
|
||||||
private TextArea typeDesc;
|
|
||||||
private Button saveTag;
|
|
||||||
private Button discardTag;
|
|
||||||
private Button tagColorPreviewBtn;
|
|
||||||
private OptionGroup createOptiongroup;
|
|
||||||
private OptionGroup assignOptiongroup;
|
private OptionGroup assignOptiongroup;
|
||||||
private ComboBox typeNameComboBox;
|
|
||||||
protected static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
|
||||||
private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
|
||||||
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
|
||||||
private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
|
||||||
private Set<ColorSelector> selectors;
|
|
||||||
private Color selectedColor;
|
|
||||||
private ColorPickerGradient colorSelect;
|
|
||||||
private Slider redSlider;
|
|
||||||
private Slider greenSlider;
|
|
||||||
private Slider blueSlider;
|
|
||||||
private Window swTypeWindow;
|
|
||||||
protected boolean tagPreviewBtnClicked = false;
|
|
||||||
private VerticalLayout comboLayout;
|
|
||||||
private VerticalLayout sliders;
|
|
||||||
private VerticalLayout colorPickerLayout;
|
|
||||||
private HorizontalLayout mainLayout;
|
|
||||||
private VerticalLayout fieldLayout;
|
|
||||||
|
|
||||||
/** RGB color converter. */
|
@Override
|
||||||
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
protected void addListeners() {
|
||||||
|
super.addListeners();
|
||||||
/**
|
optiongroup.addValueChangeListener(this::createOptionValueChanged);
|
||||||
* Initialize the artifact details layout.
|
|
||||||
*/
|
|
||||||
public void init() {
|
|
||||||
createComponents();
|
|
||||||
buildLayout();
|
|
||||||
addListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createComponents() {
|
@Override
|
||||||
createTypeStr = i18n.get("label.create.type");
|
protected void createRequiredComponents() {
|
||||||
updateTypeStr = i18n.get("label.update.type");
|
|
||||||
|
super.createRequiredComponents();
|
||||||
|
|
||||||
singleAssignStr = i18n.get("label.singleAssign.type");
|
singleAssignStr = i18n.get("label.singleAssign.type");
|
||||||
multiAssignStr = i18n.get("label.multiAssign.type");
|
multiAssignStr = i18n.get("label.multiAssign.type");
|
||||||
createType = SPUIComponentProvider.getLabel(createTypeStr, null);
|
|
||||||
updateType = SPUIComponentProvider.getLabel(updateTypeStr, null);
|
|
||||||
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
||||||
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
|
||||||
madatoryLabel = getMandatoryLabel();
|
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
|
||||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
|
||||||
|
|
||||||
typeName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME,
|
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
||||||
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME, true, "", i18n.get("textfield.name"), true,
|
||||||
typeName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
|
tagName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
|
||||||
|
|
||||||
typeKey = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY,
|
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
|
||||||
true, "", i18n.get("textfield.key"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY, true, "", i18n.get("textfield.key"), true,
|
||||||
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
typeKey.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
|
typeKey.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
|
||||||
|
|
||||||
typeDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC,
|
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
|
||||||
false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC, false, "",
|
||||||
|
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
|
|
||||||
typeDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
|
tagDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
|
||||||
typeDesc.setImmediate(true);
|
tagDesc.setImmediate(true);
|
||||||
typeDesc.setNullRepresentation("");
|
tagDesc.setNullRepresentation("");
|
||||||
|
|
||||||
typeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
|
|
||||||
i18n.get("label.combobox.type"));
|
|
||||||
typeNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
|
||||||
typeNameComboBox.setImmediate(true);
|
|
||||||
|
|
||||||
saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_SW_TYPE_SAVE, "", "", "", true, FontAwesome.SAVE,
|
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
|
||||||
|
|
||||||
discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
|
|
||||||
"discard-button-style", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
|
||||||
|
|
||||||
tagColorPreviewBtn = new Button();
|
|
||||||
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
|
||||||
|
|
||||||
selectors = new HashSet<>();
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview = new SpColorPickerPreview(selectedColor);
|
|
||||||
|
|
||||||
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
colorSelect.setWidth("220px");
|
|
||||||
|
|
||||||
redSlider = createRGBSlider("", "red");
|
|
||||||
greenSlider = createRGBSlider("", "green");
|
|
||||||
blueSlider = createRGBSlider("", "blue");
|
|
||||||
setRgbSliderValues(selectedColor);
|
|
||||||
|
|
||||||
createUpdateOptionGroup();
|
|
||||||
|
|
||||||
singleMultiOptionGroup();
|
singleMultiOptionGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
@Override
|
||||||
comboLayout = new VerticalLayout();
|
protected void buildLayout() {
|
||||||
|
|
||||||
sliders = new VerticalLayout();
|
super.buildLayout();
|
||||||
sliders.addComponents(redSlider, greenSlider, blueSlider);
|
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||||
|
getFormLayout().addComponent(typeKey, 4);
|
||||||
selectors.add(colorSelect);
|
getFormLayout().addComponent(assignOptiongroup);
|
||||||
|
|
||||||
colorPickerLayout = new VerticalLayout();
|
|
||||||
colorPickerLayout.setStyleName("rgb-vertical-layout");
|
|
||||||
colorPickerLayout.addComponent(selPreview);
|
|
||||||
colorPickerLayout.addComponent(colorSelect);
|
|
||||||
|
|
||||||
fieldLayout = new VerticalLayout();
|
|
||||||
fieldLayout.setSpacing(true);
|
|
||||||
fieldLayout.setMargin(false);
|
|
||||||
fieldLayout.setWidth("100%");
|
|
||||||
fieldLayout.setHeight(null);
|
|
||||||
fieldLayout.addComponent(createOptiongroup);
|
|
||||||
fieldLayout.addComponent(comboLayout);
|
|
||||||
fieldLayout.addComponent(madatoryLabel);
|
|
||||||
fieldLayout.addComponent(typeName);
|
|
||||||
fieldLayout.addComponent(typeKey);
|
|
||||||
fieldLayout.addComponent(typeDesc);
|
|
||||||
fieldLayout.addComponent(assignOptiongroup);
|
|
||||||
|
|
||||||
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
|
|
||||||
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
|
||||||
fieldLayout.addComponent(colorLabelLayout);
|
|
||||||
|
|
||||||
final HorizontalLayout buttonLayout = new HorizontalLayout();
|
|
||||||
buttonLayout.addComponent(saveTag);
|
|
||||||
buttonLayout.addComponent(discardTag);
|
|
||||||
buttonLayout.setComponentAlignment(discardTag, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonLayout.setComponentAlignment(saveTag, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonLayout.addStyleName("window-style");
|
|
||||||
buttonLayout.setWidth("152px");
|
|
||||||
|
|
||||||
final VerticalLayout fieldButtonLayout = new VerticalLayout();
|
|
||||||
fieldButtonLayout.addComponent(fieldLayout);
|
|
||||||
fieldButtonLayout.addComponent(buttonLayout);
|
|
||||||
|
|
||||||
mainLayout = new HorizontalLayout();
|
|
||||||
mainLayout.addComponent(fieldButtonLayout);
|
|
||||||
setCompositionRoot(mainLayout);
|
|
||||||
typeName.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListeners() {
|
@Override
|
||||||
saveTag.addClickListener(event -> save());
|
public void createWindow() {
|
||||||
discardTag.addClickListener(event -> discard());
|
|
||||||
colorSelect.addColorChangeListener(this);
|
|
||||||
selPreview.addColorChangeListener(this);
|
|
||||||
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
|
|
||||||
createOptiongroup.addValueChangeListener(event -> createOptionValueChanged(event));
|
|
||||||
typeNameComboBox.addValueChangeListener(event -> typeNameChosen(event));
|
|
||||||
slidersValueChangeListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Window getWindow() {
|
|
||||||
reset();
|
reset();
|
||||||
swTypeWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.type"), null,
|
window = SPUIComponentProvider.getWindow(i18n.get("caption.add.type"), null,
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, this::save, this::discard, null);
|
||||||
swTypeWindow.setContent(this);
|
|
||||||
return swTypeWindow;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,100 +125,35 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
* @param event
|
* @param event
|
||||||
* ValueChangeEvent
|
* ValueChangeEvent
|
||||||
*/
|
*/
|
||||||
private void createOptionValueChanged(final ValueChangeEvent event) {
|
@Override
|
||||||
if ("Update Type".equals(event.getProperty().getValue())) {
|
protected void createOptionValueChanged(final ValueChangeEvent event) {
|
||||||
typeName.clear();
|
|
||||||
typeDesc.clear();
|
super.createOptionValueChanged(event);
|
||||||
typeKey.clear();
|
|
||||||
typeKey.setEnabled(false);
|
if (updateTypeStr.equals(event.getProperty().getValue())) {
|
||||||
typeName.setEnabled(false);
|
|
||||||
assignOptiongroup.setEnabled(false);
|
assignOptiongroup.setEnabled(false);
|
||||||
|
|
||||||
populateTypeNameCombo();
|
|
||||||
// show target name combo
|
|
||||||
comboLayout.addComponent(comboLabel);
|
|
||||||
comboLayout.addComponent(typeNameComboBox);
|
|
||||||
} else {
|
} else {
|
||||||
typeKey.setEnabled(true);
|
|
||||||
typeName.setEnabled(true);
|
|
||||||
typeName.clear();
|
|
||||||
typeDesc.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
assignOptiongroup.setEnabled(true);
|
assignOptiongroup.setEnabled(true);
|
||||||
// hide target name combo
|
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(typeNameComboBox);
|
|
||||||
}
|
}
|
||||||
// close the color picker layout
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
// reset the selected color - Set defualt color
|
|
||||||
restoreComponentStyles();
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
|
|
||||||
// remove the sliders and color picker layout
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate Software Module Type name combo.
|
|
||||||
*/
|
|
||||||
public void populateTypeNameCombo() {
|
|
||||||
typeNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
|
||||||
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
|
||||||
typeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reset the components.
|
* reset the components.
|
||||||
*/
|
*/
|
||||||
private void reset() {
|
@Override
|
||||||
typeName.setEnabled(true);
|
protected void reset() {
|
||||||
typeName.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
typeDesc.clear();
|
|
||||||
restoreComponentStyles();
|
|
||||||
|
|
||||||
// hide target name combo
|
super.reset();
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(typeNameComboBox);
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
createOptiongroup.select(createTypeStr);
|
|
||||||
assignOptiongroup.select(singleAssignStr);
|
assignOptiongroup.select(singleAssignStr);
|
||||||
// Default green color
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void typeNameChosen(final ValueChangeEvent event) {
|
@Override
|
||||||
final String tagSelected = (String) event.getProperty().getValue();
|
protected void resetTagNameField() {
|
||||||
if (null != tagSelected) {
|
|
||||||
setTypeTagCombo(tagSelected);
|
|
||||||
} else {
|
|
||||||
resetTagNameField();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetTagNameField() {
|
|
||||||
typeName.setEnabled(false);
|
|
||||||
typeName.clear();
|
|
||||||
|
|
||||||
|
super.resetTagNameField();
|
||||||
typeKey.clear();
|
typeKey.clear();
|
||||||
typeDesc.clear();
|
tagDesc.clear();
|
||||||
restoreComponentStyles();
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
assignOptiongroup.select(singleAssignStr);
|
assignOptiongroup.select(singleAssignStr);
|
||||||
// Default green color
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,12 +163,13 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
* @param targetTagSelected
|
* @param targetTagSelected
|
||||||
* as the selected tag from combo
|
* as the selected tag from combo
|
||||||
*/
|
*/
|
||||||
private void setTypeTagCombo(final String targetTagSelected) {
|
@Override
|
||||||
typeName.setValue(targetTagSelected);
|
protected void setTagDetails(final String targetTagSelected) {
|
||||||
|
tagName.setValue(targetTagSelected);
|
||||||
final SoftwareModuleType selectedTypeTag = swTypeManagementService
|
final SoftwareModuleType selectedTypeTag = swTypeManagementService
|
||||||
.findSoftwareModuleTypeByName(targetTagSelected);
|
.findSoftwareModuleTypeByName(targetTagSelected);
|
||||||
if (null != selectedTypeTag) {
|
if (null != selectedTypeTag) {
|
||||||
typeDesc.setValue(selectedTypeTag.getDescription());
|
tagDesc.setValue(selectedTypeTag.getDescription());
|
||||||
typeKey.setValue(selectedTypeTag.getKey());
|
typeKey.setValue(selectedTypeTag.getKey());
|
||||||
if (selectedTypeTag.getMaxAssignments() == Integer.MAX_VALUE) {
|
if (selectedTypeTag.getMaxAssignments() == Integer.MAX_VALUE) {
|
||||||
assignOptiongroup.setValue(multiAssignStr);
|
assignOptiongroup.setValue(multiAssignStr);
|
||||||
@@ -406,46 +177,10 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
assignOptiongroup.setValue(singleAssignStr);
|
assignOptiongroup.setValue(singleAssignStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null == selectedTypeTag.getColour()) {
|
setColorPickerComponentsColor(selectedTypeTag.getColour());
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, DEFAULT_COLOR);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
selectedColor = rgbToColorConverter(selectedTypeTag.getColour());
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, selectedTypeTag.getColour());
|
|
||||||
getPreviewButtonColor(selectedTypeTag.getColour());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic styles for window.
|
|
||||||
*
|
|
||||||
* @param top
|
|
||||||
* int value
|
|
||||||
* @param marginLeft
|
|
||||||
* int value
|
|
||||||
*/
|
|
||||||
private void getPreviewButtonColor(final String color) {
|
|
||||||
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createUpdateOptionGroup() {
|
|
||||||
final List<String> optionValues = new ArrayList<>();
|
|
||||||
if (permChecker.hasCreateDistributionPermission()) {
|
|
||||||
optionValues.add(createType.getValue());
|
|
||||||
}
|
|
||||||
if (permChecker.hasUpdateDistributionPermission()) {
|
|
||||||
optionValues.add(updateType.getValue());
|
|
||||||
}
|
|
||||||
createOptionGroupByValues(optionValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void singleMultiOptionGroup() {
|
private void singleMultiOptionGroup() {
|
||||||
final List<String> optionValues = new ArrayList<>();
|
final List<String> optionValues = new ArrayList<>();
|
||||||
optionValues.add(singleAssign.getValue());
|
optionValues.add(singleAssign.getValue());
|
||||||
@@ -453,16 +188,6 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
assignOptionGroupByValues(optionValues);
|
assignOptionGroupByValues(optionValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOptionGroupByValues(final List<String> tagOptions) {
|
|
||||||
createOptiongroup = new OptionGroup("", tagOptions);
|
|
||||||
createOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
|
||||||
createOptiongroup.addStyleName("custom-option-group");
|
|
||||||
createOptiongroup.setNullSelectionAllowed(false);
|
|
||||||
if (!tagOptions.isEmpty()) {
|
|
||||||
createOptiongroup.select(tagOptions.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assignOptionGroupByValues(final List<String> tagOptions) {
|
private void assignOptionGroupByValues(final List<String> tagOptions) {
|
||||||
assignOptiongroup = new OptionGroup("", tagOptions);
|
assignOptiongroup = new OptionGroup("", tagOptions);
|
||||||
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||||
@@ -471,156 +196,32 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
assignOptiongroup.select(tagOptions.get(0));
|
assignOptiongroup.select(tagOptions.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label getMandatoryLabel() {
|
@Override
|
||||||
final Label label = new Label(i18n.get("label.mandatory.field"));
|
protected void save(final ClickEvent event) {
|
||||||
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
if (!mandatoryValuesPresent()) {
|
||||||
return label;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Slider createRGBSlider(final String caption, final String styleName) {
|
final SoftwareModuleType existingSMTypeByKey = swTypeManagementService
|
||||||
final Slider slider = new Slider(caption, 0, 255);
|
.findSoftwareModuleTypeByKey(typeKey.getValue());
|
||||||
slider.setImmediate(true);
|
final SoftwareModuleType existingSMTypeByName = swTypeManagementService
|
||||||
slider.setWidth("150px");
|
.findSoftwareModuleTypeByName(tagName.getValue());
|
||||||
slider.addStyleName(styleName);
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
return slider;
|
if (!checkIsDuplicateByKey(existingSMTypeByKey) && !checkIsDuplicate(existingSMTypeByName)) {
|
||||||
}
|
createNewSWModuleType();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
private void setRgbSliderValues(final Color color) {
|
updateSWModuleType(existingSMTypeByName);
|
||||||
try {
|
|
||||||
final double redColorValue = color.getRed();
|
|
||||||
redSlider.setValue(new Double(redColorValue));
|
|
||||||
final double blueColorValue = color.getBlue();
|
|
||||||
blueSlider.setValue(new Double(blueColorValue));
|
|
||||||
final double greenColorValue = color.getGreen();
|
|
||||||
greenSlider.setValue(new Double(greenColorValue));
|
|
||||||
} catch (final ValueOutOfBoundsException e) {
|
|
||||||
LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
|
|
||||||
+ color.getBlue(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Value change listeners implementations of sliders.
|
|
||||||
*/
|
|
||||||
private void slidersValueChangeListeners() {
|
|
||||||
redSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = -8336732888800920839L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double red = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
greenSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 1236358037766775663L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double green = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), (int) green, selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
blueSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 8466370763686043947L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double blue = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), selectedColor.getGreen(), (int) blue);
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setColorToComponents(final Color newColor) {
|
|
||||||
setColor(newColor);
|
|
||||||
colorSelect.setColor(newColor);
|
|
||||||
getPreviewButtonColor(newColor.getCSS());
|
|
||||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, newColor.getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reset the tag name and tag description component border color.
|
|
||||||
*/
|
|
||||||
private void restoreComponentStyles() {
|
|
||||||
typeName.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeDesc.removeStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
|
||||||
if (mandatoryValuesPresent()) {
|
|
||||||
final SoftwareModuleType existingType = swTypeManagementService
|
|
||||||
.findSoftwareModuleTypeByName(typeName.getValue());
|
|
||||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
|
||||||
if (!checkIsKeyDuplicate(typeKey.getValue()) && !checkIsDuplicate(existingType)) {
|
|
||||||
createNewSWModuleType();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
updateSWModuleType(existingType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkIsKeyDuplicate(final String key) {
|
|
||||||
final SoftwareModuleType existingKeyType = swTypeManagementService.findSoftwareModuleTypeByKey(key);
|
|
||||||
if (existingKeyType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.type.key.swmodule.duplicate.check", new Object[] { existingKeyType.getKey() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean mandatoryValuesPresent() {
|
|
||||||
if (Strings.isNullOrEmpty(typeName.getValue()) && Strings.isNullOrEmpty(typeKey.getValue())) {
|
|
||||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
|
||||||
}
|
|
||||||
if (createOptiongroup.getValue().equals(updateTypeStr)) {
|
|
||||||
if (null == typeNameComboBox.getValue()) {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.typename"));
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean checkIsDuplicate(final SoftwareModuleType existingType) {
|
|
||||||
if (existingType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeWindow() {
|
|
||||||
swTypeWindow.close();
|
|
||||||
UI.getCurrent().removeWindow(swTypeWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void discard() {
|
|
||||||
UI.getCurrent().removeWindow(swTypeWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new tag.
|
|
||||||
*/
|
|
||||||
private void createNewSWModuleType() {
|
private void createNewSWModuleType() {
|
||||||
int assignNumber = 0;
|
int assignNumber = 0;
|
||||||
final String colorPicked = getColorPickedString();
|
final String colorPicked = ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview());
|
||||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeName.getValue());
|
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
||||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
|
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||||
final String assignValue = (String) assignOptiongroup.getValue();
|
final String assignValue = (String) assignOptiongroup.getValue();
|
||||||
if (null != assignValue && assignValue.equalsIgnoreCase(singleAssignStr)) {
|
if (null != assignValue && assignValue.equalsIgnoreCase(singleAssignStr)) {
|
||||||
assignNumber = 1;
|
assignNumber = 1;
|
||||||
@@ -651,38 +252,16 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get color picked value in string.
|
|
||||||
*
|
|
||||||
* @return String of color picked value.
|
|
||||||
*/
|
|
||||||
private String getColorPickedString() {
|
|
||||||
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
|
|
||||||
+ getSelPreview().getColor().getBlue() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Color view.
|
|
||||||
*
|
|
||||||
* @return ColorPickerPreview as UI
|
|
||||||
*/
|
|
||||||
public SpColorPickerPreview getSelPreview() {
|
|
||||||
return selPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update tag.
|
|
||||||
*/
|
|
||||||
private void updateSWModuleType(final SoftwareModuleType existingType) {
|
private void updateSWModuleType(final SoftwareModuleType existingType) {
|
||||||
|
|
||||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeName.getValue());
|
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
|
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||||
if (null != typeNameValue) {
|
if (null != typeNameValue) {
|
||||||
existingType.setName(typeNameValue);
|
existingType.setName(typeNameValue);
|
||||||
|
|
||||||
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
|
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
|
||||||
|
|
||||||
existingType.setColour(getColorPickedString());
|
existingType.setColour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
|
||||||
swTypeManagementService.updateSoftwareModuleType(existingType);
|
swTypeManagementService.updateSoftwareModuleType(existingType);
|
||||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
|
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
|
||||||
closeWindow();
|
closeWindow();
|
||||||
@@ -699,55 +278,33 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
* Open color picker on click of preview button. Auto select the color based
|
* Open color picker on click of preview button. Auto select the color based
|
||||||
* on target tag if already selected.
|
* on target tag if already selected.
|
||||||
*/
|
*/
|
||||||
private void previewButtonClicked() {
|
@Override
|
||||||
|
protected void previewButtonClicked() {
|
||||||
if (!tagPreviewBtnClicked) {
|
if (!tagPreviewBtnClicked) {
|
||||||
final String selectedOption = (String) createOptiongroup.getValue();
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTypeStr)) {
|
if (StringUtils.isNotEmpty(selectedOption) && selectedOption.equalsIgnoreCase(updateTypeStr)) {
|
||||||
if (null != typeNameComboBox.getValue()) {
|
if (null != tagNameComboBox.getValue()) {
|
||||||
|
|
||||||
final SoftwareModuleType typeSelected = swTypeManagementService
|
final SoftwareModuleType typeSelected = swTypeManagementService
|
||||||
.findSoftwareModuleTypeByName(typeNameComboBox.getValue().toString());
|
.findSoftwareModuleTypeByName(tagNameComboBox.getValue().toString());
|
||||||
if (null != typeSelected) {
|
if (null != typeSelected) {
|
||||||
selectedColor = typeSelected.getColour() != null ? rgbToColorConverter(typeSelected.getColour())
|
getColorPickerLayout().setSelectedColor(typeSelected.getColour() != null
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
? ColorPickerHelper.rgbToColorConverter(typeSelected.getColour())
|
||||||
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
getColorPickerLayout().setSelectedColor(
|
||||||
|
ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selPreview.setColor(selectedColor);
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
fieldLayout.addComponent(sliders);
|
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||||
mainLayout.addComponent(colorPickerLayout);
|
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
|
} else {
|
||||||
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
}
|
}
|
||||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Covert RGB code to {@Color}.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* RGB vale
|
|
||||||
* @return Color
|
|
||||||
*/
|
|
||||||
protected Color rgbToColorConverter(final String value) {
|
|
||||||
if (value.startsWith("rgb")) {
|
|
||||||
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
|
||||||
final int red = Integer.parseInt(colors[0]);
|
|
||||||
final int green = Integer.parseInt(colors[1]);
|
|
||||||
final int blue = Integer.parseInt(colors[2]);
|
|
||||||
if (colors.length > 3) {
|
|
||||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
|
||||||
return new Color(red, green, blue, alpha);
|
|
||||||
} else {
|
|
||||||
return new Color(red, green, blue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addColorChangeListener(final ColorChangeListener listener) {
|
public void addColorChangeListener(final ColorChangeListener listener) {
|
||||||
LOG.debug("inside addColorChangeListener");
|
LOG.debug("inside addColorChangeListener");
|
||||||
@@ -759,63 +316,16 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setColor(final Color color) {
|
|
||||||
if (color == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedColor = color;
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
final String colorPickedPreview = selPreview.getColor().getCSS();
|
|
||||||
if (typeName.isEnabled() && null != colorSelect) {
|
|
||||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, colorPickedPreview);
|
|
||||||
colorSelect.setColor(selPreview.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void colorChanged(final ColorChangeEvent event) {
|
protected void populateTagNameCombo() {
|
||||||
setColor(event.getColor());
|
tagNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||||
for (final ColorSelector select : selectors) {
|
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
|
||||||
if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(selectedColor)) {
|
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||||
select.setColor(selectedColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setRgbSliderValues(selectedColor);
|
|
||||||
getPreviewButtonColor(event.getColor().getCSS());
|
|
||||||
createDynamicStyleForComponents(typeName, typeKey, typeDesc, event.getColor().getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set tag name and desc field border color based on chosen color.
|
|
||||||
*
|
|
||||||
* @param tagName
|
|
||||||
* @param tagDesc
|
|
||||||
* @param taregtTagColor
|
|
||||||
*/
|
|
||||||
private void createDynamicStyleForComponents(final TextField typeName, final TextField typeKey,
|
|
||||||
final TextArea typeDesc, final String typeTagColor) {
|
|
||||||
getTargetDynamicStyles(typeTagColor);
|
|
||||||
typeName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get target style - Dynamically as per the color picked, cannot be done
|
|
||||||
* from the static css.
|
|
||||||
*
|
|
||||||
* @param colorPickedPreview
|
|
||||||
*/
|
|
||||||
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
|
||||||
Page.getCurrent().getJavaScript()
|
|
||||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,16 +245,16 @@ 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("", ValoTheme.TEXTFIELD_TINY, false, null, null,
|
final TextField sha1 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
sha1.setId(swNameVersion + "/" + customFile.getFileName() + "/sha1");
|
sha1.setId(swNameVersion + "/" + customFile.getFileName() + "/sha1");
|
||||||
|
|
||||||
final TextField md5 = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, null,
|
final TextField md5 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
md5.setId(swNameVersion + "/" + customFile.getFileName() + "/md5");
|
md5.setId(swNameVersion + "/" + customFile.getFileName() + "/md5");
|
||||||
|
|
||||||
final TextField customFileName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false,
|
final TextField customFileName = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
||||||
null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
customFileName.setId(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
|
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);
|
||||||
@@ -265,8 +265,8 @@ public class UploadConfirmationwindow implements Button.ClickListener {
|
|||||||
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("", ValoTheme.TEXTFIELD_TINY, false,
|
final TextField fileNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
|
||||||
null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
fileNameTextField.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
|
fileNameTextField.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
|
||||||
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
|
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
|
||||||
fileNameTextField.setValue(customFileName);
|
fileNameTextField.setValue(customFileName);
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
SPUIButtonStyleSmall.class);
|
SPUIButtonStyleSmall.class);
|
||||||
processBtn.setIcon(FontAwesome.BELL);
|
processBtn.setIcon(FontAwesome.BELL);
|
||||||
processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||||
processBtn.addClickListener(event -> displayConfirmWindow(event));
|
processBtn.addClickListener(this::displayConfirmWindow);
|
||||||
processBtn.setHtmlContentAllowed(true);
|
processBtn.setHtmlContentAllowed(true);
|
||||||
processBtn.setEnabled(false);
|
processBtn.setEnabled(false);
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
SPUIButtonStyleSmall.class);
|
SPUIButtonStyleSmall.class);
|
||||||
discardBtn.setIcon(FontAwesome.TRASH_O);
|
discardBtn.setIcon(FontAwesome.TRASH_O);
|
||||||
discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
|
||||||
discardBtn.addClickListener(event -> discardUploadData(event));
|
discardBtn.addClickListener(this::discardUploadData);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkForDuplicate(final String filename, final SoftwareModule selectedSw) {
|
boolean checkForDuplicate(final String filename, final SoftwareModule selectedSw) {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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.colorpicker;
|
||||||
|
|
||||||
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides color constants for the ColorPickerLayout
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ColorPickerConstants {
|
||||||
|
|
||||||
|
public static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
||||||
|
public static final Color START_COLOR = new Color(0, 146, 58);
|
||||||
|
|
||||||
|
private ColorPickerConstants() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* 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.colorpicker;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
|
import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains helper methods for the ColorPickerLayout to handle the ColorPicker
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ColorPickerHelper {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(ColorPickerHelper.class);
|
||||||
|
|
||||||
|
private ColorPickerHelper() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get color picked value as string.
|
||||||
|
*
|
||||||
|
* @return String of color picked value.
|
||||||
|
*/
|
||||||
|
public static String getColorPickedString(final SpColorPickerPreview preview) {
|
||||||
|
|
||||||
|
final Color color = preview.getColor();
|
||||||
|
return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Covert RGB code to {@Color}.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* RGB vale
|
||||||
|
* @return Color
|
||||||
|
*/
|
||||||
|
public static Color rgbToColorConverter(final String value) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(value) || (StringUtils.isNotEmpty(value) && !value.startsWith("rgb"))) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"String to convert is empty or of invalid format - value: '" + value + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// RGB color format rgb/rgba(255,255,255,0.1)
|
||||||
|
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
||||||
|
final int red = Integer.parseInt(colors[0]);
|
||||||
|
final int green = Integer.parseInt(colors[1]);
|
||||||
|
final int blue = Integer.parseInt(colors[2]);
|
||||||
|
if (colors.length > 3) {
|
||||||
|
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
||||||
|
return new Color(red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
return new Color(red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Gets the selectedColor in the ColorPickerLayout and sets the slider
|
||||||
|
* values
|
||||||
|
*
|
||||||
|
* @param colorPickerLayout
|
||||||
|
* colorPickerLayout
|
||||||
|
*/
|
||||||
|
public static void setRgbSliderValues(final ColorPickerLayout colorPickerLayout) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final double redColorValue = colorPickerLayout.getSelectedColor().getRed();
|
||||||
|
colorPickerLayout.getRedSlider().setValue(Double.valueOf(redColorValue));
|
||||||
|
final double blueColorValue = colorPickerLayout.getSelectedColor().getBlue();
|
||||||
|
colorPickerLayout.getBlueSlider().setValue(Double.valueOf(blueColorValue));
|
||||||
|
final double greenColorValue = colorPickerLayout.getSelectedColor().getGreen();
|
||||||
|
colorPickerLayout.getGreenSlider().setValue(Double.valueOf(greenColorValue));
|
||||||
|
} catch (final ValueOutOfBoundsException e) {
|
||||||
|
LOG.error("Unable to set RGB color value to " + colorPickerLayout.getSelectedColor().getRed() + ","
|
||||||
|
+ colorPickerLayout.getSelectedColor().getGreen() + ","
|
||||||
|
+ colorPickerLayout.getSelectedColor().getBlue(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
/**
|
||||||
|
* 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.colorpicker;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
|
||||||
|
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
||||||
|
|
||||||
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
|
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
||||||
|
import com.vaadin.ui.GridLayout;
|
||||||
|
import com.vaadin.ui.Slider;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorPickerGradient;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Defines the Layout for the ColorPicker
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ColorPickerLayout extends GridLayout {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7025970080613796692L;
|
||||||
|
|
||||||
|
private SpColorPickerPreview selPreview;
|
||||||
|
|
||||||
|
private ColorPickerGradient colorSelect;
|
||||||
|
private Set<ColorSelector> selectors;
|
||||||
|
private Color selectedColor;
|
||||||
|
|
||||||
|
/** RGB color converter. */
|
||||||
|
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
||||||
|
|
||||||
|
private Slider redSlider;
|
||||||
|
private Slider greenSlider;
|
||||||
|
private Slider blueSlider;
|
||||||
|
|
||||||
|
public ColorPickerLayout() {
|
||||||
|
|
||||||
|
setColumns(2);
|
||||||
|
setRows(4);
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
setStyleName("rgb-vertical-layout");
|
||||||
|
|
||||||
|
addComponent(redSlider, 0, 1);
|
||||||
|
addComponent(greenSlider, 0, 2);
|
||||||
|
addComponent(blueSlider, 0, 3);
|
||||||
|
|
||||||
|
addComponent(selPreview, 1, 0);
|
||||||
|
addComponent(colorSelect, 1, 1, 1, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
selectors = new HashSet<>();
|
||||||
|
selectedColor = getDefaultColor();
|
||||||
|
selPreview = new SpColorPickerPreview(selectedColor);
|
||||||
|
|
||||||
|
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
|
||||||
|
colorSelect.setColor(selectedColor);
|
||||||
|
colorSelect.setWidth("220px");
|
||||||
|
|
||||||
|
redSlider = createRGBSlider("", "red");
|
||||||
|
greenSlider = createRGBSlider("", "green");
|
||||||
|
blueSlider = createRGBSlider("", "blue");
|
||||||
|
|
||||||
|
selectors.add(colorSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Slider createRGBSlider(final String caption, final String styleName) {
|
||||||
|
final Slider slider = new Slider(caption, 0, 255);
|
||||||
|
slider.setImmediate(true);
|
||||||
|
slider.setWidth("150px");
|
||||||
|
slider.addStyleName(styleName);
|
||||||
|
return slider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpColorPickerPreview getSelPreview() {
|
||||||
|
return selPreview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelPreview(final SpColorPickerPreview selPreview) {
|
||||||
|
this.selPreview = selPreview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorPickerGradient getColorSelect() {
|
||||||
|
return colorSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColorSelect(final ColorPickerGradient colorSelect) {
|
||||||
|
this.colorSelect = colorSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ColorSelector> getSelectors() {
|
||||||
|
return selectors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getSelectedColor() {
|
||||||
|
return selectedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedColor(final Color selectedColor) {
|
||||||
|
this.selectedColor = selectedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Coordinates2Color getRgbConverter() {
|
||||||
|
return rgbConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getDefaultColor() {
|
||||||
|
return new Color(44, 151, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Slider getRedSlider() {
|
||||||
|
return redSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRedSlider(final Slider redSlider) {
|
||||||
|
this.redSlider = redSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Slider getGreenSlider() {
|
||||||
|
return greenSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGreenSlider(final Slider greenSlider) {
|
||||||
|
this.greenSlider = greenSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Slider getBlueSlider() {
|
||||||
|
return blueSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlueSlider(final Slider blueSlider) {
|
||||||
|
this.blueSlider = blueSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.ui.common;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleBorderWithIcon;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
|
|
||||||
|
import com.vaadin.data.Property.ValueChangeListener;
|
||||||
|
import com.vaadin.server.FontAwesome;
|
||||||
|
import com.vaadin.ui.AbstractOrderedLayout;
|
||||||
|
import com.vaadin.ui.Alignment;
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.Button.ClickListener;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.Link;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
import com.vaadin.ui.Window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Superclass for pop-up-windows including a minimize and close icon in the
|
||||||
|
* upper right corner and a save and cancel button at the bottom.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CommonDialogWindow extends Window {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1321949234316858703L;
|
||||||
|
|
||||||
|
private final VerticalLayout mainLayout = new VerticalLayout();
|
||||||
|
|
||||||
|
private final String caption;
|
||||||
|
|
||||||
|
private final Component content;
|
||||||
|
|
||||||
|
private final String helpLink;
|
||||||
|
|
||||||
|
private Button saveButton;
|
||||||
|
|
||||||
|
private Button cancelButton;
|
||||||
|
|
||||||
|
private HorizontalLayout buttonsLayout;
|
||||||
|
|
||||||
|
protected ValueChangeListener buttonEnableListener;
|
||||||
|
|
||||||
|
private final ClickListener saveButtonClickListener;
|
||||||
|
|
||||||
|
private final ClickListener cancelButtonClickListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param caption
|
||||||
|
* the caption
|
||||||
|
* @param content
|
||||||
|
* the content
|
||||||
|
* @param helpLink
|
||||||
|
* the helpLinks
|
||||||
|
* @param saveButtonClickListener
|
||||||
|
* the saveButtonClickListener
|
||||||
|
* @param cancelButtonClickListener
|
||||||
|
* the cancelButtonClickListener
|
||||||
|
*/
|
||||||
|
public CommonDialogWindow(final String caption, final Component content, final String helpLink,
|
||||||
|
final ClickListener saveButtonClickListener, final ClickListener cancelButtonClickListener) {
|
||||||
|
checkNotNull(saveButtonClickListener);
|
||||||
|
checkNotNull(cancelButtonClickListener);
|
||||||
|
this.caption = caption;
|
||||||
|
this.content = content;
|
||||||
|
this.helpLink = helpLink;
|
||||||
|
this.saveButtonClickListener = saveButtonClickListener;
|
||||||
|
this.cancelButtonClickListener = cancelButtonClickListener;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final void init() {
|
||||||
|
|
||||||
|
if (content instanceof AbstractOrderedLayout) {
|
||||||
|
((AbstractOrderedLayout) content).setSpacing(true);
|
||||||
|
((AbstractOrderedLayout) content).setMargin(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != content) {
|
||||||
|
mainLayout.addComponent(content);
|
||||||
|
}
|
||||||
|
final HorizontalLayout buttonLayout = createActionButtonsLayout();
|
||||||
|
mainLayout.addComponent(buttonLayout);
|
||||||
|
mainLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER);
|
||||||
|
|
||||||
|
setCaption(caption);
|
||||||
|
setContent(mainLayout);
|
||||||
|
setResizable(false);
|
||||||
|
center();
|
||||||
|
setModal(true);
|
||||||
|
addStyleName("fontsize");
|
||||||
|
}
|
||||||
|
|
||||||
|
private HorizontalLayout createActionButtonsLayout() {
|
||||||
|
|
||||||
|
buttonsLayout = new HorizontalLayout();
|
||||||
|
buttonsLayout.setSizeFull();
|
||||||
|
buttonsLayout.setSpacing(true);
|
||||||
|
|
||||||
|
createSaveButton();
|
||||||
|
|
||||||
|
createCancelButton();
|
||||||
|
buttonsLayout.addStyleName("actionButtonsMargin");
|
||||||
|
|
||||||
|
addHelpLink();
|
||||||
|
|
||||||
|
return buttonsLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCancelButton() {
|
||||||
|
cancelButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.CANCEL_BUTTON, "Cancel", "", "", true,
|
||||||
|
FontAwesome.TIMES, SPUIButtonStyleBorderWithIcon.class);
|
||||||
|
cancelButton.setSizeUndefined();
|
||||||
|
cancelButton.addStyleName("default-color");
|
||||||
|
cancelButton.addClickListener(cancelButtonClickListener);
|
||||||
|
|
||||||
|
buttonsLayout.addComponent(cancelButton);
|
||||||
|
buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_LEFT);
|
||||||
|
buttonsLayout.setExpandRatio(cancelButton, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSaveButton() {
|
||||||
|
saveButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SAVE_BUTTON, "Save", "", "", true,
|
||||||
|
FontAwesome.SAVE, SPUIButtonStyleBorderWithIcon.class);
|
||||||
|
saveButton.setSizeUndefined();
|
||||||
|
saveButton.addStyleName("default-color");
|
||||||
|
saveButton.addClickListener(saveButtonClickListener);
|
||||||
|
buttonsLayout.addComponent(saveButton);
|
||||||
|
buttonsLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT);
|
||||||
|
buttonsLayout.setExpandRatio(saveButton, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHelpLink() {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(helpLink)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Link helpLinkComponent = SPUIComponentProvider.getHelpLink(helpLink);
|
||||||
|
buttonsLayout.addComponent(helpLinkComponent);
|
||||||
|
buttonsLayout.setComponentAlignment(helpLinkComponent, Alignment.MIDDLE_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaveButtonEnabled(final boolean enabled) {
|
||||||
|
saveButton.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelButtonEnabled(final boolean enabled) {
|
||||||
|
cancelButton.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HorizontalLayout getButtonsLayout() {
|
||||||
|
return buttonsLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -125,8 +125,7 @@ public abstract class AbstractFilterButtons extends Table {
|
|||||||
} else if (id != null && isClickedByDefault(name)) {
|
} else if (id != null && isClickedByDefault(name)) {
|
||||||
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
|
||||||
}
|
}
|
||||||
final DragAndDropWrapper wrapper = createDragAndDropWrapper(typeButton, name, id);
|
return createDragAndDropWrapper(typeButton, name, id);
|
||||||
return wrapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isNoTagSateSelected() {
|
protected boolean isNoTagSateSelected() {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -1388340600522323332L;
|
private static final long serialVersionUID = -1388340600522323332L;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SpPermissionChecker permChecker;
|
protected SpPermissionChecker permChecker;
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
|||||||
if (hasCreateUpdatePermission() && isAddTagRequired()) {
|
if (hasCreateUpdatePermission() && isAddTagRequired()) {
|
||||||
config = SPUIComponentProvider.getButton(getConfigureFilterButtonId(), "", "", "", true, FontAwesome.COG,
|
config = SPUIComponentProvider.getButton(getConfigureFilterButtonId(), "", "", "", true, FontAwesome.COG,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
config.addClickListener(event -> settingsIconClicked(event));
|
config.addClickListener(this::settingsIconClicked);
|
||||||
}
|
}
|
||||||
hideIcon = SPUIComponentProvider.getButton(getHideButtonId(), "", "", "", true, FontAwesome.TIMES,
|
hideIcon = SPUIComponentProvider.getButton(getHideButtonId(), "", "", "", true, FontAwesome.TIMES,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
@@ -92,8 +91,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createHeaderCaption() {
|
private Label createHeaderCaption() {
|
||||||
final Label captionLabel = SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
return SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||||
return captionLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private TextField createSearchField() {
|
||||||
final TextField textField = SPUIComponentProvider.getTextField("filter-box", "text-style filter-box-hide",
|
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
||||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
textField.setId(getSearchBoxId());
|
textField.setId(getSearchBoxId());
|
||||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
||||||
@@ -123,14 +123,14 @@ public abstract class AbstractGridHeader extends VerticalLayout {
|
|||||||
private Button createAddButton() {
|
private Button createAddButton() {
|
||||||
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
button.addClickListener(event -> addNewItem(event));
|
button.addClickListener(this::addNewItem);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createCloseButton() {
|
private Button createCloseButton() {
|
||||||
final Button button = SPUIComponentProvider.getButton(getCloseButtonId(), "", "", null, false,
|
final Button button = SPUIComponentProvider.getButton(getCloseButtonId(), "", "", null, false,
|
||||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||||
button.addClickListener(event -> onClose(event));
|
button.addClickListener(this::onClose);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private TextField createSearchField() {
|
||||||
final TextField textField = SPUIComponentProvider.getTextField("filter-box", "text-style filter-box-hide",
|
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
|
||||||
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
textField.setId(getSearchBoxId());
|
textField.setId(getSearchBoxId());
|
||||||
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
textField.setWidth(100.0f, Unit.PERCENTAGE);
|
||||||
@@ -235,14 +235,14 @@ public abstract class AbstractTableHeader extends VerticalLayout {
|
|||||||
private Button createAddIcon() {
|
private Button createAddIcon() {
|
||||||
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
button.addClickListener(event -> addNewItem(event));
|
button.addClickListener(this::addNewItem);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createBulkUploadIcon() {
|
private Button createBulkUploadIcon() {
|
||||||
final Button button = SPUIComponentProvider.getButton(getBulkUploadIconId(), "", "", null, false,
|
final Button button = SPUIComponentProvider.getButton(getBulkUploadIconId(), "", "", null, false,
|
||||||
FontAwesome.UPLOAD, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.UPLOAD, SPUIButtonStyleSmallNoBorder.class);
|
||||||
button.addClickListener(event -> bulkUpload(event));
|
button.addClickListener(this::bulkUpload);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
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;
|
||||||
@@ -32,8 +33,10 @@ import com.vaadin.server.FontAwesome;
|
|||||||
import com.vaadin.server.Resource;
|
import com.vaadin.server.Resource;
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
import com.vaadin.shared.ui.label.ContentMode;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.Button.ClickListener;
|
||||||
import com.vaadin.ui.CheckBox;
|
import com.vaadin.ui.CheckBox;
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
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;
|
||||||
@@ -137,6 +140,24 @@ public final class SPUIComponentProvider {
|
|||||||
return SPUILabelDecorator.getDeocratedLabel(name, 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 CommonDialogWindow getWindow(final String caption, final String id, final String type,
|
||||||
|
final Component content, final ClickListener saveButtonClickListener,
|
||||||
|
final ClickListener cancelButtonClickListener, final String helpLink) {
|
||||||
|
return SPUIWindowDecorator.getDeocratedWindow(caption, id, type, content, saveButtonClickListener,
|
||||||
|
cancelButtonClickListener, helpLink);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get window component.
|
* Get window component.
|
||||||
*
|
*
|
||||||
@@ -155,6 +176,8 @@ public final class SPUIComponentProvider {
|
|||||||
/**
|
/**
|
||||||
* Get Label UI component.
|
* Get Label UI component.
|
||||||
*
|
*
|
||||||
|
* @param caption
|
||||||
|
* set the caption of the textfield
|
||||||
* @param style
|
* @param style
|
||||||
* set style
|
* set style
|
||||||
* @param styleName
|
* @param styleName
|
||||||
@@ -163,7 +186,7 @@ public final class SPUIComponentProvider {
|
|||||||
* to set field as mandatory
|
* to set field as mandatory
|
||||||
* @param data
|
* @param data
|
||||||
* component data
|
* component data
|
||||||
* @param promt
|
* @param prompt
|
||||||
* prompt user for input
|
* prompt user for input
|
||||||
* @param immediate
|
* @param immediate
|
||||||
* set component's immediate mode specified mode
|
* set component's immediate mode specified mode
|
||||||
@@ -171,9 +194,11 @@ public final class SPUIComponentProvider {
|
|||||||
* maximum characters allowed
|
* maximum characters allowed
|
||||||
* @return TextField text field
|
* @return TextField text field
|
||||||
*/
|
*/
|
||||||
public static TextField getTextField(final String style, final String styleName, final boolean required,
|
public static TextField getTextField(final String caption, final String style, final String styleName,
|
||||||
final String data, final String promt, final boolean immediate, final int maxLengthAllowed) {
|
final boolean required, final String data, final String prompt, final boolean immediate,
|
||||||
return SPUITextFieldDecorator.decorate(style, styleName, required, data, promt, immediate, maxLengthAllowed);
|
final int maxLengthAllowed) {
|
||||||
|
return SPUITextFieldDecorator.decorate(caption, style, styleName, required, data, prompt, immediate,
|
||||||
|
maxLengthAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,14 +218,16 @@ public final class SPUIComponentProvider {
|
|||||||
* maximum characters allowed
|
* maximum characters allowed
|
||||||
* @return TextArea text area
|
* @return TextArea text area
|
||||||
*/
|
*/
|
||||||
public static TextArea getTextArea(final String style, final String styleName, final boolean required,
|
public static TextArea getTextArea(final String caption, final String style, final String styleName,
|
||||||
final String data, final String promt, final int maxLength) {
|
final boolean required, final String data, final String promt, final int maxLength) {
|
||||||
return SPUITextAreaDecorator.decorate(style, styleName, required, data, promt, maxLength);
|
return SPUITextAreaDecorator.decorate(caption, style, styleName, required, data, promt, maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Label UI component.
|
* Get Label UI component.
|
||||||
*
|
*
|
||||||
|
* @param caption
|
||||||
|
* caption of the combo box
|
||||||
* @param height
|
* @param height
|
||||||
* combo box height
|
* combo box height
|
||||||
* @param width
|
* @param width
|
||||||
@@ -217,9 +244,9 @@ public final class SPUIComponentProvider {
|
|||||||
* input prompt
|
* input prompt
|
||||||
* @return ComboBox
|
* @return ComboBox
|
||||||
*/
|
*/
|
||||||
public static ComboBox getComboBox(final String height, final String width, final String style,
|
public static ComboBox getComboBox(final String caption, final String height, final String width,
|
||||||
final String styleName, final boolean required, final String data, final String promt) {
|
final String style, final String styleName, final boolean required, final String data, final String promt) {
|
||||||
return SPUIComboBoxDecorator.decorate(height, width, style, styleName, required, data, promt);
|
return SPUIComboBoxDecorator.decorate(caption, height, width, style, styleName, required, data, promt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* 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 com.vaadin.server.Resource;
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button with icon decorator.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SPUIButtonStyleBorderWithIcon implements SPUIButtonDecorator {
|
||||||
|
|
||||||
|
private Button button;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
|
||||||
|
|
||||||
|
this.button = button;
|
||||||
|
|
||||||
|
setButtonStyle(style, setStyle);
|
||||||
|
setButtonIcon(icon);
|
||||||
|
|
||||||
|
button.addStyleName(ValoTheme.LABEL_SMALL);
|
||||||
|
button.setSizeFull();
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setButtonStyle(final String style, final boolean setStyle) {
|
||||||
|
|
||||||
|
if (style == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setStyle) {
|
||||||
|
button.setStyleName(style);
|
||||||
|
} else {
|
||||||
|
button.addStyleName(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setButtonIcon(final Resource icon) {
|
||||||
|
|
||||||
|
if (icon == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
button.setIcon(icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
package org.eclipse.hawkbit.ui.decorators;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -29,6 +31,8 @@ public final class SPUIComboBoxDecorator {
|
|||||||
/**
|
/**
|
||||||
* Decorate.
|
* Decorate.
|
||||||
*
|
*
|
||||||
|
* @param caption
|
||||||
|
* caption of the combobox
|
||||||
* @param height
|
* @param height
|
||||||
* as H
|
* as H
|
||||||
* @param width
|
* @param width
|
||||||
@@ -41,39 +45,42 @@ public final class SPUIComboBoxDecorator {
|
|||||||
* as T|F
|
* as T|F
|
||||||
* @param data
|
* @param data
|
||||||
* as data
|
* as data
|
||||||
* @param promt
|
* @param prompt
|
||||||
* as promt
|
* as promt
|
||||||
* @return ComboBox as comp
|
* @return ComboBox as comp
|
||||||
*/
|
*/
|
||||||
public static ComboBox decorate(final String height, final String width, final String style, final String styleName,
|
public static ComboBox decorate(final String caption, final String height, final String width, final String style,
|
||||||
final boolean required, final String data, final String promt) {
|
final String styleName, final boolean required, final String data, final String prompt) {
|
||||||
final ComboBox spUICombo = new ComboBox();
|
final ComboBox spUICombo = new ComboBox();
|
||||||
// Default settings
|
// Default settings
|
||||||
spUICombo.setRequired(required);
|
spUICombo.setRequired(required);
|
||||||
spUICombo.addStyleName(ValoTheme.COMBOBOX_TINY);
|
spUICombo.addStyleName(ValoTheme.COMBOBOX_TINY);
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(caption)) {
|
||||||
|
spUICombo.setCaption(caption);
|
||||||
|
}
|
||||||
// Add style
|
// Add style
|
||||||
if (null != style) {
|
if (StringUtils.isNotEmpty(style)) {
|
||||||
spUICombo.setStyleName(style);
|
spUICombo.setStyleName(style);
|
||||||
}
|
}
|
||||||
// Add style Name
|
// Add style Name
|
||||||
if (null != styleName) {
|
if (StringUtils.isNotEmpty(styleName)) {
|
||||||
spUICombo.addStyleName(styleName);
|
spUICombo.addStyleName(styleName);
|
||||||
}
|
}
|
||||||
// Add height
|
// Add height
|
||||||
if (null != height) {
|
if (StringUtils.isNotEmpty(height)) {
|
||||||
spUICombo.setHeight(height);
|
spUICombo.setHeight(height);
|
||||||
}
|
}
|
||||||
// AddWidth
|
// AddWidth
|
||||||
if (null != width) {
|
if (StringUtils.isNotEmpty(width)) {
|
||||||
spUICombo.setWidth(width);
|
spUICombo.setWidth(width);
|
||||||
}
|
}
|
||||||
// Set promt
|
// Set prompt
|
||||||
if (null != promt) {
|
if (StringUtils.isNotEmpty(prompt)) {
|
||||||
spUICombo.setInputPrompt(promt);
|
spUICombo.setInputPrompt(prompt);
|
||||||
}
|
}
|
||||||
// Set Data
|
// Set Data
|
||||||
if (null != data) {
|
if (StringUtils.isNotEmpty(data)) {
|
||||||
spUICombo.setData(data);
|
spUICombo.setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
package org.eclipse.hawkbit.ui.decorators;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.vaadin.ui.TextArea;
|
import com.vaadin.ui.TextArea;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -37,33 +39,36 @@ public final class SPUITextAreaDecorator {
|
|||||||
* to set field as mandatory
|
* to set field as mandatory
|
||||||
* @param data
|
* @param data
|
||||||
* component data
|
* component data
|
||||||
* @param promt
|
* @param prompt
|
||||||
* as user for input
|
* as user for input
|
||||||
* @param maxLength
|
* @param maxLength
|
||||||
* maximum characters allowed
|
* maximum characters allowed
|
||||||
* @return TextArea as comp
|
* @return TextArea as comp
|
||||||
*/
|
*/
|
||||||
public static TextArea decorate(String style, String styleName, boolean required, String data, String promt,
|
public static TextArea decorate(final String caption, final String style, final String styleName,
|
||||||
int maxLength) {
|
final boolean required, final String data, final String prompt, final int maxLength) {
|
||||||
final TextArea spUITxtArea = new TextArea();
|
final TextArea spUITxtArea = new TextArea();
|
||||||
// Default settings
|
// Default settings
|
||||||
spUITxtArea.setRequired(false);
|
spUITxtArea.setRequired(false);
|
||||||
spUITxtArea.addStyleName(ValoTheme.COMBOBOX_SMALL);
|
spUITxtArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
|
||||||
|
if (StringUtils.isNotEmpty(caption)) {
|
||||||
|
spUITxtArea.setCaption(caption);
|
||||||
|
}
|
||||||
if (required) {
|
if (required) {
|
||||||
spUITxtArea.setRequired(true);
|
spUITxtArea.setRequired(true);
|
||||||
}
|
}
|
||||||
// Add style
|
// Add style
|
||||||
if (null != style) {
|
if (StringUtils.isNotEmpty(style)) {
|
||||||
spUITxtArea.setStyleName(style);
|
spUITxtArea.setStyleName(style);
|
||||||
}
|
}
|
||||||
// Add style Name
|
// Add style Name
|
||||||
if (null != styleName) {
|
if (StringUtils.isNotEmpty(styleName)) {
|
||||||
spUITxtArea.addStyleName(styleName);
|
spUITxtArea.addStyleName(styleName);
|
||||||
}
|
}
|
||||||
if (null != promt) {
|
if (StringUtils.isNotEmpty(prompt)) {
|
||||||
spUITxtArea.setInputPrompt(promt);
|
spUITxtArea.setInputPrompt(prompt);
|
||||||
}
|
}
|
||||||
if (null != data) {
|
if (StringUtils.isNotEmpty(data)) {
|
||||||
spUITxtArea.setData(data);
|
spUITxtArea.setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
package org.eclipse.hawkbit.ui.decorators;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.vaadin.ui.TextField;
|
import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -27,8 +29,9 @@ public final class SPUITextFieldDecorator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorate.
|
|
||||||
*
|
*
|
||||||
|
* @param caption
|
||||||
|
* set the caption of the textfield
|
||||||
* @param style
|
* @param style
|
||||||
* set style
|
* set style
|
||||||
* @param styleName
|
* @param styleName
|
||||||
@@ -37,7 +40,7 @@ public final class SPUITextFieldDecorator {
|
|||||||
* to set field as mandatory
|
* to set field as mandatory
|
||||||
* @param data
|
* @param data
|
||||||
* component data
|
* component data
|
||||||
* @param promt
|
* @param prompt
|
||||||
* prompt user for input
|
* prompt user for input
|
||||||
* @param immediate
|
* @param immediate
|
||||||
* as for display
|
* as for display
|
||||||
@@ -45,9 +48,13 @@ public final class SPUITextFieldDecorator {
|
|||||||
* maximum characters allowed
|
* maximum characters allowed
|
||||||
* @return Text field as decorated
|
* @return Text field as decorated
|
||||||
*/
|
*/
|
||||||
public static TextField decorate(String style, String styleName, boolean required, String data, String promt,
|
public static TextField decorate(final String caption, final String style, final String styleName,
|
||||||
boolean immediate, int maxLengthAllowed) {
|
final boolean required, final String data, final String prompt, final boolean immediate,
|
||||||
|
final int maxLengthAllowed) {
|
||||||
final TextField spUITxtFld = new TextField();
|
final TextField spUITxtFld = new TextField();
|
||||||
|
if (StringUtils.isNotEmpty(caption)) {
|
||||||
|
spUITxtFld.setCaption(caption);
|
||||||
|
}
|
||||||
// Default settings
|
// Default settings
|
||||||
spUITxtFld.setRequired(false);
|
spUITxtFld.setRequired(false);
|
||||||
spUITxtFld.addStyleName(ValoTheme.TEXTFIELD_SMALL);
|
spUITxtFld.addStyleName(ValoTheme.TEXTFIELD_SMALL);
|
||||||
@@ -58,17 +65,17 @@ public final class SPUITextFieldDecorator {
|
|||||||
spUITxtFld.setImmediate(true);
|
spUITxtFld.setImmediate(true);
|
||||||
}
|
}
|
||||||
// Add style
|
// Add style
|
||||||
if (null != style) {
|
if (StringUtils.isNotEmpty(style)) {
|
||||||
spUITxtFld.setStyleName(style);
|
spUITxtFld.setStyleName(style);
|
||||||
}
|
}
|
||||||
// Add style Name
|
// Add style Name
|
||||||
if (null != styleName) {
|
if (StringUtils.isNotEmpty(styleName)) {
|
||||||
spUITxtFld.addStyleName(styleName);
|
spUITxtFld.addStyleName(styleName);
|
||||||
}
|
}
|
||||||
if (null != promt) {
|
if (StringUtils.isNotEmpty(prompt)) {
|
||||||
spUITxtFld.setInputPrompt(promt);
|
spUITxtFld.setInputPrompt(prompt);
|
||||||
}
|
}
|
||||||
if (null != data) {
|
if (StringUtils.isNotEmpty(data)) {
|
||||||
spUITxtFld.setData(data);
|
spUITxtFld.setData(data);
|
||||||
}
|
}
|
||||||
if (maxLengthAllowed > 0) {
|
if (maxLengthAllowed > 0) {
|
||||||
|
|||||||
@@ -8,9 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.decorators;
|
package org.eclipse.hawkbit.ui.decorators;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
|
|
||||||
|
import com.vaadin.ui.Button.ClickListener;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +31,38 @@ public final class SPUIWindowDecorator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorates window based on type.
|
||||||
|
*
|
||||||
|
* @param caption
|
||||||
|
* window caption
|
||||||
|
* @param id
|
||||||
|
* window id
|
||||||
|
* @param type
|
||||||
|
* window type
|
||||||
|
* @return Window
|
||||||
|
*/
|
||||||
|
public static CommonDialogWindow getDeocratedWindow(final String caption, final String id, final String type,
|
||||||
|
final Component content, final ClickListener saveButtonClickListener,
|
||||||
|
final ClickListener cancelButtonClickListener, final String helpLink) {
|
||||||
|
|
||||||
|
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, saveButtonClickListener,
|
||||||
|
cancelButtonClickListener);
|
||||||
|
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.
|
* Decorates window based on type.
|
||||||
*
|
*
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.disttype;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
|
import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent;
|
||||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||||
@@ -21,7 +22,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distribution Set Type filter buttons header.
|
* Distribution Set Type filter buttons header.
|
||||||
@@ -38,6 +38,8 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout;
|
private CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout;
|
||||||
|
|
||||||
|
private CommonDialogWindow addUpdateWindow;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -59,10 +61,8 @@ public class DSTypeFilterHeader extends AbstractFilterHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void settingsIconClicked(final ClickEvent event) {
|
protected void settingsIconClicked(final ClickEvent event) {
|
||||||
final Window addUpdateWindow = createUpdateDistSetTypeLayout.getWindow();
|
addUpdateWindow = createUpdateDistSetTypeLayout.getWindow();
|
||||||
UI.getCurrent().addWindow(addUpdateWindow);
|
UI.getCurrent().addWindow(addUpdateWindow);
|
||||||
addUpdateWindow.setVisible(Boolean.TRUE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -66,10 +66,9 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void settingsIconClicked(final ClickEvent event) {
|
protected void settingsIconClicked(final ClickEvent event) {
|
||||||
final Window addUpdateWindow = createUpdateSWTypeLayout.getWindow();
|
final Window window = createUpdateSWTypeLayout.getWindow();
|
||||||
UI.getCurrent().addWindow(addUpdateWindow);
|
UI.getCurrent().addWindow(window);
|
||||||
addUpdateWindow.setVisible(Boolean.TRUE);
|
window.setVisible(Boolean.TRUE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
|
|
||||||
private static final long serialVersionUID = 7474232427119031474L;
|
private static final long serialVersionUID = 7474232427119031474L;
|
||||||
|
|
||||||
private static final String breadcrumbCustomFilters = "breadcrumb.target.filter.custom.filters";
|
private static final String BREADCRUMB_CUSTOM_FILTERS = "breadcrumb.target.filter.custom.filters";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
@@ -242,19 +242,20 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
final Button createFilterViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
final Button createFilterViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
SPUIButtonStyleSmallNoBorder.class);
|
||||||
createFilterViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
|
createFilterViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");
|
||||||
createFilterViewLink.setDescription(i18n.get(breadcrumbCustomFilters));
|
createFilterViewLink.setDescription(i18n.get(BREADCRUMB_CUSTOM_FILTERS));
|
||||||
createFilterViewLink.setCaption(i18n.get(breadcrumbCustomFilters));
|
createFilterViewLink.setCaption(i18n.get(BREADCRUMB_CUSTOM_FILTERS));
|
||||||
createFilterViewLink.addClickListener(value -> showCustomFiltersView());
|
createFilterViewLink.addClickListener(value -> showCustomFiltersView());
|
||||||
|
|
||||||
return createFilterViewLink;
|
return createFilterViewLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createNameTextField() {
|
private TextField createNameTextField() {
|
||||||
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
final TextField nameField = SPUIComponentProvider.getTextField(i18n.get("textfield.customfiltername"), "",
|
||||||
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.customfiltername"), true,
|
||||||
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
|
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
|
||||||
nameField.setPropertyDataSource(nameLabel);
|
nameField.setPropertyDataSource(nameLabel);
|
||||||
nameField.addTextChangeListener(event -> onFilterNameChange(event));
|
nameField.addTextChangeListener(this::onFilterNameChange);
|
||||||
return nameField;
|
return nameField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,8 +452,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private TextField createSearchField() {
|
||||||
final TextField textField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, "", "",
|
final TextField textField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, "",
|
||||||
true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
"", true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
||||||
textField.setId("custom.query.text.Id");
|
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);
|
||||||
@@ -490,15 +491,11 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
public void buttonClick(final ClickEvent event) {
|
public void buttonClick(final ClickEvent event) {
|
||||||
if (SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
|
if (SPUIComponentIdProvider.CUSTOM_FILTER_SAVE_ICON.equals(event.getComponent().getId())
|
||||||
&& manadatoryFieldsPresent()) {
|
&& manadatoryFieldsPresent()) {
|
||||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
if (filterManagementUIState.isCreateFilterViewDisplayed() && !doesAlreadyExists()) {
|
||||||
if (!doesAlreadyExists()) {
|
createTargetFilterQuery();
|
||||||
createTargetFilterQuery();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!nameTextField.getValue().equals(oldFilterName)) {
|
if (!nameTextField.getValue().equals(oldFilterName) && !doesAlreadyExists()) {
|
||||||
if (!doesAlreadyExists()) {
|
updateCustomFilter();
|
||||||
updateCustomFilter();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
updateCustomFilter();
|
updateCustomFilter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class TargetFilterHeader extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createSearchField() {
|
private TextField createSearchField() {
|
||||||
final TextField campSearchTextField = SPUIComponentProvider.getTextField("filter-box",
|
final TextField campSearchTextField = SPUIComponentProvider.getTextField(null, "filter-box",
|
||||||
"text-style filter-box-hide", false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
"text-style filter-box-hide", false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
campSearchTextField.setId("target.filter.search.text.Id");
|
campSearchTextField.setId("target.filter.search.text.Id");
|
||||||
campSearchTextField.setWidth(500.0f, Unit.PIXELS);
|
campSearchTextField.setWidth(500.0f, Unit.PIXELS);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public class TargetFilterTable extends Table {
|
|||||||
SPUILabelDefinitions.DELETE_CUSTOM_FILTER, ValoTheme.BUTTON_TINY + " " + "redicon", true,
|
SPUILabelDefinitions.DELETE_CUSTOM_FILTER, ValoTheme.BUTTON_TINY + " " + "redicon", true,
|
||||||
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
|
||||||
deleteIcon.setData(itemId);
|
deleteIcon.setData(itemId);
|
||||||
deleteIcon.addClickListener(event -> onDelete(event));
|
deleteIcon.addClickListener(this::onDelete);
|
||||||
return deleteIcon;
|
return deleteIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ public class TargetFilterTable extends Table {
|
|||||||
SPUILabelDefinitions.UPDATE_CUSTOM_FILTER, null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
SPUILabelDefinitions.UPDATE_CUSTOM_FILTER, null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||||
updateIcon.setData(tfName);
|
updateIcon.setData(tfName);
|
||||||
updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
|
updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
|
||||||
updateIcon.addClickListener(event -> onClickOfDetailButton(event));
|
updateIcon.addClickListener(this::onClickOfDetailButton);
|
||||||
return updateIcon;
|
return updateIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,647 @@
|
|||||||
|
/**
|
||||||
|
* 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.layouts;
|
||||||
|
|
||||||
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||||
|
import org.eclipse.hawkbit.repository.TagManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Tag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
|
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.UINotification;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
|
import com.vaadin.data.Property.ValueChangeListener;
|
||||||
|
import com.vaadin.server.Page;
|
||||||
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
|
import com.vaadin.ui.Alignment;
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.ComboBox;
|
||||||
|
import com.vaadin.ui.CustomComponent;
|
||||||
|
import com.vaadin.ui.FormLayout;
|
||||||
|
import com.vaadin.ui.GridLayout;
|
||||||
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.Label;
|
||||||
|
import com.vaadin.ui.OptionGroup;
|
||||||
|
import com.vaadin.ui.TextArea;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for create/update target tag layout.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCreateUpdateTagLayout extends CustomComponent
|
||||||
|
implements ColorChangeListener, ColorSelector {
|
||||||
|
private static final long serialVersionUID = 4229177824620576456L;
|
||||||
|
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||||
|
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||||
|
protected static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
||||||
|
protected static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected I18N i18n;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected transient TagManagement tagManagement;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected SpPermissionChecker permChecker;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected transient UINotification uiNotification;
|
||||||
|
|
||||||
|
private final FormLayout formLayout = new FormLayout();
|
||||||
|
|
||||||
|
protected String createTagStr;
|
||||||
|
protected String updateTagStr;
|
||||||
|
protected Label comboLabel;
|
||||||
|
protected CommonDialogWindow window;
|
||||||
|
|
||||||
|
protected Label colorLabel;
|
||||||
|
protected Label madatoryLabel;
|
||||||
|
protected TextField tagName;
|
||||||
|
protected TextArea tagDesc;
|
||||||
|
protected Button tagColorPreviewBtn;
|
||||||
|
protected OptionGroup optiongroup;
|
||||||
|
protected ComboBox tagNameComboBox;
|
||||||
|
|
||||||
|
protected VerticalLayout comboLayout;
|
||||||
|
protected ColorPickerLayout colorPickerLayout;
|
||||||
|
protected GridLayout mainLayout;
|
||||||
|
protected VerticalLayout contentLayout;
|
||||||
|
|
||||||
|
protected boolean tagPreviewBtnClicked = false;
|
||||||
|
|
||||||
|
private String colorPicked;
|
||||||
|
protected String tagNameValue;
|
||||||
|
protected String tagDescValue;
|
||||||
|
|
||||||
|
protected void createWindow() {
|
||||||
|
reset();
|
||||||
|
setWindow(SPUIComponentProvider.getWindow(i18n.get("caption.add.tag"), null,
|
||||||
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, this::save, this::discard, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save new tag / update new tag.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
protected abstract void save(final Button.ClickEvent event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discard the changes and close the popup.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
protected void discard(final Button.ClickEvent event) {
|
||||||
|
UI.getCurrent().removeWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate target name combo.
|
||||||
|
*/
|
||||||
|
protected abstract void populateTagNameCombo();
|
||||||
|
|
||||||
|
protected abstract void setTagDetails(final String tagSelected);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init the layout.
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
setSizeUndefined();
|
||||||
|
createRequiredComponents();
|
||||||
|
buildLayout();
|
||||||
|
createWindow();
|
||||||
|
addListeners();
|
||||||
|
eventBus.subscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
void destroy() {
|
||||||
|
eventBus.unsubscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createRequiredComponents() {
|
||||||
|
|
||||||
|
createTagStr = i18n.get("label.create.tag");
|
||||||
|
updateTagStr = i18n.get("label.update.tag");
|
||||||
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
||||||
|
madatoryLabel = getMandatoryLabel();
|
||||||
|
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
||||||
|
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||||
|
|
||||||
|
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
|
||||||
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME, true, "", i18n.get("textfield.name"), true,
|
||||||
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
|
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
||||||
|
|
||||||
|
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("");
|
||||||
|
|
||||||
|
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", "", null, null, false, "",
|
||||||
|
i18n.get("label.combobox.tag"));
|
||||||
|
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
||||||
|
tagNameComboBox.setImmediate(true);
|
||||||
|
|
||||||
|
tagColorPreviewBtn = new Button();
|
||||||
|
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buildLayout() {
|
||||||
|
|
||||||
|
mainLayout = new GridLayout(3, 2);
|
||||||
|
mainLayout.setSpacing(true);
|
||||||
|
comboLayout = new VerticalLayout();
|
||||||
|
colorPickerLayout = new ColorPickerLayout();
|
||||||
|
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||||
|
contentLayout = new VerticalLayout();
|
||||||
|
|
||||||
|
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
|
||||||
|
colorLabelLayout.setMargin(false);
|
||||||
|
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
||||||
|
|
||||||
|
formLayout.addComponent(optiongroup);
|
||||||
|
formLayout.addComponent(comboLayout);
|
||||||
|
formLayout.addComponent(madatoryLabel);
|
||||||
|
formLayout.addComponent(tagName);
|
||||||
|
formLayout.addComponent(tagDesc);
|
||||||
|
formLayout.addStyleName("form-lastrow");
|
||||||
|
formLayout.setSizeFull();
|
||||||
|
|
||||||
|
contentLayout.addComponent(formLayout);
|
||||||
|
contentLayout.addComponent(colorLabelLayout);
|
||||||
|
contentLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
|
||||||
|
contentLayout.setComponentAlignment(colorLabelLayout, Alignment.MIDDLE_LEFT);
|
||||||
|
contentLayout.setSizeUndefined();
|
||||||
|
|
||||||
|
mainLayout.setSizeFull();
|
||||||
|
mainLayout.addComponent(contentLayout, 0, 0);
|
||||||
|
|
||||||
|
setCompositionRoot(mainLayout);
|
||||||
|
tagName.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addListeners() {
|
||||||
|
colorPickerLayout.getColorSelect().addColorChangeListener(this);
|
||||||
|
colorPickerLayout.getSelPreview().addColorChangeListener(this);
|
||||||
|
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
|
||||||
|
tagNameComboBox.addValueChangeListener(this::tagNameChosen);
|
||||||
|
slidersValueChangeListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open color picker on click of preview button. Auto select the color based
|
||||||
|
* on target tag if already selected.
|
||||||
|
*/
|
||||||
|
protected void previewButtonClicked() {
|
||||||
|
if (!tagPreviewBtnClicked) {
|
||||||
|
setColor();
|
||||||
|
mainLayout.getComponent(1, 0);
|
||||||
|
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||||
|
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||||
|
} else {
|
||||||
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
|
}
|
||||||
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setColor() {
|
||||||
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
|
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagStr)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagNameComboBox.getValue() == null) {
|
||||||
|
colorPickerLayout
|
||||||
|
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue().toString());
|
||||||
|
|
||||||
|
if (targetTagSelected == null) {
|
||||||
|
final DistributionSetTag distTag = tagManagement
|
||||||
|
.findDistributionSetTag(tagNameComboBox.getValue().toString());
|
||||||
|
colorPickerLayout.setSelectedColor(
|
||||||
|
distTag.getColour() != null ? ColorPickerHelper.rgbToColorConverter(distTag.getColour())
|
||||||
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
} else {
|
||||||
|
colorPickerLayout.setSelectedColor(targetTagSelected.getColour() != null
|
||||||
|
? ColorPickerHelper.rgbToColorConverter(targetTagSelected.getColour())
|
||||||
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Label getMandatoryLabel() {
|
||||||
|
final Label label = new Label(i18n.get("label.mandatory.field"));
|
||||||
|
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tagNameChosen(final ValueChangeEvent event) {
|
||||||
|
final String tagSelected = (String) event.getProperty().getValue();
|
||||||
|
if (null != tagSelected) {
|
||||||
|
setTagDetails(tagSelected);
|
||||||
|
} else {
|
||||||
|
resetTagNameField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetTagNameField() {
|
||||||
|
tagName.setEnabled(false);
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
restoreComponentStyles();
|
||||||
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
|
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
||||||
|
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||||
|
tagPreviewBtnClicked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for option group - Create tag/Update.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* ValueChangeEvent
|
||||||
|
*/
|
||||||
|
protected void optionValueChanged(final ValueChangeEvent event) {
|
||||||
|
|
||||||
|
if (updateTagStr.equals(event.getProperty().getValue())) {
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
tagName.setEnabled(false);
|
||||||
|
populateTagNameCombo();
|
||||||
|
// show target name combo
|
||||||
|
comboLayout.addComponent(comboLabel);
|
||||||
|
comboLayout.addComponent(tagNameComboBox);
|
||||||
|
} else {
|
||||||
|
tagName.setEnabled(true);
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
// hide target name combo
|
||||||
|
comboLayout.removeComponent(comboLabel);
|
||||||
|
comboLayout.removeComponent(tagNameComboBox);
|
||||||
|
}
|
||||||
|
// close the color picker layout
|
||||||
|
tagPreviewBtnClicked = false;
|
||||||
|
// reset the selected color - Set default color
|
||||||
|
restoreComponentStyles();
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
colorPickerLayout.getSelPreview()
|
||||||
|
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reset the components.
|
||||||
|
*/
|
||||||
|
protected void reset() {
|
||||||
|
tagName.setEnabled(true);
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
restoreComponentStyles();
|
||||||
|
|
||||||
|
// hide target name combo
|
||||||
|
comboLayout.removeComponent(comboLabel);
|
||||||
|
comboLayout.removeComponent(tagNameComboBox);
|
||||||
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
|
|
||||||
|
// Default green color
|
||||||
|
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
||||||
|
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||||
|
tagPreviewBtnClicked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On change of color in color picker ,change RGB sliders, components border
|
||||||
|
* color and color of preview button.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void colorChanged(final ColorChangeEvent event) {
|
||||||
|
setColor(event.getColor());
|
||||||
|
for (final ColorSelector select : colorPickerLayout.getSelectors()) {
|
||||||
|
if (!event.getSource().equals(select) && select.equals(this)
|
||||||
|
&& !select.getColor().equals(colorPickerLayout.getSelectedColor())) {
|
||||||
|
select.setColor(colorPickerLayout.getSelectedColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||||
|
getPreviewButtonColor(event.getColor().getCSS());
|
||||||
|
createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic styles for window.
|
||||||
|
*
|
||||||
|
* @param top
|
||||||
|
* int value
|
||||||
|
* @param marginLeft
|
||||||
|
* int value
|
||||||
|
*/
|
||||||
|
protected void getPreviewButtonColor(final String color) {
|
||||||
|
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tag name and desc field border color based on chosen color.
|
||||||
|
*
|
||||||
|
* @param tagName
|
||||||
|
* @param tagDesc
|
||||||
|
* @param taregtTagColor
|
||||||
|
*/
|
||||||
|
protected void createDynamicStyleForComponents(final TextField tagName, final TextArea tagDesc,
|
||||||
|
final String taregtTagColor) {
|
||||||
|
tagName.removeStyleName(SPUIDefinitions.TAG_NAME);
|
||||||
|
tagDesc.removeStyleName(SPUIDefinitions.TAG_DESC);
|
||||||
|
getTargetDynamicStyles(taregtTagColor);
|
||||||
|
tagName.addStyleName(TAG_NAME_DYNAMIC_STYLE);
|
||||||
|
tagDesc.addStyleName(TAG_DESC_DYNAMIC_STYLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reset the tag name and tag description component border color.
|
||||||
|
*/
|
||||||
|
protected void restoreComponentStyles() {
|
||||||
|
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
|
||||||
|
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
|
||||||
|
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
|
||||||
|
tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get target style - Dynamically as per the color picked, cannot be done
|
||||||
|
* from the static css.
|
||||||
|
*
|
||||||
|
* @param colorPickedPreview
|
||||||
|
*/
|
||||||
|
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
||||||
|
Page.getCurrent().getJavaScript()
|
||||||
|
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getColor() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColor(final Color color) {
|
||||||
|
if (color == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
colorPickerLayout.setSelectedColor(color);
|
||||||
|
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
||||||
|
final String colorPickedPreview = colorPickerLayout.getSelPreview().getColor().getCSS();
|
||||||
|
if (tagName.isEnabled() && null != colorPickerLayout.getColorSelect()) {
|
||||||
|
createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
|
||||||
|
colorPickerLayout.getColorSelect().setColor(colorPickerLayout.getSelPreview().getColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void closeWindow() {
|
||||||
|
window.close();
|
||||||
|
UI.getCurrent().removeWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create option group with Create tag/Update tag based on permissions.
|
||||||
|
*/
|
||||||
|
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||||
|
|
||||||
|
optiongroup = new OptionGroup("Select Action");
|
||||||
|
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||||
|
optiongroup.addStyleName("custom-option-group");
|
||||||
|
optiongroup.setNullSelectionAllowed(false);
|
||||||
|
|
||||||
|
if (hasCreatePermission) {
|
||||||
|
optiongroup.addItem(createTagStr);
|
||||||
|
}
|
||||||
|
if (hasUpdatePermission) {
|
||||||
|
optiongroup.addItem(updateTagStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptionGroupDefaultValue(hasCreatePermission, hasUpdatePermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOptionGroupDefaultValue(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||||
|
|
||||||
|
if (hasCreatePermission) {
|
||||||
|
optiongroup.select(createTagStr);
|
||||||
|
}
|
||||||
|
if (hasUpdatePermission && !hasCreatePermission) {
|
||||||
|
optiongroup.select(updateTagStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addColorChangeListener(final ColorChangeListener listener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeColorChangeListener(final ColorChangeListener listener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorPickerLayout getColorPickerLayout() {
|
||||||
|
return colorPickerLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonDialogWindow getWindow() {
|
||||||
|
reset();
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWindow(final CommonDialogWindow window) {
|
||||||
|
this.window = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value change listeners implementations of sliders.
|
||||||
|
*/
|
||||||
|
private void slidersValueChangeListeners() {
|
||||||
|
colorPickerLayout.getRedSlider().addValueChangeListener(new ValueChangeListener() {
|
||||||
|
private static final long serialVersionUID = -8336732888800920839L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChange(final ValueChangeEvent event) {
|
||||||
|
final double red = (Double) event.getProperty().getValue();
|
||||||
|
final Color newColor = new Color((int) red, colorPickerLayout.getSelectedColor().getGreen(),
|
||||||
|
colorPickerLayout.getSelectedColor().getBlue());
|
||||||
|
setColorToComponents(newColor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerLayout.getGreenSlider().addValueChangeListener(new ValueChangeListener() {
|
||||||
|
private static final long serialVersionUID = 1236358037766775663L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChange(final ValueChangeEvent event) {
|
||||||
|
final double green = (Double) event.getProperty().getValue();
|
||||||
|
final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(), (int) green,
|
||||||
|
colorPickerLayout.getSelectedColor().getBlue());
|
||||||
|
setColorToComponents(newColor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerLayout.getBlueSlider().addValueChangeListener(new ValueChangeListener() {
|
||||||
|
private static final long serialVersionUID = 8466370763686043947L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChange(final ValueChangeEvent event) {
|
||||||
|
final double blue = (Double) event.getProperty().getValue();
|
||||||
|
final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(),
|
||||||
|
colorPickerLayout.getSelectedColor().getGreen(), (int) blue);
|
||||||
|
setColorToComponents(newColor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setColorToComponents(final Color newColor) {
|
||||||
|
setColor(newColor);
|
||||||
|
colorPickerLayout.getColorSelect().setColor(newColor);
|
||||||
|
getPreviewButtonColor(newColor.getCSS());
|
||||||
|
createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new tag.
|
||||||
|
*/
|
||||||
|
protected void createNewTag() {
|
||||||
|
colorPicked = ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview());
|
||||||
|
tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
|
tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update tag.
|
||||||
|
*/
|
||||||
|
protected void updateExistingTag(final Tag targetObj) {
|
||||||
|
final String nameUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
|
final String descUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||||
|
|
||||||
|
if (null != nameUpdateValue) {
|
||||||
|
targetObj.setName(nameUpdateValue);
|
||||||
|
targetObj.setDescription(null != descUpdateValue ? descUpdateValue : null);
|
||||||
|
targetObj.setColour(ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview()));
|
||||||
|
if (targetObj instanceof TargetTag) {
|
||||||
|
tagManagement.updateTargetTag((TargetTag) targetObj);
|
||||||
|
} else if (targetObj instanceof DistributionSetTag) {
|
||||||
|
tagManagement.updateDistributionSetTag((DistributionSetTag) targetObj);
|
||||||
|
}
|
||||||
|
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() }));
|
||||||
|
closeWindow();
|
||||||
|
} else {
|
||||||
|
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void displaySuccess(final String tagName) {
|
||||||
|
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { tagName }));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void displayValidationError(final String errorMessage) {
|
||||||
|
uiNotification.displayValidationError(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTagColor(final Color selectedColor, final String previewColor) {
|
||||||
|
getColorPickerLayout().setSelectedColor(selectedColor);
|
||||||
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
createDynamicStyleForComponents(tagName, tagDesc, previewColor);
|
||||||
|
getPreviewButtonColor(previewColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Boolean mandatoryValuesPresent() {
|
||||||
|
if (Strings.isNullOrEmpty(tagName.getValue())) {
|
||||||
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
|
}
|
||||||
|
if (optiongroup.getValue().equals(updateTagStr)) {
|
||||||
|
if (null == tagNameComboBox.getValue()) {
|
||||||
|
displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME));
|
||||||
|
} else {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Boolean checkIsDuplicate(final Tag existingTag) {
|
||||||
|
if (existingTag != null) {
|
||||||
|
displayValidationError(i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() }));
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColorPicked() {
|
||||||
|
return colorPicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColorPicked(final String colorPicked) {
|
||||||
|
this.colorPicked = colorPicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagNameValue() {
|
||||||
|
return tagNameValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagNameValue(final String tagNameValue) {
|
||||||
|
this.tagNameValue = tagNameValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagDescValue() {
|
||||||
|
return tagDescValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagDescValue(final String tagDescValue) {
|
||||||
|
this.tagDescValue = tagDescValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormLayout getFormLayout() {
|
||||||
|
return formLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
/**
|
||||||
|
* 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.layouts;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
|
import com.vaadin.server.Page;
|
||||||
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
|
import com.vaadin.ui.OptionGroup;
|
||||||
|
import com.vaadin.ui.TextArea;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
||||||
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Superclass defining common properties and methods for creating/updating
|
||||||
|
* types.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayout {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5732904956185988397L;
|
||||||
|
|
||||||
|
protected String createTypeStr;
|
||||||
|
protected String updateTypeStr;
|
||||||
|
protected TextField typeKey;
|
||||||
|
|
||||||
|
public static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||||
|
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addListeners() {
|
||||||
|
super.addListeners();
|
||||||
|
optiongroup.addValueChangeListener(this::createOptionValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createRequiredComponents() {
|
||||||
|
|
||||||
|
createTypeStr = i18n.get("label.create.type");
|
||||||
|
updateTypeStr = i18n.get("label.update.type");
|
||||||
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||||
|
madatoryLabel = getMandatoryLabel();
|
||||||
|
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
||||||
|
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||||
|
|
||||||
|
tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false,
|
||||||
|
"", i18n.get("label.combobox.type"));
|
||||||
|
tagNameComboBox.setId(SPUIDefinitions.NEW_DISTRIBUTION_SET_TYPE_NAME_COMBO);
|
||||||
|
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
||||||
|
tagNameComboBox.setImmediate(true);
|
||||||
|
tagNameComboBox.setPageLength(SPUIDefinitions.DIST_TYPE_SIZE);
|
||||||
|
|
||||||
|
tagColorPreviewBtn = new Button();
|
||||||
|
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||||
|
|
||||||
|
createOptionGroup(permChecker.hasCreateDistributionPermission(), permChecker.hasUpdateDistributionPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setColorToComponents(final Color newColor) {
|
||||||
|
|
||||||
|
super.setColorToComponents(newColor);
|
||||||
|
createDynamicStyleForComponents(tagName, typeKey, tagDesc, newColor.getCSS());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tag name and desc field border color based on chosen color.
|
||||||
|
*
|
||||||
|
* @param tagName
|
||||||
|
* @param tagDesc
|
||||||
|
* @param taregtTagColor
|
||||||
|
*/
|
||||||
|
protected void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
|
||||||
|
final TextArea typeDesc, final String typeTagColor) {
|
||||||
|
|
||||||
|
tagName.removeStyleName(SPUIDefinitions.TYPE_NAME);
|
||||||
|
typeKey.removeStyleName(SPUIDefinitions.TYPE_KEY);
|
||||||
|
typeDesc.removeStyleName(SPUIDefinitions.TYPE_DESC);
|
||||||
|
getDynamicStyles(typeTagColor);
|
||||||
|
tagName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||||
|
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||||
|
typeDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get target style - Dynamically as per the color picked, cannot be done
|
||||||
|
* from the static css.
|
||||||
|
*
|
||||||
|
* @param colorPickedPreview
|
||||||
|
*/
|
||||||
|
private void getDynamicStyles(final String colorPickedPreview) {
|
||||||
|
|
||||||
|
Page.getCurrent().getJavaScript()
|
||||||
|
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reset the components.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void reset() {
|
||||||
|
|
||||||
|
super.reset();
|
||||||
|
typeKey.clear();
|
||||||
|
restoreComponentStyles();
|
||||||
|
setOptionGroupDefaultValue(permChecker.hasCreateDistributionPermission(),
|
||||||
|
permChecker.hasUpdateDistributionPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for option group - Create tag/Update.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* ValueChangeEvent
|
||||||
|
*/
|
||||||
|
protected void createOptionValueChanged(final ValueChangeEvent event) {
|
||||||
|
|
||||||
|
if (updateTypeStr.equals(event.getProperty().getValue())) {
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
typeKey.clear();
|
||||||
|
typeKey.setEnabled(false);
|
||||||
|
tagName.setEnabled(false);
|
||||||
|
populateTagNameCombo();
|
||||||
|
comboLayout.addComponent(comboLabel);
|
||||||
|
comboLayout.addComponent(tagNameComboBox);
|
||||||
|
} else {
|
||||||
|
typeKey.setEnabled(true);
|
||||||
|
tagName.setEnabled(true);
|
||||||
|
window.setSaveButtonEnabled(true);
|
||||||
|
tagName.clear();
|
||||||
|
tagDesc.clear();
|
||||||
|
typeKey.clear();
|
||||||
|
comboLayout.removeComponent(comboLabel);
|
||||||
|
comboLayout.removeComponent(tagNameComboBox);
|
||||||
|
}
|
||||||
|
restoreComponentStyles();
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
getColorPickerLayout().getSelPreview()
|
||||||
|
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.vaadin.ui.components.colorpicker.ColorSelector#setColor(com.vaadin.
|
||||||
|
* shared.ui.colorpicker .Color)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setColor(final Color color) {
|
||||||
|
|
||||||
|
if (color == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getColorPickerLayout().setSelectedColor(color);
|
||||||
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
final String colorPickedPreview = getColorPickerLayout().getSelPreview().getColor().getCSS();
|
||||||
|
if (tagName.isEnabled() && null != getColorPickerLayout().getColorSelect()) {
|
||||||
|
createDynamicStyleForComponents(tagName, typeKey, tagDesc, colorPickedPreview);
|
||||||
|
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelPreview().getColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reset the tag name and tag description component border color.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void restoreComponentStyles() {
|
||||||
|
super.restoreComponentStyles();
|
||||||
|
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||||
|
typeKey.addStyleName(SPUIDefinitions.TYPE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create option group with Create tag/Update tag based on permissions.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||||
|
|
||||||
|
optiongroup = new OptionGroup("Select Action");
|
||||||
|
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||||
|
optiongroup.addStyleName("custom-option-group");
|
||||||
|
optiongroup.setNullSelectionAllowed(false);
|
||||||
|
|
||||||
|
if (hasCreatePermission) {
|
||||||
|
optiongroup.addItem(createTypeStr);
|
||||||
|
}
|
||||||
|
if (hasUpdatePermission) {
|
||||||
|
optiongroup.addItem(updateTypeStr);
|
||||||
|
}
|
||||||
|
setOptionGroupDefaultValue(hasCreatePermission, hasUpdatePermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setOptionGroupDefaultValue(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||||
|
|
||||||
|
if (hasCreatePermission) {
|
||||||
|
optiongroup.select(createTypeStr);
|
||||||
|
}
|
||||||
|
if (hasUpdatePermission && !hasCreatePermission) {
|
||||||
|
optiongroup.select(updateTypeStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setColorPickerComponentsColor(final String color) {
|
||||||
|
|
||||||
|
if (null == color) {
|
||||||
|
getColorPickerLayout()
|
||||||
|
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
createDynamicStyleForComponents(tagName, typeKey, tagDesc, ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
} else {
|
||||||
|
getColorPickerLayout().setSelectedColor(ColorPickerHelper.rgbToColorConverter(color));
|
||||||
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
createDynamicStyleForComponents(tagName, typeKey, tagDesc, color);
|
||||||
|
getPreviewButtonColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void colorChanged(final ColorChangeEvent event) {
|
||||||
|
setColor(event.getColor());
|
||||||
|
for (final ColorSelector select : getColorPickerLayout().getSelectors()) {
|
||||||
|
if (!event.getSource().equals(select) && select.equals(this)
|
||||||
|
&& !select.getColor().equals(getColorPickerLayout().getSelectedColor())) {
|
||||||
|
select.setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColorPickerHelper.setRgbSliderValues(getColorPickerLayout());
|
||||||
|
getPreviewButtonColor(event.getColor().getCSS());
|
||||||
|
createDynamicStyleForComponents(tagName, typeKey, tagDesc, event.getColor().getCSS());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Boolean checkIsDuplicate(final NamedEntity existingType) {
|
||||||
|
|
||||||
|
if (existingType != null) {
|
||||||
|
uiNotification.displayValidationError(
|
||||||
|
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Boolean checkIsDuplicateByKey(final NamedEntity existingType) {
|
||||||
|
|
||||||
|
if (existingType != null) {
|
||||||
|
if (existingType instanceof DistributionSetType) {
|
||||||
|
uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check",
|
||||||
|
new Object[] { ((DistributionSetType) existingType).getKey() }));
|
||||||
|
return Boolean.TRUE;
|
||||||
|
} else if (existingType instanceof SoftwareModuleType) {
|
||||||
|
uiNotification.displayValidationError(i18n.get("message.type.key.swmodule.duplicate.check",
|
||||||
|
new Object[] { ((SoftwareModuleType) existingType).getKey() }));
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean mandatoryValuesPresent() {
|
||||||
|
if (Strings.isNullOrEmpty(tagName.getValue()) || Strings.isNullOrEmpty(typeKey.getValue())) {
|
||||||
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
||||||
|
}
|
||||||
|
if (optiongroup.getValue().equals(updateTypeStr)) {
|
||||||
|
if (null == tagNameComboBox.getValue()) {
|
||||||
|
displayValidationError(i18n.get("message.error.missing.tagName"));
|
||||||
|
} else {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void save(final ClickEvent event) {
|
||||||
|
// is implemented in the inherited class
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populateTagNameCombo() {
|
||||||
|
// is implemented in the inherited class
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setTagDetails(final String tagSelected) {
|
||||||
|
// is implemented in the inherited class
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,10 +22,10 @@ import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||||
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.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;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
@@ -47,21 +47,17 @@ import com.vaadin.data.Property.ValueChangeEvent;
|
|||||||
import com.vaadin.data.Property.ValueChangeListener;
|
import com.vaadin.data.Property.ValueChangeListener;
|
||||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||||
import com.vaadin.event.FieldEvents.TextChangeListener;
|
import com.vaadin.event.FieldEvents.TextChangeListener;
|
||||||
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.Alignment;
|
|
||||||
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.Component;
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.CustomComponent;
|
||||||
|
import com.vaadin.ui.FormLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
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.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +66,7 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5602182034230568435L;
|
private static final long serialVersionUID = -5602182034230568435L;
|
||||||
|
|
||||||
@@ -94,8 +90,6 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient EntityFactory entityFactory;
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
private Button saveDistributionBtn;
|
|
||||||
private Button discardDistributionBtn;
|
|
||||||
private TextField distNameTextField;
|
private TextField distNameTextField;
|
||||||
private TextField distVersionTextField;
|
private TextField distVersionTextField;
|
||||||
private Label madatoryLabel;
|
private Label madatoryLabel;
|
||||||
@@ -104,7 +98,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
private ComboBox distsetTypeNameComboBox;
|
private ComboBox distsetTypeNameComboBox;
|
||||||
private boolean editDistribution = Boolean.FALSE;
|
private boolean editDistribution = Boolean.FALSE;
|
||||||
private Long editDistId;
|
private Long editDistId;
|
||||||
private Window addDistributionWindow;
|
private CommonDialogWindow addDistributionWindow;
|
||||||
private String originalDistName;
|
private String originalDistName;
|
||||||
private String originalDistVersion;
|
private String originalDistVersion;
|
||||||
private String originalDistDescription;
|
private String originalDistDescription;
|
||||||
@@ -117,6 +111,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
private TextChangeListener distVersionTextFieldListener;
|
private TextChangeListener distVersionTextFieldListener;
|
||||||
private ValueChangeListener distsetTypeNameComboBoxListener;
|
private ValueChangeListener distsetTypeNameComboBoxListener;
|
||||||
|
|
||||||
|
private FormLayout formLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize Distribution Add and Edit Window.
|
* Initialize Distribution Add and Edit Window.
|
||||||
*/
|
*/
|
||||||
@@ -127,53 +123,51 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
private void buildLayout() {
|
||||||
/* action button layout ( save & discard ) */
|
|
||||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
|
||||||
buttonsLayout.setSizeFull();
|
|
||||||
buttonsLayout.setStyleName("dist-buttons-horz-layout");
|
|
||||||
buttonsLayout.addComponents(saveDistributionBtn, discardDistributionBtn);
|
|
||||||
buttonsLayout.setComponentAlignment(saveDistributionBtn, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonsLayout.setComponentAlignment(discardDistributionBtn, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonsLayout.addStyleName("window-style");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The main layout of the window contains mandatory info, textboxes
|
* The main layout of the window contains mandatory info, textboxes
|
||||||
* (controller Id, name & description) and action buttons layout
|
* (controller Id, name & description) and action buttons layout
|
||||||
*/
|
*/
|
||||||
setSpacing(Boolean.TRUE);
|
|
||||||
addStyleName("lay-color");
|
addStyleName("lay-color");
|
||||||
setSizeUndefined();
|
setSizeUndefined();
|
||||||
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
|
|
||||||
reqMigStepCheckbox);
|
|
||||||
|
|
||||||
addComponent(buttonsLayout);
|
formLayout = new FormLayout();
|
||||||
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
|
formLayout.addComponent(madatoryLabel);
|
||||||
|
formLayout.addComponent(distsetTypeNameComboBox);
|
||||||
|
formLayout.addComponent(distNameTextField);
|
||||||
|
formLayout.addComponent(distVersionTextField);
|
||||||
|
formLayout.addComponent(descTextArea);
|
||||||
|
formLayout.addComponent(reqMigStepCheckbox);
|
||||||
|
|
||||||
|
setCompositionRoot(formLayout);
|
||||||
|
|
||||||
distNameTextField.focus();
|
distNameTextField.focus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create required UI components.
|
* Create required UI components.
|
||||||
*/
|
*/
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
distNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
distNameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
|
||||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
|
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
|
||||||
distNameTextField.setNullRepresentation("");
|
distNameTextField.setNullRepresentation("");
|
||||||
|
|
||||||
distVersionTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
distVersionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
|
||||||
i18n.get("textfield.version"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
|
||||||
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
|
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
|
||||||
distVersionTextField.setNullRepresentation("");
|
distVersionTextField.setNullRepresentation("");
|
||||||
|
|
||||||
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox("", "", null, "", false, "",
|
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, "",
|
||||||
i18n.get("label.combobox.type"));
|
false, "", i18n.get("label.combobox.type"));
|
||||||
distsetTypeNameComboBox.setImmediate(true);
|
distsetTypeNameComboBox.setImmediate(true);
|
||||||
distsetTypeNameComboBox.setNullSelectionAllowed(false);
|
distsetTypeNameComboBox.setNullSelectionAllowed(false);
|
||||||
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
|
||||||
|
|
||||||
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTAREA_TINY, false, null,
|
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
|
||||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
||||||
|
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
|
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
|
||||||
descTextArea.setNullRepresentation("");
|
descTextArea.setNullRepresentation("");
|
||||||
|
|
||||||
@@ -185,16 +179,6 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
"dist-checkbox-style", null, false, "");
|
"dist-checkbox-style", null, false, "");
|
||||||
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
|
reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
|
||||||
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
|
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
|
||||||
|
|
||||||
/* save or update button */
|
|
||||||
saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.DIST_ADD_SAVE, "", "", "", true,
|
|
||||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveDistributionBtn.addClickListener(event -> saveDistribution());
|
|
||||||
|
|
||||||
/* close button */
|
|
||||||
discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.DIST_ADD_DISCARD, "", "", "",
|
|
||||||
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
discardDistributionBtn.addClickListener(event -> discardDistribution());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,7 +201,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enableSaveButton() {
|
private void enableSaveButton() {
|
||||||
saveDistributionBtn.setEnabled(true);
|
addDistributionWindow.setSaveButtonEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType getDefaultDistributionSetType() {
|
private DistributionSetType getDefaultDistributionSetType() {
|
||||||
@@ -226,7 +210,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void disableSaveButton() {
|
private void disableSaveButton() {
|
||||||
saveDistributionBtn.setEnabled(false);
|
addDistributionWindow.setSaveButtonEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDistribution() {
|
private void saveDistribution() {
|
||||||
@@ -414,7 +398,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
|
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
|
||||||
descTextArea.clear();
|
descTextArea.clear();
|
||||||
reqMigStepCheckbox.clear();
|
reqMigStepCheckbox.clear();
|
||||||
saveDistributionBtn.setEnabled(true);
|
if (addDistributionWindow != null) {
|
||||||
|
addDistributionWindow.setSaveButtonEnabled(true);
|
||||||
|
}
|
||||||
removeListeners();
|
removeListeners();
|
||||||
changedComponents.clear();
|
changedComponents.clear();
|
||||||
}
|
}
|
||||||
@@ -496,7 +482,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
public void populateValuesOfDistribution(final Long editDistId) {
|
public void populateValuesOfDistribution(final Long editDistId) {
|
||||||
this.editDistId = editDistId;
|
this.editDistId = editDistId;
|
||||||
editDistribution = Boolean.TRUE;
|
editDistribution = Boolean.TRUE;
|
||||||
saveDistributionBtn.setEnabled(false);
|
addDistributionWindow.setSaveButtonEnabled(false);
|
||||||
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
|
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
|
||||||
if (distSet != null) {
|
if (distSet != null) {
|
||||||
distNameTextField.setValue(distSet.getName());
|
distNameTextField.setValue(distSet.getName());
|
||||||
@@ -518,13 +504,15 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window getWindow() {
|
public CommonDialogWindow getWindow() {
|
||||||
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
|
||||||
populateRequiredComponents();
|
populateRequiredComponents();
|
||||||
resetComponents();
|
resetComponents();
|
||||||
addDistributionWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.dist"), null,
|
addDistributionWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.dist"), null,
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> saveDistribution(), event -> discardDistribution(),
|
||||||
addDistributionWindow.setContent(this);
|
null);
|
||||||
|
addDistributionWindow.getButtonsLayout().removeStyleName("actionButtonsMargin");
|
||||||
|
|
||||||
return addDistributionWindow;
|
return addDistributionWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,4 +532,5 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
public void setOriginalDistSetTYpe(final String originalDistSetType) {
|
public void setOriginalDistSetTYpe(final String originalDistSetType) {
|
||||||
this.originalDistSetType = originalDistSetType;
|
this.originalDistSetType = originalDistSetType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.dstag;
|
package org.eclipse.hawkbit.ui.management.dstag;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
@@ -16,276 +17,37 @@ import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBu
|
|||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
|
||||||
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.SPUILabelDefinitions;
|
||||||
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.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.shared.ui.colorpicker.Color;
|
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.VaadinSessionScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.OptionGroup;
|
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
* Class for Create/Update Tag Layout of distribution set
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@VaadinSessionScope
|
@ViewScope
|
||||||
public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayout {
|
public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdateTagLayout {
|
||||||
private static final long serialVersionUID = 444276149954167545L;
|
|
||||||
|
|
||||||
@Autowired
|
private static final long serialVersionUID = 444276149954167545L;
|
||||||
private transient UINotification uiNotification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient EntityFactory entityFactory;
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
private static final String MISSING_TAG_NAME = "message.error.missing.tagname";
|
|
||||||
private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name";
|
private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name";
|
||||||
private static final String MSG_TEXTFIELD_NAME = "textfield.name";
|
private static final String MSG_TEXTFIELD_NAME = "textfield.name";
|
||||||
|
|
||||||
private Window distTagWindow;
|
|
||||||
|
|
||||||
public Window getWindow() {
|
|
||||||
reset();
|
|
||||||
distTagWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.tag"), null,
|
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
|
||||||
distTagWindow.setContent(this);
|
|
||||||
return distTagWindow;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateTagNameCombo() {
|
|
||||||
tagNameComboBox.removeAllItems();
|
|
||||||
final List<DistributionSetTag> distTagNameList = tagManagement.findAllDistributionSetTags();
|
|
||||||
distTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update DistributionTag.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void save(final ClickEvent event) {
|
|
||||||
if (mandatoryValuesPresent()) {
|
|
||||||
final DistributionSetTag existingDistTag = tagManagement.findDistributionSetTag(tagName.getValue());
|
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
|
||||||
if (!checkIsDuplicate(existingDistTag)) {
|
|
||||||
crateNewTag();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
updateTag(existingDistTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new tag.
|
|
||||||
*/
|
|
||||||
private void crateNewTag() {
|
|
||||||
|
|
||||||
final String colorPicked = getColorPickedSting();
|
|
||||||
final String tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
|
||||||
final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
|
||||||
|
|
||||||
if (null != tagNameValue) {
|
|
||||||
DistributionSetTag newDistTag = entityFactory.generateDistributionSetTag(tagNameValue, tagDescValue,
|
|
||||||
new Color(0, 146, 58).getCSS());
|
|
||||||
|
|
||||||
if (colorPicked != null) {
|
|
||||||
newDistTag.setColour(colorPicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
newDistTag = tagManagement.createDistributionSetTag(newDistTag);
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistTag.getName() }));
|
|
||||||
resetDistTagValues();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(i18n.get(MISSING_TAG_NAME));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update tag.
|
|
||||||
*/
|
|
||||||
private void updateTag(final DistributionSetTag distObj) {
|
|
||||||
final String nameUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
|
||||||
final String descUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
|
||||||
|
|
||||||
if (null != nameUpdateValue) {
|
|
||||||
distObj.setName(nameUpdateValue);
|
|
||||||
distObj.setDescription(null != descUpdateValue ? descUpdateValue : null);
|
|
||||||
// update target tag with color selected
|
|
||||||
distObj.setColour(getColorPickedSting());
|
|
||||||
tagManagement.updateDistributionSetTag(distObj);
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { distObj.getName() }));
|
|
||||||
closeWindow();
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeWindow() {
|
|
||||||
distTagWindow.close();
|
|
||||||
UI.getCurrent().removeWindow(distTagWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RESET.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void discard(final ClickEvent event) {
|
|
||||||
distTagWindow.setVisible(false);
|
|
||||||
UI.getCurrent().removeWindow(distTagWindow);
|
|
||||||
resetDistTagValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get color picked value in string.
|
|
||||||
*
|
|
||||||
* @return String of color picked value.
|
|
||||||
*/
|
|
||||||
private String getColorPickedSting() {
|
|
||||||
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
|
|
||||||
+ getSelPreview().getColor().getBlue() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Color view.
|
|
||||||
*
|
|
||||||
* @return ColorPickerPreview as UI
|
|
||||||
*/
|
|
||||||
public SpColorPickerPreview getSelPreview() {
|
|
||||||
return selPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RESET.
|
|
||||||
*/
|
|
||||||
private void resetDistTagValues() {
|
|
||||||
tagName.removeStyleName(TARGET_TAG_NAME_DYNAMIC_STYLE);
|
|
||||||
tagName.addStyleName(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
|
||||||
tagName.setValue("");
|
|
||||||
tagName.setInputPrompt(i18n.get(MSG_TEXTFIELD_NAME));
|
|
||||||
setColor(new Color(0, 146, 58));
|
|
||||||
distTagWindow.setVisible(false);
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
UI.getCurrent().removeWindow(distTagWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see hawkbit.server.ui.management.CreateUpdateTagLayout#createOptionGroup
|
|
||||||
* ()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void createOptionGroup() {
|
|
||||||
final List<String> optionValues = new ArrayList<>();
|
|
||||||
if (permChecker.hasCreateDistributionPermission()) {
|
|
||||||
optionValues.add(createTag.getValue());
|
|
||||||
}
|
|
||||||
if (permChecker.hasUpdateDistributionPermission()) {
|
|
||||||
optionValues.add(updateTag.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
createOptionGroup(optionValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createOptionGroup(final List<String> tagOptions) {
|
|
||||||
optiongroup = new OptionGroup("", tagOptions);
|
|
||||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
|
||||||
optiongroup.addStyleName("custom-option-group");
|
|
||||||
optiongroup.setNullSelectionAllowed(false);
|
|
||||||
if (!tagOptions.isEmpty()) {
|
|
||||||
optiongroup.select(tagOptions.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Boolean mandatoryValuesPresent() {
|
|
||||||
if (Strings.isNullOrEmpty(tagName.getValue())) {
|
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
|
||||||
}
|
|
||||||
if (optiongroup.getValue().equals(updateTagNw)) {
|
|
||||||
if (null == tagNameComboBox.getValue()) {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.tagname"));
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select tag & set tag name & tag desc values corresponding to selected
|
|
||||||
* tag.
|
|
||||||
*
|
|
||||||
* @param targetTagSelected
|
|
||||||
* as the selected tag from combo
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setTagDetails(final String distTagSelected) {
|
|
||||||
tagName.setValue(distTagSelected);
|
|
||||||
final DistributionSetTag selectedDistTag = tagManagement.findDistributionSetTag(distTagSelected);
|
|
||||||
if (null != selectedDistTag) {
|
|
||||||
tagDesc.setValue(selectedDistTag.getDescription());
|
|
||||||
if (null == selectedDistTag.getColour()) {
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, DEFAULT_COLOR);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
selectedColor = rgbToColorConverter(selectedDistTag.getColour());
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, selectedDistTag.getColour());
|
|
||||||
getPreviewButtonColor(selectedDistTag.getColour());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checking Tag already existed or not.
|
|
||||||
*
|
|
||||||
* @param existingDistTag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
private Boolean checkIsDuplicate(final DistributionSetTag existingDistTag) {
|
|
||||||
if (existingDistTag != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.tag.duplicate.check", new Object[] { existingDistTag.getName() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
// Exception squid:S1172 - event not needed
|
// Exception squid:S1172 - event not needed
|
||||||
@SuppressWarnings({ "squid:S1172" })
|
@SuppressWarnings({ "squid:S1172" })
|
||||||
@@ -307,4 +69,116 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
|
|||||||
populateTagNameCombo();
|
populateTagNameCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populateTagNameCombo() {
|
||||||
|
tagNameComboBox.removeAllItems();
|
||||||
|
final List<DistributionSetTag> distTagNameList = tagManagement.findAllDistributionSetTags();
|
||||||
|
distTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addListeners() {
|
||||||
|
super.addListeners();
|
||||||
|
optiongroup.addValueChangeListener(this::optionValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update DistributionTag.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(final ClickEvent event) {
|
||||||
|
if (mandatoryValuesPresent()) {
|
||||||
|
final DistributionSetTag existingDistTag = tagManagement.findDistributionSetTag(tagName.getValue());
|
||||||
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
|
if (!checkIsDuplicate(existingDistTag)) {
|
||||||
|
createNewTag();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
updateExistingTag(existingDistTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new tag.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void createNewTag() {
|
||||||
|
super.createNewTag();
|
||||||
|
if (isNotEmpty(getTagNameValue())) {
|
||||||
|
DistributionSetTag newDistTag = entityFactory.generateDistributionSetTag(tagNameValue, tagDescValue,
|
||||||
|
ColorPickerConstants.START_COLOR.getCSS());
|
||||||
|
|
||||||
|
if (isNotEmpty(getColorPicked())) {
|
||||||
|
newDistTag.setColour(getColorPicked());
|
||||||
|
}
|
||||||
|
newDistTag = tagManagement.createDistributionSetTag(newDistTag);
|
||||||
|
displaySuccess(newDistTag.getName());
|
||||||
|
resetDistTagValues();
|
||||||
|
} else {
|
||||||
|
displayValidationError(i18n.get(SPUILabelDefinitions.MISSING_TAG_NAME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RESET.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void discard(final ClickEvent event) {
|
||||||
|
super.discard(event);
|
||||||
|
resetDistTagValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RESET.
|
||||||
|
*/
|
||||||
|
private void resetDistTagValues() {
|
||||||
|
tagName.removeStyleName(TARGET_TAG_NAME_DYNAMIC_STYLE);
|
||||||
|
tagName.addStyleName(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
||||||
|
tagName.setValue("");
|
||||||
|
tagName.setInputPrompt(i18n.get(MSG_TEXTFIELD_NAME));
|
||||||
|
setColor(ColorPickerConstants.START_COLOR);
|
||||||
|
getWindow().setVisible(false);
|
||||||
|
tagPreviewBtnClicked = false;
|
||||||
|
UI.getCurrent().removeWindow(getWindow());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select tag & set tag name & tag desc values corresponding to selected
|
||||||
|
* tag.
|
||||||
|
*
|
||||||
|
* @param distTagSelected
|
||||||
|
* as the selected tag from combo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setTagDetails(final String distTagSelected) {
|
||||||
|
tagName.setValue(distTagSelected);
|
||||||
|
final DistributionSetTag selectedDistTag = tagManagement.findDistributionSetTag(distTagSelected);
|
||||||
|
if (null != selectedDistTag) {
|
||||||
|
tagDesc.setValue(selectedDistTag.getDescription());
|
||||||
|
if (null == selectedDistTag.getColour()) {
|
||||||
|
setTagColor(getColorPickerLayout().getDefaultColor(), ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
} else {
|
||||||
|
setTagColor(ColorPickerHelper.rgbToColorConverter(selectedDistTag.getColour()),
|
||||||
|
selectedDistTag.getColour());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createRequiredComponents() {
|
||||||
|
super.createRequiredComponents();
|
||||||
|
createOptionGroup(permChecker.hasCreateDistributionPermission(), permChecker.hasUpdateDistributionPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void reset() {
|
||||||
|
|
||||||
|
super.reset();
|
||||||
|
setOptionGroupDefaultValue(permChecker.hasCreateDistributionPermission(),
|
||||||
|
permChecker.hasUpdateDistributionPermission());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class ActionTypeOptionGroupLayout extends HorizontalLayout {
|
|||||||
createOptionGroup();
|
createOptionGroup();
|
||||||
addValueChangeListener();
|
addValueChangeListener();
|
||||||
setStyleName("dist-window-actiontype-horz-layout");
|
setStyleName("dist-window-actiontype-horz-layout");
|
||||||
|
setSizeUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addValueChangeListener() {
|
private void addValueChangeListener() {
|
||||||
@@ -127,8 +128,8 @@ public class ActionTypeOptionGroupLayout extends HorizontalLayout {
|
|||||||
forcedTimeDateField.setStyleName("dist-window-forcedtime");
|
forcedTimeDateField.setStyleName("dist-window-forcedtime");
|
||||||
|
|
||||||
final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
|
final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
|
||||||
forcedTimeDateField.setValue(Date.from(LocalDateTime.now().plusWeeks(2)
|
forcedTimeDateField.setValue(
|
||||||
.atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
|
Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
|
||||||
forcedTimeDateField.setImmediate(true);
|
forcedTimeDateField.setImmediate(true);
|
||||||
forcedTimeDateField.setTimeZone(tz);
|
forcedTimeDateField.setTimeZone(tz);
|
||||||
forcedTimeDateField.setLocale(i18n.getLocale());
|
forcedTimeDateField.setLocale(i18n.getLocale());
|
||||||
|
|||||||
@@ -481,8 +481,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
|||||||
/*
|
/*
|
||||||
* On delete of pinned target ,unpin refresh both target table and DS
|
* On delete of pinned target ,unpin refresh both target table and DS
|
||||||
*/
|
*/
|
||||||
managementUIState.getDistributionTableFilters().getPinnedTargetId()
|
managementUIState.getDistributionTableFilters().getPinnedTargetId().ifPresent(this::unPinDeletedTarget);
|
||||||
.ifPresent(targetId -> unPinDeletedTarget(targetId));
|
|
||||||
eventBus.publish(this, SaveActionWindowEvent.DELETED_TARGETS);
|
eventBus.publish(this, SaveActionWindowEvent.DELETED_TARGETS);
|
||||||
managementUIState.getDeletedTargetList().clear();
|
managementUIState.getDeletedTargetList().clear();
|
||||||
|
|
||||||
|
|||||||
@@ -1,587 +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.management.tag;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
|
||||||
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
|
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.vaadin.spring.events.EventBus;
|
|
||||||
|
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
|
||||||
import com.vaadin.data.Property.ValueChangeListener;
|
|
||||||
import com.vaadin.server.FontAwesome;
|
|
||||||
import com.vaadin.server.Page;
|
|
||||||
import com.vaadin.shared.ui.colorpicker.Color;
|
|
||||||
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
|
||||||
import com.vaadin.ui.Alignment;
|
|
||||||
import com.vaadin.ui.Button;
|
|
||||||
import com.vaadin.ui.ComboBox;
|
|
||||||
import com.vaadin.ui.CustomComponent;
|
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
import com.vaadin.ui.Label;
|
|
||||||
import com.vaadin.ui.OptionGroup;
|
|
||||||
import com.vaadin.ui.Slider;
|
|
||||||
import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorPickerGradient;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract class for create/update target tag layout.
|
|
||||||
*/
|
|
||||||
public abstract class CreateUpdateTagLayout extends CustomComponent implements ColorChangeListener, ColorSelector {
|
|
||||||
private static final long serialVersionUID = 4229177824620576456L;
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateTagLayout.class);
|
|
||||||
protected static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
|
||||||
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
|
||||||
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
|
||||||
private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
|
||||||
|
|
||||||
protected String createTagNw;
|
|
||||||
protected String updateTagNw;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected I18N i18n;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected transient TagManagement tagManagement;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected transient EventBus.SessionEventBus eventBus;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected SpPermissionChecker permChecker;
|
|
||||||
/**
|
|
||||||
* Local Instance of ColorPickerPreview.
|
|
||||||
*/
|
|
||||||
protected SpColorPickerPreview selPreview;
|
|
||||||
|
|
||||||
protected Label createTag;
|
|
||||||
protected Label updateTag;
|
|
||||||
private Label comboLabel;
|
|
||||||
private Label colorLabel;
|
|
||||||
private Label madatoryLabel;
|
|
||||||
protected TextField tagName;
|
|
||||||
protected TextArea tagDesc;
|
|
||||||
private Button saveTag;
|
|
||||||
private Button discardTag;
|
|
||||||
private Button tagColorPreviewBtn;
|
|
||||||
protected OptionGroup optiongroup;
|
|
||||||
protected ComboBox tagNameComboBox;
|
|
||||||
|
|
||||||
protected ColorPickerGradient colorSelect;
|
|
||||||
private Set<ColorSelector> selectors;
|
|
||||||
protected Color selectedColor;
|
|
||||||
|
|
||||||
private Slider redSlider;
|
|
||||||
private Slider greenSlider;
|
|
||||||
private Slider blueSlider;
|
|
||||||
|
|
||||||
private VerticalLayout comboLayout;
|
|
||||||
private VerticalLayout sliders;
|
|
||||||
private VerticalLayout colorPickerLayout;
|
|
||||||
private HorizontalLayout mainLayout;
|
|
||||||
private VerticalLayout fieldLayout;
|
|
||||||
|
|
||||||
/** RGB color converter. */
|
|
||||||
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
|
||||||
|
|
||||||
protected boolean tagPreviewBtnClicked = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save new tag / update new tag.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
protected abstract void save(final Button.ClickEvent event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Discard the changes and close the popup.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
protected abstract void discard(final Button.ClickEvent event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create option group with Create tag/Update tag based on permissions.
|
|
||||||
*/
|
|
||||||
protected abstract void createOptionGroup();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate target name combo.
|
|
||||||
*/
|
|
||||||
protected abstract void populateTagNameCombo();
|
|
||||||
|
|
||||||
protected abstract void setTagDetails(final String tagSelected);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init the layout.
|
|
||||||
*/
|
|
||||||
public void init() {
|
|
||||||
createRequiredComponents();
|
|
||||||
addListeners();
|
|
||||||
buildLayout();
|
|
||||||
eventBus.subscribe(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreDestroy
|
|
||||||
void destroy() {
|
|
||||||
eventBus.unsubscribe(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
|
||||||
createTagNw = i18n.get("label.create.tag");
|
|
||||||
updateTagNw = i18n.get("label.update.tag");
|
|
||||||
createTag = SPUIComponentProvider.getLabel(createTagNw, null);
|
|
||||||
updateTag = SPUIComponentProvider.getLabel(i18n.get("label.update.tag"), null);
|
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
|
||||||
madatoryLabel = getMandatoryLabel();
|
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
|
||||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
|
||||||
|
|
||||||
tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
|
|
||||||
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
|
|
||||||
|
|
||||||
tagDesc = SPUIComponentProvider.getTextArea("", 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("");
|
|
||||||
|
|
||||||
tagNameComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
|
|
||||||
i18n.get("label.combobox.tag"));
|
|
||||||
tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE);
|
|
||||||
tagNameComboBox.setImmediate(true);
|
|
||||||
|
|
||||||
saveTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_SAVE, "", "", "", true,
|
|
||||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
|
||||||
|
|
||||||
discardTag = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_TAG_DISRACD, "", "",
|
|
||||||
"discard-button-style", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
discardTag.addStyleName(ValoTheme.BUTTON_BORDERLESS);
|
|
||||||
|
|
||||||
tagColorPreviewBtn = new Button();
|
|
||||||
tagColorPreviewBtn.setId(SPUIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
|
||||||
|
|
||||||
selectors = new HashSet<>();
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview = new SpColorPickerPreview(selectedColor);
|
|
||||||
|
|
||||||
colorSelect = new ColorPickerGradient("rgb-gradient", rgbConverter);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
colorSelect.setWidth("220px");
|
|
||||||
|
|
||||||
redSlider = createRGBSlider("", "red");
|
|
||||||
greenSlider = createRGBSlider("", "green");
|
|
||||||
blueSlider = createRGBSlider("", "blue");
|
|
||||||
setRgbSliderValues(selectedColor);
|
|
||||||
|
|
||||||
createOptionGroup();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildLayout() {
|
|
||||||
comboLayout = new VerticalLayout();
|
|
||||||
|
|
||||||
sliders = new VerticalLayout();
|
|
||||||
sliders.addComponents(redSlider, greenSlider, blueSlider);
|
|
||||||
|
|
||||||
selectors.add(colorSelect);
|
|
||||||
|
|
||||||
colorPickerLayout = new VerticalLayout();
|
|
||||||
colorPickerLayout.setStyleName("rgb-vertical-layout");
|
|
||||||
colorPickerLayout.addComponent(selPreview);
|
|
||||||
colorPickerLayout.addComponent(colorSelect);
|
|
||||||
|
|
||||||
fieldLayout = new VerticalLayout();
|
|
||||||
fieldLayout.setSpacing(false);
|
|
||||||
fieldLayout.setMargin(false);
|
|
||||||
fieldLayout.setWidth("100%");
|
|
||||||
fieldLayout.setHeight(null);
|
|
||||||
fieldLayout.addComponent(optiongroup);
|
|
||||||
fieldLayout.addComponent(comboLayout);
|
|
||||||
fieldLayout.addComponent(madatoryLabel);
|
|
||||||
fieldLayout.addComponent(tagName);
|
|
||||||
fieldLayout.addComponent(tagDesc);
|
|
||||||
|
|
||||||
|
|
||||||
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
|
|
||||||
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
|
||||||
fieldLayout.addComponent(colorLabelLayout);
|
|
||||||
|
|
||||||
final HorizontalLayout buttonLayout = new HorizontalLayout();
|
|
||||||
buttonLayout.addComponent(saveTag);
|
|
||||||
buttonLayout.addComponent(discardTag);
|
|
||||||
buttonLayout.setComponentAlignment(discardTag, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonLayout.setComponentAlignment(saveTag, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonLayout.addStyleName("window-style");
|
|
||||||
buttonLayout.setWidth("152px");
|
|
||||||
|
|
||||||
final VerticalLayout fieldButtonLayout = new VerticalLayout();
|
|
||||||
fieldButtonLayout.addComponent(fieldLayout);
|
|
||||||
fieldButtonLayout.addComponent(buttonLayout);
|
|
||||||
fieldButtonLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);
|
|
||||||
|
|
||||||
mainLayout = new HorizontalLayout();
|
|
||||||
mainLayout.addComponent(fieldButtonLayout);
|
|
||||||
setCompositionRoot(mainLayout);
|
|
||||||
tagName.focus();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addListeners() {
|
|
||||||
saveTag.addClickListener(event -> save(event));
|
|
||||||
discardTag.addClickListener(event -> discard(event));
|
|
||||||
colorSelect.addColorChangeListener(this);
|
|
||||||
selPreview.addColorChangeListener(this);
|
|
||||||
tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
|
|
||||||
optiongroup.addValueChangeListener(event -> optionValueChanged(event));
|
|
||||||
tagNameComboBox.addValueChangeListener(event -> tagNameChosen(event));
|
|
||||||
slidersValueChangeListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open color picker on click of preview button. Auto select the color based
|
|
||||||
* on target tag if already selected.
|
|
||||||
*/
|
|
||||||
private void previewButtonClicked() {
|
|
||||||
if (!tagPreviewBtnClicked) {
|
|
||||||
setColor();
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
fieldLayout.addComponent(sliders);
|
|
||||||
mainLayout.addComponent(colorPickerLayout);
|
|
||||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
|
|
||||||
}
|
|
||||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setColor() {
|
|
||||||
final String selectedOption = (String) optiongroup.getValue();
|
|
||||||
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagNw)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tagNameComboBox.getValue() == null) {
|
|
||||||
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue().toString());
|
|
||||||
|
|
||||||
if (targetTagSelected == null) {
|
|
||||||
final DistributionSetTag distTag = tagManagement
|
|
||||||
.findDistributionSetTag(tagNameComboBox.getValue().toString());
|
|
||||||
selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour())
|
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
selectedColor = targetTagSelected.getColour() != null ? rgbToColorConverter(targetTagSelected.getColour())
|
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Covert RGB code to {@Color}.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* RGB vale
|
|
||||||
* @return Color
|
|
||||||
*/
|
|
||||||
protected Color rgbToColorConverter(final String value) {
|
|
||||||
if (!value.startsWith("rgb")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// RGB color format rgb/rgba(255,255,255,0.1)
|
|
||||||
final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
|
|
||||||
final int red = Integer.parseInt(colors[0]);
|
|
||||||
final int green = Integer.parseInt(colors[1]);
|
|
||||||
final int blue = Integer.parseInt(colors[2]);
|
|
||||||
if (colors.length > 3) {
|
|
||||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
|
||||||
return new Color(red, green, blue, alpha);
|
|
||||||
} else {
|
|
||||||
return new Color(red, green, blue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Label getMandatoryLabel() {
|
|
||||||
final Label label = new Label(i18n.get("label.mandatory.field"));
|
|
||||||
label.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tagNameChosen(final ValueChangeEvent event) {
|
|
||||||
final String tagSelected = (String) event.getProperty().getValue();
|
|
||||||
if (null != tagSelected) {
|
|
||||||
setTagDetails(tagSelected);
|
|
||||||
} else {
|
|
||||||
resetTagNameField();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetTagNameField() {
|
|
||||||
tagName.setEnabled(false);
|
|
||||||
tagName.clear();
|
|
||||||
|
|
||||||
tagDesc.clear();
|
|
||||||
restoreComponentStyles();
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Listener for option group - Create tag/Update.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
* ValueChangeEvent
|
|
||||||
*/
|
|
||||||
private void optionValueChanged(final ValueChangeEvent event) {
|
|
||||||
if ("Update Tag".equals(event.getProperty().getValue())) {
|
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
tagName.setEnabled(false);
|
|
||||||
populateTagNameCombo();
|
|
||||||
// show target name combo
|
|
||||||
comboLayout.addComponent(comboLabel);
|
|
||||||
comboLayout.addComponent(tagNameComboBox);
|
|
||||||
} else {
|
|
||||||
tagName.setEnabled(true);
|
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
// hide target name combo
|
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(tagNameComboBox);
|
|
||||||
}
|
|
||||||
// close the color picker layout
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
// reset the selected color - Set defualt color
|
|
||||||
restoreComponentStyles();
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
selPreview.setColor(rgbToColorConverter(DEFAULT_COLOR));
|
|
||||||
// remove the sliders and color picker layout
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reset the components.
|
|
||||||
*/
|
|
||||||
protected void reset() {
|
|
||||||
tagName.setEnabled(true);
|
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
restoreComponentStyles();
|
|
||||||
|
|
||||||
// hide target name combo
|
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(tagNameComboBox);
|
|
||||||
fieldLayout.removeComponent(sliders);
|
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
optiongroup.select(createTagNw);
|
|
||||||
|
|
||||||
// Default green color
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On change of color in color picker ,change RGB sliders, components border
|
|
||||||
* color and color of preview button.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void colorChanged(final ColorChangeEvent event) {
|
|
||||||
setColor(event.getColor());
|
|
||||||
for (final ColorSelector select : selectors) {
|
|
||||||
if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(selectedColor)) {
|
|
||||||
select.setColor(selectedColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setRgbSliderValues(selectedColor);
|
|
||||||
getPreviewButtonColor(event.getColor().getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic styles for window.
|
|
||||||
*
|
|
||||||
* @param top
|
|
||||||
* int value
|
|
||||||
* @param marginLeft
|
|
||||||
* int value
|
|
||||||
*/
|
|
||||||
protected void getPreviewButtonColor(final String color) {
|
|
||||||
Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Slider createRGBSlider(final String caption, final String styleName) {
|
|
||||||
final Slider slider = new Slider(caption, 0, 255);
|
|
||||||
slider.setImmediate(true);
|
|
||||||
slider.setWidth("150px");
|
|
||||||
slider.addStyleName(styleName);
|
|
||||||
return slider;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRgbSliderValues(final Color color) {
|
|
||||||
try {
|
|
||||||
final double redColorValue = color.getRed();
|
|
||||||
redSlider.setValue(new Double(redColorValue));
|
|
||||||
final double blueColorValue = color.getBlue();
|
|
||||||
blueSlider.setValue(new Double(blueColorValue));
|
|
||||||
final double greenColorValue = color.getGreen();
|
|
||||||
greenSlider.setValue(new Double(greenColorValue));
|
|
||||||
} catch (final ValueOutOfBoundsException e) {
|
|
||||||
LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
|
|
||||||
+ color.getBlue(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set tag name and desc field border color based on chosen color.
|
|
||||||
*
|
|
||||||
* @param tagName
|
|
||||||
* @param tagDesc
|
|
||||||
* @param taregtTagColor
|
|
||||||
*/
|
|
||||||
protected void createDynamicStyleForComponents(final TextField tagName, final TextArea tagDesc,
|
|
||||||
final String taregtTagColor) {
|
|
||||||
tagName.removeStyleName(SPUIDefinitions.TAG_NAME);
|
|
||||||
tagDesc.removeStyleName(SPUIDefinitions.TAG_DESC);
|
|
||||||
getTargetDynamicStyles(taregtTagColor);
|
|
||||||
tagName.addStyleName(TAG_NAME_DYNAMIC_STYLE);
|
|
||||||
tagDesc.addStyleName(TAG_DESC_DYNAMIC_STYLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reset the tag name and tag description component border color.
|
|
||||||
*/
|
|
||||||
private void restoreComponentStyles() {
|
|
||||||
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
|
|
||||||
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
|
|
||||||
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
|
|
||||||
tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get target style - Dynamically as per the color picked, cannot be done
|
|
||||||
* from the static css.
|
|
||||||
*
|
|
||||||
* @param colorPickedPreview
|
|
||||||
*/
|
|
||||||
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
|
||||||
Page.getCurrent().getJavaScript()
|
|
||||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Color getColor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setColor(final Color color) {
|
|
||||||
if (color == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedColor = color;
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
final String colorPickedPreview = selPreview.getColor().getCSS();
|
|
||||||
if (tagName.isEnabled() && null != colorSelect) {
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
|
|
||||||
colorSelect.setColor(selPreview.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Value change listeners implementations of sliders.
|
|
||||||
*/
|
|
||||||
private void slidersValueChangeListeners() {
|
|
||||||
redSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = -8336732888800920839L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double red = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
greenSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 1236358037766775663L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double green = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), (int) green, selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
blueSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 8466370763686043947L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double blue = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), selectedColor.getGreen(), (int) blue);
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setColorToComponents(final Color newColor) {
|
|
||||||
setColor(newColor);
|
|
||||||
colorSelect.setColor(newColor);
|
|
||||||
getPreviewButtonColor(newColor.getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addColorChangeListener(final ColorChangeListener listener) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeColorChangeListener(final ColorChangeListener listener) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,9 @@ import org.eclipse.hawkbit.repository.EntityFactory;
|
|||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
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.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.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;
|
||||||
@@ -33,18 +33,14 @@ import org.vaadin.spring.events.EventBus;
|
|||||||
|
|
||||||
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
import com.vaadin.event.FieldEvents.TextChangeEvent;
|
||||||
import com.vaadin.event.FieldEvents.TextChangeListener;
|
import com.vaadin.event.FieldEvents.TextChangeListener;
|
||||||
import com.vaadin.server.FontAwesome;
|
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.VaadinSessionScope;
|
import com.vaadin.spring.annotation.VaadinSessionScope;
|
||||||
import com.vaadin.ui.Alignment;
|
|
||||||
import com.vaadin.ui.Button;
|
|
||||||
import com.vaadin.ui.CustomComponent;
|
import com.vaadin.ui.CustomComponent;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.FormLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
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.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
@@ -78,12 +74,10 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
private TextField nameTextField;
|
private TextField nameTextField;
|
||||||
private TextArea descTextArea;
|
private TextArea descTextArea;
|
||||||
private Label madatoryLabel;
|
private Label madatoryLabel;
|
||||||
private Button saveTarget;
|
|
||||||
private Button discardTarget;
|
|
||||||
private boolean editTarget = Boolean.FALSE;
|
private boolean editTarget = Boolean.FALSE;
|
||||||
private String controllerId;
|
private String controllerId;
|
||||||
private VerticalLayout mainLayout;
|
private FormLayout formLayout;
|
||||||
private Window addTargetWindow;
|
private CommonDialogWindow window;
|
||||||
|
|
||||||
private String oldTargetName;
|
private String oldTargetName;
|
||||||
private String oldTargetDesc;
|
private String oldTargetDesc;
|
||||||
@@ -98,23 +92,22 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
buildLayout();
|
buildLayout();
|
||||||
/* register all listeners related to the Window */
|
/* register all listeners related to the Window */
|
||||||
addListeners();
|
addListeners();
|
||||||
setCompositionRoot(mainLayout);
|
setCompositionRoot(formLayout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
/* Textfield for controller Id */
|
/* Textfield for controller Id */
|
||||||
controllerIDTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
controllerIDTextField = SPUIComponentProvider.getTextField( i18n.get("prompt.target.id"), "", ValoTheme.TEXTFIELD_TINY, true, null,
|
||||||
i18n.get("prompt.target.id"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
i18n.get("prompt.target.id"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
controllerIDTextField.setId(SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
|
controllerIDTextField.setId(SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
|
||||||
|
|
||||||
/* Textfield for target name */
|
/* Textfield for target name */
|
||||||
nameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
nameTextField = SPUIComponentProvider.getTextField( i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
nameTextField.setId(SPUIComponentIdProvider.TARGET_ADD_NAME);
|
nameTextField.setId(SPUIComponentIdProvider.TARGET_ADD_NAME);
|
||||||
|
|
||||||
/* Textarea for target description */
|
/* Textarea for target description */
|
||||||
descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY, false, null,
|
descTextArea = SPUIComponentProvider.getTextArea( i18n.get("textfield.description"), "text-area-style", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
descTextArea.setId(SPUIComponentIdProvider.TARGET_ADD_DESC);
|
descTextArea.setId(SPUIComponentIdProvider.TARGET_ADD_DESC);
|
||||||
descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
@@ -122,48 +115,31 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
/* Label for mandatory symbol */
|
/* Label for mandatory symbol */
|
||||||
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
madatoryLabel = new Label(i18n.get("label.mandatory.field"));
|
||||||
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
madatoryLabel.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_SMALL);
|
||||||
|
|
||||||
/* save or update button */
|
|
||||||
saveTarget = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_SAVE, "", "", "", true,
|
|
||||||
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveTarget.addClickListener(event -> saveTargetListner());
|
|
||||||
|
|
||||||
/* close button */
|
|
||||||
discardTarget = SPUIComponentProvider.getButton(SPUIDefinitions.NEW_TARGET_DISCARD, "", "", "", true,
|
|
||||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
discardTarget.addClickListener(event -> discardTargetListner());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
private void buildLayout() {
|
||||||
/* action button layout (save & dicard) */
|
|
||||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
|
||||||
buttonsLayout.setSizeFull();
|
|
||||||
buttonsLayout.addComponents(saveTarget, discardTarget);
|
|
||||||
buttonsLayout.setComponentAlignment(saveTarget, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonsLayout.setComponentAlignment(discardTarget, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonsLayout.addStyleName("window-style");
|
|
||||||
/*
|
/*
|
||||||
* The main layout of the window contains mandatory info, textboxes
|
* The main layout of the window contains mandatory info, textboxes
|
||||||
* (controller Id, name & description) and action buttons layout
|
* (controller Id, name & description) and action buttons layout
|
||||||
*/
|
*/
|
||||||
mainLayout = new VerticalLayout();
|
|
||||||
mainLayout.setSpacing(Boolean.TRUE);
|
formLayout = new FormLayout();
|
||||||
mainLayout.addStyleName("lay-color");
|
formLayout.addComponent(madatoryLabel);
|
||||||
mainLayout.setSizeUndefined();
|
formLayout.addComponent(controllerIDTextField);
|
||||||
mainLayout.addComponent(madatoryLabel);
|
formLayout.addComponent(nameTextField);
|
||||||
mainLayout.setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
|
formLayout.addComponent(descTextArea);
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(editTarget)) {
|
if (Boolean.TRUE.equals(editTarget)) {
|
||||||
madatoryLabel.setVisible(Boolean.FALSE);
|
madatoryLabel.setVisible(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
mainLayout.addComponents(madatoryLabel, controllerIDTextField, nameTextField, descTextArea, buttonsLayout);
|
controllerIDTextField.focus();
|
||||||
nameTextField.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListeners() {
|
private void addListeners() {
|
||||||
|
|
||||||
addTargetNameChangeListner();
|
addTargetNameChangeListner();
|
||||||
addTargetDescChangeListner();
|
addTargetDescChangeListner();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTargetNameChangeListner() {
|
private void addTargetNameChangeListner() {
|
||||||
@@ -177,14 +153,13 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void textChange(final TextChangeEvent event) {
|
public void textChange(final TextChangeEvent event) {
|
||||||
if (event.getText().equals(oldTargetName) && descTextArea.getValue().equals(oldTargetDesc)) {
|
if (event.getText().equals(oldTargetName) && descTextArea.getValue().equals(oldTargetDesc)) {
|
||||||
saveTarget.setEnabled(false);
|
window.setSaveButtonEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
saveTarget.setEnabled(true);
|
window.setSaveButtonEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTargetDescChangeListner() {
|
private void addTargetDescChangeListner() {
|
||||||
@@ -198,9 +173,9 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void textChange(final TextChangeEvent event) {
|
public void textChange(final TextChangeEvent event) {
|
||||||
if (event.getText().equals(oldTargetDesc) && nameTextField.getValue().equals(oldTargetName)) {
|
if (event.getText().equals(oldTargetDesc) && nameTextField.getValue().equals(oldTargetName)) {
|
||||||
saveTarget.setEnabled(false);
|
window.setSaveButtonEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
saveTarget.setEnabled(true);
|
window.setSaveButtonEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -268,10 +243,9 @@ 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);
|
||||||
addTargetWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.target"), null,
|
window = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.target"), null,
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> saveTargetListner(), event -> discardTargetListner(), null);
|
||||||
addTargetWindow.setContent(this);
|
return window;
|
||||||
return addTargetWindow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,8 +264,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
|
|
||||||
private void closeThisWindow() {
|
private void closeThisWindow() {
|
||||||
editTarget = Boolean.FALSE;
|
editTarget = Boolean.FALSE;
|
||||||
addTargetWindow.close();
|
window.close();
|
||||||
UI.getCurrent().removeWindow(addTargetWindow);
|
UI.getCurrent().removeWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTargetValues(final Target target, final String name, final String description) {
|
private void setTargetValues(final Target target, final String name, final String description) {
|
||||||
@@ -333,19 +307,11 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
|||||||
if (target.getDescription() != null) {
|
if (target.getDescription() != null) {
|
||||||
descTextArea.setValue(target.getDescription());
|
descTextArea.setValue(target.getDescription());
|
||||||
}
|
}
|
||||||
saveTarget.setEnabled(Boolean.FALSE);
|
window.setSaveButtonEnabled(Boolean.FALSE);
|
||||||
|
|
||||||
oldTargetDesc = descTextArea.getValue();
|
oldTargetDesc = descTextArea.getValue();
|
||||||
oldTargetName = nameTextField.getValue();
|
oldTargetName = nameTextField.getValue();
|
||||||
addTargetWindow.addStyleName("target-update-window");
|
window.addStyleName("target-update-window");
|
||||||
}
|
|
||||||
|
|
||||||
public VerticalLayout getMainLayout() {
|
|
||||||
return mainLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMainLayout(final VerticalLayout mainLayout) {
|
|
||||||
this.mainLayout = mainLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,8 +195,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea getDescriptionTextArea() {
|
private TextArea getDescriptionTextArea() {
|
||||||
final TextArea description = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY,
|
final TextArea description = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"),
|
||||||
false, null, i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
"text-area-style", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
|
||||||
|
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
description.setId(SPUIComponentIdProvider.BULK_UPLOAD_DESC);
|
description.setId(SPUIComponentIdProvider.BULK_UPLOAD_DESC);
|
||||||
description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
description.setWidth("100%");
|
description.setWidth("100%");
|
||||||
@@ -205,8 +206,8 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
|
|
||||||
private ComboBox getDsComboField() {
|
private ComboBox getDsComboField() {
|
||||||
final Container container = createContainer();
|
final Container container = createContainer();
|
||||||
final ComboBox dsComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "",
|
final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.get("bulkupload.ds.name"), "", "", null,
|
||||||
i18n.get("bulkupload.ds.name"));
|
null, false, "", i18n.get("bulkupload.ds.name"));
|
||||||
dsComboBox.setSizeUndefined();
|
dsComboBox.setSizeUndefined();
|
||||||
dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE);
|
dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE);
|
||||||
dsComboBox.setImmediate(true);
|
dsComboBox.setImmediate(true);
|
||||||
@@ -353,7 +354,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* create and return window
|
||||||
|
*
|
||||||
|
* @return Window window
|
||||||
*/
|
*/
|
||||||
public Window getWindow() {
|
public Window getWindow() {
|
||||||
managementUIState.setBulkUploadWindowMinimised(false);
|
managementUIState.setBulkUploadWindowMinimised(false);
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
|
|||||||
pinBtn.setHeightUndefined();
|
pinBtn.setHeightUndefined();
|
||||||
pinBtn.setData(itemId);
|
pinBtn.setData(itemId);
|
||||||
pinBtn.setId(SPUIComponentIdProvider.TARGET_PIN_ICON + "." + itemId);
|
pinBtn.setId(SPUIComponentIdProvider.TARGET_PIN_ICON + "." + itemId);
|
||||||
pinBtn.addClickListener(event -> addPinClickListener(event));
|
pinBtn.addClickListener(this::addPinClickListener);
|
||||||
if (isPinned(((TargetIdName) itemId).getControllerId())) {
|
if (isPinned(((TargetIdName) itemId).getControllerId())) {
|
||||||
pinBtn.addStyleName(TARGET_PINNED);
|
pinBtn.addStyleName(TARGET_PINNED);
|
||||||
isTargetPinned = Boolean.TRUE;
|
isTargetPinned = Boolean.TRUE;
|
||||||
|
|||||||
@@ -1,271 +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.management.targettag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
|
||||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.vaadin.spring.events.EventScope;
|
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.vaadin.shared.ui.colorpicker.Color;
|
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
|
||||||
import com.vaadin.ui.OptionGroup;
|
|
||||||
import com.vaadin.ui.UI;
|
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SpringComponent
|
|
||||||
@ViewScope
|
|
||||||
public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 2446682350481560235L;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private transient UINotification uiNotification;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private transient EntityFactory entityFactory;
|
|
||||||
|
|
||||||
private Window targetTagWindow;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createOptionGroup() {
|
|
||||||
final List<String> optionValues = new ArrayList<>();
|
|
||||||
if (permChecker.hasCreateTargetPermission()) {
|
|
||||||
optionValues.add(createTag.getValue());
|
|
||||||
}
|
|
||||||
if (permChecker.hasUpdateTargetPermission()) {
|
|
||||||
optionValues.add(updateTag.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
createOptionGroup(optionValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createOptionGroup(final List<String> tagOptions) {
|
|
||||||
optiongroup = new OptionGroup("", tagOptions);
|
|
||||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
|
||||||
optiongroup.addStyleName("custom-option-group");
|
|
||||||
|
|
||||||
optiongroup.setNullSelectionAllowed(false);
|
|
||||||
if (!tagOptions.isEmpty()) {
|
|
||||||
optiongroup.select(tagOptions.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Window getWindow() {
|
|
||||||
reset();
|
|
||||||
targetTagWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.tag"), null,
|
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
|
||||||
targetTagWindow.setContent(this);
|
|
||||||
return targetTagWindow;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
|
||||||
// Exception squid:S1172 - event not needed
|
|
||||||
@SuppressWarnings({ "squid:S1172" })
|
|
||||||
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
|
|
||||||
populateTagNameCombo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
|
||||||
// Exception squid:S1172 - event not needed
|
|
||||||
@SuppressWarnings({ "squid:S1172" })
|
|
||||||
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
|
|
||||||
populateTagNameCombo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
|
||||||
// Exception squid:S1172 - event not needed
|
|
||||||
@SuppressWarnings({ "squid:S1172" })
|
|
||||||
void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
|
|
||||||
populateTagNameCombo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate target name combo.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void populateTagNameCombo() {
|
|
||||||
tagNameComboBox.removeAllItems();
|
|
||||||
final List<TargetTag> trgTagNameList = tagManagement.findAllTargetTags();
|
|
||||||
trgTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select tag & set tag name & tag desc values corresponding to selected
|
|
||||||
* tag.
|
|
||||||
*
|
|
||||||
* @param targetTagSelected
|
|
||||||
* as the selected tag from combo
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setTagDetails(final String targetTagSelected) {
|
|
||||||
tagName.setValue(targetTagSelected);
|
|
||||||
final TargetTag selectedTargetTag = tagManagement.findTargetTag(targetTagSelected);
|
|
||||||
if (null != selectedTargetTag) {
|
|
||||||
tagDesc.setValue(selectedTargetTag.getDescription());
|
|
||||||
if (null == selectedTargetTag.getColour()) {
|
|
||||||
selectedColor = new Color(44, 151, 32);
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, DEFAULT_COLOR);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
selectedColor = rgbToColorConverter(selectedTargetTag.getColour());
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
colorSelect.setColor(selectedColor);
|
|
||||||
createDynamicStyleForComponents(tagName, tagDesc, selectedTargetTag.getColour());
|
|
||||||
getPreviewButtonColor(selectedTargetTag.getColour());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(final ClickEvent event) {
|
|
||||||
if (mandatoryValuesPresent()) {
|
|
||||||
final TargetTag existingTag = tagManagement.findTargetTag(tagName.getValue());
|
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
|
||||||
if (!checkIsDuplicate(existingTag)) {
|
|
||||||
createNewTag();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
updateTag(existingTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean checkIsDuplicate(final TargetTag existingTag) {
|
|
||||||
if (existingTag != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean mandatoryValuesPresent() {
|
|
||||||
if (Strings.isNullOrEmpty(tagName.getValue())) {
|
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
|
||||||
}
|
|
||||||
if (optiongroup.getValue().equals(updateTagNw)) {
|
|
||||||
if (null == tagNameComboBox.getValue()) {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.tagname"));
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new tag.
|
|
||||||
*/
|
|
||||||
private void createNewTag() {
|
|
||||||
final String colorPicked = getColorPickedString();
|
|
||||||
final String tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
|
||||||
final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
|
||||||
if (null != tagNameValue) {
|
|
||||||
TargetTag newTargetTag = entityFactory.generateTargetTag(tagNameValue);
|
|
||||||
if (null != tagDescValue) {
|
|
||||||
newTargetTag.setDescription(tagDescValue);
|
|
||||||
}
|
|
||||||
newTargetTag.setColour(new Color(0, 146, 58).getCSS());
|
|
||||||
if (colorPicked != null) {
|
|
||||||
newTargetTag.setColour(colorPicked);
|
|
||||||
}
|
|
||||||
newTargetTag = tagManagement.createTargetTag(newTargetTag);
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTargetTag.getName() }));
|
|
||||||
closeWindow();
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.tagname"));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update tag.
|
|
||||||
*/
|
|
||||||
private void updateTag(final TargetTag targetObj) {
|
|
||||||
final String nameUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
|
||||||
final String descUpdateValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
|
||||||
|
|
||||||
if (null != nameUpdateValue) {
|
|
||||||
targetObj.setName(nameUpdateValue);
|
|
||||||
targetObj.setDescription(null != descUpdateValue ? descUpdateValue : null);
|
|
||||||
targetObj.setColour(getColorPickedString());
|
|
||||||
tagManagement.updateTargetTag(targetObj);
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() }));
|
|
||||||
closeWindow();
|
|
||||||
} else {
|
|
||||||
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeWindow() {
|
|
||||||
targetTagWindow.close();
|
|
||||||
UI.getCurrent().removeWindow(targetTagWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* remove target tab window.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void discard(final ClickEvent event) {
|
|
||||||
UI.getCurrent().removeWindow(targetTagWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get color picked value in string.
|
|
||||||
*
|
|
||||||
* @return String of color picked value.
|
|
||||||
*/
|
|
||||||
private String getColorPickedString() {
|
|
||||||
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
|
|
||||||
+ getSelPreview().getColor().getBlue() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Color view.
|
|
||||||
*
|
|
||||||
* @return ColorPickerPreview as UI
|
|
||||||
*/
|
|
||||||
public SpColorPickerPreview getSelPreview() {
|
|
||||||
return selPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* 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.management.targettag;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
|
||||||
|
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
|
||||||
|
import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.vaadin.spring.events.EventScope;
|
||||||
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Class for Create / Update Tag Layout of target
|
||||||
|
*/
|
||||||
|
@SpringComponent
|
||||||
|
@ViewScope
|
||||||
|
public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLayout {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2446682350481560235L;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private transient EntityFactory entityFactory;
|
||||||
|
|
||||||
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
|
// Exception squid:S1172 - event not needed
|
||||||
|
@SuppressWarnings({ "squid:S1172" })
|
||||||
|
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
|
||||||
|
populateTagNameCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
|
// Exception squid:S1172 - event not needed
|
||||||
|
@SuppressWarnings({ "squid:S1172" })
|
||||||
|
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
|
||||||
|
populateTagNameCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
|
// Exception squid:S1172 - event not needed
|
||||||
|
@SuppressWarnings({ "squid:S1172" })
|
||||||
|
void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
|
||||||
|
populateTagNameCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addListeners() {
|
||||||
|
super.addListeners();
|
||||||
|
optiongroup.addValueChangeListener(this::optionValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate target name combo.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void populateTagNameCombo() {
|
||||||
|
tagNameComboBox.removeAllItems();
|
||||||
|
final List<TargetTag> trgTagNameList = tagManagement.findAllTargetTags();
|
||||||
|
trgTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select tag & set tag name & tag desc values corresponding to selected
|
||||||
|
* tag.
|
||||||
|
*
|
||||||
|
* @param targetTagSelected
|
||||||
|
* as the selected tag from combo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setTagDetails(final String targetTagSelected) {
|
||||||
|
tagName.setValue(targetTagSelected);
|
||||||
|
final TargetTag selectedTargetTag = tagManagement.findTargetTag(targetTagSelected);
|
||||||
|
if (null != selectedTargetTag) {
|
||||||
|
tagDesc.setValue(selectedTargetTag.getDescription());
|
||||||
|
if (null == selectedTargetTag.getColour()) {
|
||||||
|
setTagColor(getColorPickerLayout().getDefaultColor(), ColorPickerConstants.DEFAULT_COLOR);
|
||||||
|
} else {
|
||||||
|
setTagColor(ColorPickerHelper.rgbToColorConverter(selectedTargetTag.getColour()),
|
||||||
|
selectedTargetTag.getColour());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(final ClickEvent event) {
|
||||||
|
if (mandatoryValuesPresent()) {
|
||||||
|
final TargetTag existingTag = tagManagement.findTargetTag(tagName.getValue());
|
||||||
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
|
if (!checkIsDuplicate(existingTag)) {
|
||||||
|
createNewTag();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateExistingTag(existingTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new tag.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void createNewTag() {
|
||||||
|
super.createNewTag();
|
||||||
|
if (isNotEmpty(getTagNameValue())) {
|
||||||
|
TargetTag newTargetTag = entityFactory.generateTargetTag(getTagNameValue());
|
||||||
|
if (isNotEmpty(getTagDescValue())) {
|
||||||
|
newTargetTag.setDescription(getTagDescValue());
|
||||||
|
}
|
||||||
|
newTargetTag.setColour(ColorPickerConstants.START_COLOR.getCSS());
|
||||||
|
if (isNotEmpty(getColorPicked())) {
|
||||||
|
newTargetTag.setColour(getColorPicked());
|
||||||
|
}
|
||||||
|
newTargetTag = tagManagement.createTargetTag(newTargetTag);
|
||||||
|
displaySuccess(newTargetTag.getName());
|
||||||
|
closeWindow();
|
||||||
|
} else {
|
||||||
|
displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createRequiredComponents() {
|
||||||
|
super.createRequiredComponents();
|
||||||
|
createOptionGroup(permChecker.hasCreateTargetPermission(), permChecker.hasUpdateTargetPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void reset() {
|
||||||
|
|
||||||
|
super.reset();
|
||||||
|
setOptionGroupDefaultValue(permChecker.hasCreateTargetPermission(), permChecker.hasUpdateTargetPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -62,7 +62,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange
|
|||||||
private CustomTargetTagFilterButtonClick customTargetTagFilterButtonClick;
|
private CustomTargetTagFilterButtonClick customTargetTagFilterButtonClick;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CreateUpdateTargetTagLayout createUpdateTargetTagLayout;
|
private CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpPermissionChecker permChecker;
|
private SpPermissionChecker permChecker;
|
||||||
@@ -170,4 +170,5 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange
|
|||||||
UI.getCurrent().addWindow(addUpdateWindow);
|
UI.getCurrent().addWindow(addUpdateWindow);
|
||||||
addUpdateWindow.setVisible(true);
|
addUpdateWindow.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader {
|
|||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CreateUpdateTargetTagLayout createUpdateTargetTagLayout;
|
private CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ManagementUIState managementUIState;
|
private ManagementUIState managementUIState;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCond
|
|||||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||||
import org.eclipse.hawkbit.ui.UiProperties;
|
import org.eclipse.hawkbit.ui.UiProperties;
|
||||||
|
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||||
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.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;
|
||||||
@@ -43,6 +43,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
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.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
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;
|
||||||
@@ -56,22 +58,15 @@ import com.vaadin.data.Property.ValueChangeEvent;
|
|||||||
import com.vaadin.data.Validator;
|
import com.vaadin.data.Validator;
|
||||||
import com.vaadin.data.validator.IntegerRangeValidator;
|
import com.vaadin.data.validator.IntegerRangeValidator;
|
||||||
import com.vaadin.data.validator.RegexpValidator;
|
import com.vaadin.data.validator.RegexpValidator;
|
||||||
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.Alignment;
|
|
||||||
import com.vaadin.ui.Button;
|
|
||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
import com.vaadin.ui.CustomComponent;
|
import com.vaadin.ui.GridLayout;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Link;
|
|
||||||
import com.vaadin.ui.OptionGroup;
|
import com.vaadin.ui.OptionGroup;
|
||||||
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.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.Window;
|
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,10 +76,12 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2999293468801479916L;
|
private static final long serialVersionUID = 2999293468801479916L;
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(AddUpdateRolloutWindowLayout.class);
|
||||||
|
|
||||||
private static final String MESSAGE_ROLLOUT_FIELD_VALUE_RANGE = "message.rollout.field.value.range";
|
private static final String MESSAGE_ROLLOUT_FIELD_VALUE_RANGE = "message.rollout.field.value.range";
|
||||||
|
|
||||||
private static final String MESSAGE_ENTER_NUMBER = "message.enter.number";
|
private static final String MESSAGE_ENTER_NUMBER = "message.enter.number";
|
||||||
@@ -118,7 +115,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient EventBus.SessionEventBus eventBus;
|
private transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
private Label madatoryLabel;
|
private Label mandatoryLabel;
|
||||||
|
|
||||||
private TextField rolloutName;
|
private TextField rolloutName;
|
||||||
|
|
||||||
@@ -136,15 +133,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
|
|
||||||
private TextArea description;
|
private TextArea description;
|
||||||
|
|
||||||
private Button saveRolloutBtn;
|
|
||||||
|
|
||||||
private Button discardRollloutBtn;
|
|
||||||
|
|
||||||
private OptionGroup errorThresholdOptionGroup;
|
private OptionGroup errorThresholdOptionGroup;
|
||||||
|
|
||||||
private Link linkToHelp;
|
private CommonDialogWindow addUpdateRolloutWindow;
|
||||||
|
|
||||||
private Window addUpdateRolloutWindow;
|
|
||||||
|
|
||||||
private Boolean editRolloutEnabled;
|
private Boolean editRolloutEnabled;
|
||||||
|
|
||||||
@@ -160,14 +151,17 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
* Create components and layout.
|
* Create components and layout.
|
||||||
*/
|
*/
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
|
setSizeUndefined();
|
||||||
createRequiredComponents();
|
createRequiredComponents();
|
||||||
buildLayout();
|
buildLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window getWindow() {
|
public CommonDialogWindow getWindow() {
|
||||||
|
|
||||||
addUpdateRolloutWindow = SPUIComponentProvider.getWindow(i18n.get("caption.configure.rollout"), null,
|
addUpdateRolloutWindow = SPUIComponentProvider.getWindow(i18n.get("caption.configure.rollout"), null,
|
||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW);
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> onRolloutSave(), event -> onDiscard(),
|
||||||
addUpdateRolloutWindow.setContent(this);
|
uiProperties.getLinks().getDocumentation().getRolloutView());
|
||||||
return addUpdateRolloutWindow;
|
return addUpdateRolloutWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +179,10 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
setDefaultSaveStartGroupOption();
|
setDefaultSaveStartGroupOption();
|
||||||
totalTargetsLabel.setVisible(false);
|
totalTargetsLabel.setVisible(false);
|
||||||
groupSizeLabel.setVisible(false);
|
groupSizeLabel.setVisible(false);
|
||||||
targetFilterQuery.setVisible(false);
|
removeComponent(targetFilterQuery);
|
||||||
targetFilterQueryCombo.setVisible(true);
|
if (getComponent(1, 3) == null) {
|
||||||
|
addComponent(targetFilterQueryCombo, 1, 3);
|
||||||
|
}
|
||||||
actionTypeOptionGroupLayout.selectDefaultOption();
|
actionTypeOptionGroupLayout.selectDefaultOption();
|
||||||
totalTargetsCount = 0L;
|
totalTargetsCount = 0L;
|
||||||
rolloutForEdit = null;
|
rolloutForEdit = null;
|
||||||
@@ -205,52 +201,43 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildLayout() {
|
private void buildLayout() {
|
||||||
final VerticalLayout mainLayout = new VerticalLayout();
|
|
||||||
mainLayout.setSpacing(Boolean.TRUE);
|
|
||||||
mainLayout.setSizeUndefined();
|
|
||||||
|
|
||||||
mainLayout.addComponents(madatoryLabel, rolloutName, distributionSet, getTargetFilterLayout(),
|
setSpacing(Boolean.TRUE);
|
||||||
getGroupDetailsLayout(), getTriggerThresoldLayout(), getErrorThresoldLayout(), description,
|
setSizeUndefined();
|
||||||
actionTypeOptionGroupLayout, linkToHelp, getSaveDiscardButtonLayout());
|
setRows(9);
|
||||||
mainLayout.setComponentAlignment(linkToHelp, Alignment.BOTTOM_RIGHT);
|
setColumns(3);
|
||||||
setCompositionRoot(mainLayout);
|
|
||||||
|
addComponent(mandatoryLabel, 1, 0, 2, 0);
|
||||||
|
addComponent(getLabel("textfield.name"), 0, 1);
|
||||||
|
addComponent(rolloutName, 1, 1);
|
||||||
|
addComponent(getLabel("prompt.distribution.set"), 0, 2);
|
||||||
|
addComponent(distributionSet, 1, 2);
|
||||||
|
addComponent(getLabel("prompt.target.filter"), 0, 3);
|
||||||
|
addComponent(targetFilterQueryCombo, 1, 3);
|
||||||
|
addComponent(totalTargetsLabel, 2, 3);
|
||||||
|
addComponent(getLabel("prompt.number.of.groups"), 0, 4);
|
||||||
|
addComponent(noOfGroups, 1, 4);
|
||||||
|
addComponent(groupSizeLabel, 2, 4);
|
||||||
|
addComponent(getLabel("prompt.tigger.threshold"), 0, 5);
|
||||||
|
addComponent(triggerThreshold, 1, 5);
|
||||||
|
addComponent(getPercentHintLabel(), 2, 5);
|
||||||
|
addComponent(getLabel("prompt.error.threshold"), 0, 6);
|
||||||
|
addComponent(errorThreshold, 1, 6);
|
||||||
|
addComponent(errorThresholdOptionGroup, 2, 6);
|
||||||
|
addComponent(getLabel("textfield.description"), 0, 7);
|
||||||
|
addComponent(description, 1, 7, 2, 7);
|
||||||
|
addComponent(actionTypeOptionGroupLayout, 0, 8, 2, 8);
|
||||||
|
|
||||||
rolloutName.focus();
|
rolloutName.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout getGroupDetailsLayout() {
|
private Label getLabel(final String key) {
|
||||||
final HorizontalLayout groupLayout = new HorizontalLayout();
|
return SPUIComponentProvider.getLabel(i18n.get(key), SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
||||||
groupLayout.setSizeFull();
|
|
||||||
groupLayout.addComponents(noOfGroups, groupSizeLabel);
|
|
||||||
groupLayout.setExpandRatio(noOfGroups, 1.0F);
|
|
||||||
groupLayout.setComponentAlignment(groupSizeLabel, Alignment.MIDDLE_LEFT);
|
|
||||||
return groupLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout getErrorThresoldLayout() {
|
private TextField getTextfield(final String key) {
|
||||||
final HorizontalLayout errorThresoldLayout = new HorizontalLayout();
|
return SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, true, null, i18n.get(key), true,
|
||||||
errorThresoldLayout.setSizeFull();
|
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
errorThresoldLayout.addComponents(errorThreshold, errorThresholdOptionGroup);
|
|
||||||
errorThresoldLayout.setExpandRatio(errorThreshold, 1.0F);
|
|
||||||
return errorThresoldLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HorizontalLayout getTargetFilterLayout() {
|
|
||||||
final HorizontalLayout targetFilterLayout = new HorizontalLayout();
|
|
||||||
targetFilterLayout.setSizeFull();
|
|
||||||
targetFilterLayout.addComponents(targetFilterQueryCombo, targetFilterQuery, totalTargetsLabel);
|
|
||||||
targetFilterLayout.setExpandRatio(targetFilterQueryCombo, 0.71F);
|
|
||||||
targetFilterLayout.setExpandRatio(targetFilterQuery, 0.70F);
|
|
||||||
targetFilterLayout.setExpandRatio(totalTargetsLabel, 0.29F);
|
|
||||||
targetFilterLayout.setComponentAlignment(totalTargetsLabel, Alignment.MIDDLE_LEFT);
|
|
||||||
return targetFilterLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HorizontalLayout getTriggerThresoldLayout() {
|
|
||||||
final HorizontalLayout triggerThresholdLayout = new HorizontalLayout();
|
|
||||||
triggerThresholdLayout.setSizeFull();
|
|
||||||
triggerThresholdLayout.addComponents(triggerThreshold, getPercentHintLabel());
|
|
||||||
triggerThresholdLayout.setExpandRatio(triggerThreshold, 1.0F);
|
|
||||||
return triggerThresholdLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label getPercentHintLabel() {
|
private Label getPercentHintLabel() {
|
||||||
@@ -260,18 +247,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
return percentSymbol;
|
return percentSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout getSaveDiscardButtonLayout() {
|
|
||||||
final HorizontalLayout buttonsLayout = new HorizontalLayout();
|
|
||||||
buttonsLayout.setSizeFull();
|
|
||||||
buttonsLayout.addComponents(saveRolloutBtn, discardRollloutBtn);
|
|
||||||
buttonsLayout.setComponentAlignment(saveRolloutBtn, Alignment.BOTTOM_LEFT);
|
|
||||||
buttonsLayout.setComponentAlignment(discardRollloutBtn, Alignment.BOTTOM_RIGHT);
|
|
||||||
buttonsLayout.addStyleName("window-style");
|
|
||||||
return buttonsLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRequiredComponents() {
|
private void createRequiredComponents() {
|
||||||
madatoryLabel = createMandatoryLabel();
|
mandatoryLabel = createMandatoryLabel();
|
||||||
rolloutName = createRolloutNameField();
|
rolloutName = createRolloutNameField();
|
||||||
distributionSet = createDistributionSetCombo();
|
distributionSet = createDistributionSetCombo();
|
||||||
populateDistributionSet();
|
populateDistributionSet();
|
||||||
@@ -282,20 +259,14 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
noOfGroups = createNoOfGroupsField();
|
noOfGroups = createNoOfGroupsField();
|
||||||
groupSizeLabel = createGroupSizeLabel();
|
groupSizeLabel = createGroupSizeLabel();
|
||||||
triggerThreshold = createTriggerThresold();
|
triggerThreshold = createTriggerThresold();
|
||||||
errorThreshold = createErrorThresold();
|
errorThreshold = createErrorThreshold();
|
||||||
description = createDescription();
|
description = createDescription();
|
||||||
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
|
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
|
||||||
setDefaultSaveStartGroupOption();
|
setDefaultSaveStartGroupOption();
|
||||||
saveRolloutBtn = createSaveButton();
|
|
||||||
discardRollloutBtn = createDiscardButton();
|
|
||||||
actionTypeOptionGroupLayout.selectDefaultOption();
|
actionTypeOptionGroupLayout.selectDefaultOption();
|
||||||
|
|
||||||
totalTargetsLabel = createTotalTargetsLabel();
|
totalTargetsLabel = createTotalTargetsLabel();
|
||||||
targetFilterQuery = createTargetFilterQuery();
|
targetFilterQuery = createTargetFilterQuery();
|
||||||
|
|
||||||
linkToHelp = SPUIComponentProvider.getHelpLink(uiProperties.getLinks().getDocumentation().getRolloutView());
|
|
||||||
actionTypeOptionGroupLayout.addStyleName(SPUIStyleDefinitions.ROLLOUT_ACTION_TYPE_LAYOUT);
|
actionTypeOptionGroupLayout.addStyleName(SPUIStyleDefinitions.ROLLOUT_ACTION_TYPE_LAYOUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Label createGroupSizeLabel() {
|
private Label createGroupSizeLabel() {
|
||||||
@@ -308,13 +279,13 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea createTargetFilterQuery() {
|
private TextArea createTargetFilterQuery() {
|
||||||
final TextArea filterField = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY,
|
final TextArea filterField = SPUIComponentProvider.getTextArea(null, "text-area-style",
|
||||||
false, null, null, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
ValoTheme.TEXTFIELD_TINY, false, null, null,
|
||||||
|
SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
|
||||||
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.setVisible(false);
|
|
||||||
filterField.setEnabled(false);
|
filterField.setEnabled(false);
|
||||||
filterField.setSizeFull();
|
filterField.setSizeUndefined();
|
||||||
return filterField;
|
return filterField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +307,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
errorThresoldOptions.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
|
errorThresoldOptions.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
|
||||||
errorThresoldOptions.addStyleName(SPUIStyleDefinitions.ROLLOUT_OPTION_GROUP);
|
errorThresoldOptions.addStyleName(SPUIStyleDefinitions.ROLLOUT_OPTION_GROUP);
|
||||||
errorThresoldOptions.setSizeUndefined();
|
errorThresoldOptions.setSizeUndefined();
|
||||||
errorThresoldOptions.addValueChangeListener(event -> onErrorThresoldOptionChange(event));
|
errorThresoldOptions.addValueChangeListener(this::onErrorThresoldOptionChange);
|
||||||
return errorThresoldOptions;
|
return errorThresoldOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,19 +317,19 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
if (event.getProperty().getValue().equals(ERRORTHRESOLDOPTIONS.COUNT.getValue())) {
|
if (event.getProperty().getValue().equals(ERRORTHRESOLDOPTIONS.COUNT.getValue())) {
|
||||||
errorThreshold.addValidator(new ErrorThresoldOptionValidator());
|
errorThreshold.addValidator(new ErrorThresoldOptionValidator());
|
||||||
} else {
|
} else {
|
||||||
errorThreshold.addValidator(new ThresoldFieldValidator());
|
errorThreshold.addValidator(new ThresholdFieldValidator());
|
||||||
}
|
}
|
||||||
errorThreshold.getValidators();
|
errorThreshold.getValidators();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox createTargetFilterQueryCombo() {
|
private ComboBox createTargetFilterQueryCombo() {
|
||||||
final ComboBox targetFilter = SPUIComponentProvider.getComboBox("", "", null, null, true, "",
|
final ComboBox targetFilter = SPUIComponentProvider.getComboBox(null, "", "", null, ValoTheme.COMBOBOX_SMALL,
|
||||||
i18n.get("prompt.target.filter"));
|
true, "", i18n.get("prompt.target.filter"));
|
||||||
targetFilter.setImmediate(true);
|
targetFilter.setImmediate(true);
|
||||||
targetFilter.setPageLength(7);
|
targetFilter.setPageLength(7);
|
||||||
targetFilter.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
targetFilter.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||||
targetFilter.setId(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_COMBO_ID);
|
targetFilter.setId(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_COMBO_ID);
|
||||||
targetFilter.setSizeFull();
|
targetFilter.setSizeUndefined();
|
||||||
targetFilter.addValueChangeListener(event -> onTargetFilterChange());
|
targetFilter.addValueChangeListener(event -> onTargetFilterChange());
|
||||||
return targetFilter;
|
return targetFilter;
|
||||||
}
|
}
|
||||||
@@ -395,24 +366,6 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
return new LazyQueryContainer(
|
return new LazyQueryContainer(
|
||||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME),
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME),
|
||||||
targetFilterQF);
|
targetFilterQF);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button createDiscardButton() {
|
|
||||||
final Button discardRollloutBtn = SPUIComponentProvider.getButton(
|
|
||||||
SPUIComponentIdProvider.ROLLOUT_CREATE_UPDATE_DISCARD_ID, "", "", "", true, FontAwesome.TIMES,
|
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
discardRollloutBtn.addClickListener(event -> onDiscard());
|
|
||||||
return discardRollloutBtn;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button createSaveButton() {
|
|
||||||
final Button saveRolloutBtn = SPUIComponentProvider.getButton(
|
|
||||||
SPUIComponentIdProvider.ROLLOUT_CREATE_UPDATE_SAVE_ID, "", "", "", true, FontAwesome.SAVE,
|
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
|
||||||
saveRolloutBtn.addClickListener(event -> onRolloutSave());
|
|
||||||
saveRolloutBtn.setImmediate(true);
|
|
||||||
return saveRolloutBtn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDiscard() {
|
private void onDiscard() {
|
||||||
@@ -591,40 +544,38 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextArea createDescription() {
|
private TextArea createDescription() {
|
||||||
final TextArea descriptionField = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY,
|
final TextArea descriptionField = SPUIComponentProvider.getTextArea(null, "text-area-style",
|
||||||
false, null, i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
|
||||||
|
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
descriptionField.setId(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID);
|
descriptionField.setId(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID);
|
||||||
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
|
||||||
descriptionField.setSizeFull();
|
descriptionField.setSizeUndefined();
|
||||||
return descriptionField;
|
return descriptionField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createErrorThresold() {
|
private TextField createErrorThreshold() {
|
||||||
final TextField errorField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
final TextField errorField = getTextfield("prompt.error.threshold");
|
||||||
i18n.get("prompt.error.threshold"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
errorField.addValidator(new ThresholdFieldValidator());
|
||||||
errorField.addValidator(new ThresoldFieldValidator());
|
|
||||||
errorField.setId(SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
|
errorField.setId(SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
|
||||||
errorField.setMaxLength(7);
|
errorField.setMaxLength(7);
|
||||||
errorField.setSizeFull();
|
errorField.setSizeUndefined();
|
||||||
return errorField;
|
return errorField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createTriggerThresold() {
|
private TextField createTriggerThresold() {
|
||||||
final TextField thresholdField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
final TextField thresholdField = getTextfield("prompt.tigger.threshold");
|
||||||
i18n.get("prompt.tigger.thresold"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
thresholdField.setId(SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
|
thresholdField.setId(SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
|
||||||
thresholdField.addValidator(new ThresoldFieldValidator());
|
thresholdField.addValidator(new ThresholdFieldValidator());
|
||||||
thresholdField.setSizeFull();
|
thresholdField.setSizeUndefined();
|
||||||
thresholdField.setMaxLength(3);
|
thresholdField.setMaxLength(3);
|
||||||
return thresholdField;
|
return thresholdField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextField createNoOfGroupsField() {
|
private TextField createNoOfGroupsField() {
|
||||||
final TextField noOfGroupsField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
final TextField noOfGroupsField = getTextfield("prompt.number.of.groups");
|
||||||
i18n.get("prompt.number.of.groups"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
noOfGroupsField.setId(SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
|
noOfGroupsField.setId(SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
|
||||||
noOfGroupsField.addValidator(new GroupNumberValidator());
|
noOfGroupsField.addValidator(new GroupNumberValidator());
|
||||||
noOfGroupsField.setSizeFull();
|
noOfGroupsField.setSizeUndefined();
|
||||||
noOfGroupsField.setMaxLength(3);
|
noOfGroupsField.setMaxLength(3);
|
||||||
noOfGroupsField.addValueChangeListener(evevt -> onGroupNumberChange());
|
noOfGroupsField.addValueChangeListener(evevt -> onGroupNumberChange());
|
||||||
return noOfGroupsField;
|
return noOfGroupsField;
|
||||||
@@ -640,13 +591,13 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox createDistributionSetCombo() {
|
private ComboBox createDistributionSetCombo() {
|
||||||
final ComboBox dsSet = SPUIComponentProvider.getComboBox("", "", null, null, true, "",
|
final ComboBox dsSet = SPUIComponentProvider.getComboBox(null, "", "", null, ValoTheme.COMBOBOX_SMALL, true, "",
|
||||||
i18n.get("prompt.distribution.set"));
|
i18n.get("prompt.distribution.set"));
|
||||||
dsSet.setImmediate(true);
|
dsSet.setImmediate(true);
|
||||||
dsSet.setPageLength(7);
|
dsSet.setPageLength(7);
|
||||||
dsSet.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
dsSet.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||||
dsSet.setId(SPUIComponentIdProvider.ROLLOUT_DS_ID);
|
dsSet.setId(SPUIComponentIdProvider.ROLLOUT_DS_ID);
|
||||||
dsSet.setSizeFull();
|
dsSet.setSizeUndefined();
|
||||||
return dsSet;
|
return dsSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,10 +616,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextField createRolloutNameField() {
|
private TextField createRolloutNameField() {
|
||||||
final TextField rolloutNameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, true, null,
|
final TextField rolloutNameField = getTextfield("textfield.name");
|
||||||
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
|
||||||
rolloutNameField.setId(SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
|
rolloutNameField.setId(SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
|
||||||
rolloutNameField.setSizeFull();
|
rolloutNameField.setSizeUndefined();
|
||||||
return rolloutNameField;
|
return rolloutNameField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,18 +652,21 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, groupSize)
|
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, groupSize)
|
||||||
.validate(Integer.valueOf(value.toString()));
|
.validate(Integer.valueOf(value.toString()));
|
||||||
}
|
}
|
||||||
} catch (final InvalidValueException ex) {
|
}
|
||||||
throw ex;
|
// suppress the need of preserve original exception, will blow
|
||||||
|
// up the
|
||||||
|
// log and not necessary here
|
||||||
|
catch (@SuppressWarnings("squid:S1166") final InvalidValueException ex) {
|
||||||
|
LOG.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getGroupSize() {
|
private int getGroupSize() {
|
||||||
return (int) Math.ceil((double) totalTargetsCount / Double.parseDouble(noOfGroups.getValue()));
|
return (int) Math.ceil((double) totalTargetsCount / Double.parseDouble(noOfGroups.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThresoldFieldValidator implements Validator {
|
class ThresholdFieldValidator implements Validator {
|
||||||
private static final long serialVersionUID = 9049939751976326550L;
|
private static final long serialVersionUID = 9049939751976326550L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -722,8 +675,12 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
|
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
|
||||||
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100)
|
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100)
|
||||||
.validate(Integer.valueOf(value.toString()));
|
.validate(Integer.valueOf(value.toString()));
|
||||||
} catch (final InvalidValueException ex) {
|
}
|
||||||
throw ex;
|
// suppress the need of preserve original exception, will blow
|
||||||
|
// up the
|
||||||
|
// log and not necessary here
|
||||||
|
catch (@SuppressWarnings("squid:S1166") final InvalidValueException ex) {
|
||||||
|
LOG.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -737,8 +694,12 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
|
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
|
||||||
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500)
|
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500)
|
||||||
.validate(Integer.valueOf(value.toString()));
|
.validate(Integer.valueOf(value.toString()));
|
||||||
} catch (final InvalidValueException ex) {
|
}
|
||||||
throw ex;
|
// suppress the need of preserve original exception, will blow
|
||||||
|
// up the
|
||||||
|
// log and not necessary here
|
||||||
|
catch (@SuppressWarnings("squid:S1166") final InvalidValueException ex) {
|
||||||
|
LOG.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,8 +727,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
|
|||||||
|
|
||||||
noOfGroups.setEnabled(false);
|
noOfGroups.setEnabled(false);
|
||||||
targetFilterQuery.setValue(rolloutForEdit.getTargetFilterQuery());
|
targetFilterQuery.setValue(rolloutForEdit.getTargetFilterQuery());
|
||||||
targetFilterQuery.setVisible(true);
|
removeComponent(targetFilterQueryCombo);
|
||||||
targetFilterQueryCombo.setVisible(false);
|
addComponent(targetFilterQuery, 1, 3);
|
||||||
|
|
||||||
totalTargetsCount = targetManagement.countTargetByTargetFilterQuery(rolloutForEdit.getTargetFilterQuery());
|
totalTargetsCount = targetManagement.countTargetByTargetFilterQuery(rolloutForEdit.getTargetFilterQuery());
|
||||||
totalTargetsLabel.setValue(getTotalTargetMessage());
|
totalTargetsLabel.setValue(getTotalTargetMessage());
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CellDescriptionGenerator getDescriptionGenerator() {
|
protected CellDescriptionGenerator getDescriptionGenerator() {
|
||||||
return cell -> getDescription(cell);
|
return this::getDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -310,10 +310,10 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
createRolloutStatusToFontMap();
|
createRolloutStatusToFontMap();
|
||||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
|
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
|
||||||
|
|
||||||
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event)));
|
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(this::onClickOfActionBtn));
|
||||||
|
|
||||||
final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
|
final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
|
||||||
customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event));
|
customObjectRenderer.addClickListener(this::onClickOfRolloutName);
|
||||||
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer);
|
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
private ContextMenu createContextMenu(final Long rolloutId) {
|
private ContextMenu createContextMenu(final Long rolloutId) {
|
||||||
final ContextMenu context = new ContextMenu();
|
final ContextMenu context = new ContextMenu();
|
||||||
context.addItemClickListener(event -> menuItemClicked(event));
|
context.addItemClickListener(this::menuItemClicked);
|
||||||
final Item row = getContainerDataSource().getItem(rolloutId);
|
final Item row = getContainerDataSource().getItem(rolloutId);
|
||||||
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
||||||
.getValue();
|
.getValue();
|
||||||
@@ -632,15 +632,13 @@ public class RolloutListGrid 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,14 +662,13 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
private static final long serialVersionUID = 6589305227035220369L;
|
private static final long serialVersionUID = 6589305227035220369L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long convertToModel(final String value, final Class<? extends Long> targetType, final Locale locale)
|
public Long convertToModel(final String value, final Class<? extends Long> targetType, final Locale locale) {
|
||||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertToPresentation(final Long value, final Class<? extends String> targetType,
|
public String convertToPresentation(final Long value, final Class<? extends String> targetType,
|
||||||
final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
final Locale locale) {
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,8 +238,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)
|
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(this::onClickOfRolloutGroupName));
|
||||||
.setRenderer(new RolloutRenderer(event -> onClickOfRolloutGroupName(event)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +258,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CellDescriptionGenerator getDescriptionGenerator() {
|
protected CellDescriptionGenerator getDescriptionGenerator() {
|
||||||
return cell -> getDescription(cell);
|
return this::getDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
||||||
@@ -324,14 +323,14 @@ 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 {
|
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 {
|
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
private transient Map<Status, StatusFontIcon> statusIconMap = new EnumMap<>(Status.class);
|
private transient Map<Status, StatusFontIcon> statusIconMap = new EnumMap<>(Status.class);
|
||||||
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final RolloutEvent event) {
|
void onEvent(final RolloutEvent event) {
|
||||||
if (RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS != event) {
|
if (RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS != event) {
|
||||||
@@ -161,7 +160,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CellDescriptionGenerator getDescriptionGenerator() {
|
protected CellDescriptionGenerator getDescriptionGenerator() {
|
||||||
return cell -> getDescription(cell);
|
return this::getDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alignColumns() {
|
private void alignColumns() {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
final Iterable<DistributionSetType> distributionSetTypeCollection = distributionSetManagement
|
final Iterable<DistributionSetType> distributionSetTypeCollection = distributionSetManagement
|
||||||
.findDistributionSetTypesAll(pageReq);
|
.findDistributionSetTypesAll(pageReq);
|
||||||
|
|
||||||
combobox = SPUIComponentProvider.getComboBox("", "330", null, null, false, "", "label.combobox.tag");
|
combobox = SPUIComponentProvider.getComboBox(null, "", "330", null, null, false, "", "label.combobox.tag");
|
||||||
combobox.setId(SPUIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX);
|
combobox.setId(SPUIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX);
|
||||||
combobox.setNullSelectionAllowed(false);
|
combobox.setNullSelectionAllowed(false);
|
||||||
for (final DistributionSetType distributionSetType : distributionSetTypeCollection) {
|
for (final DistributionSetType distributionSetType : distributionSetTypeCollection) {
|
||||||
@@ -154,4 +154,5 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
changeIcon.setVisible(false);
|
changeIcon.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
|
|||||||
|
|
||||||
final HorizontalLayout hlayout = new HorizontalLayout();
|
final HorizontalLayout hlayout = new HorizontalLayout();
|
||||||
hlayout.setSpacing(true);
|
hlayout.setSpacing(true);
|
||||||
saveConfigurationBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SYSTEM_CONFIGURATION_SAVE, "", "",
|
saveConfigurationBtn = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SYSTEM_CONFIGURATION_SAVE, "",
|
||||||
"", true, FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
"", "", true, FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
|
||||||
saveConfigurationBtn.setEnabled(false);
|
saveConfigurationBtn.setEnabled(false);
|
||||||
saveConfigurationBtn.setDescription(i18n.get("configuration.savebutton.tooltip"));
|
saveConfigurationBtn.setDescription(i18n.get("configuration.savebutton.tooltip"));
|
||||||
saveConfigurationBtn.addClickListener(event -> saveConfiguration());
|
saveConfigurationBtn.addClickListener(event -> saveConfiguration());
|
||||||
@@ -143,9 +143,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void undoConfiguration() {
|
private void undoConfiguration() {
|
||||||
configurationViews.forEach(confView -> {
|
configurationViews.forEach(confView -> confView.undo());
|
||||||
confView.undo();
|
|
||||||
});
|
|
||||||
// More methods
|
// More methods
|
||||||
saveConfigurationBtn.setEnabled(false);
|
saveConfigurationBtn.setEnabled(false);
|
||||||
undoConfigurationBtn.setEnabled(false);
|
undoConfigurationBtn.setEnabled(false);
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
|
|||||||
private VerticalLayout detailLayout;
|
private VerticalLayout detailLayout;
|
||||||
private TextField caRootAuthorityTextField;
|
private TextField caRootAuthorityTextField;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param systemManagement
|
|
||||||
* the system management to retrie the configuration
|
|
||||||
*/
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CertificateAuthenticationConfigurationItem(
|
public CertificateAuthenticationConfigurationItem(
|
||||||
final TenantConfigurationManagement tenantConfigurationManagement) {
|
final TenantConfigurationManagement tenantConfigurationManagement) {
|
||||||
@@ -70,8 +66,8 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
|
|||||||
caRootAuthorityLabel.setDescription(
|
caRootAuthorityLabel.setDescription(
|
||||||
"The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
|
"The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
|
||||||
|
|
||||||
caRootAuthorityTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, "",
|
caRootAuthorityTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
true, 128);
|
"", true, 128);
|
||||||
caRootAuthorityTextField.setWidth("500px");
|
caRootAuthorityTextField.setWidth("500px");
|
||||||
caRootAuthorityTextField.setImmediate(true);
|
caRootAuthorityTextField.setImmediate(true);
|
||||||
caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());
|
caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());
|
||||||
@@ -147,4 +143,5 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
|
|||||||
configurationCaRootAuthorityChanged = true;
|
configurationCaRootAuthorityChanged = true;
|
||||||
notifyConfigurationChanged();
|
notifyConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
|
|||||||
|
|
||||||
detailLayout = new VerticalLayout();
|
detailLayout = new VerticalLayout();
|
||||||
detailLayout.setImmediate(true);
|
detailLayout.setImmediate(true);
|
||||||
gatewayTokenNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, "",
|
gatewayTokenNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||||
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
"", true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
gatewayTokenNameTextField.setImmediate(true);
|
gatewayTokenNameTextField.setImmediate(true);
|
||||||
// hide text field until we support multiple gateway tokens for a tenan
|
// hide text field until we support multiple gateway tokens for a tenan
|
||||||
gatewayTokenNameTextField.setVisible(false);
|
gatewayTokenNameTextField.setVisible(false);
|
||||||
@@ -195,4 +195,5 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
|
|||||||
gatewayTokenNameTextField.setValue(getSecurityTokenName());
|
gatewayTokenNameTextField.setValue(getSecurityTokenName());
|
||||||
gatewayTokenkeyLabel.setValue(getSecurityTokenKey());
|
gatewayTokenkeyLabel.setValue(getSecurityTokenKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,14 +112,6 @@ public final class SPUIComponentIdProvider {
|
|||||||
* ID-Dist.JVM delete icon.
|
* ID-Dist.JVM delete icon.
|
||||||
*/
|
*/
|
||||||
public static final String DIST_DELETE_MODULE = "dist.delete.module.";
|
public static final String DIST_DELETE_MODULE = "dist.delete.module.";
|
||||||
/**
|
|
||||||
* ID-Dist.Add.save.
|
|
||||||
*/
|
|
||||||
public static final String DIST_ADD_SAVE = "dist.add.save";
|
|
||||||
/**
|
|
||||||
* ID-Dist.Add.discard.
|
|
||||||
*/
|
|
||||||
public static final String DIST_ADD_DISCARD = "dist.add.discard";
|
|
||||||
/**
|
/**
|
||||||
* /** ID-Dist.DELETE.
|
* /** ID-Dist.DELETE.
|
||||||
*/
|
*/
|
||||||
@@ -501,6 +493,16 @@ public final class SPUIComponentIdProvider {
|
|||||||
*/
|
*/
|
||||||
public static final String SYSTEM_CONFIGURATION_SAVE = "system.configuration.save";
|
public static final String SYSTEM_CONFIGURATION_SAVE = "system.configuration.save";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID for save button in pop-up-windows instance of commonDialogWindow
|
||||||
|
*/
|
||||||
|
public static final String SAVE_BUTTON = "common.dialog.window.save";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID for cancel button in pop-up-windows instance of commonDialogWindow
|
||||||
|
*/
|
||||||
|
public static final String CANCEL_BUTTON = "common.dialog.window.cancel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel button is.
|
* Cancel button is.
|
||||||
*/
|
*/
|
||||||
@@ -912,6 +914,7 @@ public final class SPUIComponentIdProvider {
|
|||||||
* Artifact uplaod view - uplod status popup id.
|
* Artifact uplaod view - uplod status popup id.
|
||||||
*/
|
*/
|
||||||
public static final String UPLOAD_STATUS_POPUP_ID = "artifact.upload.status.popup.id";
|
public static final String UPLOAD_STATUS_POPUP_ID = "artifact.upload.status.popup.id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* /* Private Constructor.
|
* /* Private Constructor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ public final class SPUIDefinitions {
|
|||||||
/**
|
/**
|
||||||
* New Target discard icon id.
|
* New Target discard icon id.
|
||||||
*/
|
*/
|
||||||
public static final String NEW_TARGET_DISCARD = "target.add.discard";
|
// public static final String NEW_TARGET_DISCARD = "target.add.discard";
|
||||||
/**
|
/**
|
||||||
* New Target add icon id.
|
* New Target add icon id.
|
||||||
*/
|
*/
|
||||||
@@ -347,11 +347,12 @@ public final class SPUIDefinitions {
|
|||||||
/**
|
/**
|
||||||
* New Target tag save icon id.
|
* New Target tag save icon id.
|
||||||
*/
|
*/
|
||||||
public static final String NEW_TARGET_TAG_SAVE = "target.tag.add.save";
|
// public static final String NEW_TARGET_TAG_SAVE = "target.tag.add.save";
|
||||||
/**
|
/**
|
||||||
* New Target tag discard icon id.
|
* New Target tag discard icon id.
|
||||||
*/
|
*/
|
||||||
public static final String NEW_TARGET_TAG_DISRACD = "target.tag.add.discard";
|
// public static final String NEW_TARGET_TAG_DISRACD =
|
||||||
|
// "target.tag.add.discard";
|
||||||
/**
|
/**
|
||||||
* New Target tag add icon id.
|
* New Target tag add icon id.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -288,4 +288,13 @@
|
|||||||
font-style:normal;
|
font-style:normal;
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-lastrow {
|
||||||
|
padding-bottom: 12px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-button-default-color {
|
||||||
|
color: #551f62;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
//Color picker layout position adjustment
|
//Color picker layout position adjustment
|
||||||
.rgb-vertical-layout {
|
.rgb-vertical-layout {
|
||||||
margin-top: 100px !important;
|
padding-bottom: 12px;
|
||||||
padding-bottom: 50px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Discard icon in create/update popup
|
//Discard icon in create/update popup
|
||||||
@@ -47,4 +46,11 @@
|
|||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
height: 75px !important;
|
height: 75px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.v-window-fontsize .v-window-closebox,
|
||||||
|
.v-window-fontsize .v-window-maximizebox,
|
||||||
|
.v-window-fontsize .v-window-restorebox {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,4 +161,8 @@
|
|||||||
.v-slot-bulk-upload-label{
|
.v-slot-bulk-upload-label{
|
||||||
line-height:0;
|
line-height:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actionButtonsMargin {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,7 @@
|
|||||||
//Create/update popup footer button layout style
|
//Create/update popup footer button layout style
|
||||||
.window-style {
|
.window-style {
|
||||||
margin-bottom: 4px !important;
|
margin-bottom: 4px !important;
|
||||||
|
margin-top: 4px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Table details style
|
//Table details style
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ rollout.group.label.target.truncated = {0} targets has been truncated in the lis
|
|||||||
|
|
||||||
|
|
||||||
prompt.number.of.groups = Number of groups
|
prompt.number.of.groups = Number of groups
|
||||||
prompt.tigger.thresold = Trigger threshold
|
prompt.tigger.threshold = Trigger threshold
|
||||||
prompt.error.threshold = Error threshold
|
prompt.error.threshold = Error threshold
|
||||||
prompt.distribution.set = Distribution set
|
prompt.distribution.set = Distribution set
|
||||||
caption.configure.rollout = Configure rollout
|
caption.configure.rollout = Configure rollout
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ menu.title = Software Provisioning
|
|||||||
|
|
||||||
#Rollout management
|
#Rollout management
|
||||||
prompt.number.of.groups = Number of groups
|
prompt.number.of.groups = Number of groups
|
||||||
prompt.tigger.thresold = Trigger threshold
|
prompt.tigger.threshold = Trigger threshold
|
||||||
prompt.error.threshold = Error threshold
|
prompt.error.threshold = Error threshold
|
||||||
prompt.distribution.set = Distribution set
|
prompt.distribution.set = Distribution set
|
||||||
caption.configure.rollout = Configure rollout
|
caption.configure.rollout = Configure rollout
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ menu.title = Software Provisioning
|
|||||||
|
|
||||||
#Rollout management
|
#Rollout management
|
||||||
prompt.number.of.groups = Number of groups
|
prompt.number.of.groups = Number of groups
|
||||||
prompt.tigger.thresold = Trigger threshold
|
prompt.tigger.threshold = Trigger threshold
|
||||||
prompt.error.threshold = Error threshold
|
prompt.error.threshold = Error threshold
|
||||||
prompt.distribution.set = Distribution set
|
prompt.distribution.set = Distribution set
|
||||||
caption.configure.rollout = Configure rollout
|
caption.configure.rollout = Configure rollout
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -69,6 +69,8 @@
|
|||||||
<jackson.version>2.5.5</jackson.version>
|
<jackson.version>2.5.5</jackson.version>
|
||||||
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
|
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
|
||||||
<spring-cloud-connectors.version>1.2.0.RELEASE</spring-cloud-connectors.version>
|
<spring-cloud-connectors.version>1.2.0.RELEASE</spring-cloud-connectors.version>
|
||||||
|
<spring-amqp.version>1.6.0.RELEASE</spring-amqp.version>
|
||||||
|
<spring-hateoas.version>0.18.0.RELEASE</spring-hateoas.version>
|
||||||
<!-- Support for MongoDB 3 -->
|
<!-- Support for MongoDB 3 -->
|
||||||
<spring-data-releasetrain.version>Fowler-SR1</spring-data-releasetrain.version>
|
<spring-data-releasetrain.version>Fowler-SR1</spring-data-releasetrain.version>
|
||||||
<mongodb.version>3.2.2</mongodb.version>
|
<mongodb.version>3.2.2</mongodb.version>
|
||||||
|
|||||||
Reference in New Issue
Block a user