class LayoutRun implements LongTask, Runnable {

        private final Layout layout;
        private final Integer iterations;
        private boolean stopRun = false;
        private ProgressTicket progressTicket;

        public LayoutRun(Layout layout) {
            this.layout = layout;
            this.iterations = null;
        }

        public LayoutRun(Layout layout, int numIterations) {
            this.layout = layout;
            this.iterations = numIterations;
        }

        @Override
        public void run() {<FILL_FUNCTION_BODY>}

        @Override
        public boolean cancel() {
            stopRun = true;
            if (layout instanceof LongTask) {
                return ((LongTask) layout).cancel();
            }
            return false;
        }

        @Override
        public void setProgressTicket(ProgressTicket progressTicket) {
            this.progressTicket = progressTicket;
            if (layout instanceof LongTask) {
                ((LongTask) layout).setProgressTicket(progressTicket);
            }
        }
    }

            Progress.setDisplayName(progressTicket, layout.getBuilder().getName());
            Progress.start(progressTicket);
            layout.initAlgo();
            long i = 0;
            while (layout.canAlgo() && !stopRun) {
                layout.goAlgo();
                i++;
                if (iterations != null && iterations.longValue() == i) {
                    break;
                }
            }
            layout.endAlgo();
            if (i > 1) {
                Progress.finish(progressTicket,
                    NbBundle.getMessage(LayoutControllerImpl.class, "LayoutRun.end", layout.getBuilder().getName(), i));
            } else {
                Progress.finish(progressTicket);
            }
        
<no_super_class>