/*
 * 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 em7.optifl.lookupdisplayer;

import java.util.Collection;
import org.openide.awt.StatusDisplayer;
import org.openide.modules.ModuleInstall;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.Utilities;

public class Installer extends ModuleInstall implements LookupListener {
    private Lookup.Result<Node> result;

    @Override
    public void restored() {
        result = Utilities.actionsGlobalContext().lookupResult(Node.class);
        result.addLookupListener(this);
    }

    @Override
    public void uninstalled() {
        result.removeLookupListener(this);
    }
    
    

    @Override
    public void resultChanged(LookupEvent ev) {
        Collection<? extends Node> allInstances = result.allInstances();
        StringBuilder sb = new StringBuilder();
        allInstances.stream().forEach((node) -> {
            sb.append("[").append(node.toString()).append("]  ");
        });
        
        StatusDisplayer.getDefault().setStatusText(sb.toString());
    }

}
