package org.safehaus.kiskis.mgmt.ui.lxcmanager;

import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Runo;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.safehaus.kiskis.mgmt.ui.lxcmanager.clone.Cloner;
import org.safehaus.kiskis.mgmt.ui.lxcmanager.manage.Manager;
import org.safehaus.kiskis.mgmt.server.ui.services.Module;
import org.safehaus.kiskis.mgmt.api.agentmanager.AgentManager;
import org.safehaus.kiskis.mgmt.api.lxcmanager.LxcManager;

public class LxcUI implements Module {

    public static final String MODULE_NAME = "LXC";
    private AgentManager agentManager;
    private LxcManager lxcManager;
    private static ExecutorService executor;

    public void setAgentManager(AgentManager agentManager) {
        this.agentManager = agentManager;
    }

    public void setLxcManager(LxcManager lxcManager) {
        this.lxcManager = lxcManager;
    }

    public void init() {
        executor = Executors.newCachedThreadPool();
    }

    public void destroy() {
        executor.shutdown();
    }

    public static ExecutorService getExecutor() {
        return executor;
    }

    public static class ModuleComponent extends CustomComponent {

        public ModuleComponent(AgentManager agentManager, LxcManager lxcManager) {

            VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setSpacing(true);
            verticalLayout.setSizeFull();

            TabSheet commandsSheet = new TabSheet();
            commandsSheet.setStyleName(Runo.TABSHEET_SMALL);
            commandsSheet.setSizeFull();

            commandsSheet.addTab(new Cloner(lxcManager), "Clone");
            commandsSheet.addTab(new Manager(agentManager, lxcManager), "Manage");

            verticalLayout.addComponent(commandsSheet);

            setCompositionRoot(verticalLayout);

        }

    }

    @Override
    public String getName() {
        return MODULE_NAME;
    }

    @Override
    public Component createComponent() {
        return new ModuleComponent(agentManager, lxcManager);
    }

}

@@ -812,16 +812,78 @@
 xecutor;
+%0A    private final static String managerTabCaption = %22Manage%22;
 %0A%0A    pu
@@ -1768,32 +1768,106 @@
 .setSizeFull();%0A
+            final Manager manager = new Manager(agentManager, lxcManager);
 %0A            com
@@ -1955,55 +1955,533 @@
 Tab(
-new Manager(agentManager, lxcManager), %22Manage%22
+manager, managerTabCaption);%0A%0A            commandsSheet.addListener(new TabSheet.SelectedTabChangeListener() %7B%0A%0A                public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) %7B%0A                    TabSheet tabsheet = event.getTabSheet();%0A                    String caption = tabsheet.getTab(event.getTabSheet().getSelectedTab()).getCaption();%0A                    if (caption.equals(managerTabCaption)) %7B%0A                        manager.getLxcInfo();%0A                    %7D%0A                %7D%0A            %7D
 );%0A%0A

prepare mongo for demo