class StatisticsControllerUIImpl implements StatisticsControllerUI {

    //    private final DynamicModelListener dynamicModelListener;
    private StatisticsModelUIImpl model;

    public StatisticsControllerUIImpl() {
//        dynamicModelListener = new DynamicModelListener() {
//
//            public void dynamicModelChanged(DynamicModelEvent event) {
//                if (event.getEventType().equals(DynamicModelEvent.EventType.IS_DYNAMIC_GRAPH)) {
//                    boolean isDynamic = (Boolean) event.getData();
//                    for (StatisticsUI ui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
//                        if (ui.getCategory().equals(StatisticsUI.CATEGORY_DYNAMIC)) {
//                            setStatisticsUIVisible(ui, isDynamic);
//                        }
//                    }
//                }
//            }
//        };
    }

    public void setup(StatisticsModelUIImpl model) {
        if (this.model == model) {
            return;
        }
        this.model = model;
        unsetup();

        if (model != null) {
//            DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
//            boolean isDynamic = dynamicController.getModel(model.getWorkspace()).isDynamicGraph();
//            if (!isDynamic) {
//                for (StatisticsUI ui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
//                    if (ui.getCategory().equals(StatisticsUI.CATEGORY_DYNAMIC)) {
//                        setStatisticsUIVisible(ui, false);
//                    }
//                }
//            }
//            //Add listener
//
//            dynamicController.addModelListener(dynamicModelListener);
        }
    }

    public void unsetup() {
        if (model != null) {
//            DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
//            dynamicController.removeModelListener(dynamicModelListener);
        }
    }

    @Override
    public void execute(final Statistics statistics) {
        StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
        final StatisticsUI[] uis = getUI(statistics);

        for (StatisticsUI s : uis) {
            s.setup(statistics);
        }
        model.setRunning(statistics, true);

        controller.execute(statistics, new LongTaskListener() {

            @Override
            public void taskFinished(LongTask task) {
                model.setRunning(statistics, false);
                for (StatisticsUI s : uis) {
                    model.addResult(s);
                    s.unsetup();
                }
            }
        });
    }

    @Override
    public void execute(final Statistics statistics, final LongTaskListener listener) {<FILL_FUNCTION_BODY>}

    public StatisticsUI[] getUI(Statistics statistics) {
        boolean dynamic = false;
        ArrayList<StatisticsUI> list = new ArrayList<>();
        for (StatisticsUI sui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
            if (sui.getStatisticsClass().equals(statistics.getClass())) {
                list.add(sui);
            }
        }
        return list.toArray(new StatisticsUI[0]);
    }

    @Override
    public void setStatisticsUIVisible(StatisticsUI ui, boolean visible) {
        if (model != null) {
            model.setVisible(ui, visible);
        }
    }
}

        StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
        final StatisticsUI[] uis = getUI(statistics);

        for (StatisticsUI s : uis) {
            s.setup(statistics);
        }
        model.setRunning(statistics, true);

        controller.execute(statistics, new LongTaskListener() {

            @Override
            public void taskFinished(LongTask task) {
                model.setRunning(statistics, false);
                for (StatisticsUI s : uis) {
                    model.addResult(s);
                    s.unsetup();
                }
                if (listener != null) {
                    listener.taskFinished(statistics instanceof LongTask ? (LongTask) statistics : null);
                }
            }
        });
    
<no_super_class>