/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.saabre.setup.ui.view.module;

import com.alee.extended.progress.WebStepProgress;
import com.alee.laf.label.WebLabel;
import com.saabre.setup.helper.NameHelper;
import com.saabre.setup.system.base.Profile;
import com.saabre.setup.system.module.script.ScriptModule;
import com.saabre.setup.system.module.script.ScriptOperation;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.border.Border;

/**
 *
 * @author Lifaen
 */
public class ScriptResultPanel extends ModuleResultPanel implements ScriptModule.Listener{
    
    // -- Attributes --
   
    private ScriptModule module;
    
    private List<WebLabel> labelList;
    private int currentProfileIndex;
    
    private static Color RED = new Color(172, 0, 0);
    private static Color GREEN = new Color(0, 122, 23);
    
    // -- Constructors --
    
    public ScriptResultPanel(ScriptModule module) 
    {
        // Initialisation --
        this.module = module;
        module.setListener(this);
        
        // Progress --
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
        this.labelList = new ArrayList<>();
        this.currentProfileIndex = 0;
        
        for(Profile profile : module.getProfileList())
        {
            WebLabel label = new WebLabel(NameHelper.upper(profile.getName())); 
            Border paddingBorder = BorderFactory.createEmptyBorder(2,0,2,0);
            
            label.setBorder(paddingBorder);
            label.setForeground(RED);
            
            labelList.add(label);
            add(label);
        }
    }
    
    // -- Events --
    
    @Override
    public void onProfileStart(Profile profile) {
        
    }

    @Override
    public void onProfileEnd() 
    {
        labelList.get(currentProfileIndex).setForeground(GREEN);
        currentProfileIndex++;
    }

    @Override
    public void onOperationStart(ScriptOperation operation) {
        
    }

    @Override
    public void onOperationEnd() {
        
    }
    
}

@@ -307,16 +307,52 @@
 bLabel;%0A
+import com.alee.laf.panel.WebPanel;%0A
 import c
@@ -937,23 +937,29 @@
 ist%3C
-WebLabel%3E label
+ProfilePanel%3E profile
 List
@@ -1465,21 +1465,23 @@
    this.
-label
+profile
 List = n
@@ -1626,112 +1626,937 @@
     
-WebLabel label = new WebLabel(NameHelper.upper(profile.getName())); %0A            Border paddingBorder = 
+ProfilePanel panel = new ProfilePanel(profile);%0A            profileList.add(panel);%0A            add(panel);%0A        %7D%0A    %7D%0A    %0A    // -- Profile Panel --%0A    %0A    private class ProfilePanel extends WebPanel%0A    %7B%0A        private Profile profile;%0A        private WebLabel label;%0A        private List%3CWebLabel%3E operationList = new ArrayList%3C%3E();%0A        private int currentOperationIndex = 0;%0A        %0A        public ProfilePanel(Profile profile)%0A        %7B%0A            this.profile = profile;%0A            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));%0A            %0A            // Label --%0A            label = new WebLabel(NameHelper.upper(profile.getName()));%0A            add(label);%0A            %0A            // Operations --%0A            for(ScriptOperation operation : profile.getScriptOperationList())%0A            %7B%0A                WebLabel label = new WebLabel(%22 %3E %22 + operation.getType());%0A                label.setBorder(
 Bord
@@ -2589,14 +2589,17 @@
 r(2,
+1
 0,2,
+1
 0)
+)
 ;%0A  
@@ -2612,52 +2612,136 @@
     
-%0A            label.setBorder(paddingBorder);
+    operationList.add(label);%0A                add(label);%0A            %7D%0A        %7D%0A        %0A        public void onEnd()%0A        %7B
 %0A   
@@ -2769,19 +2769,21 @@
 eground(
+G
 RE
-D
+EN
 );%0A     
@@ -2785,33 +2785,35 @@
         
+%7D%0A
     
-%0A
     
+%0A
         
 labelLis
@@ -2808,52 +2808,157 @@
     
-labelList.add(label);%0A            add(label)
+public void onOperationEnd()%0A        %7B%0A            operationList.get(currentOperationIndex).setForeground(GREEN);%0A            currentOperationIndex++
 ;%0A  
@@ -3141,21 +3141,23 @@
         
-label
+profile
 List.get
@@ -3178,35 +3178,22 @@
 eIndex).
-setForeground(GREEN
+onEnd(
 );%0A     
@@ -3297,33 +3297,24 @@
 peration) %7B%0A
-        %0A
     %7D%0A%0A    @
@@ -3361,24 +3361,78 @@
 ) %7B%0A        
+profileList.get(currentProfileIndex).onOperationEnd();
 %0A    %7D%0A    %0A

Add operations in script results