/**
 * Copyright (C) 2006-2018 Talend Inc. - www.talend.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.talend.sdk.component.studio.model.parameter;

import java.util.LinkedList;
import java.util.List;

import org.eclipse.swt.graphics.RGB;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElement;

/**
 * Synthetic Element Parameter which shows validation message
 */
public class ValidationLabel extends TaCoKitElementParameter {

    private static final String DELIMITER = "; ";

    private static final RGB RED = new RGB(255, 0, 0);

    private final List<String> validationMessages = new LinkedList<>();

    public ValidationLabel(final IElement element) {
        super(element);
        setColor(RED);
        setDisplayName("Validation Label");
        setFieldType(EParameterFieldType.LABEL);
        setShow(false);
        setValue("");
    }

    public void show(final String message) {
        if (!validationMessages.contains(message)) {
            validationMessages.add(message);
        }
        setValue(buildValue());
        setShow(true);
    }

    public void hide(final String message) {
        validationMessages.remove(message);
        setValue(buildValue());
        setShow(!validationMessages.isEmpty());
    }

    private String buildValue() {
        return String.join(DELIMITER, validationMessages);
    }

}

@@ -686,25 +686,22 @@
 va.util.
-LinkedLis
+HashSe
 t;%0Aimpor
@@ -712,19 +712,18 @@
 va.util.
-Lis
+Se
 t;%0A%0Aimpo
@@ -1120,19 +1120,18 @@
 e final 
-Lis
+Se
 t%3CString
@@ -1161,17 +1161,14 @@
 new 
-LinkedLis
+HashSe
 t%3C%3E(
@@ -1466,65 +1466,8 @@
 ) %7B%0A
-        if (!validationMessages.contains(message)) %7B%0A    
     
@@ -1507,18 +1507,8 @@
 e);%0A
-        %7D%0A
     

change List to Set for storing validation messages